mirror of
https://github.com/brunoherbelin/vimix.git
synced 2025-12-05 15:30:00 +01:00
New Settings export and command-line load
Allows exporting settings in XML file and launch vimix from command line with given XML filename as argument to restore all settings and windows configuration.
This commit is contained in:
@@ -38,3 +38,17 @@ Mac OSX specificities
|
|||||||
enter "/Users/[username]/Library/Application Support/vimix" and delete the folder 'vimix'
|
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
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -37,6 +37,14 @@ and exit.
|
|||||||
.BR \-F ", " \-\^\-fontsize N
|
.BR \-F ", " \-\^\-fontsize N
|
||||||
Set interface font size to specified value 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
|
.TP
|
||||||
.BR \-C ", " \-\^\-clean
|
.BR \-C ", " \-\^\-clean
|
||||||
Clean the user stored preferences of
|
Clean the user stored preferences of
|
||||||
|
|||||||
@@ -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
|
// impose C locale for all app
|
||||||
setlocale(LC_ALL, "C");
|
setlocale(LC_ALL, "C");
|
||||||
@@ -332,7 +332,8 @@ void Settings::Save(uint64_t runtime)
|
|||||||
if (settingsFilename.empty())
|
if (settingsFilename.empty())
|
||||||
settingsFilename = SystemToolkit::full_filename(SystemToolkit::settings_path(), APP_SETTINGS);
|
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);
|
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
|
// impose C locale for all app
|
||||||
setlocale(LC_ALL, "C");
|
setlocale(LC_ALL, "C");
|
||||||
@@ -406,7 +407,8 @@ void Settings::Load()
|
|||||||
|
|
||||||
// try to load settings file
|
// try to load settings file
|
||||||
XMLDocument xmlDoc;
|
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
|
// do not warn if non existing file
|
||||||
if (eResult == XML_ERROR_FILE_NOT_FOUND)
|
if (eResult == XML_ERROR_FILE_NOT_FOUND)
|
||||||
|
|||||||
@@ -390,8 +390,8 @@ struct Application
|
|||||||
extern Application application;
|
extern Application application;
|
||||||
|
|
||||||
// Save and Load store settings in XML file
|
// Save and Load store settings in XML file
|
||||||
void Save(uint64_t runtime = 0);
|
void Save(uint64_t runtime = 0, const std::string &filename = "");
|
||||||
void Load();
|
void Load(const std::string &filename = "");
|
||||||
void Lock();
|
void Lock();
|
||||||
void Unlock();
|
void Unlock();
|
||||||
void Check();
|
void Check();
|
||||||
|
|||||||
@@ -222,6 +222,8 @@ bool UserInterface::Init(int font_size)
|
|||||||
VIMIX_FILE_TYPE, VIMIX_FILE_PATTERN);
|
VIMIX_FILE_TYPE, VIMIX_FILE_PATTERN);
|
||||||
sessionimportdialog = new DialogToolkit::OpenFileDialog("Import Sources",
|
sessionimportdialog = new DialogToolkit::OpenFileDialog("Import Sources",
|
||||||
VIMIX_FILE_TYPE, VIMIX_FILE_PATTERN);
|
VIMIX_FILE_TYPE, VIMIX_FILE_PATTERN);
|
||||||
|
settingsexportdialog = new DialogToolkit::SaveFileDialog("Export settings",
|
||||||
|
SETTINGS_FILE_TYPE, SETTINGS_FILE_PATTERN);
|
||||||
|
|
||||||
// init tooltips
|
// init tooltips
|
||||||
ImGuiToolkit::setToolTipsEnabled(Settings::application.show_tooptips);
|
ImGuiToolkit::setToolTipsEnabled(Settings::application.show_tooptips);
|
||||||
@@ -880,6 +882,10 @@ void UserInterface::NewFrame()
|
|||||||
if (sessionsavedialog && sessionsavedialog->closed() && !sessionsavedialog->path().empty())
|
if (sessionsavedialog && sessionsavedialog->closed() && !sessionsavedialog->path().empty())
|
||||||
Mixer::manager().saveas(sessionsavedialog->path(), Settings::application.save_version_snapshot);
|
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
|
// overlay to ensure file dialog is modal
|
||||||
if (DialogToolkit::FileDialog::busy()){
|
if (DialogToolkit::FileDialog::busy()){
|
||||||
if (!ImGui::IsPopupOpen("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);
|
ImGui::MenuItem( MENU_SAVE_ON_EXIT, nullptr, &Settings::application.recentSessions.save_on_exit);
|
||||||
|
|
||||||
// HELP AND QUIT
|
// QUIT
|
||||||
ImGui::Separator();
|
ImGui::Separator();
|
||||||
if (ImGui::MenuItem( MENU_QUIT, SHORTCUT_QUIT) && TryClose())
|
if (ImGui::MenuItem( MENU_QUIT, SHORTCUT_QUIT) && TryClose())
|
||||||
Rendering::manager().close();
|
Rendering::manager().close();
|
||||||
@@ -5418,6 +5424,17 @@ void Navigator::RenderMainPannelSettings()
|
|||||||
// Appearance
|
// Appearance
|
||||||
//
|
//
|
||||||
ImGui::Text("Settings");
|
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;
|
int v = Settings::application.accent_color;
|
||||||
ImGui::Spacing();
|
ImGui::Spacing();
|
||||||
ImGui::SetCursorPosX(0.5f * width_);
|
ImGui::SetCursorPosX(0.5f * width_);
|
||||||
|
|||||||
@@ -202,6 +202,7 @@ protected:
|
|||||||
DialogToolkit::OpenFileDialog *sessionopendialog;
|
DialogToolkit::OpenFileDialog *sessionopendialog;
|
||||||
DialogToolkit::OpenFileDialog *sessionimportdialog;
|
DialogToolkit::OpenFileDialog *sessionimportdialog;
|
||||||
DialogToolkit::SaveFileDialog *sessionsavedialog;
|
DialogToolkit::SaveFileDialog *sessionsavedialog;
|
||||||
|
DialogToolkit::SaveFileDialog *settingsexportdialog;
|
||||||
|
|
||||||
// Favorites and playlists
|
// Favorites and playlists
|
||||||
Playlist favorites;
|
Playlist favorites;
|
||||||
|
|||||||
@@ -42,6 +42,12 @@
|
|||||||
{ \
|
{ \
|
||||||
"*.srt", "*.sub" \
|
"*.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 MINI(a, b) (((a) < (b)) ? (a) : (b))
|
||||||
#define MAXI(a, b) (((a) > (b)) ? (a) : (b))
|
#define MAXI(a, b) (((a) > (b)) ? (a) : (b))
|
||||||
#define ABS(a) (((a) < 0) ? -(a) : (a))
|
#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_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 MENU_OPEN_ON_START ICON_FA_LEVEL_UP_ALT " Restore on start"
|
||||||
#define SHORTCUT_SAVEAS_FILE CTRL_MOD "Shift+S"
|
#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 MENU_QUIT ICON_FA_POWER_OFF " Quit"
|
||||||
#define SHORTCUT_QUIT CTRL_MOD "Q"
|
#define SHORTCUT_QUIT CTRL_MOD "Q"
|
||||||
#define MENU_CUT ICON_FA_CUT " Cut"
|
#define MENU_CUT ICON_FA_CUT " Cut"
|
||||||
|
|||||||
24
src/main.cpp
24
src/main.cpp
@@ -71,6 +71,7 @@ int main(int argc, char *argv[])
|
|||||||
int headlessRequested = 0;
|
int headlessRequested = 0;
|
||||||
int helpRequested = 0;
|
int helpRequested = 0;
|
||||||
int fontsizeRequested = 0;
|
int fontsizeRequested = 0;
|
||||||
|
std::string settingsRequested;
|
||||||
int ret = -1;
|
int ret = -1;
|
||||||
|
|
||||||
for (int i = 1; i < argc; ++i) {
|
for (int i = 1; i < argc; ++i) {
|
||||||
@@ -82,6 +83,15 @@ int main(int argc, char *argv[])
|
|||||||
cleanRequested = 1;
|
cleanRequested = 1;
|
||||||
} else if (strcmp(argv[i], "--headless") == 0 || strcmp(argv[i], "-L") == 0) {
|
} else if (strcmp(argv[i], "--headless") == 0 || strcmp(argv[i], "-L") == 0) {
|
||||||
headlessRequested = 1;
|
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) {
|
} else if (strcmp(argv[i], "--help") == 0 || strcmp(argv[i], "-H") == 0) {
|
||||||
helpRequested = 1;
|
helpRequested = 1;
|
||||||
} else if (strcmp(argv[i], "--fontsize") == 0 || strcmp(argv[i], "-F") == 0) {
|
} else if (strcmp(argv[i], "--fontsize") == 0 || strcmp(argv[i], "-F") == 0) {
|
||||||
@@ -135,15 +145,19 @@ int main(int argc, char *argv[])
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (helpRequested) {
|
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]);
|
argv[0]);
|
||||||
printf("Options:\n");
|
printf("Options:\n");
|
||||||
printf(" --help : Display usage information\n");
|
printf(" --help : Display usage information\n");
|
||||||
printf(" --version : Display version information\n");
|
printf(" --version : Display version information\n");
|
||||||
printf(" --fontsize N : Force rendering font size to specified value N\n");
|
printf(" --fontsize : Force rendering font size to specified value, e.g., '-F 25'\n");
|
||||||
printf(" --headless : Run without GUI\n");
|
printf(" --settings : Run with given settings file, e.g., '-S settingsfile.xml'\n");
|
||||||
printf(" --test : Run rendering test\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(" --clean : Reset user settings\n");
|
||||||
|
printf("Filename:\n");
|
||||||
|
printf(" vimix session file (.mix extension)\n");
|
||||||
ret = 0;ret = 0;
|
ret = 0;ret = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -156,7 +170,7 @@ int main(int argc, char *argv[])
|
|||||||
///
|
///
|
||||||
/// Settings
|
/// Settings
|
||||||
///
|
///
|
||||||
Settings::Load();
|
Settings::Load( settingsRequested );
|
||||||
Settings::application.executable = std::string(argv[0]);
|
Settings::application.executable = std::string(argv[0]);
|
||||||
|
|
||||||
/// lock to inform an instance is running
|
/// lock to inform an instance is running
|
||||||
|
|||||||
Reference in New Issue
Block a user