diff --git a/docs/notes.txt b/docs/notes.txt index 2a45536..1d7ab80 100644 --- a/docs/notes.txt +++ b/docs/notes.txt @@ -38,3 +38,17 @@ Mac OSX specificities enter "/Users/[username]/Library/Application Support/vimix" and delete the folder 'vimix' - + + +Testing performance +------------------- + +Linux perf command +- Allow perf on your system +sudo sysctl -w kernel.perf_event_paranoid=-1 +- Launch command to record +perf record ./vimix +perf record --pid=XXXXX +- Analyse using https://github.com/KDAB/hotspot + + diff --git a/docs/vimix.1 b/docs/vimix.1 index dc21b14..e51d2c4 100644 --- a/docs/vimix.1 +++ b/docs/vimix.1 @@ -37,6 +37,14 @@ and exit. .BR \-F ", " \-\^\-fontsize N Set interface font size to specified value N. +.TP +.BR \-S ", " \-\^\-settings settingsfile.xml +Run using the given settings file. + +.TP +.BR \-L ", " \-\^\-headless +Run without graphical user interface (only if output windows are configured). + .TP .BR \-C ", " \-\^\-clean Clean the user stored preferences of diff --git a/src/Settings.cpp b/src/Settings.cpp index cd273ba..f2d10c0 100644 --- a/src/Settings.cpp +++ b/src/Settings.cpp @@ -69,7 +69,7 @@ XMLElement *save_knownhost(Settings::KnownHosts &h, const char *nodename, XMLDoc -void Settings::Save(uint64_t runtime) +void Settings::Save(uint64_t runtime, const std::string &filename) { // impose C locale for all app setlocale(LC_ALL, "C"); @@ -332,7 +332,8 @@ void Settings::Save(uint64_t runtime) if (settingsFilename.empty()) settingsFilename = SystemToolkit::full_filename(SystemToolkit::settings_path(), APP_SETTINGS); - XMLError eResult = xmlDoc.SaveFile(settingsFilename.c_str()); + XMLError eResult = xmlDoc.SaveFile( filename.empty() ? + settingsFilename.c_str() : filename.c_str()); XMLResultError(eResult); } @@ -395,7 +396,7 @@ void load_knownhost(Settings::KnownHosts &h, const char *nodename, XMLElement *r } } -void Settings::Load() +void Settings::Load(const string &filename) { // impose C locale for all app setlocale(LC_ALL, "C"); @@ -406,7 +407,8 @@ void Settings::Load() // try to load settings file XMLDocument xmlDoc; - XMLError eResult = xmlDoc.LoadFile(settingsFilename.c_str()); + XMLError eResult = xmlDoc.LoadFile( filename.empty() ? + settingsFilename.c_str() : filename.c_str()); // do not warn if non existing file if (eResult == XML_ERROR_FILE_NOT_FOUND) diff --git a/src/Settings.h b/src/Settings.h index 5255030..c0bc435 100644 --- a/src/Settings.h +++ b/src/Settings.h @@ -390,8 +390,8 @@ struct Application extern Application application; // Save and Load store settings in XML file -void Save(uint64_t runtime = 0); -void Load(); +void Save(uint64_t runtime = 0, const std::string &filename = ""); +void Load(const std::string &filename = ""); void Lock(); void Unlock(); void Check(); diff --git a/src/UserInterfaceManager.cpp b/src/UserInterfaceManager.cpp index 648c41e..4d88bd8 100644 --- a/src/UserInterfaceManager.cpp +++ b/src/UserInterfaceManager.cpp @@ -222,6 +222,8 @@ bool UserInterface::Init(int font_size) VIMIX_FILE_TYPE, VIMIX_FILE_PATTERN); sessionimportdialog = new DialogToolkit::OpenFileDialog("Import Sources", VIMIX_FILE_TYPE, VIMIX_FILE_PATTERN); + settingsexportdialog = new DialogToolkit::SaveFileDialog("Export settings", + SETTINGS_FILE_TYPE, SETTINGS_FILE_PATTERN); // init tooltips ImGuiToolkit::setToolTipsEnabled(Settings::application.show_tooptips); @@ -880,6 +882,10 @@ void UserInterface::NewFrame() if (sessionsavedialog && sessionsavedialog->closed() && !sessionsavedialog->path().empty()) Mixer::manager().saveas(sessionsavedialog->path(), Settings::application.save_version_snapshot); + if (settingsexportdialog && settingsexportdialog->closed() + && !settingsexportdialog->path().empty()) + Settings::Save(0, settingsexportdialog->path()); + // overlay to ensure file dialog is modal if (DialogToolkit::FileDialog::busy()){ if (!ImGui::IsPopupOpen("Busy")) @@ -1187,7 +1193,7 @@ void UserInterface::showMenuFile() ImGui::MenuItem( MENU_SAVE_ON_EXIT, nullptr, &Settings::application.recentSessions.save_on_exit); - // HELP AND QUIT + // QUIT ImGui::Separator(); if (ImGui::MenuItem( MENU_QUIT, SHORTCUT_QUIT) && TryClose()) Rendering::manager().close(); @@ -5418,6 +5424,17 @@ void Navigator::RenderMainPannelSettings() // Appearance // ImGui::Text("Settings"); + ImGui::SameLine(); + ImGui::SetCursorPosX( pannel_width_ IMGUI_RIGHT_ALIGN); + if ( ImGuiToolkit::IconButton(ICON_FA_SAVE,"Export settings\nYou can then " + "launch vimix with the option " + "'--settings filename.xml' " + "to restore output windows and configuration.") ){ + // launch file dialog to select file to save settings + if (UserInterface::manager().settingsexportdialog) + UserInterface::manager().settingsexportdialog->open(); + } + int v = Settings::application.accent_color; ImGui::Spacing(); ImGui::SetCursorPosX(0.5f * width_); diff --git a/src/UserInterfaceManager.h b/src/UserInterfaceManager.h index d515520..ee1119c 100644 --- a/src/UserInterfaceManager.h +++ b/src/UserInterfaceManager.h @@ -202,6 +202,7 @@ protected: DialogToolkit::OpenFileDialog *sessionopendialog; DialogToolkit::OpenFileDialog *sessionimportdialog; DialogToolkit::SaveFileDialog *sessionsavedialog; + DialogToolkit::SaveFileDialog *settingsexportdialog; // Favorites and playlists Playlist favorites; diff --git a/src/defines.h b/src/defines.h index 8c093dd..fbded6e 100644 --- a/src/defines.h +++ b/src/defines.h @@ -42,6 +42,12 @@ { \ "*.srt", "*.sub" \ } +#define SETTINGS_FILE_TYPE "vimix settings (XML)" +#define SETTINGS_FILE_EXT "xml" +#define SETTINGS_FILE_PATTERN \ +{ \ + "*.xml" \ +} #define MINI(a, b) (((a) < (b)) ? (a) : (b)) #define MAXI(a, b) (((a) > (b)) ? (a) : (b)) #define ABS(a) (((a) < 0) ? -(a) : (a)) @@ -173,6 +179,7 @@ #define MENU_SAVE_ON_EXIT ICON_FA_LEVEL_DOWN_ALT " Save on exit" #define MENU_OPEN_ON_START ICON_FA_LEVEL_UP_ALT " Restore on start" #define SHORTCUT_SAVEAS_FILE CTRL_MOD "Shift+S" +#define MENU_EXPORT_SETTINGS ICON_FA_FILE_EXCEL " Export settings" #define MENU_QUIT ICON_FA_POWER_OFF " Quit" #define SHORTCUT_QUIT CTRL_MOD "Q" #define MENU_CUT ICON_FA_CUT " Cut" diff --git a/src/main.cpp b/src/main.cpp index bc4c847..1c5e5ab 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -71,6 +71,7 @@ int main(int argc, char *argv[]) int headlessRequested = 0; int helpRequested = 0; int fontsizeRequested = 0; + std::string settingsRequested; int ret = -1; for (int i = 1; i < argc; ++i) { @@ -82,6 +83,15 @@ int main(int argc, char *argv[]) cleanRequested = 1; } else if (strcmp(argv[i], "--headless") == 0 || strcmp(argv[i], "-L") == 0) { headlessRequested = 1; + } else if (strcmp(argv[i], "--settings") == 0 || strcmp(argv[i], "-S") == 0) { + // get settings file argument + if (i + 1 < argc) { + settingsRequested = argv[i + 1]; // Parse next argument as integer + i++; // Skip the next argument since it's already processed + } else { + fprintf(stderr, "Error: filename missing after --settings\n"); + helpRequested = 1; + } } else if (strcmp(argv[i], "--help") == 0 || strcmp(argv[i], "-H") == 0) { helpRequested = 1; } else if (strcmp(argv[i], "--fontsize") == 0 || strcmp(argv[i], "-F") == 0) { @@ -135,15 +145,19 @@ int main(int argc, char *argv[]) } if (helpRequested) { - printf("Usage: %s [-H, --help] [-V, --version] [-F N, --fontsize N] [-L, --headless] [-T, --test] [-C, --clean] [filename]\n", + printf("Usage: %s [-H, --help] [-V, --version] [-F, --fontsize] [-L, --headless]\n" + " [-S, --settings] [-T, --test] [-C, --clean] [filename]\n", argv[0]); printf("Options:\n"); printf(" --help : Display usage information\n"); printf(" --version : Display version information\n"); - printf(" --fontsize N : Force rendering font size to specified value N\n"); - printf(" --headless : Run without GUI\n"); - printf(" --test : Run rendering test\n"); + printf(" --fontsize : Force rendering font size to specified value, e.g., '-F 25'\n"); + printf(" --settings : Run with given settings file, e.g., '-S settingsfile.xml'\n"); + printf(" --headless : Run without GUI (only if output windows configured)\n"); + printf(" --test : Run rendering test and return\n"); printf(" --clean : Reset user settings\n"); + printf("Filename:\n"); + printf(" vimix session file (.mix extension)\n"); ret = 0;ret = 0; } @@ -156,7 +170,7 @@ int main(int argc, char *argv[]) /// /// Settings /// - Settings::Load(); + Settings::Load( settingsRequested ); Settings::application.executable = std::string(argv[0]); /// lock to inform an instance is running