From 6eb702b7786a459d00c822aaac38e179dfa454ed Mon Sep 17 00:00:00 2001 From: Roman Telezhynskyi Date: Mon, 22 Apr 2024 15:47:36 +0300 Subject: [PATCH] Refactoring. Since Qt 6.7 we can start using enum QIcon::ThemeIcon. --- src/app/puzzle/scene/vpmaingraphicsview.cpp | 3 +- src/app/puzzle/vpmainwindow.cpp | 7 +- src/app/tape/tkmmainwindow.cpp | 5 +- src/app/tape/tmainwindow.cpp | 5 +- .../dialogs/dialogfinalmeasurements.cpp | 5 +- .../valentina/dialogs/dialogincrements.cpp | 4 +- .../dialogs/vwidgetbackgroundimages.cpp | 3 +- src/app/valentina/dialogs/vwidgetdetails.cpp | 28 +- src/app/valentina/dialogs/vwidgetgroups.cpp | 4 +- src/app/valentina/mainwindow.cpp | 4 +- src/libs/vmisc/literals.cpp | 2 - src/libs/vmisc/literals.h | 2 - src/libs/vmisc/theme/themeDef.cpp | 407 ++++++++++++++++++ src/libs/vmisc/theme/themeDef.h | 176 ++++++++ src/libs/vmisc/theme/vtheme.cpp | 3 +- src/libs/vmisc/vmisc.qbs | 1 + src/libs/vtools/dialogs/dialogtoolbox.cpp | 7 +- .../dialogs/tools/piece/dialoginsertnode.cpp | 3 +- .../dialogs/tools/piece/dialogpiecepath.cpp | 10 +- .../tools/piece/dialogseamallowance.cpp | 30 +- .../backgroundimage/vbackgroundimageitem.cpp | 69 ++- src/libs/vtools/tools/drawTools/vdrawtool.h | 10 +- .../vtools/tools/nodeDetails/vnodepoint.cpp | 10 +- src/libs/vtools/tools/vtoolseamallowance.cpp | 4 +- 24 files changed, 688 insertions(+), 114 deletions(-) create mode 100644 src/libs/vmisc/theme/themeDef.cpp diff --git a/src/app/puzzle/scene/vpmaingraphicsview.cpp b/src/app/puzzle/scene/vpmaingraphicsview.cpp index 644805502..a0b25494e 100644 --- a/src/app/puzzle/scene/vpmaingraphicsview.cpp +++ b/src/app/puzzle/scene/vpmaingraphicsview.cpp @@ -38,6 +38,7 @@ #include "../layout/vplayout.h" #include "../layout/vppiece.h" #include "../layout/vpsheet.h" +#include "../vmisc/theme/themeDef.h" #include "../vwidgets/vmaingraphicsscene.h" #include "undocommands/vpundopiecezvaluemove.h" #include "vpgraphicspiece.h" @@ -348,7 +349,7 @@ void VPMainGraphicsView::contextMenuEvent(QContextMenuEvent *event) restoreOriginAction->setShortcut(*restoreOriginShortcut); restoreOriginAction->setEnabled(not sheet.isNull() && sheet->TransformationOrigin().custom); - QAction *removeSheetAction = menu.addAction(QIcon::fromTheme(QStringLiteral("edit-delete")), tr("Remove sheet")); + QAction *removeSheetAction = menu.addAction(FromTheme(VThemeIcon::EditDelete), tr("Remove sheet")); removeSheetAction->setEnabled(not sheet.isNull() && layout->GetSheets().size() > 1); QAction *selectedAction = menu.exec(event->globalPos()); diff --git a/src/app/puzzle/vpmainwindow.cpp b/src/app/puzzle/vpmainwindow.cpp index 4b53aa594..cab6223ed 100644 --- a/src/app/puzzle/vpmainwindow.cpp +++ b/src/app/puzzle/vpmainwindow.cpp @@ -57,6 +57,7 @@ #include "../vmisc/dialogs/dialogselectlanguage.h" #include "../vmisc/lambdaconstants.h" #include "../vmisc/projectversion.h" +#include "../vmisc/theme/themeDef.h" #include "../vmisc/theme/vtheme.h" #include "../vmisc/vsysexits.h" #include "../vwidgets/vmaingraphicsscene.h" @@ -728,13 +729,13 @@ void VPMainWindow::SetupMenu() // Add Undo/Redo actions. undoAction = m_layout->UndoStack()->createUndoAction(this, tr("&Undo")); m_actionShortcuts.insert(VShortcutAction::Undo, undoAction); - undoAction->setIcon(QIcon::fromTheme(QStringLiteral("edit-undo"))); + undoAction->setIcon(FromTheme(VThemeIcon::EditUndo)); ui->menuSheet->addAction(undoAction); ui->toolBarUndoCommands->addAction(undoAction); redoAction = m_layout->UndoStack()->createRedoAction(this, tr("&Redo")); m_actionShortcuts.insert(VShortcutAction::Redo, redoAction); - redoAction->setIcon(QIcon::fromTheme(QStringLiteral("edit-redo"))); + redoAction->setIcon(FromTheme(VThemeIcon::EditRedo)); ui->menuSheet->addAction(redoAction); ui->toolBarUndoCommands->addAction(redoAction); @@ -883,7 +884,7 @@ void VPMainWindow::InitPropertyTabCurrentPiece() connect(ui->checkBoxCurrentPieceHorizontallyFlipped, &QCheckBox::toggled, this, &VPMainWindow::CurrentPieceHorizontallyFlippedToggled); - const QIcon warningIcon = QIcon::fromTheme(QStringLiteral("dialog-warning")); + const QIcon warningIcon = FromTheme(VThemeIcon::DialogWarning); auto WarningIcon = [warningIcon](QLabel *label) { const int size = qRound(16 * label->devicePixelRatio()); diff --git a/src/app/tape/tkmmainwindow.cpp b/src/app/tape/tkmmainwindow.cpp index 82513f0dd..ccf54a797 100644 --- a/src/app/tape/tkmmainwindow.cpp +++ b/src/app/tape/tkmmainwindow.cpp @@ -38,6 +38,7 @@ #include "../vmisc/dialogs/dialogexporttocsv.h" #include "../vmisc/dialogs/dialogselectlanguage.h" #include "../vmisc/qxtcsvmodel.h" +#include "../vmisc/theme/themeDef.h" #include "../vmisc/theme/vtheme.h" #include "../vmisc/vsysexits.h" #include "dialogs/dialogabouttape.h" @@ -1199,13 +1200,13 @@ void TKMMainWindow::DeployFormula() { ui->plainTextEditFormula->setFixedHeight(DIALOG_MAX_FORMULA_HEIGHT); // Set icon from theme (internal for Windows system) - ui->pushButtonGrow->setIcon(QIcon::fromTheme(QStringLiteral("go-next"))); + ui->pushButtonGrow->setIcon(FromTheme(VThemeIcon::GoNext)); } else { ui->plainTextEditFormula->setFixedHeight(m_formulaBaseHeight); // Set icon from theme (internal for Windows system) - ui->pushButtonGrow->setIcon(QIcon::fromTheme(QStringLiteral("go-down"))); + ui->pushButtonGrow->setIcon(FromTheme(VThemeIcon::GoDown)); } // I found that after change size of formula field, it was filed for angle formula, field for formula became black. diff --git a/src/app/tape/tmainwindow.cpp b/src/app/tape/tmainwindow.cpp index 809b78dea..0811fe055 100644 --- a/src/app/tape/tmainwindow.cpp +++ b/src/app/tape/tmainwindow.cpp @@ -45,6 +45,7 @@ #include "../vmisc/dialogs/dialogselectlanguage.h" #include "../vmisc/literals.h" #include "../vmisc/qxtcsvmodel.h" +#include "../vmisc/theme/themeDef.h" #include "../vmisc/theme/vtheme.h" #include "../vmisc/vsysexits.h" #include "../vpatterndb/calculator.h" @@ -2161,13 +2162,13 @@ void TMainWindow::DeployFormula() { ui->plainTextEditFormula->setFixedHeight(DIALOG_MAX_FORMULA_HEIGHT); // Set icon from theme (internal for Windows system) - ui->pushButtonGrow->setIcon(QIcon::fromTheme(QStringLiteral("go-next"))); + ui->pushButtonGrow->setIcon(FromTheme(VThemeIcon::GoNext)); } else { ui->plainTextEditFormula->setFixedHeight(m_formulaBaseHeight); // Set icon from theme (internal for Windows system) - ui->pushButtonGrow->setIcon(QIcon::fromTheme(QStringLiteral("go-down"))); + ui->pushButtonGrow->setIcon(FromTheme(VThemeIcon::GoDown)); } // I found that after change size of formula field, it was filed for angle formula, field for formula became black. diff --git a/src/app/valentina/dialogs/dialogfinalmeasurements.cpp b/src/app/valentina/dialogs/dialogfinalmeasurements.cpp index 70ddec630..51d019fa7 100644 --- a/src/app/valentina/dialogs/dialogfinalmeasurements.cpp +++ b/src/app/valentina/dialogs/dialogfinalmeasurements.cpp @@ -29,6 +29,7 @@ #include "dialogfinalmeasurements.h" #include "../qmuparser/qmudef.h" #include "../vmisc/compatibility.h" +#include "../vmisc/theme/themeDef.h" #include "../vmisc/theme/vtheme.h" #include "../vmisc/vabstractvalapplication.h" #include "../vmisc/vvalentinasettings.h" @@ -441,13 +442,13 @@ void DialogFinalMeasurements::DeployFormula() { ui->plainTextEditFormula->setFixedHeight(DIALOG_MAX_FORMULA_HEIGHT); // Set icon from theme (internal for Windows system) - ui->pushButtonGrow->setIcon(QIcon::fromTheme(QStringLiteral("go-next"))); + ui->pushButtonGrow->setIcon(FromTheme(VThemeIcon::GoNext)); } else { ui->plainTextEditFormula->setFixedHeight(formulaBaseHeight); // Set icon from theme (internal for Windows system) - ui->pushButtonGrow->setIcon(QIcon::fromTheme(QStringLiteral("go-down"))); + ui->pushButtonGrow->setIcon(FromTheme(VThemeIcon::GoDown)); } // I found that after change size of formula field, it was filed for angle formula, field for formula became black. diff --git a/src/app/valentina/dialogs/dialogincrements.cpp b/src/app/valentina/dialogs/dialogincrements.cpp index a83c857e3..e8149bc3e 100644 --- a/src/app/valentina/dialogs/dialogincrements.cpp +++ b/src/app/valentina/dialogs/dialogincrements.cpp @@ -1886,13 +1886,13 @@ void DialogIncrements::DeployFormula() { plainTextEditFormula->setFixedHeight(DIALOG_MAX_FORMULA_HEIGHT); // Set icon from theme (internal for Windows system) - pushButtonGrow->setIcon(QIcon::fromTheme(QStringLiteral("go-next"))); + pushButtonGrow->setIcon(FromTheme(VThemeIcon::GoNext)); } else { plainTextEditFormula->setFixedHeight(baseHeight); // Set icon from theme (internal for Windows system) - pushButtonGrow->setIcon(QIcon::fromTheme(QStringLiteral("go-down"))); + pushButtonGrow->setIcon(FromTheme(VThemeIcon::GoDown)); } // I found that after change size of formula field, it was filed for angle formula, field for formula became black. diff --git a/src/app/valentina/dialogs/vwidgetbackgroundimages.cpp b/src/app/valentina/dialogs/vwidgetbackgroundimages.cpp index f08959b6c..18e9bc7d2 100644 --- a/src/app/valentina/dialogs/vwidgetbackgroundimages.cpp +++ b/src/app/valentina/dialogs/vwidgetbackgroundimages.cpp @@ -30,6 +30,7 @@ #include "../ifc/xml/vbackgroundpatternimage.h" #include "../vmisc/def.h" #include "../vmisc/lambdaconstants.h" +#include "../vmisc/theme/themeDef.h" #include "../vmisc/theme/vtheme.h" #include "../vmisc/vabstractapplication.h" #include "../vtools/undocommands/image/hideallbackgroundimages.h" @@ -355,7 +356,7 @@ void VWidgetBackgroundImages::ContextMenu(const QPoint &pos) QAction *actionReset = menu.addAction(tr("Reset transformation")); actionReset->setEnabled(not image.Hold()); - QAction *actionDelete = menu.addAction(QIcon::fromTheme(editDeleteIcon), tr("Delete")); + QAction *actionDelete = menu.addAction(FromTheme(VThemeIcon::EditDelete), tr("Delete")); menu.addSeparator(); QAction *actionHoldAll = menu.addAction(tr("Hold All")); diff --git a/src/app/valentina/dialogs/vwidgetdetails.cpp b/src/app/valentina/dialogs/vwidgetdetails.cpp index fcb39fd0f..db51161a6 100644 --- a/src/app/valentina/dialogs/vwidgetdetails.cpp +++ b/src/app/valentina/dialogs/vwidgetdetails.cpp @@ -217,15 +217,13 @@ void VWidgetDetails::ToggledPieceItem(QTableWidgetItem *item) const bool inLayout = details->value(id).IsInLayout(); if (inLayout) { - item->setIcon( - QIcon::fromTheme(QStringLiteral("gtk-ok"), - VTheme::GetFallbackThemeIcon(QStringLiteral("16/actions/gtk-ok"), QSize(16, 16)))); + item->setIcon(FromTheme(VThemeIcon::GtkOk, + VTheme::GetFallbackThemeIcon(QStringLiteral("16/actions/gtk-ok"), QSize(16, 16)))); } else { - item->setIcon( - QIcon::fromTheme(QStringLiteral("gtk-no"), - VTheme::GetFallbackThemeIcon(QStringLiteral("16/actions/gtk-no"), QSize(16, 16)))); + item->setIcon(FromTheme(VThemeIcon::GtkNo, + VTheme::GetFallbackThemeIcon(QStringLiteral("16/actions/gtk-no"), QSize(16, 16)))); } VToolSeamAllowance *tool = nullptr; @@ -249,15 +247,13 @@ auto VWidgetDetails::PrepareInLayoutColumnCell(const VPiece &det, quint32 id) -> if (det.IsInLayout()) { - item->setIcon( - QIcon::fromTheme(QStringLiteral("gtk-ok"), - VTheme::GetFallbackThemeIcon(QStringLiteral("16/actions/gtk-ok"), QSize(16, 16)))); + item->setIcon(FromTheme(VThemeIcon::GtkOk, + VTheme::GetFallbackThemeIcon(QStringLiteral("16/actions/gtk-ok"), QSize(16, 16)))); } else { - item->setIcon( - QIcon::fromTheme(QStringLiteral("gtk-no"), - VTheme::GetFallbackThemeIcon(QStringLiteral("16/actions/gtk-no"), QSize(16, 16)))); + item->setIcon(FromTheme(VThemeIcon::GtkNo, + VTheme::GetFallbackThemeIcon(QStringLiteral("16/actions/gtk-no"), QSize(16, 16)))); } item->setData(Qt::UserRole, id); @@ -312,16 +308,14 @@ void VWidgetDetails::ShowContextMenu(const QPoint &pos) try { toolPiece = qobject_cast(VAbstractPattern::getTool(id)); - if (toolPiece) + if (toolPiece != nullptr) { pieceMode = true; menu->addSeparator(); - actionPieceOptions = - menu->addAction(QIcon::fromTheme(QStringLiteral("preferences-other")), tr("Piece options")); + actionPieceOptions = menu->addAction(FromTheme(VThemeIcon::PreferencesOther), tr("Piece options")); - actionDeletePiece = - menu->addAction(QIcon::fromTheme(QStringLiteral("edit-delete")), tr("Delete piece")); + actionDeletePiece = menu->addAction(FromTheme(VThemeIcon::EditDelete), tr("Delete piece")); actionDeletePiece->setDisabled(toolPiece->referens() > 0); } } diff --git a/src/app/valentina/dialogs/vwidgetgroups.cpp b/src/app/valentina/dialogs/vwidgetgroups.cpp index 906bd1804..70461cbf7 100644 --- a/src/app/valentina/dialogs/vwidgetgroups.cpp +++ b/src/app/valentina/dialogs/vwidgetgroups.cpp @@ -293,8 +293,8 @@ void VWidgetGroups::CtxMenu(const QPoint &pos) ? menu->addAction(VTheme::GetIconResource(resource, QStringLiteral("16x16/closed_eye.png")), tr("Hide")) : menu->addAction(VTheme::GetIconResource(resource, QStringLiteral("16x16/open_eye.png")), tr("Show")); - QAction *actionPreferences = menu->addAction(QIcon::fromTheme(preferencesOtherIcon), tr("Preferences")); - QAction *actionDelete = menu->addAction(QIcon::fromTheme(editDeleteIcon), tr("Delete")); + QAction *actionPreferences = menu->addAction(FromTheme(VThemeIcon::PreferencesOther), tr("Preferences")); + QAction *actionDelete = menu->addAction(FromTheme(VThemeIcon::EditDelete), tr("Delete")); menu->addSeparator(); QAction *actionHideAll = menu->addAction(tr("Hide All")); actionHideAll->setEnabled(MultipleChangeVisibilityTo(false)); diff --git a/src/app/valentina/mainwindow.cpp b/src/app/valentina/mainwindow.cpp index 31863ed63..3bf7cdc7a 100644 --- a/src/app/valentina/mainwindow.cpp +++ b/src/app/valentina/mainwindow.cpp @@ -5793,14 +5793,14 @@ void MainWindow::CreateMenus() undoAction = VAbstractApplication::VApp()->getUndoStack()->createUndoAction(this, tr("&Undo")); connect(undoAction, &QAction::triggered, m_toolOptions, &VToolOptionsPropertyBrowser::RefreshOptions); m_shortcutActions.insert(VShortcutAction::Undo, undoAction); - undoAction->setIcon(QIcon::fromTheme(QStringLiteral("edit-undo"))); + undoAction->setIcon(FromTheme(VThemeIcon::EditUndo)); ui->menuPatternPiece->insertAction(ui->actionLast_tool, undoAction); ui->toolBarTools->addAction(undoAction); redoAction = VAbstractApplication::VApp()->getUndoStack()->createRedoAction(this, tr("&Redo")); connect(redoAction, &QAction::triggered, m_toolOptions, &VToolOptionsPropertyBrowser::RefreshOptions); m_shortcutActions.insert(VShortcutAction::Redo, redoAction); - redoAction->setIcon(QIcon::fromTheme(QStringLiteral("edit-redo"))); + redoAction->setIcon(FromTheme(VThemeIcon::EditRedo)); ui->menuPatternPiece->insertAction(ui->actionLast_tool, redoAction); ui->toolBarTools->addAction(redoAction); diff --git a/src/libs/vmisc/literals.cpp b/src/libs/vmisc/literals.cpp index fd3020a76..98890bbe6 100644 --- a/src/libs/vmisc/literals.cpp +++ b/src/libs/vmisc/literals.cpp @@ -32,8 +32,6 @@ const QString LONG_OPTION_NO_HDPI_SCALING = QStringLiteral("no-scaling"); -const QString editDeleteIcon = QStringLiteral("edit-delete"); -const QString preferencesOtherIcon = QStringLiteral("preferences-other"); const QString degreeSymbol = QStringLiteral("°"); const QString trueStr = QStringLiteral("true"); const QString falseStr = QStringLiteral("false"); diff --git a/src/libs/vmisc/literals.h b/src/libs/vmisc/literals.h index a8f76d2b6..0edb55db3 100644 --- a/src/libs/vmisc/literals.h +++ b/src/libs/vmisc/literals.h @@ -41,8 +41,6 @@ class QStringList; extern const QString LONG_OPTION_NO_HDPI_SCALING; -extern const QString editDeleteIcon; -extern const QString preferencesOtherIcon; extern const QString degreeSymbol; extern const QString trueStr; extern const QString falseStr; diff --git a/src/libs/vmisc/theme/themeDef.cpp b/src/libs/vmisc/theme/themeDef.cpp new file mode 100644 index 000000000..422c6d918 --- /dev/null +++ b/src/libs/vmisc/theme/themeDef.cpp @@ -0,0 +1,407 @@ +/************************************************************************ + ** + ** @file themeDef.cpp + ** @author Roman Telezhynskyi + ** @date 22 4, 2024 + ** + ** @brief + ** @copyright + ** This source code is part of the Valentina project, a pattern making + ** program, whose allow create and modeling patterns of clothing. + ** Copyright (C) 2024 Valentina project + ** All Rights Reserved. + ** + ** Valentina is free software: you can redistribute it and/or modify + ** it under the terms of the GNU General Public License as published by + ** the Free Software Foundation, either version 3 of the License, or + ** (at your option) any later version. + ** + ** Valentina is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + ** GNU General Public License for more details. + ** + ** You should have received a copy of the GNU General Public License + ** along with Valentina. If not, see . + ** + *************************************************************************/ + +#include "themeDef.h" + +#include +#include + +#if QT_VERSION < QT_VERSION_CHECK(6, 4, 0) +#include "../compatibility.h" +#endif + +using namespace Qt::Literals::StringLiterals; + +namespace +{ +QT_WARNING_PUSH +QT_WARNING_DISABLE_CLANG("-Wunused-member-function") + +#if QT_VERSION >= QT_VERSION_CHECK(6, 7, 0) +using ThemeIconHash = QHash; +// NOLINTNEXTLINE +Q_GLOBAL_STATIC_WITH_ARGS(const ThemeIconHash, themeIconMapping, + ({{VThemeIcon::AddressBookNew, QIcon::ThemeIcon::AddressBookNew}, + {VThemeIcon::ApplicationExit, QIcon::ThemeIcon::ApplicationExit}, + {VThemeIcon::AppointmentNew, QIcon::ThemeIcon::AppointmentNew}, + {VThemeIcon::CallStart, QIcon::ThemeIcon::CallStart}, + {VThemeIcon::CallStop, QIcon::ThemeIcon::CallStop}, + {VThemeIcon::ContactNew, QIcon::ThemeIcon::ContactNew}, + {VThemeIcon::DocumentNew, QIcon::ThemeIcon::DocumentNew}, + {VThemeIcon::DocumentOpen, QIcon::ThemeIcon::DocumentOpen}, + {VThemeIcon::DocumentOpenRecent, QIcon::ThemeIcon::DocumentOpenRecent}, + {VThemeIcon::DocumentPageSetup, QIcon::ThemeIcon::DocumentPageSetup}, + {VThemeIcon::DocumentPrint, QIcon::ThemeIcon::DocumentPrint}, + {VThemeIcon::DocumentPrintPreview, QIcon::ThemeIcon::DocumentPrintPreview}, + {VThemeIcon::DocumentProperties, QIcon::ThemeIcon::DocumentProperties}, + {VThemeIcon::DocumentRevert, QIcon::ThemeIcon::DocumentRevert}, + {VThemeIcon::DocumentSave, QIcon::ThemeIcon::DocumentSave}, + {VThemeIcon::DocumentSaveAs, QIcon::ThemeIcon::DocumentSaveAs}, + {VThemeIcon::DocumentSend, QIcon::ThemeIcon::DocumentSend}, + {VThemeIcon::EditClear, QIcon::ThemeIcon::EditClear}, + {VThemeIcon::EditCopy, QIcon::ThemeIcon::EditCopy}, + {VThemeIcon::EditCut, QIcon::ThemeIcon::EditCut}, + {VThemeIcon::EditDelete, QIcon::ThemeIcon::EditDelete}, + {VThemeIcon::EditFind, QIcon::ThemeIcon::EditFind}, + {VThemeIcon::EditPaste, QIcon::ThemeIcon::EditPaste}, + {VThemeIcon::EditRedo, QIcon::ThemeIcon::EditRedo}, + {VThemeIcon::EditSelectAll, QIcon::ThemeIcon::EditSelectAll}, + {VThemeIcon::EditUndo, QIcon::ThemeIcon::EditUndo}, + {VThemeIcon::FolderNew, QIcon::ThemeIcon::FolderNew}, + {VThemeIcon::FormatIndentLess, QIcon::ThemeIcon::FormatIndentLess}, + {VThemeIcon::FormatIndentMore, QIcon::ThemeIcon::FormatIndentMore}, + {VThemeIcon::FormatJustifyCenter, QIcon::ThemeIcon::FormatJustifyCenter}, + {VThemeIcon::FormatJustifyFill, QIcon::ThemeIcon::FormatJustifyFill}, + {VThemeIcon::FormatJustifyLeft, QIcon::ThemeIcon::FormatJustifyLeft}, + {VThemeIcon::FormatJustifyRight, QIcon::ThemeIcon::FormatJustifyRight}, + {VThemeIcon::FormatTextDirectionLtr, QIcon::ThemeIcon::FormatTextDirectionLtr}, + {VThemeIcon::FormatTextDirectionRtl, QIcon::ThemeIcon::FormatTextDirectionRtl}, + {VThemeIcon::FormatTextBold, QIcon::ThemeIcon::FormatTextBold}, + {VThemeIcon::FormatTextItalic, QIcon::ThemeIcon::FormatTextItalic}, + {VThemeIcon::FormatTextUnderline, QIcon::ThemeIcon::FormatTextUnderline}, + {VThemeIcon::FormatTextStrikethrough, QIcon::ThemeIcon::FormatTextStrikethrough}, + {VThemeIcon::GoDown, QIcon::ThemeIcon::GoDown}, + {VThemeIcon::GoHome, QIcon::ThemeIcon::GoHome}, + {VThemeIcon::GoNext, QIcon::ThemeIcon::GoNext}, + {VThemeIcon::GoPrevious, QIcon::ThemeIcon::GoPrevious}, + {VThemeIcon::GoUp, QIcon::ThemeIcon::GoUp}, + {VThemeIcon::HelpAbout, QIcon::ThemeIcon::HelpAbout}, + {VThemeIcon::HelpFaq, QIcon::ThemeIcon::HelpFaq}, + {VThemeIcon::InsertImage, QIcon::ThemeIcon::InsertImage}, + {VThemeIcon::InsertLink, QIcon::ThemeIcon::InsertLink}, + {VThemeIcon::InsertText, QIcon::ThemeIcon::InsertText}, + {VThemeIcon::ListAdd, QIcon::ThemeIcon::InsertText}, + {VThemeIcon::ListRemove, QIcon::ThemeIcon::ListRemove}, + {VThemeIcon::MailForward, QIcon::ThemeIcon::MailForward}, + {VThemeIcon::MailMarkImportant, QIcon::ThemeIcon::MailMarkImportant}, + {VThemeIcon::MailMarkRead, QIcon::ThemeIcon::MailMarkRead}, + {VThemeIcon::MailMarkUnread, QIcon::ThemeIcon::MailMarkUnread}, + {VThemeIcon::MailMessageNew, QIcon::ThemeIcon::MailMessageNew}, + {VThemeIcon::MailReplyAll, QIcon::ThemeIcon::MailReplyAll}, + {VThemeIcon::MailReplySender, QIcon::ThemeIcon::MailReplySender}, + {VThemeIcon::MailSend, QIcon::ThemeIcon::MailSend}, + {VThemeIcon::MediaEject, QIcon::ThemeIcon::MediaEject}, + {VThemeIcon::MediaPlaybackPause, QIcon::ThemeIcon::MediaPlaybackPause}, + {VThemeIcon::MediaPlaybackStart, QIcon::ThemeIcon::MediaPlaybackStart}, + {VThemeIcon::MediaPlaybackStop, QIcon::ThemeIcon::MediaPlaybackStop}, + {VThemeIcon::MediaRecord, QIcon::ThemeIcon::MediaRecord}, + {VThemeIcon::MediaSeekBackward, QIcon::ThemeIcon::MediaSeekBackward}, + {VThemeIcon::MediaSeekForward, QIcon::ThemeIcon::MediaSeekForward}, + {VThemeIcon::MediaSkipBackward, QIcon::ThemeIcon::MediaSkipBackward}, + {VThemeIcon::MediaSkipForward, QIcon::ThemeIcon::MediaSkipForward}, + {VThemeIcon::ObjectRotateLeft, QIcon::ThemeIcon::ObjectRotateLeft}, + {VThemeIcon::ObjectRotateRight, QIcon::ThemeIcon::ObjectRotateRight}, + {VThemeIcon::ProcessStop, QIcon::ThemeIcon::ProcessStop}, + {VThemeIcon::SystemLockScreen, QIcon::ThemeIcon::SystemLockScreen}, + {VThemeIcon::SystemLogOut, QIcon::ThemeIcon::SystemLogOut}, + {VThemeIcon::SystemSearch, QIcon::ThemeIcon::SystemSearch}, + {VThemeIcon::SystemReboot, QIcon::ThemeIcon::SystemReboot}, + {VThemeIcon::SystemShutdown, QIcon::ThemeIcon::SystemShutdown}, + {VThemeIcon::ToolsCheckSpelling, QIcon::ThemeIcon::ToolsCheckSpelling}, + {VThemeIcon::ViewFullscreen, QIcon::ThemeIcon::ViewFullscreen}, + {VThemeIcon::ViewRefresh, QIcon::ThemeIcon::ViewRefresh}, + {VThemeIcon::ViewRestore, QIcon::ThemeIcon::ViewRestore}, + {VThemeIcon::WindowClose, QIcon::ThemeIcon::WindowClose}, + {VThemeIcon::WindowNew, QIcon::ThemeIcon::WindowNew}, + {VThemeIcon::ZoomFitBest, QIcon::ThemeIcon::ZoomFitBest}, + {VThemeIcon::ZoomIn, QIcon::ThemeIcon::ZoomIn}, + {VThemeIcon::ZoomOut, QIcon::ThemeIcon::ZoomOut}, + + {VThemeIcon::AudioCard, QIcon::ThemeIcon::AudioCard}, + {VThemeIcon::AudioInputMicrophone, QIcon::ThemeIcon::AudioInputMicrophone}, + {VThemeIcon::Battery, QIcon::ThemeIcon::Battery}, + {VThemeIcon::CameraPhoto, QIcon::ThemeIcon::CameraPhoto}, + {VThemeIcon::CameraVideo, QIcon::ThemeIcon::CameraVideo}, + {VThemeIcon::CameraWeb, QIcon::ThemeIcon::CameraWeb}, + {VThemeIcon::Computer, QIcon::ThemeIcon::Computer}, + {VThemeIcon::DriveHarddisk, QIcon::ThemeIcon::DriveHarddisk}, + {VThemeIcon::DriveOptical, QIcon::ThemeIcon::DriveOptical}, + {VThemeIcon::InputGaming, QIcon::ThemeIcon::InputGaming}, + {VThemeIcon::InputKeyboard, QIcon::ThemeIcon::InputKeyboard}, + {VThemeIcon::InputMouse, QIcon::ThemeIcon::InputMouse}, + {VThemeIcon::InputTablet, QIcon::ThemeIcon::InputTablet}, + {VThemeIcon::MediaFlash, QIcon::ThemeIcon::MediaFlash}, + {VThemeIcon::MediaOptical, QIcon::ThemeIcon::MediaOptical}, + {VThemeIcon::MediaTape, QIcon::ThemeIcon::MediaTape}, + {VThemeIcon::MultimediaPlayer, QIcon::ThemeIcon::MultimediaPlayer}, + {VThemeIcon::NetworkWired, QIcon::ThemeIcon::NetworkWired}, + {VThemeIcon::NetworkWireless, QIcon::ThemeIcon::NetworkWireless}, + {VThemeIcon::Phone, QIcon::ThemeIcon::Phone}, + {VThemeIcon::Printer, QIcon::ThemeIcon::Printer}, + {VThemeIcon::Scanner, QIcon::ThemeIcon::Scanner}, + {VThemeIcon::VideoDisplay, QIcon::ThemeIcon::VideoDisplay}, + + {VThemeIcon::AppointmentMissed, QIcon::ThemeIcon::AppointmentMissed}, + {VThemeIcon::AppointmentSoon, QIcon::ThemeIcon::AppointmentSoon}, + {VThemeIcon::AudioVolumeHigh, QIcon::ThemeIcon::AudioVolumeHigh}, + {VThemeIcon::AudioVolumeLow, QIcon::ThemeIcon::AudioVolumeLow}, + {VThemeIcon::AudioVolumeMedium, QIcon::ThemeIcon::AudioVolumeMedium}, + {VThemeIcon::AudioVolumeMuted, QIcon::ThemeIcon::AudioVolumeMuted}, + {VThemeIcon::BatteryCaution, QIcon::ThemeIcon::BatteryCaution}, + {VThemeIcon::BatteryLow, QIcon::ThemeIcon::BatteryLow}, + {VThemeIcon::DialogError, QIcon::ThemeIcon::DialogError}, + {VThemeIcon::DialogInformation, QIcon::ThemeIcon::DialogInformation}, + {VThemeIcon::DialogPassword, QIcon::ThemeIcon::DialogPassword}, + {VThemeIcon::DialogQuestion, QIcon::ThemeIcon::DialogQuestion}, + {VThemeIcon::DialogWarning, QIcon::ThemeIcon::DialogWarning}, + {VThemeIcon::FolderDragAccept, QIcon::ThemeIcon::FolderDragAccept}, + {VThemeIcon::FolderOpen, QIcon::ThemeIcon::FolderOpen}, + {VThemeIcon::FolderVisiting, QIcon::ThemeIcon::FolderVisiting}, + {VThemeIcon::ImageLoading, QIcon::ThemeIcon::ImageLoading}, + {VThemeIcon::ImageMissing, QIcon::ThemeIcon::ImageMissing}, + {VThemeIcon::MailAttachment, QIcon::ThemeIcon::MailAttachment}, + {VThemeIcon::MailUnread, QIcon::ThemeIcon::MailUnread}, + {VThemeIcon::MailRead, QIcon::ThemeIcon::MailRead}, + {VThemeIcon::MailReplied, QIcon::ThemeIcon::MailReplied}, + {VThemeIcon::MediaPlaylistRepeat, QIcon::ThemeIcon::MediaPlaylistRepeat}, + {VThemeIcon::MediaPlaylistShuffle, QIcon::ThemeIcon::MediaPlaylistShuffle}, + {VThemeIcon::NetworkOffline, QIcon::ThemeIcon::NetworkOffline}, + {VThemeIcon::PrinterPrinting, QIcon::ThemeIcon::PrinterPrinting}, + {VThemeIcon::SecurityHigh, QIcon::ThemeIcon::SecurityHigh}, + {VThemeIcon::SecurityLow, QIcon::ThemeIcon::SecurityLow}, + {VThemeIcon::SoftwareUpdateAvailable, QIcon::ThemeIcon::SoftwareUpdateAvailable}, + {VThemeIcon::SoftwareUpdateUrgent, QIcon::ThemeIcon::SoftwareUpdateUrgent}, + {VThemeIcon::SyncError, QIcon::ThemeIcon::SyncError}, + {VThemeIcon::SyncSynchronizing, QIcon::ThemeIcon::SyncSynchronizing}, + {VThemeIcon::UserAvailable, QIcon::ThemeIcon::UserAvailable}, + {VThemeIcon::UserOffline, QIcon::ThemeIcon::UserOffline}, + {VThemeIcon::WeatherClear, QIcon::ThemeIcon::WeatherClear}, + {VThemeIcon::WeatherClearNight, QIcon::ThemeIcon::WeatherClearNight}, + {VThemeIcon::WeatherFewClouds, QIcon::ThemeIcon::WeatherFewClouds}, + {VThemeIcon::WeatherFewCloudsNight, QIcon::ThemeIcon::WeatherFewCloudsNight}, + {VThemeIcon::WeatherFog, QIcon::ThemeIcon::WeatherFog}, + {VThemeIcon::WeatherShowers, QIcon::ThemeIcon::WeatherShowers}, + {VThemeIcon::WeatherSnow, QIcon::ThemeIcon::WeatherSnow}, + {VThemeIcon::WeatherStorm, QIcon::ThemeIcon::WeatherStorm}})) +#endif +using ThemeIconStringHash = QHash; +// NOLINTNEXTLINE +Q_GLOBAL_STATIC_WITH_ARGS(const ThemeIconStringHash, themeIconStringMapping, + ({{VThemeIcon::AddressBookNew, "address-book-new"_L1}, + {VThemeIcon::ApplicationExit, "application-exit"_L1}, + {VThemeIcon::AppointmentNew, "appointment-new"_L1}, + {VThemeIcon::CallStart, "call-start"_L1}, + {VThemeIcon::CallStop, "call-stop"_L1}, + {VThemeIcon::ContactNew, "contact-new"_L1}, + {VThemeIcon::DocumentNew, "document-new"_L1}, + {VThemeIcon::DocumentOpen, "document-open"_L1}, + {VThemeIcon::DocumentOpenRecent, "document-open-recent"_L1}, + {VThemeIcon::DocumentPageSetup, "document-page-setup"_L1}, + {VThemeIcon::DocumentPrint, "document-print"_L1}, + {VThemeIcon::DocumentPrintPreview, "document-print-preview"_L1}, + {VThemeIcon::DocumentProperties, "document-properties"_L1}, + {VThemeIcon::DocumentRevert, "document-revert"_L1}, + {VThemeIcon::DocumentSave, "document-save"_L1}, + {VThemeIcon::DocumentSaveAs, "document-save-as"_L1}, + {VThemeIcon::DocumentSend, "document-send"_L1}, + {VThemeIcon::EditClear, "edit-clear"_L1}, + {VThemeIcon::EditCopy, "edit-copy"_L1}, + {VThemeIcon::EditCut, "edit-cut"_L1}, + {VThemeIcon::EditDelete, "edit-delete"_L1}, + {VThemeIcon::EditFind, "edit-find"_L1}, + {VThemeIcon::EditPaste, "edit-paste"_L1}, + {VThemeIcon::EditRedo, "edit-redo"_L1}, + {VThemeIcon::EditSelectAll, "edit-select-all"_L1}, + {VThemeIcon::EditUndo, "edit-undo"_L1}, + {VThemeIcon::FolderNew, "folder-new"_L1}, + {VThemeIcon::FormatIndentLess, "format-indent-less"_L1}, + {VThemeIcon::FormatIndentMore, "format-indent-more"_L1}, + {VThemeIcon::FormatJustifyCenter, "format-justify-center"_L1}, + {VThemeIcon::FormatJustifyFill, "format-justify-fill"_L1}, + {VThemeIcon::FormatJustifyLeft, "format-justify-left"_L1}, + {VThemeIcon::FormatJustifyRight, "format-justify-right"_L1}, + {VThemeIcon::FormatTextDirectionLtr, "format-text-direction-ltr"_L1}, + {VThemeIcon::FormatTextDirectionRtl, "format-text-direction-rtl"_L1}, + {VThemeIcon::FormatTextBold, "format-text-bold"_L1}, + {VThemeIcon::FormatTextItalic, "format-text-italic"_L1}, + {VThemeIcon::FormatTextUnderline, "format-text-underline"_L1}, + {VThemeIcon::FormatTextStrikethrough, "format-text-strikethrough"_L1}, + {VThemeIcon::GoDown, "go-down"_L1}, + {VThemeIcon::GoHome, "go-home"_L1}, + {VThemeIcon::GoNext, "go-next"_L1}, + {VThemeIcon::GoPrevious, "go-previous"_L1}, + {VThemeIcon::GoUp, "go-up"_L1}, + {VThemeIcon::HelpAbout, "help-about"_L1}, + {VThemeIcon::HelpFaq, "help-faq"_L1}, + {VThemeIcon::InsertImage, "insert-image"_L1}, + {VThemeIcon::InsertLink, "insert-link"_L1}, + {VThemeIcon::InsertText, "insert-text"_L1}, + {VThemeIcon::ListAdd, "list-add"_L1}, + {VThemeIcon::ListRemove, "list-remove"_L1}, + {VThemeIcon::MailForward, "mail-forward"_L1}, + {VThemeIcon::MailMarkImportant, "mail-mark-important"_L1}, + {VThemeIcon::MailMarkRead, "mail-mark-read"_L1}, + {VThemeIcon::MailMarkUnread, "mail-mark-unread"_L1}, + {VThemeIcon::MailMessageNew, "mail-message-new"_L1}, + {VThemeIcon::MailReplyAll, "mail-reply-all"_L1}, + {VThemeIcon::MailReplySender, "mail-reply-sender"_L1}, + {VThemeIcon::MailSend, "mail-send"_L1}, + {VThemeIcon::MediaEject, "media-eject"_L1}, + {VThemeIcon::MediaPlaybackPause, "media-playback-pause"_L1}, + {VThemeIcon::MediaPlaybackStart, "media-playback-start"_L1}, + {VThemeIcon::MediaPlaybackStop, "media-playback-stop"_L1}, + {VThemeIcon::MediaRecord, "media-record"_L1}, + {VThemeIcon::MediaSeekBackward, "media-seek-backward"_L1}, + {VThemeIcon::MediaSeekForward, "media-seek-forward"_L1}, + {VThemeIcon::MediaSkipBackward, "media-skip-backward"_L1}, + {VThemeIcon::MediaSkipForward, "media-skip-forward"_L1}, + {VThemeIcon::ObjectRotateLeft, "object-rotate-left"_L1}, + {VThemeIcon::ObjectRotateRight, "object-rotate-right"_L1}, + {VThemeIcon::ProcessStop, "process-stop"_L1}, + {VThemeIcon::SystemLockScreen, "system-lock-screen"_L1}, + {VThemeIcon::SystemLogOut, "system-log-out"_L1}, + {VThemeIcon::SystemSearch, "system-search"_L1}, + {VThemeIcon::SystemReboot, "system-reboot"_L1}, + {VThemeIcon::SystemShutdown, "system-shutdown"_L1}, + {VThemeIcon::ToolsCheckSpelling, "tools-check-spelling"_L1}, + {VThemeIcon::ViewFullscreen, "view-fullscreen"_L1}, + {VThemeIcon::ViewRefresh, "view-refresh"_L1}, + {VThemeIcon::ViewRestore, "view-restore"_L1}, + {VThemeIcon::WindowClose, "window-close"_L1}, + {VThemeIcon::WindowNew, "window-new"_L1}, + {VThemeIcon::ZoomFitBest, "zoom-fit-best"_L1}, + {VThemeIcon::ZoomIn, "zoom-in"_L1}, + {VThemeIcon::ZoomOut, "zoom-out"_L1}, + + {VThemeIcon::AudioCard, "audio-card"_L1}, + {VThemeIcon::AudioInputMicrophone, "audio-input-microphone"_L1}, + {VThemeIcon::Battery, "battery"_L1}, + {VThemeIcon::CameraPhoto, "camera-photo"_L1}, + {VThemeIcon::CameraVideo, "camera-video"_L1}, + {VThemeIcon::CameraWeb, "camera-web"_L1}, + {VThemeIcon::Computer, "computer"_L1}, + {VThemeIcon::DriveHarddisk, "drive-harddisk"}, + {VThemeIcon::DriveOptical, "drive-optical"_L1}, + {VThemeIcon::InputGaming, "input-gaming"_L1}, + {VThemeIcon::InputKeyboard, "input-keyboard"_L1}, + {VThemeIcon::InputMouse, "input-mouse"_L1}, + {VThemeIcon::InputTablet, "input-tablet"_L1}, + {VThemeIcon::MediaFlash, "media-flash"_L1}, + {VThemeIcon::MediaOptical, "media-optical"_L1}, + {VThemeIcon::MediaTape, "media-tape"_L1}, + {VThemeIcon::MultimediaPlayer, "multimedia-player"_L1}, + {VThemeIcon::NetworkWired, "network-wired"_L1}, + {VThemeIcon::NetworkWireless, "network-wireless"_L1}, + {VThemeIcon::Phone, "phone"_L1}, + {VThemeIcon::Printer, "printer"_L1}, + {VThemeIcon::Scanner, "scanner"_L1}, + {VThemeIcon::VideoDisplay, "video-display"_L1}, + + {VThemeIcon::AppointmentMissed, "appointment-missed"_L1}, + {VThemeIcon::AppointmentSoon, "appointment-soon"_L1}, + {VThemeIcon::AudioVolumeHigh, "audio-volume-high"_L1}, + {VThemeIcon::AudioVolumeLow, "audio-volume-low"_L1}, + {VThemeIcon::AudioVolumeMedium, "audio-volume-medium"_L1}, + {VThemeIcon::AudioVolumeMuted, "audio-volume-muted"_L1}, + {VThemeIcon::BatteryCaution, "battery-caution"_L1}, + {VThemeIcon::BatteryLow, "battery-low"_L1}, + {VThemeIcon::DialogError, "dialog-error"_L1}, + {VThemeIcon::DialogInformation, "dialog-information"_L1}, + {VThemeIcon::DialogPassword, "dialog-password"_L1}, + {VThemeIcon::DialogQuestion, "dialog-question"_L1}, + {VThemeIcon::DialogWarning, "dialog-warning"_L1}, + {VThemeIcon::FolderDragAccept, "folder-drag-accept"_L1}, + {VThemeIcon::FolderOpen, "folder-open"_L1}, + {VThemeIcon::FolderVisiting, "folder-visiting"_L1}, + {VThemeIcon::ImageLoading, "image-loading"_L1}, + {VThemeIcon::ImageMissing, "image-missing"_L1}, + {VThemeIcon::MailAttachment, "mail-attachment"_L1}, + {VThemeIcon::MailUnread, "mail-unread"_L1}, + {VThemeIcon::MailRead, "mail-read"_L1}, + {VThemeIcon::MailReplied, "mail-replied"_L1}, + {VThemeIcon::MediaPlaylistRepeat, "media-playlist-repeat"_L1}, + {VThemeIcon::MediaPlaylistShuffle, "media-playlist-shuffle"_L1}, + {VThemeIcon::NetworkOffline, "network-offline"_L1}, + {VThemeIcon::PrinterPrinting, "printer-printing"_L1}, + {VThemeIcon::SecurityHigh, "security-high"_L1}, + {VThemeIcon::SecurityLow, "security-low"_L1}, + {VThemeIcon::SoftwareUpdateAvailable, "software-update-available"_L1}, + {VThemeIcon::SoftwareUpdateUrgent, "software-update-urgent"_L1}, + {VThemeIcon::SyncError, "sync-error"_L1}, + {VThemeIcon::SyncSynchronizing, "sync-synchronizing"_L1}, + {VThemeIcon::UserAvailable, "user-available"_L1}, + {VThemeIcon::UserOffline, "user-offline"_L1}, + {VThemeIcon::WeatherClear, "weather-clear"_L1}, + {VThemeIcon::WeatherClearNight, "weather-clear-night"_L1}, + {VThemeIcon::WeatherFewClouds, "weather-few-clouds"_L1}, + {VThemeIcon::WeatherFewCloudsNight, "weather-few-clouds-night"_L1}, + {VThemeIcon::WeatherFog, "weather-fog"_L1}, + {VThemeIcon::WeatherShowers, "weather-showers"_L1}, + {VThemeIcon::WeatherSnow, "weather-snow"_L1}, + {VThemeIcon::WeatherStorm, "weather-storm"_L1}, + + {VThemeIcon::PreferencesOther, "preferences-other"_L1}, + {VThemeIcon::GtkOk, "gtk-ok"_L1}, + {VThemeIcon::GtkNo, "gtk-no"_L1}})) +QT_WARNING_POP +} // namespace + +//--------------------------------------------------------------------------------------------------------------------- +auto FromTheme(VThemeIcon icon) -> QIcon +{ +#if QT_VERSION >= QT_VERSION_CHECK(6, 7, 0) + if (themeIconMapping->contains(icon)) + { + return QIcon::fromTheme(themeIconMapping->value(icon)); + } + + return QIcon::fromTheme(themeIconStringMapping->value(icon)); +#else + return QIcon::fromTheme(themeIconStringMapping->value(icon)); +#endif +} + +//--------------------------------------------------------------------------------------------------------------------- +auto FromTheme(VThemeIcon icon, const QIcon &fallback) -> QIcon +{ +#if QT_VERSION >= QT_VERSION_CHECK(6, 7, 0) + if (themeIconMapping->contains(icon)) + { + return QIcon::fromTheme(themeIconMapping->value(icon), fallback); + } + + return QIcon::fromTheme(themeIconStringMapping->value(icon), fallback); +#else + return QIcon::fromTheme(themeIconStringMapping->value(icon), fallback); +#endif +} + +//--------------------------------------------------------------------------------------------------------------------- +auto HasThemeIcon(VThemeIcon icon) -> bool +{ +#if QT_VERSION >= QT_VERSION_CHECK(6, 7, 0) + if (themeIconMapping->contains(icon)) + { + return QIcon::hasThemeIcon(themeIconMapping->value(icon)); + } + + return QIcon::hasThemeIcon(themeIconStringMapping->value(icon)); +#else + return QIcon::hasThemeIcon(themeIconStringMapping->value(icon)); +#endif +} diff --git a/src/libs/vmisc/theme/themeDef.h b/src/libs/vmisc/theme/themeDef.h index 78ef3a4a9..b4692d7a4 100644 --- a/src/libs/vmisc/theme/themeDef.h +++ b/src/libs/vmisc/theme/themeDef.h @@ -34,6 +34,8 @@ #include #endif +class QIcon; + enum class VColorRole { DefaultColor, @@ -67,4 +69,178 @@ Q_DECL_CONST_FUNCTION inline auto qHash(VColorRole key, uint seed = 0) noexcept } #endif +enum class VThemeIcon +{ + AddressBookNew, + ApplicationExit, + AppointmentNew, + CallStart, + CallStop, + ContactNew, + DocumentNew, + DocumentOpen, + DocumentOpenRecent, + DocumentPageSetup, + DocumentPrint, + DocumentPrintPreview, + DocumentProperties, + DocumentRevert, + DocumentSave, + DocumentSaveAs, + DocumentSend, + EditClear, + EditCopy, + EditCut, + EditDelete, + EditFind, + EditPaste, + EditRedo, + EditSelectAll, + EditUndo, + FolderNew, + FormatIndentLess, + FormatIndentMore, + FormatJustifyCenter, + FormatJustifyFill, + FormatJustifyLeft, + FormatJustifyRight, + FormatTextDirectionLtr, + FormatTextDirectionRtl, + FormatTextBold, + FormatTextItalic, + FormatTextUnderline, + FormatTextStrikethrough, + GoDown, + GoHome, + GoNext, + GoPrevious, + GoUp, + HelpAbout, + HelpFaq, + InsertImage, + InsertLink, + InsertText, + ListAdd, + ListRemove, + MailForward, + MailMarkImportant, + MailMarkRead, + MailMarkUnread, + MailMessageNew, + MailReplyAll, + MailReplySender, + MailSend, + MediaEject, + MediaPlaybackPause, + MediaPlaybackStart, + MediaPlaybackStop, + MediaRecord, + MediaSeekBackward, + MediaSeekForward, + MediaSkipBackward, + MediaSkipForward, + ObjectRotateLeft, + ObjectRotateRight, + ProcessStop, + SystemLockScreen, + SystemLogOut, + SystemSearch, + SystemReboot, + SystemShutdown, + ToolsCheckSpelling, + ViewFullscreen, + ViewRefresh, + ViewRestore, + WindowClose, + WindowNew, + ZoomFitBest, + ZoomIn, + ZoomOut, + + AudioCard, + AudioInputMicrophone, + Battery, + CameraPhoto, + CameraVideo, + CameraWeb, + Computer, + DriveHarddisk, + DriveOptical, + InputGaming, + InputKeyboard, + InputMouse, + InputTablet, + MediaFlash, + MediaOptical, + MediaTape, + MultimediaPlayer, + NetworkWired, + NetworkWireless, + Phone, + Printer, + Scanner, + VideoDisplay, + + AppointmentMissed, + AppointmentSoon, + AudioVolumeHigh, + AudioVolumeLow, + AudioVolumeMedium, + AudioVolumeMuted, + BatteryCaution, + BatteryLow, + DialogError, + DialogInformation, + DialogPassword, + DialogQuestion, + DialogWarning, + FolderDragAccept, + FolderOpen, + FolderVisiting, + ImageLoading, + ImageMissing, + MailAttachment, + MailUnread, + MailRead, + MailReplied, + MediaPlaylistRepeat, + MediaPlaylistShuffle, + NetworkOffline, + PrinterPrinting, + SecurityHigh, + SecurityLow, + SoftwareUpdateAvailable, + SoftwareUpdateUrgent, + SyncError, + SyncSynchronizing, + UserAvailable, + UserOffline, + WeatherClear, + WeatherClearNight, + WeatherFewClouds, + WeatherFewCloudsNight, + WeatherFog, + WeatherShowers, + WeatherSnow, + WeatherStorm, + + // Not supported by Qt + PreferencesOther, + GtkOk, + GtkNo +}; + +#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) +Q_DECL_CONST_FUNCTION inline auto qHash(VThemeIcon key, uint seed = 0) noexcept -> uint +{ + auto underlyingValue = static_cast::type>(key); + return ::qHash(underlyingValue, seed); +} +#endif + +auto FromTheme(VThemeIcon icon) -> QIcon; +auto FromTheme(VThemeIcon icon, const QIcon &fallback) -> QIcon; + +auto HasThemeIcon(VThemeIcon icon) -> bool; + #endif // THEMEDEF_H diff --git a/src/libs/vmisc/theme/vtheme.cpp b/src/libs/vmisc/theme/vtheme.cpp index 38d50a1bf..d8babac56 100644 --- a/src/libs/vmisc/theme/vtheme.cpp +++ b/src/libs/vmisc/theme/vtheme.cpp @@ -334,8 +334,7 @@ void VTheme::InitApplicationStyle() //--------------------------------------------------------------------------------------------------------------------- void VTheme::SetIconTheme() { - static const char *GENERIC_ICON_TO_CHECK = "document-open"; - if (not QIcon::hasThemeIcon(GENERIC_ICON_TO_CHECK)) + if (not HasThemeIcon(VThemeIcon::DocumentOpen)) { // If there is no default working icon theme then we should // use an icon theme that we provide via a .qrc file diff --git a/src/libs/vmisc/vmisc.qbs b/src/libs/vmisc/vmisc.qbs index dd9d8862f..bc9f4ec2c 100644 --- a/src/libs/vmisc/vmisc.qbs +++ b/src/libs/vmisc/vmisc.qbs @@ -142,6 +142,7 @@ VLib { name: "theme" prefix: "theme/" files: [ + "themeDef.cpp", "themeDef.h", "vapplicationstyle.cpp", "vapplicationstyle.h", diff --git a/src/libs/vtools/dialogs/dialogtoolbox.cpp b/src/libs/vtools/dialogs/dialogtoolbox.cpp index 95a7ca30f..b45cb2f08 100644 --- a/src/libs/vtools/dialogs/dialogtoolbox.cpp +++ b/src/libs/vtools/dialogs/dialogtoolbox.cpp @@ -37,6 +37,7 @@ #include "../vgeometry/vspline.h" #include "../vgeometry/vsplinepath.h" #include "../vmisc/def.h" +#include "../vmisc/theme/themeDef.h" #include "../vmisc/vabstractapplication.h" #include "../vpatterndb/calculator.h" #include "../vpatterndb/variables/vcurvelength.h" @@ -223,13 +224,13 @@ void DeployFormula(QDialog *dialog, QPlainTextEdit *formula, QPushButton *button { formula->setFixedHeight(dialogMaxFormulaHeight); // Set icon from theme (internal for Windows system) - buttonGrowLength->setIcon(QIcon::fromTheme(QStringLiteral("go-next"))); + buttonGrowLength->setIcon(FromTheme(VThemeIcon::GoNext)); } else { formula->setFixedHeight(formulaBaseHeight); // Set icon from theme (internal for Windows system) - buttonGrowLength->setIcon(QIcon::fromTheme(QStringLiteral("go-down"))); + buttonGrowLength->setIcon(FromTheme(VThemeIcon::GoDown)); } // I found that after change size of formula field, it was filed for angle formula, field for formula became black. @@ -609,7 +610,7 @@ auto EachPointLabelIsUnique(QListWidget *listWidget) -> bool //--------------------------------------------------------------------------------------------------------------------- auto DialogWarningIcon() -> QString { - const QIcon icon = QIcon::fromTheme(QStringLiteral("dialog-warning")); + const QIcon icon = FromTheme(VThemeIcon::DialogWarning); const QPixmap pixmap = icon.pixmap(QSize(16, 16)); QByteArray byteArray; diff --git a/src/libs/vtools/dialogs/tools/piece/dialoginsertnode.cpp b/src/libs/vtools/dialogs/tools/piece/dialoginsertnode.cpp index 35e36f655..188e0899e 100644 --- a/src/libs/vtools/dialogs/tools/piece/dialoginsertnode.cpp +++ b/src/libs/vtools/dialogs/tools/piece/dialoginsertnode.cpp @@ -27,6 +27,7 @@ *************************************************************************/ #include "dialoginsertnode.h" +#include "../vmisc/theme/themeDef.h" #include "../vpatterndb/vcontainer.h" #include "ui_dialoginsertnode.h" @@ -217,7 +218,7 @@ void DialogInsertNode::ShowContextMenu(const QPoint &pos) QListWidgetItem *rowItem = ui->listWidget->item(row); SCASSERT(rowItem != nullptr); - QAction *actionDelete = menu->addAction(QIcon::fromTheme(editDeleteIcon), tr("Delete")); + QAction *actionDelete = menu->addAction(FromTheme(VThemeIcon::EditDelete), tr("Delete")); QAction *selectedAction = menu->exec(ui->listWidget->viewport()->mapToGlobal(pos)); if (selectedAction == actionDelete) diff --git a/src/libs/vtools/dialogs/tools/piece/dialogpiecepath.cpp b/src/libs/vtools/dialogs/tools/piece/dialogpiecepath.cpp index b90368737..b7d296dd4 100644 --- a/src/libs/vtools/dialogs/tools/piece/dialogpiecepath.cpp +++ b/src/libs/vtools/dialogs/tools/piece/dialogpiecepath.cpp @@ -263,7 +263,7 @@ void DialogPiecePath::CheckState() } else { - const QIcon icon = QIcon::fromTheme(QStringLiteral("dialog-warning")); + const QIcon icon = FromTheme(VThemeIcon::DialogWarning); ui->tabWidget->setTabIcon(tabSeamAllowanceIndex, icon); } @@ -276,7 +276,7 @@ void DialogPiecePath::CheckState() } else { - const QIcon icon = QIcon::fromTheme(QStringLiteral("dialog-warning")); + const QIcon icon = FromTheme(VThemeIcon::DialogWarning); ui->tabWidget->setTabIcon(tabControlIndex, icon); } @@ -292,7 +292,7 @@ void DialogPiecePath::CheckState() } else { - const QIcon icon = QIcon::fromTheme(QStringLiteral("dialog-warning")); + const QIcon icon = FromTheme(VThemeIcon::DialogWarning); ui->tabWidget->setTabIcon(tabPassmarksIndex, icon); } @@ -2348,8 +2348,8 @@ auto DialogPiecePath::InitContextMenu(QMenu *menu, const VPieceNode &rowNode) -> actionExcluded->setChecked(rowNode.IsExcluded()); contextMenu.insert(static_cast(ContextMenuOption::Excluded), actionExcluded); - QAction *actionDelete = menu->addAction(QIcon::fromTheme(QStringLiteral("edit-delete")), - QApplication::translate("DialogSeamAllowance", "Delete")); + QAction *actionDelete = + menu->addAction(FromTheme(VThemeIcon::EditDelete), QApplication::translate("DialogSeamAllowance", "Delete")); contextMenu.insert(static_cast(ContextMenuOption::Delete), actionDelete); return contextMenu; diff --git a/src/libs/vtools/dialogs/tools/piece/dialogseamallowance.cpp b/src/libs/vtools/dialogs/tools/piece/dialogseamallowance.cpp index 107ba9527..86fc1a7f5 100644 --- a/src/libs/vtools/dialogs/tools/piece/dialogseamallowance.cpp +++ b/src/libs/vtools/dialogs/tools/piece/dialogseamallowance.cpp @@ -603,7 +603,7 @@ void DialogSeamAllowance::CheckTabPathsState() m_ftb->SetTabText(TabOrder::Paths, (isValid && flagMainPathIsValid && isNameAndUUIDValid) ? tr("Paths") : tr("Paths") + '*'_L1); - const QIcon warningIcon = QIcon::fromTheme(QStringLiteral("dialog-warning")); + const QIcon warningIcon = FromTheme(VThemeIcon::DialogWarning); uiTabPaths->tabWidget->setTabIcon(uiTabPaths->tabWidget->indexOf(uiTabPaths->tabSeamAllowance), isValid ? QIcon() : warningIcon); @@ -641,7 +641,7 @@ void DialogSeamAllowance::CheckTabPassmarksState() m_ftb->SetTabText(TabOrder::Passmarks, tr("Passmarks") + (allFormulasValid ? QString() : QChar('*'))); - const QIcon icon = QIcon::fromTheme(QStringLiteral("dialog-warning")); + const QIcon icon = FromTheme(VThemeIcon::DialogWarning); uiTabPassmarks->tabWidget->setTabIcon(uiTabPassmarks->tabWidget->indexOf(uiTabPassmarks->tabManualShape), allFormulasValid ? QIcon() : icon); @@ -670,7 +670,7 @@ void DialogSeamAllowance::CheckTabFoldLineState() m_ftb->SetTabText(TabOrder::FoldLine, tr("Fold line") + (allFormulasValid ? QString() : QChar('*'))); - const QIcon icon = QIcon::fromTheme(QStringLiteral("dialog-warning")); + const QIcon icon = FromTheme(VThemeIcon::DialogWarning); uiTabFoldLine->tabWidget->setTabIcon(uiTabFoldLine->tabWidget->indexOf(uiTabFoldLine->tabShape), allFormulasValid ? QIcon() : icon); } @@ -1205,7 +1205,7 @@ void DialogSeamAllowance::ShowCustomSAContextMenu(const QPoint &pos) } QScopedPointer const menu(new QMenu()); - QAction *actionOption = menu->addAction(QIcon::fromTheme(preferencesOtherIcon), tr("Options")); + QAction *actionOption = menu->addAction(FromTheme(VThemeIcon::PreferencesOther), tr("Options")); QListWidgetItem *rowItem = uiTabPaths->listWidgetCustomSA->item(row); SCASSERT(rowItem != nullptr); @@ -1215,7 +1215,7 @@ void DialogSeamAllowance::ShowCustomSAContextMenu(const QPoint &pos) actionReverse->setCheckable(true); actionReverse->setChecked(record.reverse); - QAction *actionDelete = menu->addAction(QIcon::fromTheme(editDeleteIcon), tr("Delete")); + QAction *actionDelete = menu->addAction(FromTheme(VThemeIcon::EditDelete), tr("Delete")); QAction *selectedAction = menu->exec(uiTabPaths->listWidgetCustomSA->viewport()->mapToGlobal(pos)); if (selectedAction == actionDelete) @@ -1257,8 +1257,8 @@ void DialogSeamAllowance::ShowInternalPathsContextMenu(const QPoint &pos) } QScopedPointer const menu(new QMenu()); - QAction *actionOption = menu->addAction(QIcon::fromTheme(preferencesOtherIcon), tr("Options")); - QAction *actionDelete = menu->addAction(QIcon::fromTheme(editDeleteIcon), tr("Delete")); + QAction *actionOption = menu->addAction(FromTheme(VThemeIcon::PreferencesOther), tr("Options")); + QAction *actionDelete = menu->addAction(FromTheme(VThemeIcon::EditDelete), tr("Delete")); QAction *selectedAction = menu->exec(uiTabPaths->listWidgetInternalPaths->viewport()->mapToGlobal(pos)); if (selectedAction == actionDelete) @@ -1292,7 +1292,7 @@ void DialogSeamAllowance::ShowPinsContextMenu(const QPoint &pos) } QScopedPointer const menu(new QMenu()); - QAction *actionDelete = menu->addAction(QIcon::fromTheme(editDeleteIcon), tr("Delete")); + QAction *actionDelete = menu->addAction(FromTheme(VThemeIcon::EditDelete), tr("Delete")); QAction *selectedAction = menu->exec(uiTabPins->listWidgetPins->viewport()->mapToGlobal(pos)); if (selectedAction == actionDelete) @@ -1341,7 +1341,7 @@ void DialogSeamAllowance::ShowPlaceLabelsContextMenu(const QPoint &pos) UpdateCurrentPlaceLabelRecords(); }; - QAction *actionOption = menu->addAction(QIcon::fromTheme(preferencesOtherIcon), tr("Options")); + QAction *actionOption = menu->addAction(FromTheme(VThemeIcon::PreferencesOther), tr("Options")); menu->addSeparator(); QAction *actionSegment = InitAction(tr("Segment"), PlaceLabelType::Segment); QAction *actionRectangle = InitAction(tr("Rectangle"), PlaceLabelType::Rectangle); @@ -1354,7 +1354,7 @@ void DialogSeamAllowance::ShowPlaceLabelsContextMenu(const QPoint &pos) QAction *actionButton = InitAction(tr("Button"), PlaceLabelType::Button); QAction *actionCircle = InitAction(tr("Circle"), PlaceLabelType::Circle); menu->addSeparator(); - QAction *actionDelete = menu->addAction(QIcon::fromTheme(editDeleteIcon), tr("Delete")); + QAction *actionDelete = menu->addAction(FromTheme(VThemeIcon::EditDelete), tr("Delete")); QAction *selectedAction = menu->exec(uiTabPlaceLabels->listWidgetPlaceLabels->viewport()->mapToGlobal(pos)); if (selectedAction == actionDelete) @@ -2210,7 +2210,7 @@ void DialogSeamAllowance::UpdateDetailLabelValues() if (not flagDLAngle || not(flagDLFormulas || flagDPin) || not flagPLAngle || not(flagPLFormulas || flagPPin)) { m_ftb->SetTabText(TabOrder::Labels, tr("Labels") + '*'); - const QIcon icon = QIcon::fromTheme(QStringLiteral("dialog-warning")); + const QIcon icon = FromTheme(VThemeIcon::DialogWarning); uiTabLabels->tabWidget->setTabIcon(uiTabLabels->tabWidget->indexOf(uiTabLabels->tabLabels), icon); } else @@ -2293,7 +2293,7 @@ void DialogSeamAllowance::UpdatePatternLabelValues() if (not flagDLAngle || not(flagDLFormulas || flagDPin) || not flagPLAngle || not(flagPLFormulas || flagPPin)) { m_ftb->SetTabText(TabOrder::Labels, tr("Labels") + '*'); - const QIcon icon = QIcon::fromTheme(QStringLiteral("dialog-warning")); + const QIcon icon = FromTheme(VThemeIcon::DialogWarning); uiTabLabels->tabWidget->setTabIcon(uiTabLabels->tabWidget->indexOf(uiTabLabels->tabLabels), icon); } else @@ -3177,7 +3177,7 @@ void DialogSeamAllowance::DetailPinPointChanged() topPinId == NULL_ID &&bottomPinId == NULL_ID ? color = OkColor(this) : color = errorColor; m_ftb->SetTabText(TabOrder::Labels, tr("Labels") + '*'); - const QIcon icon = QIcon::fromTheme(QStringLiteral("dialog-warning")); + const QIcon icon = FromTheme(VThemeIcon::DialogWarning); uiTabLabels->tabWidget->setTabIcon(uiTabLabels->tabWidget->indexOf(uiTabLabels->tabLabels), icon); } EnableDetailLabelFormulaControls(not flagDPin); @@ -3210,7 +3210,7 @@ void DialogSeamAllowance::PatternPinPointChanged() topPinId == NULL_ID &&bottomPinId == NULL_ID ? color = OkColor(this) : color = errorColor; m_ftb->SetTabText(TabOrder::Labels, tr("Labels") + '*'); - const QIcon icon = QIcon::fromTheme(QStringLiteral("dialog-warning")); + const QIcon icon = FromTheme(VThemeIcon::DialogWarning); uiTabLabels->tabWidget->setTabIcon(uiTabLabels->tabWidget->indexOf(uiTabLabels->tabLabels), icon); } EnablePatternLabelFormulaControls(not flagPPin); @@ -5383,7 +5383,7 @@ auto DialogSeamAllowance::InitMainPathContextMenu(QMenu *menu, const VPieceNode contextMenu.insert(static_cast(MainPathContextMenuOption::Excluded), actionExcluded); QAction *actionDelete = - menu->addAction(QIcon::fromTheme(editDeleteIcon), QApplication::translate("DialogSeamAllowance", "Delete")); + menu->addAction(FromTheme(VThemeIcon::EditDelete), QApplication::translate("DialogSeamAllowance", "Delete")); contextMenu.insert(static_cast(MainPathContextMenuOption::Delete), actionDelete); return contextMenu; diff --git a/src/libs/vtools/tools/backgroundimage/vbackgroundimageitem.cpp b/src/libs/vtools/tools/backgroundimage/vbackgroundimageitem.cpp index 596c7a87d..cd30afce7 100644 --- a/src/libs/vtools/tools/backgroundimage/vbackgroundimageitem.cpp +++ b/src/libs/vtools/tools/backgroundimage/vbackgroundimageitem.cpp @@ -27,34 +27,35 @@ *************************************************************************/ #include "vbackgroundimageitem.h" -#include "../vmisc/vabstractvalapplication.h" -#include "../vwidgets/vmaingraphicsview.h" -#include "../ifc/xml/vabstractpattern.h" -#include "../../undocommands/image/movebackgroundimage.h" +#include "../../undocommands/image/hidebackgroundimage.h" #include "../../undocommands/image/holdbackgroundimage.h" +#include "../../undocommands/image/movebackgroundimage.h" +#include "../../undocommands/image/opaquebackgroundimage.h" +#include "../../undocommands/image/renamebackgroundimage.h" +#include "../../undocommands/image/resetbackgroundimage.h" #include "../../undocommands/image/rotatebackgroundimage.h" #include "../../undocommands/image/scalebackgroundimage.h" -#include "../../undocommands/image/renamebackgroundimage.h" -#include "../../undocommands/image/hidebackgroundimage.h" -#include "../../undocommands/image/resetbackgroundimage.h" -#include "../../undocommands/image/opaquebackgroundimage.h" #include "../../undocommands/image/zvaluemovebackgroundimage.h" +#include "../ifc/xml/vabstractpattern.h" #include "../toolsdef.h" +#include "../vmisc/theme/themeDef.h" +#include "../vmisc/vabstractvalapplication.h" +#include "../vwidgets/vmaingraphicsview.h" -#include -#include -#include -#include #include -#include +#include +#include #include +#include +#include +#include //--------------------------------------------------------------------------------------------------------------------- VBackgroundImageItem::VBackgroundImageItem(const VBackgroundPatternImage &image, VAbstractPattern *doc, QGraphicsItem *parent) - : QGraphicsObject{parent}, - m_image(image), - m_doc(doc) + : QGraphicsObject{parent}, + m_image(image), + m_doc(doc) { SCASSERT(doc != nullptr) @@ -176,7 +177,7 @@ void VBackgroundImageItem::PositionChanged(QUuid id) QTransform const newMatrix = m_image.Matrix(); if (not VFuzzyComparePossibleNulls(oldMatrix.m31(), newMatrix.m31()) || - not VFuzzyComparePossibleNulls(oldMatrix.m32(), newMatrix.m32())) + not VFuzzyComparePossibleNulls(oldMatrix.m32(), newMatrix.m32())) { prepareGeometryChange(); update(); @@ -352,7 +353,7 @@ void VBackgroundImageItem::mouseMoveEvent(QGraphicsSceneMouseEvent *event) void VBackgroundImageItem::mouseReleaseEvent(QGraphicsSceneMouseEvent *event) { if (event->button() == Qt::LeftButton && event->type() != QEvent::GraphicsSceneMouseDoubleClick && - (flags() & QGraphicsItem::ItemIsMovable)) + (flags() & QGraphicsItem::ItemIsMovable)) { m_lastMoveDistance = QPointF(); SetItemOverrideCursor(this, cursorArrowOpenHand, 1, 1); @@ -422,16 +423,16 @@ void VBackgroundImageItem::contextMenuEvent(QGraphicsSceneContextMenuEvent *even actionVisible->setCheckable(true); actionVisible->setChecked(m_image.Visible()); - #if defined(Q_OS_MAC) +#if defined(Q_OS_MAC) const QString actionShowTitle = tr("Show in Finder"); #else const QString actionShowTitle = tr("Show in Explorer"); #endif - QAction *actionShow = menu.addAction(QIcon::fromTheme(QStringLiteral("system-search")), actionShowTitle); + QAction *actionShow = menu.addAction(FromTheme(VThemeIcon::SystemSearch), actionShowTitle); actionShow->setVisible(false); actionShow->setEnabled(QFileInfo::exists(m_image.FilePath())); - QAction *actionSaveAs = menu.addAction(QIcon::fromTheme(QStringLiteral("document-save-as")), tr("Save as …")); + QAction *actionSaveAs = menu.addAction(FromTheme(VThemeIcon::DocumentSaveAs), tr("Save as …")); actionSaveAs->setVisible(false); if (not m_image.FilePath().isEmpty()) @@ -446,7 +447,7 @@ void VBackgroundImageItem::contextMenuEvent(QGraphicsSceneContextMenuEvent *even QAction *actionReset = menu.addAction(tr("Reset transformation")); actionReset->setEnabled(not m_image.Hold()); - QAction *actionRemove = menu.addAction(QIcon::fromTheme(QStringLiteral("edit-delete")), tr("Delete")); + QAction *actionRemove = menu.addAction(FromTheme(VThemeIcon::EditDelete), tr("Delete")); QAction *selectedAction = menu.exec(event->screenPos()); if (selectedAction == holdOption) @@ -481,16 +482,16 @@ void VBackgroundImageItem::keyPressEvent(QKeyEvent *event) const int move = (event->modifiers() & Qt::ShiftModifier) ? 10 : 1; int angle = 15; - if(event->modifiers() & Qt::ControlModifier) + if (event->modifiers() & Qt::ControlModifier) { angle = 90; } - else if(event->modifiers() & Qt::AltModifier) + else if (event->modifiers() & Qt::AltModifier) { angle = 1; } - switch(event->key()) + switch (event->key()) { case Qt::Key_Left: TranslateImageOn(-move, 0); @@ -557,16 +558,10 @@ void VBackgroundImageItem::keyReleaseEvent(QKeyEvent *event) return; } } - else if (event->key() == Qt::Key_Left || - event->key() == Qt::Key_Right || - event->key() == Qt::Key_Up || - event->key() == Qt::Key_Down || - event->key() == Qt::Key_BracketLeft || - event->key() == Qt::Key_BracketRight || - event->key() == Qt::Key_Period || - event->key() == Qt::Key_Greater || - event->key() == Qt::Key_Comma || - event->key() == Qt::Key_Less) + else if (event->key() == Qt::Key_Left || event->key() == Qt::Key_Right || event->key() == Qt::Key_Up || + event->key() == Qt::Key_Down || event->key() == Qt::Key_BracketLeft || + event->key() == Qt::Key_BracketRight || event->key() == Qt::Key_Period || + event->key() == Qt::Key_Greater || event->key() == Qt::Key_Comma || event->key() == Qt::Key_Less) { if (not event->isAutoRepeat()) { @@ -612,7 +607,7 @@ void VBackgroundImageItem::UpdateHoldState() m_image = m_doc->GetBackgroundImage(m_image.Id()); setFlag(QGraphicsItem::ItemIsMovable, not m_image.Hold()); setFlag(QGraphicsItem::ItemSendsGeometryChanges, not m_image.Hold()); - setFlag(QGraphicsItem::ItemIsFocusable, not m_image.Hold());// For keyboard input focus + setFlag(QGraphicsItem::ItemIsFocusable, not m_image.Hold()); // For keyboard input focus emit UpdateControls(); } @@ -644,7 +639,7 @@ void VBackgroundImageItem::InitImage() setFlag(QGraphicsItem::ItemIsMovable, not m_image.Hold()); setFlag(QGraphicsItem::ItemSendsGeometryChanges, not m_image.Hold()); - setFlag(QGraphicsItem::ItemIsFocusable, not m_image.Hold());// For keyboard input focus + setFlag(QGraphicsItem::ItemIsFocusable, not m_image.Hold()); // For keyboard input focus setVisible(m_image.Visible()); } diff --git a/src/libs/vtools/tools/drawTools/vdrawtool.h b/src/libs/vtools/tools/drawTools/vdrawtool.h index 2932dd0f4..db243ca62 100644 --- a/src/libs/vtools/tools/drawTools/vdrawtool.h +++ b/src/libs/vtools/tools/drawTools/vdrawtool.h @@ -183,16 +183,14 @@ void VDrawTool::ContextMenu(QGraphicsSceneContextMenuEvent *event, quint32 itemI qCDebug(vTool, "Creating tool context menu."); QMenu menu; - QAction *actionOption = - menu.addAction(QIcon::fromTheme(QStringLiteral("preferences-other")), VDrawTool::tr("Options")); + QAction *actionOption = menu.addAction(FromTheme(VThemeIcon::PreferencesOther), VDrawTool::tr("Options")); // add the menu "add to group" to the context menu QMap groupsNotContainingItem = doc->GetGroupsContainingItem(this->getId(), itemId, false); auto *actionsAddToGroup = new QActionGroup(this); if (not groupsNotContainingItem.empty()) { - QMenu *menuAddToGroup = - menu.addMenu(QIcon::fromTheme(QStringLiteral("list-add")), VDrawTool::tr("Add to group")); + QMenu *menuAddToGroup = menu.addMenu(FromTheme(VThemeIcon::ListAdd), VDrawTool::tr("Add to group")); QStringList list = QStringList(groupsNotContainingItem.values()); list.sort(Qt::CaseInsensitive); @@ -216,7 +214,7 @@ void VDrawTool::ContextMenu(QGraphicsSceneContextMenuEvent *event, quint32 itemI if (not groupsContainingItem.empty()) { QMenu *menuRemoveFromGroup = - menu.addMenu(QIcon::fromTheme(QStringLiteral("list-remove")), VDrawTool::tr("Remove from group")); + menu.addMenu(FromTheme(VThemeIcon::ListRemove), VDrawTool::tr("Remove from group")); QStringList list = QStringList(groupsContainingItem.values()); list.sort(Qt::CaseInsensitive); @@ -246,7 +244,7 @@ void VDrawTool::ContextMenu(QGraphicsSceneContextMenuEvent *event, quint32 itemI QAction *actionRestoreLabelPosition = menu.addAction(VDrawTool::tr("Restore label position")); actionRestoreLabelPosition->setVisible(itemType == GOType::Point); - QAction *actionRemove = menu.addAction(QIcon::fromTheme(QStringLiteral("edit-delete")), VDrawTool::tr("Delete")); + QAction *actionRemove = menu.addAction(FromTheme(VThemeIcon::EditDelete), VDrawTool::tr("Delete")); if (showRemove == RemoveOption::Enable) { if (ref == Referens::Follow) diff --git a/src/libs/vtools/tools/nodeDetails/vnodepoint.cpp b/src/libs/vtools/tools/nodeDetails/vnodepoint.cpp index b913aedca..fa630936c 100644 --- a/src/libs/vtools/tools/nodeDetails/vnodepoint.cpp +++ b/src/libs/vtools/tools/nodeDetails/vnodepoint.cpp @@ -331,9 +331,9 @@ auto VNodePoint::InitContextMenu(QMenu *menu, vidtype pieceId, quint32 referens) separatorAct->setSeparator(true); menu->addAction(separatorAct); - contextMenu.insert(static_cast(ContextMenuOption::Option), - menu->addAction(QIcon::fromTheme(QStringLiteral("preferences-other")), - QCoreApplication::translate("VNodePoint", "Options"))); + contextMenu.insert( + static_cast(ContextMenuOption::Option), + menu->addAction(FromTheme(VThemeIcon::PreferencesOther), QCoreApplication::translate("VNodePoint", "Options"))); const VPiece detail = VAbstractTool::data.GetPiece(pieceId); @@ -370,8 +370,8 @@ auto VNodePoint::InitContextMenu(QMenu *menu, vidtype pieceId, quint32 referens) reseteLabelTemplateOption->setEnabled(not doc->GetDefaultPieceLabelPath().isEmpty()); contextMenu.insert(static_cast(ContextMenuOption::ResetLabelTemplate), reseteLabelTemplateOption); - QAction *actionRemove = menu->addAction(QIcon::fromTheme(QStringLiteral("edit-delete")), - QCoreApplication::translate("VNodePoint", "Delete")); + QAction *actionRemove = + menu->addAction(FromTheme(VThemeIcon::EditDelete), QCoreApplication::translate("VNodePoint", "Delete")); referens > 1 ? actionRemove->setEnabled(false) : actionRemove->setEnabled(true); contextMenu.insert(static_cast(ContextMenuOption::Remove), actionRemove); diff --git a/src/libs/vtools/tools/vtoolseamallowance.cpp b/src/libs/vtools/tools/vtoolseamallowance.cpp index 162eec305..95fe3e250 100644 --- a/src/libs/vtools/tools/vtoolseamallowance.cpp +++ b/src/libs/vtools/tools/vtoolseamallowance.cpp @@ -1538,7 +1538,7 @@ void VToolSeamAllowance::contextMenuEvent(QGraphicsSceneContextMenuEvent *event) } QMenu menu; - QAction *actionOption = menu.addAction(QIcon::fromTheme(QStringLiteral("preferences-other")), tr("Options")); + QAction *actionOption = menu.addAction(FromTheme(VThemeIcon::PreferencesOther), tr("Options")); const VPiece detail = VAbstractTool::data.GetPiece(m_id); @@ -1573,7 +1573,7 @@ void VToolSeamAllowance::contextMenuEvent(QGraphicsSceneContextMenuEvent *event) QAction *reseteLabelTemplateOption = menu.addAction(tr("Reset piece label template")); reseteLabelTemplateOption->setEnabled(not doc->GetDefaultPieceLabelPath().isEmpty()); - QAction *actionRemove = menu.addAction(QIcon::fromTheme(QStringLiteral("edit-delete")), tr("Delete")); + QAction *actionRemove = menu.addAction(FromTheme(VThemeIcon::EditDelete), tr("Delete")); actionRemove->setDisabled(_referens > 0); QAction *selectedAction = menu.exec(event->screenPos());