Skip to content

Commit 21ca36b

Browse files
committed
chore: cleanup + addition
- remove clear cache option - provide single app data cleanup option - close settings with esc button
1 parent 74216cf commit 21ca36b

File tree

3 files changed

+54
-98
lines changed

3 files changed

+54
-98
lines changed

src/settingswidget.cpp

Lines changed: 11 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,6 @@ void SettingsWidget::refresh() {
243243
ui->themeComboBox->setCurrentText(
244244
utils::toCamelCase(settings.value("windowTheme", "light").toString()));
245245

246-
ui->cacheSize->setText(utils::refreshCacheSize(cachePath()));
247246
ui->cookieSize->setText(utils::refreshCacheSize(persistentStoragePath()));
248247

249248
// update dict settings at runtime
@@ -279,43 +278,21 @@ QString SettingsWidget::persistentStoragePath() {
279278
return enginePersistentStoragePath;
280279
}
281280

282-
void SettingsWidget::on_deleteCache_clicked() {
283-
QMessageBox msgBox;
284-
msgBox.setText("This will delete the cache! Cache makes "
285-
"application load faster.");
286-
msgBox.setIconPixmap(
287-
QPixmap(":/icons/information-line.png")
288-
.scaled(42, 42, Qt::KeepAspectRatio, Qt::SmoothTransformation));
289-
290-
msgBox.setInformativeText("Delete cache?");
291-
msgBox.setStandardButtons(QMessageBox::Yes | QMessageBox::No);
292-
msgBox.setDefaultButton(QMessageBox::No);
293-
int ret = msgBox.exec();
294-
switch (ret) {
295-
case QMessageBox::Yes: {
296-
utils::delete_cache(this->cachePath());
297-
refresh();
298-
break;
299-
}
300-
case QMessageBox::No:
301-
break;
302-
}
303-
}
304-
305281
void SettingsWidget::on_deletePersistentData_clicked() {
306282
QMessageBox msgBox;
307283
msgBox.setText("This will delete Persistent Data ! Persistent data includes "
308-
"persistent cookies, HTML5 local storage, and visited links.");
284+
"persistent cookies and Cache, and Quit the application.");
309285
msgBox.setIconPixmap(
310286
QPixmap(":/icons/information-line.png")
311287
.scaled(42, 42, Qt::KeepAspectRatio, Qt::SmoothTransformation));
312-
msgBox.setInformativeText("Delete Cookies?");
288+
msgBox.setInformativeText("Delete Cookies and Quit Application?");
313289
msgBox.setStandardButtons(QMessageBox::Yes | QMessageBox::No);
314290
msgBox.setDefaultButton(QMessageBox::No);
315291
int ret = msgBox.exec();
316292
switch (ret) {
317293
case QMessageBox::Yes: {
318294
clearAllData();
295+
qApp->quit();
319296
break;
320297
}
321298
case QMessageBox::No:
@@ -773,3 +750,11 @@ void SettingsWidget::on_fullWidthViewCheckbox_toggled(bool checked) {
773750
settings.setValue("fullWidthView", checked);
774751
emit updateFullWidthView(checked);
775752
}
753+
754+
void SettingsWidget::keyPressEvent(QKeyEvent *e)
755+
{
756+
if (e->key() == Qt::Key_Escape)
757+
this->close();
758+
759+
QWidget::keyPressEvent(e);
760+
}

src/settingswidget.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ class SettingsWidget : public QWidget {
3232
void updateFullWidthView(bool checked);
3333

3434
public:
35-
explicit SettingsWidget(QWidget *parent = nullptr,int screenNumber = 0,
35+
explicit SettingsWidget(QWidget *parent = nullptr, int screenNumber = 0,
3636
QString engineCachePath = "",
3737
QString enginePersistentStoragePath = "");
3838
~SettingsWidget();
@@ -51,7 +51,7 @@ public slots:
5151
protected slots:
5252
bool eventFilter(QObject *obj, QEvent *event);
5353
void closeEvent(QCloseEvent *event);
54-
54+
void keyPressEvent(QKeyEvent *e);
5555
private slots:
5656
QString cachePath();
5757
QString persistentStoragePath();
@@ -67,8 +67,6 @@ private slots:
6767
void on_chnageCurrentPasswordPushButton_clicked();
6868
void on_closeButtonActionComboBox_currentIndexChanged(int index);
6969
void on_defaultUserAgentButton_clicked();
70-
void on_deleteCache_clicked();
71-
void on_deletePersistentData_clicked();
7270
void on_dictComboBox_currentIndexChanged(const QString &arg1);
7371
void on_enableSpellCheck_toggled(bool checked);
7472
void on_minimizeOnTrayIconClick_toggled(bool checked);
@@ -99,6 +97,8 @@ private slots:
9997

10098
void on_fullWidthViewCheckbox_toggled(bool checked);
10199

100+
void on_deletePersistentData_clicked();
101+
102102
private:
103103
Ui::SettingsWidget *ui;
104104
QString engineCachePath, enginePersistentStoragePath;

src/settingswidget.ui

Lines changed: 39 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66
<rect>
77
<x>0</x>
88
<y>0</y>
9-
<width>693</width>
10-
<height>867</height>
9+
<width>651</width>
10+
<height>841</height>
1111
</rect>
1212
</property>
1313
<property name="windowTitle">
@@ -38,8 +38,7 @@
3838
</sizepolicy>
3939
</property>
4040
<property name="styleSheet">
41-
<string notr="true">
42-
</string>
41+
<string notr="true"/>
4342
</property>
4443
<layout class="QHBoxLayout" name="horizontalLayout_7">
4544
<item>
@@ -96,8 +95,8 @@ background:transparent;
9695
<rect>
9796
<x>0</x>
9897
<y>0</y>
99-
<width>677</width>
100-
<height>791</height>
98+
<width>635</width>
99+
<height>760</height>
101100
</rect>
102101
</property>
103102
<layout class="QVBoxLayout" name="verticalLayout_5">
@@ -917,15 +916,34 @@ background:transparent;
917916
<item>
918917
<widget class="QGroupBox" name="groupBox_7">
919918
<property name="title">
920-
<string>Storage and Other Settings</string>
919+
<string>Storage </string>
921920
</property>
922921
<layout class="QVBoxLayout" name="verticalLayout_3">
923922
<item>
924923
<layout class="QGridLayout" name="gridLayout_2">
924+
<item row="0" column="0">
925+
<widget class="QLabel" name="label_11">
926+
<property name="sizePolicy">
927+
<sizepolicy hsizetype="Preferred" vsizetype="Maximum">
928+
<horstretch>0</horstretch>
929+
<verstretch>0</verstretch>
930+
</sizepolicy>
931+
</property>
932+
<property name="font">
933+
<font>
934+
<pointsize>10</pointsize>
935+
<italic>false</italic>
936+
</font>
937+
</property>
938+
<property name="text">
939+
<string>Property</string>
940+
</property>
941+
</widget>
942+
</item>
925943
<item row="1" column="2">
926-
<widget class="QPushButton" name="deleteCache">
944+
<widget class="QPushButton" name="deletePersistentData">
927945
<property name="text">
928-
<string> Clear</string>
946+
<string> Clear (requires restart)</string>
929947
</property>
930948
<property name="icon">
931949
<iconset resource="icons.qrc">
@@ -934,14 +952,17 @@ background:transparent;
934952
</widget>
935953
</item>
936954
<item row="1" column="0">
937-
<widget class="QLabel" name="label_3">
955+
<widget class="QLabel" name="label_5">
956+
<property name="toolTip">
957+
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Persistent data includes persistent cookies, HTML5 local storage, and visited links.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
958+
</property>
938959
<property name="text">
939-
<string>Cache</string>
960+
<string>Persistent data</string>
940961
</property>
941962
</widget>
942963
</item>
943964
<item row="1" column="1">
944-
<widget class="QLabel" name="cacheSize">
965+
<widget class="QLabel" name="cookieSize">
945966
<property name="text">
946967
<string>-</string>
947968
</property>
@@ -950,27 +971,8 @@ background:transparent;
950971
</property>
951972
</widget>
952973
</item>
953-
<item row="0" column="0">
954-
<widget class="QLabel" name="label_11">
955-
<property name="sizePolicy">
956-
<sizepolicy hsizetype="Preferred" vsizetype="Maximum">
957-
<horstretch>0</horstretch>
958-
<verstretch>0</verstretch>
959-
</sizepolicy>
960-
</property>
961-
<property name="font">
962-
<font>
963-
<pointsize>10</pointsize>
964-
<italic>false</italic>
965-
</font>
966-
</property>
967-
<property name="text">
968-
<string>Property</string>
969-
</property>
970-
</widget>
971-
</item>
972-
<item row="0" column="2">
973-
<widget class="QLabel" name="label_13">
974+
<item row="0" column="1">
975+
<widget class="QLabel" name="label_12">
974976
<property name="sizePolicy">
975977
<sizepolicy hsizetype="Preferred" vsizetype="Maximum">
976978
<horstretch>0</horstretch>
@@ -984,15 +986,15 @@ background:transparent;
984986
</font>
985987
</property>
986988
<property name="text">
987-
<string>Action</string>
989+
<string>Size</string>
988990
</property>
989991
<property name="alignment">
990992
<set>Qt::AlignCenter</set>
991993
</property>
992994
</widget>
993995
</item>
994-
<item row="0" column="1">
995-
<widget class="QLabel" name="label_12">
996+
<item row="0" column="2">
997+
<widget class="QLabel" name="label_13">
996998
<property name="sizePolicy">
997999
<sizepolicy hsizetype="Preferred" vsizetype="Maximum">
9981000
<horstretch>0</horstretch>
@@ -1006,44 +1008,13 @@ background:transparent;
10061008
</font>
10071009
</property>
10081010
<property name="text">
1009-
<string>Size</string>
1010-
</property>
1011-
<property name="alignment">
1012-
<set>Qt::AlignCenter</set>
1013-
</property>
1014-
</widget>
1015-
</item>
1016-
<item row="2" column="0">
1017-
<widget class="QLabel" name="label_5">
1018-
<property name="toolTip">
1019-
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Persistent data includes persistent cookies, HTML5 local storage, and visited links.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
1020-
</property>
1021-
<property name="text">
1022-
<string>Persistent data</string>
1023-
</property>
1024-
</widget>
1025-
</item>
1026-
<item row="2" column="1">
1027-
<widget class="QLabel" name="cookieSize">
1028-
<property name="text">
1029-
<string>-</string>
1011+
<string>Action</string>
10301012
</property>
10311013
<property name="alignment">
10321014
<set>Qt::AlignCenter</set>
10331015
</property>
10341016
</widget>
10351017
</item>
1036-
<item row="2" column="2">
1037-
<widget class="QPushButton" name="deletePersistentData">
1038-
<property name="text">
1039-
<string> Clear</string>
1040-
</property>
1041-
<property name="icon">
1042-
<iconset resource="icons.qrc">
1043-
<normaloff>:/icons/delete-bin-3-line.png</normaloff>:/icons/delete-bin-3-line.png</iconset>
1044-
</property>
1045-
</widget>
1046-
</item>
10471018
</layout>
10481019
</item>
10491020
</layout>

0 commit comments

Comments
 (0)