diff --git a/src/common/appconfig.h b/src/common/appconfig.h index e624efdcfd..795944384c 100644 --- a/src/common/appconfig.h +++ b/src/common/appconfig.h @@ -23,18 +23,18 @@ struct Config { }; struct autostart : Config { - static QString name() { return "autostart"; } + static QString name() { return QStringLiteral("autostart"); } static Value defaultValue(); }; struct maxitems : Config { - static QString name() { return "maxitems"; } + static QString name() { return QStringLiteral("maxitems"); } static Value defaultValue() { return 200; } static Value value(Value v) { return qBound(0, v, maxItems); } }; struct item_data_threshold : Config { - static QString name() { return "item_data_threshold"; } + static QString name() { return QStringLiteral("item_data_threshold"); } static Value defaultValue() { return 1024; } static const char *description() { return "Maximum item data size in bytes to save in tab data file" @@ -43,93 +43,93 @@ struct item_data_threshold : Config { }; struct clipboard_tab : Config { - static QString name() { return "clipboard_tab"; } + static QString name() { return QStringLiteral("clipboard_tab"); } static Value defaultValue() { return defaultClipboardTabName(); } }; struct expire_tab : Config { - static QString name() { return "expire_tab"; } + static QString name() { return QStringLiteral("expire_tab"); } }; struct editor : Config { - static QString name() { return "editor"; } + static QString name() { return QStringLiteral("editor"); } static Value defaultValue(); }; struct item_popup_interval : Config { - static QString name() { return "item_popup_interval"; } + static QString name() { return QStringLiteral("item_popup_interval"); } }; struct notification_position : Config { - static QString name() { return "notification_position"; } + static QString name() { return QStringLiteral("notification_position"); } static Value defaultValue() { return 3; } }; struct clipboard_notification_lines : Config { - static QString name() { return "clipboard_notification_lines"; } + static QString name() { return QStringLiteral("clipboard_notification_lines"); } static Value value(Value v) { return qBound(0, v, 100); } }; struct notification_horizontal_offset : Config { - static QString name() { return "notification_horizontal_offset"; } + static QString name() { return QStringLiteral("notification_horizontal_offset"); } static Value defaultValue() { return 10; } }; struct notification_vertical_offset : Config { - static QString name() { return "notification_vertical_offset"; } + static QString name() { return QStringLiteral("notification_vertical_offset"); } static Value defaultValue() { return 10; } }; struct notification_maximum_width : Config { - static QString name() { return "notification_maximum_width"; } + static QString name() { return QStringLiteral("notification_maximum_width"); } static Value defaultValue() { return 300; } }; struct notification_maximum_height : Config { - static QString name() { return "notification_maximum_height"; } + static QString name() { return QStringLiteral("notification_maximum_height"); } static Value defaultValue() { return 100; } }; struct edit_ctrl_return : Config { - static QString name() { return "edit_ctrl_return"; } + static QString name() { return QStringLiteral("edit_ctrl_return"); } static Value defaultValue() { return true; } }; struct move : Config { - static QString name() { return "move"; } + static QString name() { return QStringLiteral("move"); } static Value defaultValue() { return true; } }; struct show_simple_items : Config { - static QString name() { return "show_simple_items"; } + static QString name() { return QStringLiteral("show_simple_items"); } static Value defaultValue() { return false; } }; struct number_search : Config { - static QString name() { return "number_search"; } + static QString name() { return QStringLiteral("number_search"); } static Value defaultValue() { return false; } }; struct check_clipboard : Config { - static QString name() { return "check_clipboard"; } + static QString name() { return QStringLiteral("check_clipboard"); } static Value defaultValue() { return true; } }; struct confirm_exit : Config { - static QString name() { return "confirm_exit"; } + static QString name() { return QStringLiteral("confirm_exit"); } static Value defaultValue() { return true; } }; struct vi : Config { - static QString name() { return "vi"; } + static QString name() { return QStringLiteral("vi"); } }; struct save_filter_history : Config { - static QString name() { return "save_filter_history"; } + static QString name() { return QStringLiteral("save_filter_history"); } }; struct filter_regular_expression : Config { - static QString name() { return "filter_regular_expression"; } + static QString name() { return QStringLiteral("filter_regular_expression"); } static Value defaultValue() { return false; } static const char *description() { return "Use regular expressions to search items"; @@ -137,7 +137,7 @@ struct filter_regular_expression : Config { }; struct filter_case_insensitive : Config { - static QString name() { return "filter_case_insensitive"; } + static QString name() { return QStringLiteral("filter_case_insensitive"); } static Value defaultValue() { return true; } static const char *description() { return "Use case-insensitive item search"; @@ -145,16 +145,16 @@ struct filter_case_insensitive : Config { }; struct always_on_top : Config { - static QString name() { return "always_on_top"; } + static QString name() { return QStringLiteral("always_on_top"); } }; struct close_on_unfocus : Config { - static QString name() { return "close_on_unfocus"; } + static QString name() { return QStringLiteral("close_on_unfocus"); } static Value defaultValue() { return true; } }; struct close_on_unfocus_delay_ms : Config { - static QString name() { return "close_on_unfocus_delay_ms"; } + static QString name() { return QStringLiteral("close_on_unfocus_delay_ms"); } static Value defaultValue() { return 500; } static const char *description() { return "Delay to close the main window when unfocused/deactivated"; @@ -162,12 +162,12 @@ struct close_on_unfocus_delay_ms : Config { }; struct open_windows_on_current_screen : Config { - static QString name() { return "open_windows_on_current_screen"; } + static QString name() { return QStringLiteral("open_windows_on_current_screen"); } static Value defaultValue() { return true; } }; struct restore_geometry : Config { - static QString name() { return "restore_geometry"; } + static QString name() { return QStringLiteral("restore_geometry"); } static Value defaultValue() { return true; } static const char *description() { return "Restore position and size for the main window and other dialogs"; @@ -175,38 +175,38 @@ struct restore_geometry : Config { }; struct transparency_focused : Config { - static QString name() { return "transparency_focused"; } + static QString name() { return QStringLiteral("transparency_focused"); } static Value value(Value v) { return qBound(0, v, 100); } }; struct transparency : Config { - static QString name() { return "transparency"; } + static QString name() { return QStringLiteral("transparency"); } static Value value(Value v) { return qBound(0, v, 100); } }; struct hide_tabs : Config { - static QString name() { return "hide_tabs"; } + static QString name() { return QStringLiteral("hide_tabs"); } }; struct hide_toolbar : Config { - static QString name() { return "hide_toolbar"; } + static QString name() { return QStringLiteral("hide_toolbar"); } }; struct hide_toolbar_labels : Config { - static QString name() { return "hide_toolbar_labels"; } + static QString name() { return QStringLiteral("hide_toolbar_labels"); } static Value defaultValue() { return true; } }; struct disable_tray : Config { - static QString name() { return "disable_tray"; } + static QString name() { return QStringLiteral("disable_tray"); } }; struct hide_main_window : Config { - static QString name() { return "hide_main_window"; } + static QString name() { return QStringLiteral("hide_main_window"); } }; struct hide_main_window_in_task_bar : Config { - static QString name() { return "hide_main_window_in_task_bar"; } + static QString name() { return QStringLiteral("hide_main_window_in_task_bar"); } static Value defaultValue() { return false; } static const char *description() { return "Avoid showing entry for the main window in the task bar"; @@ -214,20 +214,20 @@ struct hide_main_window_in_task_bar : Config { }; struct tab_tree : Config { - static QString name() { return "tab_tree"; } + static QString name() { return QStringLiteral("tab_tree"); } }; struct show_tab_item_count : Config { - static QString name() { return "show_tab_item_count"; } + static QString name() { return QStringLiteral("show_tab_item_count"); } }; struct text_wrap : Config { - static QString name() { return "text_wrap"; } + static QString name() { return QStringLiteral("text_wrap"); } static Value defaultValue() { return true; } }; struct text_tab_width : Config { - static QString name() { return "text_tab_width"; } + static QString name() { return QStringLiteral("text_tab_width"); } static Value defaultValue() { return 8; } static const char *description() { return "Width of Tab character in number of spaces"; @@ -235,53 +235,53 @@ struct text_tab_width : Config { }; struct activate_item_with_single_click : Config { - static QString name() { return "activate_item_with_single_click"; } + static QString name() { return QStringLiteral("activate_item_with_single_click"); } static Value defaultValue() { return false; } }; struct activate_closes : Config { - static QString name() { return "activate_closes"; } + static QString name() { return QStringLiteral("activate_closes"); } static Value defaultValue() { return true; } }; struct activate_focuses : Config { - static QString name() { return "activate_focuses"; } + static QString name() { return QStringLiteral("activate_focuses"); } static Value defaultValue() { return true; } }; struct activate_pastes : Config { - static QString name() { return "activate_pastes"; } + static QString name() { return QStringLiteral("activate_pastes"); } static Value defaultValue() { return true; } }; struct tray_items : Config { - static QString name() { return "tray_items"; } + static QString name() { return QStringLiteral("tray_items"); } static Value defaultValue() { return 5; } static Value value(Value v) { return qBound(0, v, 99); } }; struct tray_item_paste : Config { - static QString name() { return "tray_item_paste"; } + static QString name() { return QStringLiteral("tray_item_paste"); } static Value defaultValue() { return true; } }; struct tray_commands : Config { - static QString name() { return "tray_commands"; } + static QString name() { return QStringLiteral("tray_commands"); } static Value defaultValue() { return true; } }; struct tray_tab_is_current : Config { - static QString name() { return "tray_tab_is_current"; } + static QString name() { return QStringLiteral("tray_tab_is_current"); } static Value defaultValue() { return true; } }; struct tray_images : Config { - static QString name() { return "tray_images"; } + static QString name() { return QStringLiteral("tray_images"); } static Value defaultValue() { return true; } }; struct tray_menu_open_on_left_click : Config { - static QString name() { return "tray_menu_open_on_left_click"; } + static QString name() { return QStringLiteral("tray_menu_open_on_left_click"); } static Value defaultValue() { return false; } static const char *description() { return "Open tray menu on left mouse button"; @@ -289,11 +289,11 @@ struct tray_menu_open_on_left_click : Config { }; struct tray_tab : Config { - static QString name() { return "tray_tab"; } + static QString name() { return QStringLiteral("tray_tab"); } }; struct command_history_size : Config { - static QString name() { return "command_history_size"; } + static QString name() { return QStringLiteral("command_history_size"); } static Value defaultValue() { return 100; } static const char *description() { return "Number of commands to keep in action dialog history"; @@ -301,24 +301,24 @@ struct command_history_size : Config { }; struct check_selection : Config { - static QString name() { return "check_selection"; } + static QString name() { return QStringLiteral("check_selection"); } }; struct copy_clipboard : Config { - static QString name() { return "copy_clipboard"; } + static QString name() { return QStringLiteral("copy_clipboard"); } }; struct copy_selection : Config { - static QString name() { return "copy_selection"; } + static QString name() { return QStringLiteral("copy_selection"); } }; struct run_selection : Config { - static QString name() { return "run_selection"; } + static QString name() { return QStringLiteral("run_selection"); } static Value defaultValue() { return true; } }; struct tabs : Config { - static QString name() { return "tabs"; } + static QString name() { return QStringLiteral("tabs"); } static Value value(Value v) { v.removeAll(QString()); v.removeDuplicates(); @@ -330,7 +330,7 @@ struct tabs : Config { }; struct show_advanced_command_settings : Config { - static QString name() { return "show_advanced_command_settings"; } + static QString name() { return QStringLiteral("show_advanced_command_settings"); } static Value defaultValue() { return false; } static const char *description() { return "Show advanced command configuration in Command dialog"; @@ -338,12 +338,12 @@ struct show_advanced_command_settings : Config { }; struct autocompletion : Config { - static QString name() { return "autocompletion"; } + static QString name() { return QStringLiteral("autocompletion"); } static Value defaultValue() { return true; } }; struct max_process_manager_rows : Config { - static QString name() { return "max_process_manager_rows"; } + static QString name() { return QStringLiteral("max_process_manager_rows"); } static Value defaultValue() { return 1000; } static const char *description() { return "Maximum number of rows in process manager dialog"; @@ -351,7 +351,7 @@ struct max_process_manager_rows : Config { }; struct save_delay_ms_on_item_added : Config { - static QString name() { return "save_delay_ms_on_item_added"; } + static QString name() { return QStringLiteral("save_delay_ms_on_item_added"); } static Value defaultValue() { return 5 * 60 * 1000; } static const char *description() { return "Tab save delay after an item is added to the tab"; @@ -359,7 +359,7 @@ struct save_delay_ms_on_item_added : Config { }; struct save_delay_ms_on_item_modified : Config { - static QString name() { return "save_delay_ms_on_item_modified"; } + static QString name() { return QStringLiteral("save_delay_ms_on_item_modified"); } static Value defaultValue() { return 5 * 60 * 1000; } static const char *description() { return "Tab save delay after an item is modified in the tab"; @@ -367,7 +367,7 @@ struct save_delay_ms_on_item_modified : Config { }; struct save_delay_ms_on_item_removed : Config { - static QString name() { return "save_delay_ms_on_item_removed"; } + static QString name() { return QStringLiteral("save_delay_ms_on_item_removed"); } static Value defaultValue() { return 10 * 60 * 1000; } static const char *description() { return "Tab save delay after an item is removed from the tab"; @@ -375,7 +375,7 @@ struct save_delay_ms_on_item_removed : Config { }; struct save_delay_ms_on_item_moved : Config { - static QString name() { return "save_delay_ms_on_item_moved"; } + static QString name() { return QStringLiteral("save_delay_ms_on_item_moved"); } static Value defaultValue() { return 30 * 60 * 1000; } static const char *description() { return "Tab save delay after an item is moved in the tab"; @@ -383,7 +383,7 @@ struct save_delay_ms_on_item_moved : Config { }; struct save_delay_ms_on_item_edited : Config { - static QString name() { return "save_delay_ms_on_item_edited"; } + static QString name() { return QStringLiteral("save_delay_ms_on_item_edited"); } static Value defaultValue() { return 1000; } static const char *description() { return "Tab save delay after an item is edited in the tab"; @@ -391,7 +391,7 @@ struct save_delay_ms_on_item_edited : Config { }; struct save_on_app_deactivated : Config { - static QString name() { return "save_on_app_deactivated"; } + static QString name() { return QStringLiteral("save_on_app_deactivated"); } static Value defaultValue() { return true; } static const char *description() { return "Save unsaved tabs immediately after the app is deactivated (main window loses focus)"; @@ -399,7 +399,7 @@ struct save_on_app_deactivated : Config { }; struct native_menu_bar : Config { - static QString name() { return "native_menu_bar"; } + static QString name() { return QStringLiteral("native_menu_bar"); } #ifdef Q_OS_MAC // Native menu bar doesn't show on macOS. // See: https://github.com/hluk/CopyQ/issues/1444 @@ -413,7 +413,7 @@ struct native_menu_bar : Config { }; struct native_tray_menu : Config { - static QString name() { return "native_tray_menu"; } + static QString name() { return QStringLiteral("native_tray_menu"); } static Value defaultValue() { return false; } static const char *description() { return "Use native tray menu (menu items search may not work)"; @@ -421,7 +421,7 @@ struct native_tray_menu : Config { }; struct script_paste_delay_ms : Config { - static QString name() { return "script_paste_delay_ms"; } + static QString name() { return QStringLiteral("script_paste_delay_ms"); } static Value defaultValue() { return 250; } static const char *description() { return "Delay after pasting from script (when using `paste()`)"; @@ -429,7 +429,7 @@ struct script_paste_delay_ms : Config { }; struct window_paste_with_ctrl_v_regex : Config { - static QString name() { return "window_paste_with_ctrl_v_regex"; } + static QString name() { return QStringLiteral("window_paste_with_ctrl_v_regex"); } static const char *description() { return "Regular expression matching window titles where Ctrl+V should be used for pasting" " instead of the default Shift+Insert"; @@ -437,7 +437,7 @@ struct window_paste_with_ctrl_v_regex : Config { }; struct window_wait_before_raise_ms : Config { - static QString name() { return "window_wait_before_raise_ms"; } + static QString name() { return QStringLiteral("window_wait_before_raise_ms"); } #ifdef Q_OS_WIN static Value defaultValue() { return 0; } #else @@ -449,7 +449,7 @@ struct window_wait_before_raise_ms : Config { }; struct window_wait_raised_ms : Config { - static QString name() { return "window_wait_raised_ms"; } + static QString name() { return QStringLiteral("window_wait_raised_ms"); } static Value defaultValue() { return 150; } static const char *description() { return "Wait interval for raising target window for pasting"; @@ -457,7 +457,7 @@ struct window_wait_raised_ms : Config { }; struct window_wait_after_raised_ms : Config { - static QString name() { return "window_wait_after_raised_ms"; } + static QString name() { return QStringLiteral("window_wait_after_raised_ms"); } #ifdef Q_OS_WIN static Value defaultValue() { return 150; } #elif defined(Q_OS_MAC) @@ -471,7 +471,7 @@ struct window_wait_after_raised_ms : Config { }; struct window_key_press_time_ms : Config { - static QString name() { return "window_key_press_time_ms"; } + static QString name() { return QStringLiteral("window_key_press_time_ms"); } #ifdef Q_OS_WIN static Value defaultValue() { return 0; } #elif defined(Q_OS_MAC) @@ -486,7 +486,7 @@ struct window_key_press_time_ms : Config { }; struct window_wait_for_modifier_released_ms : Config { - static QString name() { return "window_wait_for_modifier_released_ms"; } + static QString name() { return QStringLiteral("window_wait_for_modifier_released_ms"); } static Value defaultValue() { return 2000; } static const char *description() { return "Wait for any keyboard modifiers to be released before simulating/sending" @@ -495,7 +495,7 @@ struct window_wait_for_modifier_released_ms : Config { }; struct update_clipboard_owner_delay_ms : Config { - static QString name() { return "update_clipboard_owner_delay_ms"; } + static QString name() { return QStringLiteral("update_clipboard_owner_delay_ms"); } static Value defaultValue() { return -1; } static const char *description() { return "Delay to update new clipboard owner window title" @@ -504,7 +504,7 @@ struct update_clipboard_owner_delay_ms : Config { }; struct row_index_from_one : Config { - static QString name() { return "row_index_from_one"; } + static QString name() { return QStringLiteral("row_index_from_one"); } static Value defaultValue() { return true; } static const char *description() { return "Index items/rows in UI starting from 1 instead of 0" @@ -513,14 +513,14 @@ struct row_index_from_one : Config { }; struct style : Config { - static QString name() { return "style"; } + static QString name() { return QStringLiteral("style"); } static const char *description() { return "Current application style (available styles can be listed with `copyq styles` command)"; } }; struct native_notifications : Config { - static QString name() { return "native_notifications"; } + static QString name() { return QStringLiteral("native_notifications"); } static Value defaultValue() { return true; } }; diff --git a/src/common/commandstore.cpp b/src/common/commandstore.cpp index b315424604..fee3ef7aeb 100644 --- a/src/common/commandstore.cpp +++ b/src/common/commandstore.cpp @@ -15,6 +15,9 @@ namespace { +const QLatin1String falseString("false"); +const QLatin1String trueString("true"); + void normalizeLineBreaks(QString &cmd) { if (cmd.startsWith("\n ")) { @@ -29,68 +32,68 @@ void normalizeLineBreaks(QString &cmd) void loadCommand(const QSettings &settings, Commands *commands) { Command c; - c.enable = settings.value("Enable", true).toBool(); - - c.name = settings.value("Name").toString(); - c.re = QRegularExpression( settings.value("Match").toString() ); - c.wndre = QRegularExpression( settings.value("Window").toString() ); - c.matchCmd = settings.value("MatchCommand").toString(); - c.cmd = settings.value("Command").toString(); - c.sep = settings.value("Separator").toString(); - - c.input = settings.value("Input").toString(); - if ( c.input == "false" || c.input == "true" ) - c.input = c.input == "true" ? QString(mimeText) : QString(); - - c.output = settings.value("Output").toString(); - if ( c.output == "false" || c.output == "true" ) - c.output = c.output == "true" ? QString(mimeText) : QString(); - - c.wait = settings.value("Wait").toBool(); - c.automatic = settings.value("Automatic").toBool(); - c.display = settings.value("Display").toBool(); - c.transform = settings.value("Transform").toBool(); - c.hideWindow = settings.value("HideWindow").toBool(); - c.icon = settings.value("Icon").toString(); - c.shortcuts = settings.value("Shortcut").toStringList(); - c.globalShortcuts = settings.value("GlobalShortcut").toStringList(); - c.tab = settings.value("Tab").toString(); - c.outputTab = settings.value("OutputTab").toString(); - c.internalId = settings.value("InternalId").toString(); - c.inMenu = settings.value("InMenu").toBool(); - c.isScript = settings.value("IsScript").toBool(); - - const auto globalShortcutsOption = settings.value("IsGlobalShortcut"); + c.enable = settings.value(QStringLiteral("Enable"), true).toBool(); + + c.name = settings.value(QStringLiteral("Name")).toString(); + c.re = QRegularExpression( settings.value(QStringLiteral("Match")).toString() ); + c.wndre = QRegularExpression( settings.value(QStringLiteral("Window")).toString() ); + c.matchCmd = settings.value(QStringLiteral("MatchCommand")).toString(); + c.cmd = settings.value(QStringLiteral("Command")).toString(); + c.sep = settings.value(QStringLiteral("Separator")).toString(); + + c.input = settings.value(QStringLiteral("Input")).toString(); + if (c.input == falseString || c.input == trueString) + c.input = c.input == trueString ? mimeText : QLatin1String(); + + c.output = settings.value(QStringLiteral("Output")).toString(); + if (c.output == falseString || c.output == trueString) + c.output = c.output == trueString ? mimeText : QLatin1String(); + + c.wait = settings.value(QStringLiteral("Wait")).toBool(); + c.automatic = settings.value(QStringLiteral("Automatic")).toBool(); + c.display = settings.value(QStringLiteral("Display")).toBool(); + c.transform = settings.value(QStringLiteral("Transform")).toBool(); + c.hideWindow = settings.value(QStringLiteral("HideWindow")).toBool(); + c.icon = settings.value(QStringLiteral("Icon")).toString(); + c.shortcuts = settings.value(QStringLiteral("Shortcut")).toStringList(); + c.globalShortcuts = settings.value(QStringLiteral("GlobalShortcut")).toStringList(); + c.tab = settings.value(QStringLiteral("Tab")).toString(); + c.outputTab = settings.value(QStringLiteral("OutputTab")).toString(); + c.internalId = settings.value(QStringLiteral("InternalId")).toString(); + c.inMenu = settings.value(QStringLiteral("InMenu")).toBool(); + c.isScript = settings.value(QStringLiteral("IsScript")).toBool(); + + const auto globalShortcutsOption = settings.value(QStringLiteral("IsGlobalShortcut")); if ( globalShortcutsOption.isValid() ) { - c.isGlobalShortcut = settings.value("IsGlobalShortcut").toBool(); + c.isGlobalShortcut = globalShortcutsOption.toBool(); } else { // Backwards compatibility with v3.1.2 and below. - if ( c.globalShortcuts.contains("DISABLED") ) + if ( c.globalShortcuts.contains(QLatin1String("DISABLED")) ) c.globalShortcuts.clear(); c.isGlobalShortcut = !c.globalShortcuts.isEmpty(); } - if (settings.value("Ignore").toBool()) + if (settings.value(QStringLiteral("Ignore")).toBool()) c.remove = c.automatic = true; else - c.remove = settings.value("Remove").toBool(); + c.remove = settings.value(QStringLiteral("Remove")).toBool(); commands->append(c); } -void saveValue(const char *key, const QRegularExpression &re, QSettings *settings) +void saveValue(const QString &key, const QRegularExpression &re, QSettings *settings) { settings->setValue(key, re.pattern()); } -void saveValue(const char *key, const QVariant &value, QSettings *settings) +void saveValue(const QString &key, const QVariant &value, QSettings *settings) { settings->setValue(key, value); } /// Save only modified command properties. template -void saveNewValue(const char *key, const Command &command, const Member &member, QSettings *settings) +void saveNewValue(const QString &key, const Command &command, const Member &member, QSettings *settings) { if (command.*member != Command().*member) saveValue(key, command.*member, settings); @@ -98,35 +101,35 @@ void saveNewValue(const char *key, const Command &command, const Member &member, void saveCommand(const Command &c, QSettings *settings) { - saveNewValue("Name", c, &Command::name, settings); - saveNewValue("Match", c, &Command::re, settings); - saveNewValue("Window", c, &Command::wndre, settings); - saveNewValue("MatchCommand", c, &Command::matchCmd, settings); - saveNewValue("Command", c, &Command::cmd, settings); - saveNewValue("Input", c, &Command::input, settings); - saveNewValue("Output", c, &Command::output, settings); + saveNewValue(QStringLiteral("Name"), c, &Command::name, settings); + saveNewValue(QStringLiteral("Match"), c, &Command::re, settings); + saveNewValue(QStringLiteral("Window"), c, &Command::wndre, settings); + saveNewValue(QStringLiteral("MatchCommand"), c, &Command::matchCmd, settings); + saveNewValue(QStringLiteral("Command"), c, &Command::cmd, settings); + saveNewValue(QStringLiteral("Input"), c, &Command::input, settings); + saveNewValue(QStringLiteral("Output"), c, &Command::output, settings); // Separator for new command is set to '\n' for convenience. // But this value shouldn't be saved if output format is not set. - if ( c.sep != "\\n" || !c.output.isEmpty() ) - saveNewValue("Separator", c, &Command::sep, settings); - - saveNewValue("Wait", c, &Command::wait, settings); - saveNewValue("Automatic", c, &Command::automatic, settings); - saveNewValue("Display", c, &Command::display, settings); - saveNewValue("InMenu", c, &Command::inMenu, settings); - saveNewValue("IsGlobalShortcut", c, &Command::isGlobalShortcut, settings); - saveNewValue("IsScript", c, &Command::isScript, settings); - saveNewValue("Transform", c, &Command::transform, settings); - saveNewValue("Remove", c, &Command::remove, settings); - saveNewValue("HideWindow", c, &Command::hideWindow, settings); - saveNewValue("Enable", c, &Command::enable, settings); - saveNewValue("Icon", c, &Command::icon, settings); - saveNewValue("Shortcut", c, &Command::shortcuts, settings); - saveNewValue("GlobalShortcut", c, &Command::globalShortcuts, settings); - saveNewValue("Tab", c, &Command::tab, settings); - saveNewValue("OutputTab", c, &Command::outputTab, settings); - saveNewValue("InternalId", c, &Command::internalId, settings); + if ( c.sep != QLatin1String("\\n") || !c.output.isEmpty() ) + saveNewValue(QStringLiteral("Separator"), c, &Command::sep, settings); + + saveNewValue(QStringLiteral("Wait"), c, &Command::wait, settings); + saveNewValue(QStringLiteral("Automatic"), c, &Command::automatic, settings); + saveNewValue(QStringLiteral("Display"), c, &Command::display, settings); + saveNewValue(QStringLiteral("InMenu"), c, &Command::inMenu, settings); + saveNewValue(QStringLiteral("IsGlobalShortcut"), c, &Command::isGlobalShortcut, settings); + saveNewValue(QStringLiteral("IsScript"), c, &Command::isScript, settings); + saveNewValue(QStringLiteral("Transform"), c, &Command::transform, settings); + saveNewValue(QStringLiteral("Remove"), c, &Command::remove, settings); + saveNewValue(QStringLiteral("HideWindow"), c, &Command::hideWindow, settings); + saveNewValue(QStringLiteral("Enable"), c, &Command::enable, settings); + saveNewValue(QStringLiteral("Icon"), c, &Command::icon, settings); + saveNewValue(QStringLiteral("Shortcut"), c, &Command::shortcuts, settings); + saveNewValue(QStringLiteral("GlobalShortcut"), c, &Command::globalShortcuts, settings); + saveNewValue(QStringLiteral("Tab"), c, &Command::tab, settings); + saveNewValue(QStringLiteral("OutputTab"), c, &Command::outputTab, settings); + saveNewValue(QStringLiteral("InternalId"), c, &Command::internalId, settings); } Commands importCommands(QSettings *settings) diff --git a/src/common/predefinedcommands.cpp b/src/common/predefinedcommands.cpp index 1438cc2ac1..236755aace 100644 --- a/src/common/predefinedcommands.cpp +++ b/src/common/predefinedcommands.cpp @@ -39,7 +39,7 @@ QVector predefinedCommands() c = &commands.first(); c->name = AddCommandDialog::tr("New command"); c->icon = QString(QChar(IconFile)); - c->input = c->output = ""; + c->input = c->output = QString(); c->wait = c->automatic = c->remove = false; c->sep = QLatin1String("\\n"); @@ -84,7 +84,7 @@ synchronizeToSelection = function() { c->name = AddCommandDialog::tr("Open in &Browser"); c->re = reURL; c->icon = QString(QChar(IconGlobe)); - c->cmd = "copyq open %1"; + c->cmd = QStringLiteral("copyq open %1"); c->hideWindow = true; c->inMenu = true; @@ -92,7 +92,7 @@ synchronizeToSelection = function() { c->name = AddCommandDialog::tr("Paste as Plain Text"); c->input = mimeText; c->icon = QString(QChar(IconPaste)); - c->cmd = "copyq:" + pasteAsPlainTextScript("input()"); + c->cmd = QStringLiteral("copyq:") + pasteAsPlainTextScript("input()"); c->hideWindow = true; c->inMenu = true; @@ -100,7 +100,7 @@ synchronizeToSelection = function() { c->name = AddCommandDialog::tr("Autoplay videos"); c->re = QRegularExpression("^http://.*\\.(mp4|avi|mkv|wmv|flv|ogv)$"); c->icon = QString(QChar(IconCirclePlay)); - c->cmd = "copyq open %1"; + c->cmd = QStringLiteral("copyq open %1"); c->automatic = true; c->hideWindow = true; c->inMenu = true; @@ -109,24 +109,24 @@ synchronizeToSelection = function() { c->name = AddCommandDialog::tr("Copy URL (web address) to other tab"); c->re = reURL; c->icon = QString(QChar(IconCopy)); - c->tab = "&web"; + c->tab = QStringLiteral("&web"); c->automatic = true; c = newCommand(&commands); c->name = AddCommandDialog::tr("Create thumbnail (needs ImageMagick)"); c->icon = QString(QChar(IconImage)); - c->cmd = "convert - -resize 92x92 png:-"; - c->input = "image/png"; - c->output = "image/png"; + c->cmd = QStringLiteral("convert - -resize 92x92 png:-"); + c->input = QStringLiteral("image/png"); + c->output = QStringLiteral("image/png"); c->inMenu = true; c = newCommand(&commands); c->name = AddCommandDialog::tr("Create QR Code from URL (needs qrencode)"); c->re = reURL; c->icon = QString(QChar(IconQrcode)); - c->cmd = "qrencode -o - -t PNG -s 6"; + c->cmd = QStringLiteral("qrencode -o - -t PNG -s 6"); c->input = mimeText; - c->output = "image/png"; + c->output = QStringLiteral("image/png"); c->inMenu = true; const auto todoTab = AddCommandDialog::tr("Tasks", "Tab name for some predefined commands"); @@ -144,7 +144,6 @@ synchronizeToSelection = function() { .arg(todoTabQuoted); c->icon = QString(QChar(IconShare)); c->tab = todoTab; - c->input = mimeText; c->remove = true; c->inMenu = true; @@ -163,7 +162,7 @@ synchronizeToSelection = function() { c->icon = QString(QChar(IconAsterisk)); c->remove = true; c->automatic = true; - c->cmd = "copyq ignore"; + c->cmd = QStringLiteral("copyq ignore"); } c = newCommand(&commands); @@ -177,8 +176,8 @@ synchronizeToSelection = function() { c->name = AddCommandDialog::tr("Clear Current Tab"); c->icon = QString(QChar(IconBroom)); c->inMenu = true; - c->cmd = "copyq: ItemSelection(selectedTab()).selectRemovable().removeAll()"; - c->matchCmd = "copyq: tab(selectedTab()); if (size() == 0) fail()"; + c->cmd = QStringLiteral("copyq: ItemSelection(selectedTab()).selectRemovable().removeAll()"); + c->matchCmd = QStringLiteral("copyq: tab(selectedTab()); if (size() == 0) fail()"); return commands; } diff --git a/src/gui/menuitems.cpp b/src/gui/menuitems.cpp index 4f434107f2..ed3b189451 100644 --- a/src/gui/menuitems.cpp +++ b/src/gui/menuitems.cpp @@ -39,120 +39,120 @@ void addMenuItem( MenuItems menuItems() { MenuItems items; - addMenuItem( items, Actions::File_New, QObject::tr("&New Item"), "new", QKeySequence::New, - "document-new", IconFileLines ); - addMenuItem( items, Actions::File_Import, QObject::tr("&Import..."), "import", QObject::tr("Ctrl+I"), - "document-open", IconFolderOpen ); - addMenuItem( items, Actions::File_Export, QObject::tr("&Export..."), "export", QKeySequence::Save, - "document-save", IconFloppyDisk ); - addMenuItem( items, Actions::File_Preferences, QObject::tr("&Preferences..."), "preferences", QObject::tr("Ctrl+P"), - "preferences-other", IconWrench ); + addMenuItem( items, Actions::File_New, QObject::tr("&New Item"), QStringLiteral("new"), QKeySequence::New, + QStringLiteral("document-new"), IconFileLines ); + addMenuItem( items, Actions::File_Import, QObject::tr("&Import..."), QStringLiteral("import"), QObject::tr("Ctrl+I"), + QStringLiteral("document-open"), IconFolderOpen ); + addMenuItem( items, Actions::File_Export, QObject::tr("&Export..."), QStringLiteral("export"), QKeySequence::Save, + QStringLiteral("document-save"), IconFloppyDisk ); + addMenuItem( items, Actions::File_Preferences, QObject::tr("&Preferences..."), QStringLiteral("preferences"), QObject::tr("Ctrl+P"), + QStringLiteral("preferences-other"), IconWrench ); addMenuItem( items, Actions::File_Commands, QObject::tr("C&ommands..."), - "commands", QObject::tr("F6"), "system-run", IconGear ); + QStringLiteral("commands"), QObject::tr("F6"), QStringLiteral("system-run"), IconGear ); addMenuItem( items, Actions::File_ShowClipboardContent, QObject::tr("Show &Clipboard Content"), - "show_clipboard_content", QObject::tr("Ctrl+Shift+C"), "dialog-information", IconPaste ); + QStringLiteral("show_clipboard_content"), QObject::tr("Ctrl+Shift+C"), QStringLiteral("dialog-information"), IconPaste ); addMenuItem( items, Actions::File_ShowPreview, QObject::tr("&Show Preview"), - "show_item_preview", QObject::tr("F7"), "document-print-preview", IconEye ); + QStringLiteral("show_item_preview"), QObject::tr("F7"), QStringLiteral("document-print-preview"), IconEye ); addMenuItem( items, Actions::File_ToggleClipboardStoring, QObject::tr("&Toggle Clipboard Storing"), - "toggle_clipboard_storing", QObject::tr("Ctrl+Shift+X"), "", IconBan ); + QStringLiteral("toggle_clipboard_storing"), QObject::tr("Ctrl+Shift+X"), QStringLiteral(""), IconBan ); addMenuItem( items, Actions::File_ProcessManager, QObject::tr("P&rocess Manager"), - "process_manager", QObject::tr("Ctrl+Shift+Z"), "system-search", IconGears ); - addMenuItem( items, Actions::File_Exit, QObject::tr("E&xit"), "exit", QObject::tr("Ctrl+Q"), - "application-exit", IconPowerOff ); + QStringLiteral("process_manager"), QObject::tr("Ctrl+Shift+Z"), QStringLiteral("system-search"), IconGears ); + addMenuItem( items, Actions::File_Exit, QObject::tr("E&xit"), QStringLiteral("exit"), QObject::tr("Ctrl+Q"), + QStringLiteral("application-exit"), IconPowerOff ); addMenuItem( items, Actions::Edit_SortSelectedItems, QObject::tr("&Sort Selected Items"), - "sort_selected_items", QObject::tr("Ctrl+Shift+S"), - "view-sort-ascending", IconArrowDownAZ ); + QStringLiteral("sort_selected_items"), QObject::tr("Ctrl+Shift+S"), + QStringLiteral("view-sort-ascending"), IconArrowDownAZ ); addMenuItem( items, Actions::Edit_ReverseSelectedItems, QObject::tr("&Reverse Selected Items"), - "reverse_selected_items", QObject::tr("Ctrl+Shift+R"), - "view-sort-descending", IconArrowUpAZ ); + QStringLiteral("reverse_selected_items"), QObject::tr("Ctrl+Shift+R"), + QStringLiteral("view-sort-descending"), IconArrowUpAZ ); addMenuItem( items, Actions::Edit_PasteItems, QObject::tr("&Paste Items"), - "paste_selected_items", QKeySequence::Paste, "edit-paste", IconPaste ); + QStringLiteral("paste_selected_items"), QKeySequence::Paste, QStringLiteral("edit-paste"), IconPaste ); addMenuItem( items, Actions::Edit_CopySelectedItems, QObject::tr("&Copy Selected Items"), - "copy_selected_items", QKeySequence::Copy, "edit-copy", IconCopy ); + QStringLiteral("copy_selected_items"), QKeySequence::Copy, QStringLiteral("edit-copy"), IconCopy ); addMenuItem( items, Actions::Edit_FindItems, QObject::tr("&Find"), - "find_items", QKeySequence::FindNext, "edit-find", IconMagnifyingGlass ); + QStringLiteral("find_items"), QKeySequence::FindNext, QStringLiteral("edit-find"), IconMagnifyingGlass ); addMenuItem(items, Actions::Editor_Save, QObject::tr("Save Item"), - "editor_save", QObject::tr("F2", "Shortcut to save item editor changes"), "document-save", IconFloppyDisk); + QStringLiteral("editor_save"), QObject::tr("F2", "Shortcut to save item editor changes"), QStringLiteral("document-save"), IconFloppyDisk); addMenuItem(items, Actions::Editor_Cancel, QObject::tr("Cancel Editing"), - "editor_cancel", QObject::tr("Escape", "Shortcut to revert item editor changes"), "document-revert", IconTrash); + QStringLiteral("editor_cancel"), QObject::tr("Escape", "Shortcut to revert item editor changes"), QStringLiteral("document-revert"), IconTrash); addMenuItem(items, Actions::Editor_Undo, QObject::tr("Undo"), - "editor_undo", QKeySequence::Undo, "edit-undo", IconRotateLeft); + QStringLiteral("editor_undo"), QKeySequence::Undo, QStringLiteral("edit-undo"), IconRotateLeft); addMenuItem(items, Actions::Editor_Redo, QObject::tr("Redo"), - "editor_redo", QKeySequence::Redo, "edit-redo", IconRotateRight); + QStringLiteral("editor_redo"), QKeySequence::Redo, QStringLiteral("edit-redo"), IconRotateRight); addMenuItem(items, Actions::Editor_Font, QObject::tr("Font"), - "editor_font", QKeySequence(), "preferences-desktop-font", IconFont); + QStringLiteral("editor_font"), QKeySequence(), QStringLiteral("preferences-desktop-font"), IconFont); addMenuItem(items, Actions::Editor_Bold, QObject::tr("Bold"), - "editor_bold", QKeySequence::Bold, "format-text-bold", IconBold); + QStringLiteral("editor_bold"), QKeySequence::Bold, QStringLiteral("format-text-bold"), IconBold); addMenuItem(items, Actions::Editor_Italic, QObject::tr("Italic"), - "editor_italic", QKeySequence::Italic, "format-text-italic", IconItalic); + QStringLiteral("editor_italic"), QKeySequence::Italic, QStringLiteral("format-text-italic"), IconItalic); addMenuItem(items, Actions::Editor_Underline, QObject::tr("Underline"), - "editor_underline", QKeySequence::Underline, "format-text-underline", IconUnderline); + QStringLiteral("editor_underline"), QKeySequence::Underline, QStringLiteral("format-text-underline"), IconUnderline); addMenuItem(items, Actions::Editor_Strikethrough, QObject::tr("Strikethrough"), - "editor_strikethrough", QKeySequence(), "format-text-strikethrough", IconStrikethrough); + QStringLiteral("editor_strikethrough"), QKeySequence(), QStringLiteral("format-text-strikethrough"), IconStrikethrough); addMenuItem(items, Actions::Editor_Foreground, QObject::tr("Foreground"), - "editor_foreground", QKeySequence(), "", IconPaintbrush); + QStringLiteral("editor_foreground"), QKeySequence(), QStringLiteral(""), IconPaintbrush); addMenuItem(items, Actions::Editor_Background, QObject::tr("Background"), - "editor_background", QKeySequence(), "", IconSquare); + QStringLiteral("editor_background"), QKeySequence(), QStringLiteral(""), IconSquare); addMenuItem(items, Actions::Editor_EraseStyle, QObject::tr("Erase Style"), - "editor_erase_style", QKeySequence(), "", IconEraser); + QStringLiteral("editor_erase_style"), QKeySequence(), QStringLiteral(""), IconEraser); addMenuItem(items, Actions::Editor_Search, QObject::tr("Search"), - "editor_search", QKeySequence::Find, "edit-find", IconMagnifyingGlass); + QStringLiteral("editor_search"), QKeySequence::Find, QStringLiteral("edit-find"), IconMagnifyingGlass); addMenuItem( items, Actions::Item_MoveToClipboard, QObject::tr("A&ctivate Items", "copies selected items to clipboard and moves them to top (depending on settings)"), - "move_to_clipboard", QKeySequence(), "clipboard", IconPaste ); + QStringLiteral("move_to_clipboard"), QKeySequence(), QStringLiteral("clipboard"), IconPaste ); addMenuItem( items, Actions::Item_ShowContent, QObject::tr("&Show Content..."), - "show_item_content", QObject::tr("F4"), "dialog-information", IconCircleInfo ); + QStringLiteral("show_item_content"), QObject::tr("F4"), QStringLiteral("dialog-information"), IconCircleInfo ); addMenuItem( items, Actions::Item_Remove, QObject::tr("&Remove"), - "delete_item", shortcutToRemove(), "list-remove", IconTrash ); - addMenuItem( items, Actions::Item_Edit, QObject::tr("&Edit"), "edit", QObject::tr("F2"), - "accessories-text-editor", IconPenToSquare ); + QStringLiteral("delete_item"), shortcutToRemove(), QStringLiteral("list-remove"), IconTrash ); + addMenuItem( items, Actions::Item_Edit, QObject::tr("&Edit"), QStringLiteral("edit"), QObject::tr("F2"), + QStringLiteral("accessories-text-editor"), IconPenToSquare ); addMenuItem( items, Actions::Item_EditNotes, QObject::tr("Edit &Notes"), - "edit_notes", QObject::tr("Shift+F2"), "accessories-text-editor", IconPenToSquare ); + QStringLiteral("edit_notes"), QObject::tr("Shift+F2"), QStringLiteral("accessories-text-editor"), IconPenToSquare ); addMenuItem( items, Actions::Item_EditWithEditor, QObject::tr("E&dit with Editor"), - "editor", QObject::tr("Ctrl+E"), "accessories-text-editor", IconPencil ); - addMenuItem( items, Actions::Item_Action, QObject::tr("&Action..."), "system-run", QObject::tr("F5"), - "action", IconBolt ); + QStringLiteral("editor"), QObject::tr("Ctrl+E"), QStringLiteral("accessories-text-editor"), IconPencil ); + addMenuItem( items, Actions::Item_Action, QObject::tr("&Action..."), QStringLiteral("system-run"), QObject::tr("F5"), + QStringLiteral("action"), IconBolt ); addMenuItem( items, Actions::Item_MoveUp, QObject::tr("Move Up"), - "move_up", QObject::tr("Ctrl+Up"), "go-up", IconAngleUp ); + QStringLiteral("move_up"), QObject::tr("Ctrl+Up"), QStringLiteral("go-up"), IconAngleUp ); addMenuItem( items, Actions::Item_MoveDown, QObject::tr("Move Down"), - "move_down", QObject::tr("Ctrl+Down"), "go-down", IconAngleDown ); + QStringLiteral("move_down"), QObject::tr("Ctrl+Down"), QStringLiteral("go-down"), IconAngleDown ); addMenuItem( items, Actions::Item_MoveToTop, QObject::tr("Move to Top"), - "move_to_top", QObject::tr("Ctrl+Home"), "go-top", IconAnglesUp ); + QStringLiteral("move_to_top"), QObject::tr("Ctrl+Home"), QStringLiteral("go-top"), IconAnglesUp ); addMenuItem( items, Actions::Item_MoveToBottom, QObject::tr("Move to Bottom"), - "move_to_bottom", QObject::tr("Ctrl+End"), "go-bottom", IconAnglesDown ); + QStringLiteral("move_to_bottom"), QObject::tr("Ctrl+End"), QStringLiteral("go-bottom"), IconAnglesDown ); addMenuItem( items, Actions::Tabs_NewTab, QObject::tr("&New Tab"), - "new_tab", QObject::tr("Ctrl+T"), ":/images/tab_new" ); + QStringLiteral("new_tab"), QObject::tr("Ctrl+T"), QStringLiteral(":/images/tab_new") ); addMenuItem( items, Actions::Tabs_RenameTab, QObject::tr("R&ename Tab"), - "rename_tab", QObject::tr("Ctrl+F2"), ":/images/tab_rename" ); + QStringLiteral("rename_tab"), QObject::tr("Ctrl+F2"), QStringLiteral(":/images/tab_rename") ); addMenuItem( items, Actions::Tabs_RemoveTab, QObject::tr("Re&move Tab"), - "remove_tab", QObject::tr("Ctrl+W"), ":/images/tab_remove" ); + QStringLiteral("remove_tab"), QObject::tr("Ctrl+W"), QStringLiteral(":/images/tab_remove") ); addMenuItem( items, Actions::Tabs_ChangeTabIcon, QObject::tr("&Change Tab Icon"), - "change_tab_icon", QObject::tr("Ctrl+Shift+T"), ":/images/tab_icon" ); + QStringLiteral("change_tab_icon"), QObject::tr("Ctrl+Shift+T"), QStringLiteral(":/images/tab_icon") ); addMenuItem( items, Actions::Tabs_NextTab, QObject::tr("Ne&xt Tab"), - "next_tab", QObject::tr("Right", "Default shortcut to focus next tab"), - "go-next", IconArrowRight ); + QStringLiteral("next_tab"), QObject::tr("Right", "Default shortcut to focus next tab"), + QStringLiteral("go-next"), IconArrowRight ); addMenuItem( items, Actions::Tabs_PreviousTab, QObject::tr("&Previous Tab"), - "previous_tab", QObject::tr("Left", "Default shortcut to focus previous tab"), - "go-previous", IconArrowLeft ); + QStringLiteral("previous_tab"), QObject::tr("Left", "Default shortcut to focus previous tab"), + QStringLiteral("go-previous"), IconArrowLeft ); - addMenuItem( items, Actions::Help_Help, QObject::tr("&Help"), "help", QKeySequence::HelpContents, - "help-contents", IconCircleQuestion ); - addMenuItem( items, Actions::Help_ShowLog, QObject::tr("&Show Log"), "show-log", QObject::tr("F12"), - "help-about", IconCircleExclamation ); - addMenuItem( items, Actions::Help_About, QObject::tr("&About"), "about", QKeySequence::WhatsThis, - "help-about", IconCircleInfo ); + addMenuItem( items, Actions::Help_Help, QObject::tr("&Help"), QStringLiteral("help"), QKeySequence::HelpContents, + QStringLiteral("help-contents"), IconCircleQuestion ); + addMenuItem( items, Actions::Help_ShowLog, QObject::tr("&Show Log"), QStringLiteral("show-log"), QObject::tr("F12"), + QStringLiteral("help-about"), IconCircleExclamation ); + addMenuItem( items, Actions::Help_About, QObject::tr("&About"), QStringLiteral("about"), QKeySequence::WhatsThis, + QStringLiteral("help-about"), IconCircleInfo ); - addMenuItem( items, Actions::ItemMenu, QObject::tr("Open Item Context Menu"), "item-menu", + addMenuItem( items, Actions::ItemMenu, QObject::tr("Open Item Context Menu"), QStringLiteral("item-menu"), QObject::tr("Shift+F10", "Default shortcut to open item context menu"), - "", IconRectangleList ); + QStringLiteral(""), IconRectangleList ); return items; } diff --git a/src/item/itemstore.cpp b/src/item/itemstore.cpp index 80c77734ea..a0efa99890 100644 --- a/src/item/itemstore.cpp +++ b/src/item/itemstore.cpp @@ -20,7 +20,7 @@ namespace { QString itemFileName(const QString &id) { QString part( id.toUtf8().toBase64() ); - part.replace( QChar('/'), QString('-') ); + part.replace( QChar('/'), QChar('-') ); return getConfigurationFilePath("_tab_") + part + QLatin1String(".dat"); }