refactor: remove double-click-window behavior

- remove double-click-window behavior entirely
- remove the icon of copy image action
This commit is contained in:
2026-07-24 15:07:30 +08:00
parent aa13355966
commit b1d12cc406
7 changed files with 6 additions and 85 deletions
+1 -1
View File
@@ -55,7 +55,7 @@ void ActionManager::setupAction(MainWindow *mainWindow)
// TODO: We may replace all Qt theme icons to our custom icon for visual consistency. // TODO: We may replace all Qt theme icons to our custom icon for visual consistency.
// TODO: Some icons are invalid. // TODO: Some icons are invalid.
CREATE_NEW_THEMEICON_ACTION(mainWindow, actionCopyPixmap, edit-copy); CREATE_NEW_ACTION(mainWindow, actionCopyPixmap);
CREATE_NEW_ACTION(mainWindow, actionCopyFilePath); CREATE_NEW_ACTION(mainWindow, actionCopyFilePath);
CREATE_NEW_ICON_ACTION(mainWindow, actionPrevPicture, go-previous); CREATE_NEW_ICON_ACTION(mainWindow, actionPrevPicture, go-previous);
-30
View File
@@ -297,36 +297,6 @@ QStringList MainWindow::supportedImageFormats()
return formatFilters; return formatFilters;
} }
void MainWindow::mouseDoubleClickEvent(QMouseEvent *event)
{
// The forward/back mouse button can also used to trigger a mouse double-click event
// Since we use that for gallery navigation so we ignore these two buttons.
if (event->buttons() & Qt::ForwardButton || event->buttons() & Qt::BackButton) {
return;
}
switch (Settings::instance()->doubleClickBehavior()) {
case Settings::DoubleClickBehavior::Close:
closeWindow();
event->accept();
break;
case Settings::DoubleClickBehavior::Maximize:
toggleMaximize();
event->accept();
break;
case Settings::DoubleClickBehavior::FullScreen:
toggleFullscreen();
event->accept();
break;
case Settings::DoubleClickBehavior::Ignore:
break;
}
// blumia: don't call parent constructor here, seems it will cause mouse move
// event get called even if we set event->accept();
// return QMainWindow::mouseDoubleClickEvent(event);
}
void MainWindow::wheelEvent(QWheelEvent *event) void MainWindow::wheelEvent(QWheelEvent *event)
{ {
QPoint numDegrees = event->angleDelta() / 8; QPoint numDegrees = event->angleDelta() / 8;
-1
View File
@@ -38,7 +38,6 @@ public:
static QStringList supportedImageFormats(); static QStringList supportedImageFormats();
protected slots: protected slots:
void mouseDoubleClickEvent(QMouseEvent *event) override;
void wheelEvent(QWheelEvent *event) override; void wheelEvent(QWheelEvent *event) override;
void contextMenuEvent(QContextMenuEvent *event) override; void contextMenuEvent(QContextMenuEvent *event) override;
void dragEnterEvent(QDragEnterEvent *event) override; void dragEnterEvent(QDragEnterEvent *event) override;
-12
View File
@@ -65,12 +65,6 @@ bool Settings::svgTiny12Only() const
#endif // QT_VERSION < QT_VERSION_CHECK(6, 9, 3) #endif // QT_VERSION < QT_VERSION_CHECK(6, 9, 3)
} }
Settings::DoubleClickBehavior Settings::doubleClickBehavior() const
{
QString result = m_qsettings->value("double_click_behavior", "").toString();
return QEnumHelper::fromString<DoubleClickBehavior>(result, DoubleClickBehavior::Ignore);
}
Settings::MouseWheelBehavior Settings::mouseWheelBehavior() const Settings::MouseWheelBehavior Settings::mouseWheelBehavior() const
{ {
QString result = m_qsettings->value("mouse_wheel_behavior", "").toString(); QString result = m_qsettings->value("mouse_wheel_behavior", "").toString();
@@ -107,12 +101,6 @@ void Settings::setSvgTiny12Only(bool on)
m_qsettings->sync(); m_qsettings->sync();
} }
void Settings::setDoubleClickBehavior(DoubleClickBehavior dcb)
{
m_qsettings->setValue("double_click_behavior", QEnumHelper::toString(dcb));
m_qsettings->sync();
}
void Settings::setMouseWheelBehavior(MouseWheelBehavior mwb) void Settings::setMouseWheelBehavior(MouseWheelBehavior mwb)
{ {
m_qsettings->setValue("mouse_wheel_behavior", QEnumHelper::toString(mwb)); m_qsettings->setValue("mouse_wheel_behavior", QEnumHelper::toString(mwb));
-10
View File
@@ -11,14 +11,6 @@ class Settings : public QObject
{ {
Q_OBJECT Q_OBJECT
public: public:
enum DoubleClickBehavior {
Ignore,
Close,
Maximize,
FullScreen,
};
Q_ENUM(DoubleClickBehavior)
enum MouseWheelBehavior { enum MouseWheelBehavior {
Zoom, Zoom,
Switch, Switch,
@@ -38,7 +30,6 @@ public:
bool useLightCheckerboard() const; bool useLightCheckerboard() const;
bool loopGallery() const; bool loopGallery() const;
bool svgTiny12Only() const; bool svgTiny12Only() const;
DoubleClickBehavior doubleClickBehavior() const;
MouseWheelBehavior mouseWheelBehavior() const; MouseWheelBehavior mouseWheelBehavior() const;
WindowSizeBehavior initWindowSizeBehavior() const; WindowSizeBehavior initWindowSizeBehavior() const;
Qt::HighDpiScaleFactorRoundingPolicy hiDpiScaleFactorBehavior() const; Qt::HighDpiScaleFactorRoundingPolicy hiDpiScaleFactorBehavior() const;
@@ -46,7 +37,6 @@ public:
void setUseLightCheckerboard(bool light); void setUseLightCheckerboard(bool light);
void setLoopGallery(bool on); void setLoopGallery(bool on);
void setSvgTiny12Only(bool on); void setSvgTiny12Only(bool on);
void setDoubleClickBehavior(DoubleClickBehavior dcb);
void setMouseWheelBehavior(MouseWheelBehavior mwb); void setMouseWheelBehavior(MouseWheelBehavior mwb);
void setInitWindowSizeBehavior(WindowSizeBehavior wsb); void setInitWindowSizeBehavior(WindowSizeBehavior wsb);
void setHiDpiScaleFactorBehavior(Qt::HighDpiScaleFactorRoundingPolicy hidpi); void setHiDpiScaleFactorBehavior(Qt::HighDpiScaleFactorRoundingPolicy hidpi);
-16
View File
@@ -49,15 +49,6 @@ private:
Pairs pairs; Pairs pairs;
}; };
static EnumComboBoxTransformer<Settings::DoubleClickBehavior> DC_OPTIONS {
{
{Settings::DoubleClickBehavior::Ignore, QCoreApplication::translate("SettingsDialog", "Do nothing")},
{Settings::DoubleClickBehavior::Close, QCoreApplication::translate("SettingsDialog", "Close the window")},
{Settings::DoubleClickBehavior::Maximize, QCoreApplication::translate("SettingsDialog", "Toggle maximize")},
{Settings::DoubleClickBehavior::FullScreen, QCoreApplication::translate("SettingsDialog", "Toggle fullscreen")}
}
};
static EnumComboBoxTransformer<Settings::MouseWheelBehavior, QString> MW_OPTIONS { static EnumComboBoxTransformer<Settings::MouseWheelBehavior, QString> MW_OPTIONS {
{ {
{ Settings::MouseWheelBehavior::Zoom, QCoreApplication::translate("SettingsDialog", "Zoom in and out") }, { Settings::MouseWheelBehavior::Zoom, QCoreApplication::translate("SettingsDialog", "Zoom in and out") },
@@ -92,9 +83,6 @@ SettingsDialog::SettingsDialog(QWidget *parent)
ui->m_useLightCheckerboard->setChecked(settings->useLightCheckerboard()); ui->m_useLightCheckerboard->setChecked(settings->useLightCheckerboard());
ui->m_loopGallery->setChecked(settings->loopGallery()); ui->m_loopGallery->setChecked(settings->loopGallery());
ui->m_svgTiny12Only->setChecked(settings->svgTiny12Only()); ui->m_svgTiny12Only->setChecked(settings->svgTiny12Only());
ui->m_doubleClickBehavior->setModel(DC_OPTIONS.buildComboBoxModel(this));
Settings::DoubleClickBehavior dcb = settings->doubleClickBehavior();
ui->m_doubleClickBehavior->setCurrentIndex(DC_OPTIONS.to_index(dcb));
ui->m_mouseWheelBehavior->setModel(MW_OPTIONS.buildComboBoxModel(this)); ui->m_mouseWheelBehavior->setModel(MW_OPTIONS.buildComboBoxModel(this));
Settings::MouseWheelBehavior mwb = settings->mouseWheelBehavior(); Settings::MouseWheelBehavior mwb = settings->mouseWheelBehavior();
ui->m_mouseWheelBehavior->setCurrentIndex(MW_OPTIONS.to_index(mwb)); ui->m_mouseWheelBehavior->setCurrentIndex(MW_OPTIONS.to_index(mwb));
@@ -125,10 +113,6 @@ SettingsDialog::SettingsDialog(QWidget *parent)
Settings::instance()->setSvgTiny12Only(state == Qt::Checked); Settings::instance()->setSvgTiny12Only(state == Qt::Checked);
}); });
connect(ui->m_doubleClickBehavior, QOverload<int>::of(&QComboBox::currentIndexChanged), this, [ = ](int index){
Settings::instance()->setDoubleClickBehavior(DC_OPTIONS.to_value(index));
});
connect(ui->m_mouseWheelBehavior, QOverload<int>::of(&QComboBox::currentIndexChanged), this, [ = ](int index){ connect(ui->m_mouseWheelBehavior, QOverload<int>::of(&QComboBox::currentIndexChanged), this, [ = ](int index){
Settings::instance()->setMouseWheelBehavior(MW_OPTIONS.to_value(index)); Settings::instance()->setMouseWheelBehavior(MW_OPTIONS.to_value(index));
}); });
+5 -15
View File
@@ -41,43 +41,33 @@
</widget> </widget>
</item> </item>
<item row="3" column="0"> <item row="3" column="0">
<widget class="QLabel" name="m_doubleClickBehaviorLabel">
<property name="text">
<string>Double-click behavior</string>
</property>
</widget>
</item>
<item row="3" column="1">
<widget class="QComboBox" name="m_doubleClickBehavior"/>
</item>
<item row="4" column="0">
<widget class="QLabel" name="m_mouseWheelBehaviorLabel"> <widget class="QLabel" name="m_mouseWheelBehaviorLabel">
<property name="text"> <property name="text">
<string>Mouse wheel behavior</string> <string>Mouse wheel behavior</string>
</property> </property>
</widget> </widget>
</item> </item>
<item row="4" column="1"> <item row="3" column="1">
<widget class="QComboBox" name="m_mouseWheelBehavior"/> <widget class="QComboBox" name="m_mouseWheelBehavior"/>
</item> </item>
<item row="5" column="0"> <item row="4" column="0">
<widget class="QLabel" name="m_initWindowSizeBehaviorLabel"> <widget class="QLabel" name="m_initWindowSizeBehaviorLabel">
<property name="text"> <property name="text">
<string>Default window size</string> <string>Default window size</string>
</property> </property>
</widget> </widget>
</item> </item>
<item row="5" column="1"> <item row="4" column="1">
<widget class="QComboBox" name="m_initWindowSizeBehavior"/> <widget class="QComboBox" name="m_initWindowSizeBehavior"/>
</item> </item>
<item row="6" column="0"> <item row="5" column="0">
<widget class="QLabel" name="m_hiDpiRoundingPolicyBehaviorLabel"> <widget class="QLabel" name="m_hiDpiRoundingPolicyBehaviorLabel">
<property name="text"> <property name="text">
<string>HiDPI scale factor rounding policy</string> <string>HiDPI scale factor rounding policy</string>
</property> </property>
</widget> </widget>
</item> </item>
<item row="6" column="1"> <item row="5" column="1">
<widget class="QComboBox" name="m_hiDpiRoundingPolicyBehavior"/> <widget class="QComboBox" name="m_hiDpiRoundingPolicyBehavior"/>
</item> </item>
</layout> </layout>