New option: Pointer mode.

This commit is contained in:
Roman Telezhynskyi 2023-08-29 18:49:16 +03:00
parent 4f2fb335fa
commit e29ab9c7d9
7 changed files with 93 additions and 14 deletions

View File

@ -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.

View File

@ -143,6 +143,14 @@ PreferencesConfigurationPage::PreferencesConfigurationPage(QWidget *parent)
ui->comboBoxThemeMode->setCurrentIndex(index);
}
// Pointer mode
SetPointerModeComboBox();
index = ui->comboBoxPointerMode->findData(static_cast<int>(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<VToolPointerMode>(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<int>(VThemeMode::Light));
}
//---------------------------------------------------------------------------------------------------------------------
void PreferencesConfigurationPage::SetPointerModeComboBox()
{
ui->comboBoxPointerMode->clear();
ui->comboBoxPointerMode->addItem(tr("Tool icon cursor"), static_cast<int>(VToolPointerMode::ToolIcon));
ui->comboBoxPointerMode->addItem(tr("Arrow cursor"), static_cast<int>(VToolPointerMode::Arrow));
}
//---------------------------------------------------------------------------------------------------------------------
void PreferencesConfigurationPage::InitUnits()
{

View File

@ -65,6 +65,7 @@ private:
void SetLabelComboBox(const QStringList &list);
void SetThemeModeComboBox();
void SetPointerModeComboBox();
void InitUnits();
void RetranslateUi();
};

View File

@ -33,9 +33,9 @@
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<y>-101</y>
<width>624</width>
<height>904</height>
<height>937</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout_2">
@ -364,6 +364,27 @@
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_4">
<item>
<widget class="QLabel" name="label_18">
<property name="text">
<string>Pointer mode:</string>
</property>
</widget>
</item>
<item>
<widget class="QComboBox" name="comboBoxPointerMode">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
</widget>
</item>
</layout>
</item>
<item>
<widget class="QCheckBox" name="checkBoxDontUseNativeDialog">
<property name="text">

View File

@ -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,6 +814,10 @@ void MainWindow::SetToolButton(bool checked, Tool t, const QString &cursor, cons
CancelTool();
emit EnableItemMove(false);
m_currentTool = m_lastUsedTool = t;
VValentinaSettings *settings = VAbstractValApplication::VApp()->ValentinaSettings();
if (settings->GetPointerMode() == VToolPointerMode::ToolIcon)
{
const QString resource = QStringLiteral("toolcursor");
auto cursorResource = VTheme::GetResourceName(resource, cursor);
if (qApp->devicePixelRatio() >= 2) // NOLINT(cppcoreguidelines-pro-type-static-cast-downcast)
@ -829,6 +834,8 @@ void MainWindow::SetToolButton(bool checked, Tool t, const QString &cursor, cons
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);

View File

@ -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<int>(VToolPointerMode::ToolIcon)).toInt();
if (val < 0 || val > 2)
{
val = 0;
}
return static_cast<VToolPointerMode>(val);
}
//---------------------------------------------------------------------------------------------------------------------
void VValentinaSettings::SetPointerMode(VToolPointerMode mode)
{
setValue(*settingConfigurationToolPointerMode, static_cast<int>(mode));
}
//---------------------------------------------------------------------------------------------------------------------
template <typename T>
auto VValentinaSettings::GetCachedValue(T &cache, const QString &setting, T defValue, T valueMin, T valueMax) const -> T

View File

@ -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