diff --git a/ChangeLog.txt b/ChangeLog.txt index 5c489c65c..cf10ad3ae 100644 --- a/ChangeLog.txt +++ b/ChangeLog.txt @@ -36,6 +36,7 @@ - Increased requirement for minimal Qt version. - Support for Dark mode. - Fix issue with passing incorrect number of dimension to Tape. +- New option: Pointer mode. # Valentina 0.7.52 September 12, 2022 - Fix crash when default locale is ru. diff --git a/src/app/valentina/dialogs/configpages/preferencesconfigurationpage.cpp b/src/app/valentina/dialogs/configpages/preferencesconfigurationpage.cpp index a4e3b03c3..74db0af33 100644 --- a/src/app/valentina/dialogs/configpages/preferencesconfigurationpage.cpp +++ b/src/app/valentina/dialogs/configpages/preferencesconfigurationpage.cpp @@ -143,6 +143,14 @@ PreferencesConfigurationPage::PreferencesConfigurationPage(QWidget *parent) ui->comboBoxThemeMode->setCurrentIndex(index); } + // Pointer mode + SetPointerModeComboBox(); + index = ui->comboBoxPointerMode->findData(static_cast(settings->GetPointerMode())); + if (index != -1) + { + ui->comboBoxPointerMode->setCurrentIndex(index); + } + // Native dialogs ui->checkBoxDontUseNativeDialog->setChecked(settings->IsDontUseNativeDialog()); @@ -224,6 +232,8 @@ auto PreferencesConfigurationPage::Apply() -> QStringList QGuiApplication::restoreOverrideCursor(); } + settings->SetPointerMode(static_cast(ui->comboBoxPointerMode->currentData().toInt())); + if (settings->IsDontUseNativeDialog() != ui->checkBoxDontUseNativeDialog->isChecked()) { settings->SetDontUseNativeDialog(ui->checkBoxDontUseNativeDialog->isChecked()); @@ -319,6 +329,14 @@ void PreferencesConfigurationPage::SetThemeModeComboBox() ui->comboBoxThemeMode->addItem(tr("Light", "theme"), static_cast(VThemeMode::Light)); } +//--------------------------------------------------------------------------------------------------------------------- +void PreferencesConfigurationPage::SetPointerModeComboBox() +{ + ui->comboBoxPointerMode->clear(); + ui->comboBoxPointerMode->addItem(tr("Tool icon cursor"), static_cast(VToolPointerMode::ToolIcon)); + ui->comboBoxPointerMode->addItem(tr("Arrow cursor"), static_cast(VToolPointerMode::Arrow)); +} + //--------------------------------------------------------------------------------------------------------------------- void PreferencesConfigurationPage::InitUnits() { diff --git a/src/app/valentina/dialogs/configpages/preferencesconfigurationpage.h b/src/app/valentina/dialogs/configpages/preferencesconfigurationpage.h index 853f63878..563c284dc 100644 --- a/src/app/valentina/dialogs/configpages/preferencesconfigurationpage.h +++ b/src/app/valentina/dialogs/configpages/preferencesconfigurationpage.h @@ -65,6 +65,7 @@ private: void SetLabelComboBox(const QStringList &list); void SetThemeModeComboBox(); + void SetPointerModeComboBox(); void InitUnits(); void RetranslateUi(); }; diff --git a/src/app/valentina/dialogs/configpages/preferencesconfigurationpage.ui b/src/app/valentina/dialogs/configpages/preferencesconfigurationpage.ui index c21796358..ee4f51c9d 100644 --- a/src/app/valentina/dialogs/configpages/preferencesconfigurationpage.ui +++ b/src/app/valentina/dialogs/configpages/preferencesconfigurationpage.ui @@ -33,9 +33,9 @@ 0 - 0 + -101 624 - 904 + 937 @@ -364,6 +364,27 @@ + + + + + + Pointer mode: + + + + + + + + 0 + 0 + + + + + + diff --git a/src/app/valentina/mainwindow.cpp b/src/app/valentina/mainwindow.cpp index ecd055e12..eca712488 100644 --- a/src/app/valentina/mainwindow.cpp +++ b/src/app/valentina/mainwindow.cpp @@ -78,6 +78,7 @@ #include "../vmisc/dialogs/dialogselectlanguage.h" #include "../vmisc/qxtcsvmodel.h" #include "../vmisc/theme/vtheme.h" +#include "../vmisc/vcommonsettings.h" #include "../vmisc/vmodifierkey.h" #include "../vmisc/vsysexits.h" #include "../vmisc/vvalentinasettings.h" @@ -813,22 +814,28 @@ void MainWindow::SetToolButton(bool checked, Tool t, const QString &cursor, cons CancelTool(); emit EnableItemMove(false); m_currentTool = m_lastUsedTool = t; - const QString resource = QStringLiteral("toolcursor"); - auto cursorResource = VTheme::GetResourceName(resource, cursor); - if (qApp->devicePixelRatio() >= 2) // NOLINT(cppcoreguidelines-pro-type-static-cast-downcast) + + VValentinaSettings *settings = VAbstractValApplication::VApp()->ValentinaSettings(); + if (settings->GetPointerMode() == VToolPointerMode::ToolIcon) { - // Try to load HiDPI versions of the cursors if availible - auto hiDPICursor = QString(cursor).replace(QLatin1String(".png"), QLatin1String("@2x.png")); - auto cursorHiDPIResource = VTheme::GetResourceName(resource, hiDPICursor); - if (QFileInfo::exists(cursorHiDPIResource)) + const QString resource = QStringLiteral("toolcursor"); + auto cursorResource = VTheme::GetResourceName(resource, cursor); + if (qApp->devicePixelRatio() >= 2) // NOLINT(cppcoreguidelines-pro-type-static-cast-downcast) { - cursorResource = cursorHiDPIResource; + // Try to load HiDPI versions of the cursors if availible + auto hiDPICursor = QString(cursor).replace(QLatin1String(".png"), QLatin1String("@2x.png")); + auto cursorHiDPIResource = VTheme::GetResourceName(resource, hiDPICursor); + if (QFileInfo::exists(cursorHiDPIResource)) + { + cursorResource = cursorHiDPIResource; + } } + QPixmap pixmap(cursorResource); + QCursor cur(pixmap, 2, 2); + ui->view->viewport()->setCursor(cur); + ui->view->setCurrentCursorShape(); // Hack to fix problem with a cursor } - QPixmap pixmap(cursorResource); - QCursor cur(pixmap, 2, 2); - ui->view->viewport()->setCursor(cur); - ui->view->setCurrentCursorShape(); // Hack to fix problem with a cursor + m_statusLabel->setText(toolTip); ui->view->setShowToolOptions(false); m_dialogTool = new Dialog(pattern, 0, this); diff --git a/src/libs/vmisc/vvalentinasettings.cpp b/src/libs/vmisc/vvalentinasettings.cpp index 411e4c527..b4a1585c5 100644 --- a/src/libs/vmisc/vvalentinasettings.cpp +++ b/src/libs/vmisc/vvalentinasettings.cpp @@ -56,6 +56,9 @@ QT_WARNING_DISABLE_CLANG("-Wunused-member-function") Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingConfigurationLabelLanguage, (QLatin1String("configuration/label_language"))) // NOLINTNEXTLINE +Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingConfigurationToolPointerMode, + (QLatin1String("configuration/toolPointerMode"))) +// NOLINTNEXTLINE Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingAutoRefreshPatternMessage, (QLatin1String("configuration/autoRefreshPatternMessage"))) @@ -1034,6 +1037,25 @@ void VValentinaSettings::SetShowGrainline(bool value) setValue(*settingLayoutShowGrainline, value); } +//--------------------------------------------------------------------------------------------------------------------- +auto VValentinaSettings::GetPointerMode() const -> VToolPointerMode +{ + int val = value(*settingConfigurationToolPointerMode, static_cast(VToolPointerMode::ToolIcon)).toInt(); + + if (val < 0 || val > 2) + { + val = 0; + } + + return static_cast(val); +} + +//--------------------------------------------------------------------------------------------------------------------- +void VValentinaSettings::SetPointerMode(VToolPointerMode mode) +{ + setValue(*settingConfigurationToolPointerMode, static_cast(mode)); +} + //--------------------------------------------------------------------------------------------------------------------- template auto VValentinaSettings::GetCachedValue(T &cache, const QString &setting, T defValue, T valueMin, T valueMax) const -> T diff --git a/src/libs/vmisc/vvalentinasettings.h b/src/libs/vmisc/vvalentinasettings.h index 8f9f0738b..258378f80 100644 --- a/src/libs/vmisc/vvalentinasettings.h +++ b/src/libs/vmisc/vvalentinasettings.h @@ -37,6 +37,12 @@ #include "vcommonsettings.h" +enum class VToolPointerMode +{ + ToolIcon = 0, + Arrow = 1 +}; + class VValentinaSettings : public VCommonSettings { Q_OBJECT // NOLINT @@ -242,6 +248,9 @@ public: auto GetShowGrainline() const -> bool; void SetShowGrainline(bool value); + auto GetPointerMode() const -> VToolPointerMode; + void SetPointerMode(VToolPointerMode mode); + private: Q_DISABLE_COPY_MOVE(VValentinaSettings) // NOLINT