From 21ca36bd3a23ff7e89cb0246e8383dfcb473ed24 Mon Sep 17 00:00:00 2001 From: Keshav Bhatt Date: Thu, 26 Jan 2023 20:22:04 +0530 Subject: chore: cleanup + addition - remove clear cache option - provide single app data cleanup option - close settings with esc button --- src/settingswidget.cpp | 37 +++++------------ src/settingswidget.h | 8 ++-- src/settingswidget.ui | 107 ++++++++++++++++++------------------------------- 3 files changed, 54 insertions(+), 98 deletions(-) diff --git a/src/settingswidget.cpp b/src/settingswidget.cpp index 1322e17..4bd213d 100644 --- a/src/settingswidget.cpp +++ b/src/settingswidget.cpp @@ -243,7 +243,6 @@ void SettingsWidget::refresh() { ui->themeComboBox->setCurrentText( utils::toCamelCase(settings.value("windowTheme", "light").toString())); - ui->cacheSize->setText(utils::refreshCacheSize(cachePath())); ui->cookieSize->setText(utils::refreshCacheSize(persistentStoragePath())); // update dict settings at runtime @@ -279,43 +278,21 @@ QString SettingsWidget::persistentStoragePath() { return enginePersistentStoragePath; } -void SettingsWidget::on_deleteCache_clicked() { - QMessageBox msgBox; - msgBox.setText("This will delete the cache! Cache makes " - "application load faster."); - msgBox.setIconPixmap( - QPixmap(":/icons/information-line.png") - .scaled(42, 42, Qt::KeepAspectRatio, Qt::SmoothTransformation)); - - msgBox.setInformativeText("Delete cache?"); - msgBox.setStandardButtons(QMessageBox::Yes | QMessageBox::No); - msgBox.setDefaultButton(QMessageBox::No); - int ret = msgBox.exec(); - switch (ret) { - case QMessageBox::Yes: { - utils::delete_cache(this->cachePath()); - refresh(); - break; - } - case QMessageBox::No: - break; - } -} - void SettingsWidget::on_deletePersistentData_clicked() { QMessageBox msgBox; msgBox.setText("This will delete Persistent Data ! Persistent data includes " - "persistent cookies, HTML5 local storage, and visited links."); + "persistent cookies and Cache, and Quit the application."); msgBox.setIconPixmap( QPixmap(":/icons/information-line.png") .scaled(42, 42, Qt::KeepAspectRatio, Qt::SmoothTransformation)); - msgBox.setInformativeText("Delete Cookies?"); + msgBox.setInformativeText("Delete Cookies and Quit Application?"); msgBox.setStandardButtons(QMessageBox::Yes | QMessageBox::No); msgBox.setDefaultButton(QMessageBox::No); int ret = msgBox.exec(); switch (ret) { case QMessageBox::Yes: { clearAllData(); + qApp->quit(); break; } case QMessageBox::No: @@ -773,3 +750,11 @@ void SettingsWidget::on_fullWidthViewCheckbox_toggled(bool checked) { settings.setValue("fullWidthView", checked); emit updateFullWidthView(checked); } + +void SettingsWidget::keyPressEvent(QKeyEvent *e) +{ + if (e->key() == Qt::Key_Escape) + this->close(); + + QWidget::keyPressEvent(e); +} diff --git a/src/settingswidget.h b/src/settingswidget.h index 8e8eab8..d533343 100644 --- a/src/settingswidget.h +++ b/src/settingswidget.h @@ -32,7 +32,7 @@ signals: void updateFullWidthView(bool checked); public: - explicit SettingsWidget(QWidget *parent = nullptr,int screenNumber = 0, + explicit SettingsWidget(QWidget *parent = nullptr, int screenNumber = 0, QString engineCachePath = "", QString enginePersistentStoragePath = ""); ~SettingsWidget(); @@ -51,7 +51,7 @@ public slots: protected slots: bool eventFilter(QObject *obj, QEvent *event); void closeEvent(QCloseEvent *event); - + void keyPressEvent(QKeyEvent *e); private slots: QString cachePath(); QString persistentStoragePath(); @@ -67,8 +67,6 @@ private slots: void on_chnageCurrentPasswordPushButton_clicked(); void on_closeButtonActionComboBox_currentIndexChanged(int index); void on_defaultUserAgentButton_clicked(); - void on_deleteCache_clicked(); - void on_deletePersistentData_clicked(); void on_dictComboBox_currentIndexChanged(const QString &arg1); void on_enableSpellCheck_toggled(bool checked); void on_minimizeOnTrayIconClick_toggled(bool checked); @@ -99,6 +97,8 @@ private slots: void on_fullWidthViewCheckbox_toggled(bool checked); + void on_deletePersistentData_clicked(); + private: Ui::SettingsWidget *ui; QString engineCachePath, enginePersistentStoragePath; diff --git a/src/settingswidget.ui b/src/settingswidget.ui index 1b259a8..295d91f 100644 --- a/src/settingswidget.ui +++ b/src/settingswidget.ui @@ -6,8 +6,8 @@ 0 0 - 693 - 867 + 651 + 841 @@ -38,8 +38,7 @@ - - + @@ -96,8 +95,8 @@ background:transparent; 0 0 - 677 - 791 + 635 + 760 @@ -917,15 +916,34 @@ background:transparent; - Storage and Other Settings + Storage + + + + + 0 + 0 + + + + + 10 + false + + + + Property + + + - + - Clear + Clear (requires restart) @@ -934,14 +952,17 @@ background:transparent; - + + + <html><head/><body><p>Persistent data includes persistent cookies, HTML5 local storage, and visited links.</p></body></html> + - Cache + Persistent data - + - @@ -950,27 +971,8 @@ background:transparent; - - - - - 0 - 0 - - - - - 10 - false - - - - Property - - - - - + + 0 @@ -984,15 +986,15 @@ background:transparent; - Action + Size Qt::AlignCenter - - + + 0 @@ -1006,44 +1008,13 @@ background:transparent; - Size - - - Qt::AlignCenter - - - - - - - <html><head/><body><p>Persistent data includes persistent cookies, HTML5 local storage, and visited links.</p></body></html> - - - Persistent data - - - - - - - - + Action Qt::AlignCenter - - - - Clear - - - - :/icons/delete-bin-3-line.png:/icons/delete-bin-3-line.png - - - -- cgit v1.2.3