refactor: remove double-click-window behavior
- remove double-click-window behavior entirely - remove the icon of copy image action
This commit is contained in:
@@ -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: Some icons are invalid.
|
||||
|
||||
CREATE_NEW_THEMEICON_ACTION(mainWindow, actionCopyPixmap, edit-copy);
|
||||
CREATE_NEW_ACTION(mainWindow, actionCopyPixmap);
|
||||
CREATE_NEW_ACTION(mainWindow, actionCopyFilePath);
|
||||
|
||||
CREATE_NEW_ICON_ACTION(mainWindow, actionPrevPicture, go-previous);
|
||||
|
||||
@@ -297,36 +297,6 @@ QStringList MainWindow::supportedImageFormats()
|
||||
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)
|
||||
{
|
||||
QPoint numDegrees = event->angleDelta() / 8;
|
||||
|
||||
@@ -38,7 +38,6 @@ public:
|
||||
static QStringList supportedImageFormats();
|
||||
|
||||
protected slots:
|
||||
void mouseDoubleClickEvent(QMouseEvent *event) override;
|
||||
void wheelEvent(QWheelEvent *event) override;
|
||||
void contextMenuEvent(QContextMenuEvent *event) override;
|
||||
void dragEnterEvent(QDragEnterEvent *event) override;
|
||||
|
||||
@@ -65,12 +65,6 @@ bool Settings::svgTiny12Only() const
|
||||
#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
|
||||
{
|
||||
QString result = m_qsettings->value("mouse_wheel_behavior", "").toString();
|
||||
@@ -107,12 +101,6 @@ void Settings::setSvgTiny12Only(bool on)
|
||||
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)
|
||||
{
|
||||
m_qsettings->setValue("mouse_wheel_behavior", QEnumHelper::toString(mwb));
|
||||
|
||||
@@ -11,14 +11,6 @@ class Settings : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
enum DoubleClickBehavior {
|
||||
Ignore,
|
||||
Close,
|
||||
Maximize,
|
||||
FullScreen,
|
||||
};
|
||||
Q_ENUM(DoubleClickBehavior)
|
||||
|
||||
enum MouseWheelBehavior {
|
||||
Zoom,
|
||||
Switch,
|
||||
@@ -38,7 +30,6 @@ public:
|
||||
bool useLightCheckerboard() const;
|
||||
bool loopGallery() const;
|
||||
bool svgTiny12Only() const;
|
||||
DoubleClickBehavior doubleClickBehavior() const;
|
||||
MouseWheelBehavior mouseWheelBehavior() const;
|
||||
WindowSizeBehavior initWindowSizeBehavior() const;
|
||||
Qt::HighDpiScaleFactorRoundingPolicy hiDpiScaleFactorBehavior() const;
|
||||
@@ -46,7 +37,6 @@ public:
|
||||
void setUseLightCheckerboard(bool light);
|
||||
void setLoopGallery(bool on);
|
||||
void setSvgTiny12Only(bool on);
|
||||
void setDoubleClickBehavior(DoubleClickBehavior dcb);
|
||||
void setMouseWheelBehavior(MouseWheelBehavior mwb);
|
||||
void setInitWindowSizeBehavior(WindowSizeBehavior wsb);
|
||||
void setHiDpiScaleFactorBehavior(Qt::HighDpiScaleFactorRoundingPolicy hidpi);
|
||||
|
||||
@@ -49,15 +49,6 @@ private:
|
||||
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 {
|
||||
{
|
||||
{ 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_loopGallery->setChecked(settings->loopGallery());
|
||||
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));
|
||||
Settings::MouseWheelBehavior mwb = settings->mouseWheelBehavior();
|
||||
ui->m_mouseWheelBehavior->setCurrentIndex(MW_OPTIONS.to_index(mwb));
|
||||
@@ -125,10 +113,6 @@ SettingsDialog::SettingsDialog(QWidget *parent)
|
||||
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){
|
||||
Settings::instance()->setMouseWheelBehavior(MW_OPTIONS.to_value(index));
|
||||
});
|
||||
|
||||
+5
-15
@@ -41,43 +41,33 @@
|
||||
</widget>
|
||||
</item>
|
||||
<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">
|
||||
<property name="text">
|
||||
<string>Mouse wheel behavior</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="1">
|
||||
<item row="3" column="1">
|
||||
<widget class="QComboBox" name="m_mouseWheelBehavior"/>
|
||||
</item>
|
||||
<item row="5" column="0">
|
||||
<item row="4" column="0">
|
||||
<widget class="QLabel" name="m_initWindowSizeBehaviorLabel">
|
||||
<property name="text">
|
||||
<string>Default window size</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="5" column="1">
|
||||
<item row="4" column="1">
|
||||
<widget class="QComboBox" name="m_initWindowSizeBehavior"/>
|
||||
</item>
|
||||
<item row="6" column="0">
|
||||
<item row="5" column="0">
|
||||
<widget class="QLabel" name="m_hiDpiRoundingPolicyBehaviorLabel">
|
||||
<property name="text">
|
||||
<string>HiDPI scale factor rounding policy</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="6" column="1">
|
||||
<item row="5" column="1">
|
||||
<widget class="QComboBox" name="m_hiDpiRoundingPolicyBehavior"/>
|
||||
</item>
|
||||
</layout>
|
||||
|
||||
Reference in New Issue
Block a user