feat: able to disable built-in close window animation
This commit is contained in:
parent
3cfb25db9a
commit
1623ca315a
@ -75,11 +75,7 @@ MainWindow::MainWindow(QWidget *parent)
|
||||
m_exitAnimationGroup->addAnimation(m_fadeOutAnimation);
|
||||
m_exitAnimationGroup->addAnimation(m_floatUpAnimation);
|
||||
connect(m_exitAnimationGroup, &QParallelAnimationGroup::finished,
|
||||
#ifdef Q_OS_MAC
|
||||
this, &QWidget::hide);
|
||||
#else
|
||||
this, &QWidget::close);
|
||||
#endif
|
||||
this, &MainWindow::doCloseWindow);
|
||||
|
||||
GraphicsScene * scene = new GraphicsScene(this);
|
||||
|
||||
@ -580,12 +576,16 @@ void MainWindow::centerWindow()
|
||||
|
||||
void MainWindow::closeWindow()
|
||||
{
|
||||
QRect windowRect(this->geometry());
|
||||
m_floatUpAnimation->setStartValue(windowRect);
|
||||
m_floatUpAnimation->setEndValue(windowRect.adjusted(0, -80, 0, 0));
|
||||
m_floatUpAnimation->setStartValue(QRect(this->geometry().x(), this->geometry().y(), this->geometry().width(), this->geometry().height()));
|
||||
m_floatUpAnimation->setEndValue(QRect(this->geometry().x(), this->geometry().y()-80, this->geometry().width(), this->geometry().height()));
|
||||
m_exitAnimationGroup->start();
|
||||
if (Settings::instance()->useBuiltInCloseAnimation()) {
|
||||
QRect windowRect(this->geometry());
|
||||
m_floatUpAnimation->setStartValue(windowRect);
|
||||
m_floatUpAnimation->setEndValue(windowRect.adjusted(0, -80, 0, 0));
|
||||
m_floatUpAnimation->setStartValue(QRect(this->geometry().x(), this->geometry().y(), this->geometry().width(), this->geometry().height()));
|
||||
m_floatUpAnimation->setEndValue(QRect(this->geometry().x(), this->geometry().y()-80, this->geometry().width(), this->geometry().height()));
|
||||
m_exitAnimationGroup->start();
|
||||
} else {
|
||||
doCloseWindow();
|
||||
}
|
||||
}
|
||||
|
||||
void MainWindow::updateWidgetsPosition()
|
||||
@ -912,6 +912,15 @@ void MainWindow::on_actionQuitApp_triggered()
|
||||
quitAppAction(false);
|
||||
}
|
||||
|
||||
void MainWindow::doCloseWindow()
|
||||
{
|
||||
#ifdef Q_OS_MAC
|
||||
this->hide();
|
||||
#else
|
||||
this->close();
|
||||
#endif
|
||||
}
|
||||
|
||||
bool MainWindow::updateFileWatcher(const QString &basePath)
|
||||
{
|
||||
m_fileSystemWatcher->removePaths(m_fileSystemWatcher->files());
|
||||
|
@ -106,6 +106,8 @@ private slots:
|
||||
void on_actionLocateInFileManager_triggered();
|
||||
void on_actionQuitApp_triggered();
|
||||
|
||||
void doCloseWindow();
|
||||
|
||||
private:
|
||||
bool updateFileWatcher(const QString & basePath = QString());
|
||||
|
||||
|
@ -45,12 +45,17 @@ Settings *Settings::instance()
|
||||
return m_settings_instance;
|
||||
}
|
||||
|
||||
bool Settings::stayOnTop()
|
||||
bool Settings::stayOnTop() const
|
||||
{
|
||||
return m_qsettings->value("stay_on_top", true).toBool();
|
||||
}
|
||||
|
||||
bool Settings::useLightCheckerboard()
|
||||
bool Settings::useBuiltInCloseAnimation() const
|
||||
{
|
||||
return m_qsettings->value("use_built_in_close_animation", true).toBool();
|
||||
}
|
||||
|
||||
bool Settings::useLightCheckerboard() const
|
||||
{
|
||||
return m_qsettings->value("use_light_checkerboard", false).toBool();
|
||||
}
|
||||
@ -89,6 +94,12 @@ void Settings::setStayOnTop(bool on)
|
||||
m_qsettings->sync();
|
||||
}
|
||||
|
||||
void Settings::setUseBuiltInCloseAnimation(bool on)
|
||||
{
|
||||
m_qsettings->setValue("use_built_in_close_animation", on);
|
||||
m_qsettings->sync();
|
||||
}
|
||||
|
||||
void Settings::setUseLightCheckerboard(bool light)
|
||||
{
|
||||
m_qsettings->setValue("use_light_checkerboard", light);
|
||||
|
@ -34,14 +34,16 @@ public:
|
||||
|
||||
static Settings *instance();
|
||||
|
||||
bool stayOnTop();
|
||||
bool useLightCheckerboard();
|
||||
bool stayOnTop() const;
|
||||
bool useBuiltInCloseAnimation() const;
|
||||
bool useLightCheckerboard() const;
|
||||
DoubleClickBehavior doubleClickBehavior() const;
|
||||
MouseWheelBehavior mouseWheelBehavior() const;
|
||||
WindowSizeBehavior initWindowSizeBehavior() const;
|
||||
Qt::HighDpiScaleFactorRoundingPolicy hiDpiScaleFactorBehavior() const;
|
||||
|
||||
void setStayOnTop(bool on);
|
||||
void setUseBuiltInCloseAnimation(bool on);
|
||||
void setUseLightCheckerboard(bool light);
|
||||
void setDoubleClickBehavior(DoubleClickBehavior dcb);
|
||||
void setMouseWheelBehavior(MouseWheelBehavior mwb);
|
||||
|
@ -20,6 +20,7 @@
|
||||
SettingsDialog::SettingsDialog(QWidget *parent)
|
||||
: QDialog(parent)
|
||||
, m_stayOnTop(new QCheckBox)
|
||||
, m_useBuiltInCloseAnimation(new QCheckBox)
|
||||
, m_useLightCheckerboard(new QCheckBox)
|
||||
, m_doubleClickBehavior(new QComboBox)
|
||||
, m_mouseWheelBehavior(new QComboBox)
|
||||
@ -118,6 +119,7 @@ SettingsDialog::SettingsDialog(QWidget *parent)
|
||||
}
|
||||
|
||||
settingsForm->addRow(tr("Stay on top when start-up"), m_stayOnTop);
|
||||
settingsForm->addRow(tr("Use built-in close window animation"), m_useBuiltInCloseAnimation);
|
||||
settingsForm->addRow(tr("Use light-color checkerboard"), m_useLightCheckerboard);
|
||||
settingsForm->addRow(tr("Double-click behavior"), m_doubleClickBehavior);
|
||||
settingsForm->addRow(tr("Mouse wheel behavior"), m_mouseWheelBehavior);
|
||||
@ -125,6 +127,7 @@ SettingsDialog::SettingsDialog(QWidget *parent)
|
||||
settingsForm->addRow(tr("HiDPI scale factor rounding policy"), m_hiDpiRoundingPolicyBehavior);
|
||||
|
||||
m_stayOnTop->setChecked(Settings::instance()->stayOnTop());
|
||||
m_useBuiltInCloseAnimation->setChecked(Settings::instance()->useBuiltInCloseAnimation());
|
||||
m_useLightCheckerboard->setChecked(Settings::instance()->useLightCheckerboard());
|
||||
m_doubleClickBehavior->setModel(new QStringListModel(dcbDropDown));
|
||||
Settings::DoubleClickBehavior dcb = Settings::instance()->doubleClickBehavior();
|
||||
@ -148,6 +151,10 @@ SettingsDialog::SettingsDialog(QWidget *parent)
|
||||
Settings::instance()->setStayOnTop(state == Qt::Checked);
|
||||
});
|
||||
|
||||
connect(m_useBuiltInCloseAnimation, &QCheckBox::stateChanged, this, [ = ](int state){
|
||||
Settings::instance()->setUseBuiltInCloseAnimation(state == Qt::Checked);
|
||||
});
|
||||
|
||||
connect(m_useLightCheckerboard, &QCheckBox::stateChanged, this, [ = ](int state){
|
||||
Settings::instance()->setUseLightCheckerboard(state == Qt::Checked);
|
||||
});
|
||||
|
@ -23,6 +23,7 @@ public slots:
|
||||
|
||||
private:
|
||||
QCheckBox * m_stayOnTop = nullptr;
|
||||
QCheckBox * m_useBuiltInCloseAnimation = nullptr;
|
||||
QCheckBox * m_useLightCheckerboard = nullptr;
|
||||
QComboBox * m_doubleClickBehavior = nullptr;
|
||||
QComboBox * m_mouseWheelBehavior = nullptr;
|
||||
|
Loading…
x
Reference in New Issue
Block a user