Skip to content

Commit

Permalink
Fixed issue #110 to handle changing background sequence.
Browse files Browse the repository at this point in the history
  • Loading branch information
ahlstromcj committed May 24, 2023
1 parent eb08a8c commit 3a3af4a
Show file tree
Hide file tree
Showing 13 changed files with 185 additions and 58 deletions.
4 changes: 3 additions & 1 deletion Seq66qt5/seq66qt5.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
* \library seq66qt5 application
* \author Chris Ahlstrom
* \date 2017-09-05
* \updates 2023-03-30
* \updates 2023-05-24
* \license GNU GPLv2 or above
*
* This is an attempt to change from the hoary old (or, as H.P. Lovecraft
Expand All @@ -34,6 +34,7 @@

#include <QApplication> /* QApplication etc. */

#include "seq66_features.hpp" /* seq66::set_app_path() */
#include "qt5nsmanager.hpp" /* an seq66::smanager for Qt 5 */
#include "os/daemonize.hpp" /* seq66::session_close(), etc. */

Expand Down Expand Up @@ -76,6 +77,7 @@ int
main (int argc, char * argv [])
{
QApplication app(argc, argv); /* main application object */
seq66::set_app_path(argv[0]); /* log for future usage */

#if defined USE_RING_BUFFER_TEST && defined SEQ66_PLATFORM_DEBUG
if (! seq66::run_ring_test())
Expand Down
14 changes: 6 additions & 8 deletions TODO
Original file line number Diff line number Diff line change
Expand Up @@ -7,20 +7,18 @@ Some of these issues will be pushed off for the distant Seq66v2.
Current:

- Windows: No shortcut in Start menu after setup.
- Investigate cannot click on 'MIDI Clock' tab in preferences (alt-C OK).
- User manual and tutorials entry menus seems to open something but close
quick (I do have a default pdf reader).
- Tempo is not saved with new song (but works with for example
- Fixed: Tempo is not saved with new song (but works with for example
Kraftwerk-Europe_Endless-reconstructed.midi provided in data folder).
This is due to a known issue, must remember to Save. Added code to
fix this, but TEST with playlist active.
- Investigate: cannot click on 'MIDI Clock' tab in preferences (alt-C OK).

Patterns editor:

- Often Ctrl-Z is not working event though click undo button works.
- No undo on velocity changes. Works, but was not always seen, had to set
a dirty status.
- When a background sequence is chosen, it is s not possible to display
- Fixed: Often Ctrl-Z is not working event though click undo button works.
- Fixed: No undo on velocity changes. Works, but was not always seen,
had to set a dirty status.
- Fixed:When a background sequence is chosen, it is not possible to display
another one or to turn it off.

Added code to pass arrow events from the qscrollslave to the
Expand Down
4 changes: 2 additions & 2 deletions libseq66/include/play/sequence.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
* \library seq66 application
* \author Chris Ahlstrom
* \date 2015-07-30
* \updates 2023-05-22
* \updates 2023-05-24
* \license GNU GPLv2 or above
*
* The functions add_list_var() and add_long_list() have been replaced by
Expand Down Expand Up @@ -1834,7 +1834,7 @@ class sequence

void musical_key (int key, bool user_change = false);
void musical_scale (int scale, bool user_change = false);
void background_sequence (int bs, bool user_change = false);
bool background_sequence (int bs, bool user_change = false);
void show_events () const;
bool copy_events (const eventlist & newevents);
midipulse unit_measure (bool reset = false) const;
Expand Down
4 changes: 3 additions & 1 deletion libseq66/include/seq66_features.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
* \library seq66 application
* \author Chris Ahlstrom
* \date 2018-11-24
* \updates 2023-05-09
* \updates 2023-05-24
* \license GNU GPLv2 or above
*
* Provides some useful functions for displaying information about the
Expand Down Expand Up @@ -85,12 +85,14 @@ extern void set_app_build_os (const std::string & abuild_os);
extern void set_app_build_issue (const std::string & abuild_issue);
extern void set_app_engine (const std::string & aengine);
extern void set_app_name (const std::string & aname);
extern void set_app_path (const std::string & apath);
extern void set_app_type (const std::string & atype);
extern void set_app_cli (bool iscli);
extern void set_arg_0 (const std::string & arg);
extern void set_client_name (const std::string & cname);
extern void set_package_name (const std::string & pname);
extern const std::string & seq_app_name ();
extern const std::string & seq_app_path ();
extern const std::string & seq_app_tag ();
extern const std::string & seq_app_type ();
extern bool seq_app_cli ();
Expand Down
55 changes: 32 additions & 23 deletions libseq66/src/cfg/settings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
* \library seq66 application
* \author Chris Ahlstrom
* \date 2016-05-17
* \updates 2022-10-04
* \updates 2023-05-24
* \license GNU GPLv2 or above
*
* The first part of this file defines a couple of global structure
Expand All @@ -35,6 +35,7 @@

#include <stdexcept> /* std::invalid_argument */

#include "seq66_features.hpp" /* seq66::seq_app_path() */
#include "cfg/settings.hpp" /* std::rc(), usr(), and much more */

/*
Expand Down Expand Up @@ -450,36 +451,39 @@ pdf_user_manual_url ()

/**
* This list is useful to look up the installed documentation.
*
* Windows:
*/

const tokenization &
doc_folder_list ()
{
#if defined SEQ66_PLATFORM_WINDOWS
static tokenization s_folder_list
{
"C:/Program Files (x86)/Seq66/data/doc",
"C:/Program Files/Seq66/data/doc",
"" /* terminator */
};
#else
static bool s_uninitialized = true;
static tokenization s_folder_list;
static std::string s_usr_dir;
static std::string s_usr_local_dir;
if (s_uninitialized)
{
#if defined SEQ66_PLATFORM_WINDOWS
static std::string s_64_dir = "C:/Program Files/Seq66/data/doc";
static std::string s_32_dir = "C:/Program Files (x86)/Seq66/data/doc";
std::string app_path = seq_app_path();
s_64_dir[0] = app_path[0];
s_32_dir[0] = app_path[0];
s_folder_list.push_back(s_64_dir);
s_folder_list.push_back(s_32_dir);
#else
static std::string s_usr_dir;
static std::string s_usr_local_dir;
s_usr_dir = "/usr/share/doc/" + seq_api_subdirectory();
s_usr_local_dir = "/usr/local/share/doc/" + seq_api_subdirectory();
s_folder_list.push_back(s_usr_dir);
s_folder_list.push_back(s_usr_local_dir);
s_folder_list.push_back("data/share/doc"); /* source distro file? */
#if defined SEQ66_PLATFORM_DEBUG
s_folder_list.push_back("../seq66/data/share/doc"); /* shadow dir */
#endif
#endif
s_uninitialized = false;
}
#endif
return s_folder_list;
}

Expand All @@ -491,20 +495,25 @@ doc_folder_list ()
const tokenization &
tutorial_folder_list ()
{
#if defined SEQ66_PLATFORM_WINDOWS
static tokenization s_folder_list
{
"C:/Program Files (x86)/Seq66/data/doc/tutorial",
"C:/Program Files/Seq66/data/doc/tutorial",
"" /* terminator */
};
#else
static bool s_uninitialized = true;
static tokenization s_folder_list;
static std::string s_usr_dir;
static std::string s_usr_local_dir;
if (s_uninitialized)
{
#if defined SEQ66_PLATFORM_WINDOWS
static std::string s_64_dir =
"C:/Program Files/Seq66/data/doc/tutorial";
static std::string s_32_dir =
"C:/Program Files (x86)/Seq66/data/doc/tutorial";

std::string app_path = seq_app_path();
s_64_dir[0] = app_path[0];
s_32_dir[0] = app_path[0];
s_folder_list.push_back(s_64_dir);
s_folder_list.push_back(s_32_dir);

#else
static std::string s_usr_dir;
static std::string s_usr_local_dir;
s_usr_dir = "/usr/share/doc/" + seq_api_subdirectory();
s_usr_local_dir = "/usr/local/share/doc/" + seq_api_subdirectory();
s_usr_dir += "/tutorial";
Expand All @@ -514,10 +523,10 @@ tutorial_folder_list ()
s_folder_list.push_back("data/share/doc/tutorial");
#if defined SEQ66_PLATFORM_DEBUG
s_folder_list.push_back("../seq66/data/share/doc/tutorial");
#endif
#endif
s_uninitialized = false;
}
#endif
return s_folder_list;
}

Expand Down
74 changes: 72 additions & 2 deletions libseq66/src/os/shellexecute.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -107,16 +107,86 @@ open_local_url (const std::string & url)

#elif defined SEQ66_PLATFORM_WINDOWS

/*
* Information for the future. However, Because ShellExecute() can delegate
* execution to Shell extensions implementations) that are activated using
* Component Object Model (COM), COM should be initialized before
* ShellExecuteEx() is called.
*
\verbatim
HINSTANCE ShellExecuteA
(
[in, optional] HWND hwnd,
[in, optional] LPCSTR lpOperation,
[in] LPCSTR lpFile,
[in, optional] LPCSTR lpParameters,
[in, optional] LPCSTR lpDirectory,
[in] INT nShowCmd
);
\endverbatim
*
* - hwnd. A handle to the parent window used for displaying a UI or error
* messages. This value can be NULL if the operation is not associated
* with a window.
* - lpOperation. A verb that specifies the action to be performed.
* Generally, the actions available from an object's shortcut menu are
* usable. Common verbs for Seq66 usage: edit. Launches an editor and
* opens the document for editing. If lpFile is not a document file, the
* function will fail.
* - open. Opens the item specified by the lpFile parameter. Can be a
* file or folder.
* - NULL. The default verb is used, if available. If not, the "open"
* verb is used. If neither verb is available, the system uses the
* first verb listed in the registry.
* - lpFile. A string that specifies the file/object on which to execute
* the verb.
* - lpParameters. If lpFile specifies an executable file, this parameter
* is a pointer to a null-terminated string that specifies the parameters
* to be passed to the application. If lpFile specifies a document,
* lpParameters should be NULL.
* - lpDirectory. A string specifying the default (working) directory for
* the action. If this value is NULL, the current working directory is
* used.
* - nShowCmd. The flags that specify how an application is to be displayed
* when it is opened.
* - Return value. Success is a value greater than 32. If the function
* fails, it returns an error value that indicates the cause of the
* failure. The return value is cast as an HINSTANCE for backward
* compatibility with 16-bit Windows applications. It is not a true
* HINSTANCE, however. It can be cast only to an INT_PTR and compared to
* either 32 or error codes. (See the web page).
*/

bool
open_pdf (const std::string & pdfspec)
{
return command_line(pdfspec);
std::string cmd = usr().user_pdf_viewer();
if (cmd.empty())
{
return command_line(pdfspec);
}
else
{
cmd += " ";
cmd += pdfspec;
return command_line(cmd);
}
}

bool
open_url (const std::string & url)
{
return command_line(url);
std::string cmd = usr().user_browser();
if (cmd.empty())
{
return command_line(url);
}
else
{
cmd += " ";
cmd += url;
return command_line(url);
}
}

bool
Expand Down
10 changes: 6 additions & 4 deletions libseq66/src/play/sequence.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
* \library seq66 application
* \author Chris Ahlstrom
* \date 2015-07-24
* \updates 2023-05-23
* \updates 2023-05-24
* \license GNU GPLv2 or above
*
* The functionality of this class also includes handling some of the
Expand Down Expand Up @@ -438,19 +438,21 @@ sequence::musical_scale (int scale, bool user_change)
}
}

void
bool
sequence::background_sequence (int bs, bool user_change)
{
bool result = false;
if (seq::legal(bs))
{
bool change = bs != m_background_sequence;
if (change)
result = bs != m_background_sequence;
if (result)
{
m_background_sequence = short(bs);
if (user_change)
modify();
}
}
return result;
}

/**
Expand Down
21 changes: 19 additions & 2 deletions libseq66/src/seq66_features.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
* \library seq66 application
* \author Chris Ahlstrom
* \date 2017-03-12
* \updates 2023-05-08
* \updates 2023-05-24
* \license GNU GPLv2 or above
*
* The first part of this file defines a couple of global structure
Expand Down Expand Up @@ -78,6 +78,7 @@ static std::string s_jack_version;
static std::string s_qt_version;
static std::string s_app_engine = SEQ66_APP_ENGINE;
static std::string s_app_name = SEQ66_APP_NAME;
static std::string s_app_path;
static std::string s_app_type = SEQ66_APP_TYPE;
static bool s_app_cli = false;
static std::string s_apptag = SEQ66_APP_NAME " " SEQ66_VERSION;
Expand Down Expand Up @@ -126,6 +127,16 @@ set_app_name (const std::string & aname)
s_app_name = aname;
}

/**
* Sets the path to the application. Most useful on Windows.
*/

void
set_app_path (const std::string & apath)
{
s_app_path = apath;
}

/**
* Sets the current type of the application.
*/
Expand Down Expand Up @@ -199,6 +210,12 @@ seq_app_name ()
return s_app_name;
}

const std::string &
seq_app_path ()
{
return s_app_path;
}

const std::string &
seq_app_type ()
{
Expand Down Expand Up @@ -449,7 +466,7 @@ seq_build_details ()
<< "GNU C++ " << __GNUC__ << "." << __GNUC_MINOR__
<< "." << __GNUC_PATCHLEVEL__ << "\n"
#endif
<< "Executable: " << seq_app_name()
<< "Executable: " << seq_app_name() << " (" << seq_app_path() << ")"
<< "; " << seq_app_type() << " interface"
<< "; " << seq_app_engine() << " engine" << "\n"
;
Expand Down
Loading

0 comments on commit 3a3af4a

Please sign in to comment.