From b3a4f756b9263fb7efe1c9d0040116cf8f631175 Mon Sep 17 00:00:00 2001 From: Lukas Holecek Date: Sun, 21 Apr 2024 08:08:52 +0200 Subject: [PATCH] Avoid unnecesary string allocations --- src/common/commandstore.cpp | 133 +++++++++++++++--------------- src/common/predefinedcommands.cpp | 27 +++--- src/gui/menuitems.cpp | 128 ++++++++++++++-------------- src/item/itemstore.cpp | 2 +- 4 files changed, 146 insertions(+), 144 deletions(-) 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"); }