mirror of
https://github.com/ciphervance/supercell-wx.git
synced 2025-10-29 22:30:04 +00:00
Merge pull request #451 from AdenKoperczak/remove_spinbox_scrolling
Remove scrolling editing settings
This commit is contained in:
commit
6c7b5b3d22
6 changed files with 210 additions and 39 deletions
|
|
@ -362,6 +362,9 @@ set(SRC_UI_SETUP source/scwx/qt/ui/setup/audio_codec_page.cpp
|
|||
source/scwx/qt/ui/setup/map_provider_page.cpp
|
||||
source/scwx/qt/ui/setup/setup_wizard.cpp
|
||||
source/scwx/qt/ui/setup/welcome_page.cpp)
|
||||
set(HDR_UI_WIDGETS source/scwx/qt/ui/widgets/focused_combo_box.hpp
|
||||
source/scwx/qt/ui/widgets/focused_double_spin_box.hpp
|
||||
source/scwx/qt/ui/widgets/focused_spin_box.hpp)
|
||||
set(HDR_UTIL source/scwx/qt/util/color.hpp
|
||||
source/scwx/qt/util/file.hpp
|
||||
source/scwx/qt/util/geographic_lib.hpp
|
||||
|
|
@ -473,6 +476,7 @@ set(PROJECT_SOURCES ${HDR_MAIN}
|
|||
${SRC_UI_SETTINGS}
|
||||
${HDR_UI_SETUP}
|
||||
${SRC_UI_SETUP}
|
||||
${HDR_UI_WIDGETS}
|
||||
${HDR_UTIL}
|
||||
${SRC_UTIL}
|
||||
${HDR_VIEW}
|
||||
|
|
@ -512,6 +516,7 @@ source_group("Header Files\\ui\\settings" FILES ${HDR_UI_SETTINGS})
|
|||
source_group("Source Files\\ui\\settings" FILES ${SRC_UI_SETTINGS})
|
||||
source_group("Header Files\\ui\\setup" FILES ${HDR_UI_SETUP})
|
||||
source_group("Source Files\\ui\\setup" FILES ${SRC_UI_SETUP})
|
||||
source_group("Header Files\\ui\\widgets" FILES ${HDR_UI_WIDGETS})
|
||||
source_group("UI Files\\ui" FILES ${UI_UI})
|
||||
source_group("Header Files\\util" FILES ${HDR_UTIL})
|
||||
source_group("Source Files\\util" FILES ${SRC_UTIL})
|
||||
|
|
|
|||
|
|
@ -2,21 +2,17 @@
|
|||
#include <scwx/qt/settings/settings_interface.hpp>
|
||||
#include <scwx/qt/settings/unit_settings.hpp>
|
||||
#include <scwx/qt/types/unit_types.hpp>
|
||||
#include <scwx/qt/ui/widgets/focused_combo_box.hpp>
|
||||
|
||||
#include <boost/algorithm/string.hpp>
|
||||
#include <boost/unordered/unordered_flat_map.hpp>
|
||||
#include <QGridLayout>
|
||||
#include <QLabel>
|
||||
#include <QComboBox>
|
||||
#include <QScrollArea>
|
||||
#include <QToolButton>
|
||||
#include <QVBoxLayout>
|
||||
|
||||
namespace scwx
|
||||
{
|
||||
namespace qt
|
||||
{
|
||||
namespace ui
|
||||
namespace scwx::qt::ui
|
||||
{
|
||||
|
||||
static const std::string logPrefix_ =
|
||||
|
|
@ -51,7 +47,7 @@ public:
|
|||
[&row, &self, this](
|
||||
settings::SettingsInterface<std::string>& settingsInterface,
|
||||
const std::string& labelName,
|
||||
QComboBox* comboBox)
|
||||
QFocusedComboBox* comboBox)
|
||||
{
|
||||
QLabel* label = new QLabel(QObject::tr(labelName.c_str()), self);
|
||||
QToolButton* resetButton = new QToolButton(self);
|
||||
|
|
@ -72,9 +68,12 @@ public:
|
|||
++row;
|
||||
};
|
||||
|
||||
QComboBox* accumulationComboBox = new QComboBox(self);
|
||||
// Qt manages the memory for these widgets
|
||||
// NOLINTBEGIN(cppcoreguidelines-owning-memory)
|
||||
auto* accumulationComboBox = new QFocusedComboBox(self);
|
||||
accumulationComboBox->setSizePolicy(QSizePolicy::Expanding,
|
||||
QSizePolicy::Preferred);
|
||||
accumulationComboBox->setFocusPolicy(Qt::StrongFocus);
|
||||
accumulationUnits_.SetSettingsVariable(unitSettings.accumulation_units());
|
||||
SCWX_SETTINGS_COMBO_BOX(accumulationUnits_,
|
||||
accumulationComboBox,
|
||||
|
|
@ -82,9 +81,10 @@ public:
|
|||
types::GetAccumulationUnitsName);
|
||||
AddRow(accumulationUnits_, "Accumulation", accumulationComboBox);
|
||||
|
||||
QComboBox* echoTopsComboBox = new QComboBox(self);
|
||||
auto* echoTopsComboBox = new QFocusedComboBox(self);
|
||||
echoTopsComboBox->setSizePolicy(QSizePolicy::Expanding,
|
||||
QSizePolicy::Preferred);
|
||||
echoTopsComboBox->setFocusPolicy(Qt::StrongFocus);
|
||||
echoTopsUnits_.SetSettingsVariable(unitSettings.echo_tops_units());
|
||||
SCWX_SETTINGS_COMBO_BOX(echoTopsUnits_,
|
||||
echoTopsComboBox,
|
||||
|
|
@ -92,9 +92,10 @@ public:
|
|||
types::GetEchoTopsUnitsName);
|
||||
AddRow(echoTopsUnits_, "Echo Tops", echoTopsComboBox);
|
||||
|
||||
QComboBox* speedComboBox = new QComboBox(self);
|
||||
auto* speedComboBox = new QFocusedComboBox(self);
|
||||
speedComboBox->setSizePolicy(QSizePolicy::Expanding,
|
||||
QSizePolicy::Preferred);
|
||||
speedComboBox->setFocusPolicy(Qt::StrongFocus);
|
||||
speedUnits_.SetSettingsVariable(unitSettings.speed_units());
|
||||
SCWX_SETTINGS_COMBO_BOX(speedUnits_,
|
||||
speedComboBox,
|
||||
|
|
@ -102,9 +103,10 @@ public:
|
|||
types::GetSpeedUnitsName);
|
||||
AddRow(speedUnits_, "Speed", speedComboBox);
|
||||
|
||||
QComboBox* distanceComboBox = new QComboBox(self);
|
||||
auto* distanceComboBox = new QFocusedComboBox(self);
|
||||
distanceComboBox->setSizePolicy(QSizePolicy::Expanding,
|
||||
QSizePolicy::Preferred);
|
||||
QSizePolicy::Preferred);
|
||||
distanceComboBox->setFocusPolicy(Qt::StrongFocus);
|
||||
distanceUnits_.SetSettingsVariable(unitSettings.distance_units());
|
||||
SCWX_SETTINGS_COMBO_BOX(distanceUnits_,
|
||||
distanceComboBox,
|
||||
|
|
@ -112,9 +114,10 @@ public:
|
|||
types::GetDistanceUnitsName);
|
||||
AddRow(distanceUnits_, "Distance", distanceComboBox);
|
||||
|
||||
QComboBox* otherComboBox = new QComboBox(self);
|
||||
auto* otherComboBox = new QFocusedComboBox(self);
|
||||
otherComboBox->setSizePolicy(QSizePolicy::Expanding,
|
||||
QSizePolicy::Preferred);
|
||||
otherComboBox->setFocusPolicy(Qt::StrongFocus);
|
||||
otherUnits_.SetSettingsVariable(unitSettings.other_units());
|
||||
SCWX_SETTINGS_COMBO_BOX(otherUnits_,
|
||||
otherComboBox,
|
||||
|
|
@ -122,12 +125,19 @@ public:
|
|||
types::GetOtherUnitsName);
|
||||
AddRow(otherUnits_, "Other", otherComboBox);
|
||||
|
||||
QSpacerItem* spacer =
|
||||
auto* spacer =
|
||||
new QSpacerItem(0, 0, QSizePolicy::Minimum, QSizePolicy::Expanding);
|
||||
gridLayout_->addItem(spacer, row, 0);
|
||||
|
||||
// NOLINTEND(cppcoreguidelines-owning-memory)
|
||||
}
|
||||
~Impl() = default;
|
||||
|
||||
Impl(const Impl&) = delete;
|
||||
Impl(Impl&&) = delete;
|
||||
Impl& operator=(const Impl&) = delete;
|
||||
Impl& operator=(Impl&&) = delete;
|
||||
|
||||
QWidget* contents_;
|
||||
QLayout* layout_;
|
||||
QScrollArea* scrollArea_ {};
|
||||
|
|
@ -147,6 +157,4 @@ UnitSettingsWidget::UnitSettingsWidget(QWidget* parent) :
|
|||
|
||||
UnitSettingsWidget::~UnitSettingsWidget() = default;
|
||||
|
||||
} // namespace ui
|
||||
} // namespace qt
|
||||
} // namespace scwx
|
||||
} // namespace scwx::qt::ui
|
||||
|
|
|
|||
|
|
@ -135,7 +135,7 @@
|
|||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>-412</y>
|
||||
<y>0</y>
|
||||
<width>511</width>
|
||||
<height>873</height>
|
||||
</rect>
|
||||
|
|
@ -160,13 +160,25 @@
|
|||
<number>0</number>
|
||||
</property>
|
||||
<item row="1" column="2">
|
||||
<widget class="QComboBox" name="clockFormatComboBox"/>
|
||||
<widget class="QFocusedComboBox" name="clockFormatComboBox">
|
||||
<property name="focusPolicy">
|
||||
<enum>Qt::FocusPolicy::StrongFocus</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="8" column="2">
|
||||
<widget class="QComboBox" name="positioningPluginComboBox"/>
|
||||
<widget class="QFocusedComboBox" name="positioningPluginComboBox">
|
||||
<property name="focusPolicy">
|
||||
<enum>Qt::FocusPolicy::StrongFocus</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="6" column="2">
|
||||
<widget class="QSpinBox" name="gridHeightSpinBox"/>
|
||||
<widget class="QFocusedSpinBox" name="gridHeightSpinBox">
|
||||
<property name="focusPolicy">
|
||||
<enum>Qt::FocusPolicy::StrongFocus</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="23" column="0">
|
||||
<widget class="QLabel" name="label_31">
|
||||
|
|
@ -265,7 +277,11 @@
|
|||
</widget>
|
||||
</item>
|
||||
<item row="2" column="2">
|
||||
<widget class="QComboBox" name="defaultAlertActionComboBox"/>
|
||||
<widget class="QFocusedComboBox" name="defaultAlertActionComboBox">
|
||||
<property name="focusPolicy">
|
||||
<enum>Qt::FocusPolicy::StrongFocus</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="12" column="0">
|
||||
<widget class="QLabel" name="label_4">
|
||||
|
|
@ -293,10 +309,18 @@
|
|||
</widget>
|
||||
</item>
|
||||
<item row="5" column="2">
|
||||
<widget class="QSpinBox" name="gridWidthSpinBox"/>
|
||||
<widget class="QFocusedSpinBox" name="gridWidthSpinBox">
|
||||
<property name="focusPolicy">
|
||||
<enum>Qt::FocusPolicy::StrongFocus</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="2">
|
||||
<widget class="QComboBox" name="defaultTimeZoneComboBox"/>
|
||||
<widget class="QFocusedComboBox" name="defaultTimeZoneComboBox">
|
||||
<property name="focusPolicy">
|
||||
<enum>Qt::FocusPolicy::StrongFocus</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="4">
|
||||
<widget class="QToolButton" name="resetDefaultAlertActionButton">
|
||||
|
|
@ -321,7 +345,10 @@
|
|||
</widget>
|
||||
</item>
|
||||
<item row="10" column="2">
|
||||
<widget class="QSpinBox" name="nmeaBaudRateSpinBox">
|
||||
<widget class="QFocusedSpinBox" name="nmeaBaudRateSpinBox">
|
||||
<property name="focusPolicy">
|
||||
<enum>Qt::FocusPolicy::StrongFocus</enum>
|
||||
</property>
|
||||
<property name="minimum">
|
||||
<number>1</number>
|
||||
</property>
|
||||
|
|
@ -413,13 +440,21 @@
|
|||
</widget>
|
||||
</item>
|
||||
<item row="11" column="2">
|
||||
<widget class="QComboBox" name="mapProviderComboBox"/>
|
||||
<widget class="QFocusedComboBox" name="mapProviderComboBox">
|
||||
<property name="focusPolicy">
|
||||
<enum>Qt::FocusPolicy::StrongFocus</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="9" column="2">
|
||||
<widget class="QLineEdit" name="nmeaSourceLineEdit"/>
|
||||
</item>
|
||||
<item row="3" column="2">
|
||||
<widget class="QComboBox" name="radarSiteComboBox"/>
|
||||
<widget class="QFocusedComboBox" name="radarSiteComboBox">
|
||||
<property name="focusPolicy">
|
||||
<enum>Qt::FocusPolicy::StrongFocus</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="19" column="3">
|
||||
<widget class="QToolButton" name="themeFileSelectButton">
|
||||
|
|
@ -443,7 +478,11 @@
|
|||
</widget>
|
||||
</item>
|
||||
<item row="18" column="2">
|
||||
<widget class="QComboBox" name="themeComboBox"/>
|
||||
<widget class="QFocusedComboBox" name="themeComboBox">
|
||||
<property name="focusPolicy">
|
||||
<enum>Qt::FocusPolicy::StrongFocus</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="18" column="0">
|
||||
<widget class="QLabel" name="label_5">
|
||||
|
|
@ -466,13 +505,16 @@
|
|||
</widget>
|
||||
</item>
|
||||
<item row="23" column="2">
|
||||
<widget class="QDoubleSpinBox" name="radarSiteThresholdSpinBox">
|
||||
<widget class="QFocusedDoubleSpinBox" name="radarSiteThresholdSpinBox">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Minimum" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="focusPolicy">
|
||||
<enum>Qt::FocusPolicy::StrongFocus</enum>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Set to 0 to disable</string>
|
||||
</property>
|
||||
|
|
@ -623,7 +665,10 @@
|
|||
</widget>
|
||||
</item>
|
||||
<item row="24" column="2">
|
||||
<widget class="QDoubleSpinBox" name="cursorIconScaleSpinBox">
|
||||
<widget class="QFocusedDoubleSpinBox" name="cursorIconScaleSpinBox">
|
||||
<property name="focusPolicy">
|
||||
<enum>Qt::FocusPolicy::StrongFocus</enum>
|
||||
</property>
|
||||
<property name="decimals">
|
||||
<number>1</number>
|
||||
</property>
|
||||
|
|
@ -765,8 +810,8 @@
|
|||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>80</width>
|
||||
<height>18</height>
|
||||
<width>503</width>
|
||||
<height>380</height>
|
||||
</rect>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout_3">
|
||||
|
|
@ -875,7 +920,10 @@
|
|||
</widget>
|
||||
</item>
|
||||
<item row="2" column="1" colspan="2">
|
||||
<widget class="QDoubleSpinBox" name="alertAudioLatitudeSpinBox">
|
||||
<widget class="QFocusedDoubleSpinBox" name="alertAudioLatitudeSpinBox">
|
||||
<property name="focusPolicy">
|
||||
<enum>Qt::FocusPolicy::StrongFocus</enum>
|
||||
</property>
|
||||
<property name="decimals">
|
||||
<number>4</number>
|
||||
</property>
|
||||
|
|
@ -891,7 +939,10 @@
|
|||
</widget>
|
||||
</item>
|
||||
<item row="5" column="1" colspan="2">
|
||||
<widget class="QDoubleSpinBox" name="alertAudioRadiusSpinBox">
|
||||
<widget class="QFocusedDoubleSpinBox" name="alertAudioRadiusSpinBox">
|
||||
<property name="focusPolicy">
|
||||
<enum>Qt::FocusPolicy::StrongFocus</enum>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Set to 0 to disable</string>
|
||||
</property>
|
||||
|
|
@ -943,7 +994,10 @@
|
|||
</widget>
|
||||
</item>
|
||||
<item row="3" column="1" colspan="2">
|
||||
<widget class="QDoubleSpinBox" name="alertAudioLongitudeSpinBox">
|
||||
<widget class="QFocusedDoubleSpinBox" name="alertAudioLongitudeSpinBox">
|
||||
<property name="focusPolicy">
|
||||
<enum>Qt::FocusPolicy::StrongFocus</enum>
|
||||
</property>
|
||||
<property name="decimals">
|
||||
<number>4</number>
|
||||
</property>
|
||||
|
|
@ -1040,16 +1094,23 @@
|
|||
</widget>
|
||||
</item>
|
||||
<item row="4" column="1" colspan="2">
|
||||
<widget class="QComboBox" name="alertAudioRadarSiteComboBox"/>
|
||||
<widget class="QFocusedComboBox" name="alertAudioRadarSiteComboBox">
|
||||
<property name="focusPolicy">
|
||||
<enum>Qt::FocusPolicy::StrongFocus</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1" colspan="2">
|
||||
<widget class="QComboBox" name="alertAudioLocationMethodComboBox">
|
||||
<widget class="QFocusedComboBox" name="alertAudioLocationMethodComboBox">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="focusPolicy">
|
||||
<enum>Qt::FocusPolicy::StrongFocus</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="6">
|
||||
|
|
@ -1360,7 +1421,10 @@
|
|||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QSpinBox" name="hoverTextWrapSpinBox">
|
||||
<widget class="QFocusedSpinBox" name="hoverTextWrapSpinBox">
|
||||
<property name="focusPolicy">
|
||||
<enum>Qt::FocusPolicy::StrongFocus</enum>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<number>999</number>
|
||||
</property>
|
||||
|
|
@ -1385,7 +1449,11 @@
|
|||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QComboBox" name="tooltipMethodComboBox"/>
|
||||
<widget class="QFocusedComboBox" name="tooltipMethodComboBox">
|
||||
<property name="focusPolicy">
|
||||
<enum>Qt::FocusPolicy::StrongFocus</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QCheckBox" name="placefileTextDropShadowCheckBox">
|
||||
|
|
@ -1446,6 +1514,21 @@
|
|||
<extends>QLineEdit</extends>
|
||||
<header>scwx/qt/ui/api_key_edit_widget.hpp</header>
|
||||
</customwidget>
|
||||
<customwidget>
|
||||
<class>QFocusedDoubleSpinBox</class>
|
||||
<extends>QDoubleSpinBox</extends>
|
||||
<header>scwx/qt/ui/widgets/focused_double_spin_box.hpp</header>
|
||||
</customwidget>
|
||||
<customwidget>
|
||||
<class>QFocusedSpinBox</class>
|
||||
<extends>QSpinBox</extends>
|
||||
<header>scwx/qt/ui/widgets/focused_spin_box.hpp</header>
|
||||
</customwidget>
|
||||
<customwidget>
|
||||
<class>QFocusedComboBox</class>
|
||||
<extends>QComboBox</extends>
|
||||
<header>scwx/qt/ui/widgets/focused_combo_box.hpp</header>
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
<resources>
|
||||
<include location="../../../../scwx-qt.qrc"/>
|
||||
|
|
|
|||
25
scwx-qt/source/scwx/qt/ui/widgets/focused_combo_box.hpp
Normal file
25
scwx-qt/source/scwx/qt/ui/widgets/focused_combo_box.hpp
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
#pragma once
|
||||
|
||||
#include <QComboBox>
|
||||
#include <QWheelEvent>
|
||||
|
||||
class QFocusedComboBox : public QComboBox
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
using QComboBox::QComboBox;
|
||||
|
||||
protected:
|
||||
void wheelEvent(QWheelEvent* event) override
|
||||
{
|
||||
if (hasFocus())
|
||||
{
|
||||
QComboBox::wheelEvent(event);
|
||||
}
|
||||
else
|
||||
{
|
||||
event->ignore();
|
||||
}
|
||||
}
|
||||
};
|
||||
|
|
@ -0,0 +1,25 @@
|
|||
#pragma once
|
||||
|
||||
#include <QDoubleSpinBox>
|
||||
#include <QWheelEvent>
|
||||
|
||||
class QFocusedDoubleSpinBox : public QDoubleSpinBox
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
using QDoubleSpinBox::QDoubleSpinBox;
|
||||
|
||||
protected:
|
||||
void wheelEvent(QWheelEvent* event) override
|
||||
{
|
||||
if (hasFocus())
|
||||
{
|
||||
QDoubleSpinBox::wheelEvent(event);
|
||||
}
|
||||
else
|
||||
{
|
||||
event->ignore();
|
||||
}
|
||||
}
|
||||
};
|
||||
25
scwx-qt/source/scwx/qt/ui/widgets/focused_spin_box.hpp
Normal file
25
scwx-qt/source/scwx/qt/ui/widgets/focused_spin_box.hpp
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
#pragma once
|
||||
|
||||
#include <QSpinBox>
|
||||
#include <QWheelEvent>
|
||||
|
||||
class QFocusedSpinBox : public QSpinBox
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
using QSpinBox::QSpinBox;
|
||||
|
||||
protected:
|
||||
void wheelEvent(QWheelEvent* event) override
|
||||
{
|
||||
if (hasFocus())
|
||||
{
|
||||
QSpinBox::wheelEvent(event);
|
||||
}
|
||||
else
|
||||
{
|
||||
event->ignore();
|
||||
}
|
||||
}
|
||||
};
|
||||
Loading…
Add table
Add a link
Reference in a new issue