9 |
10 | Settings::Settings(QWidget *parent, const QString &setting_path) : QWidget(parent), ui(new Ui::Settings)
11 | {
12 | ui->setupUi(this);
13 | this->setting_path = setting_path;
14 |
15 | #ifdef COLORPICKER_SNAPCRAFT_BUILD
16 | ui->ratePushButton->show();
17 | #else
18 | ui->ratePushButton->hide();
19 | #endif
20 | }
21 |
22 | void Settings::keyPressEvent(QKeyEvent *e)
23 | {
24 | // esc key to close settings widget
25 | if (e->key() == Qt::Key_Escape)
26 | this->close();
27 | }
28 |
29 | void Settings::setAdvanceMode()
30 | {
31 | ui->advance->blockSignals(true);
32 | ui->simple->blockSignals(true);
33 | ui->advance->setChecked(true);
34 | ui->simple->setChecked(false);
35 | ui->advance->blockSignals(false);
36 | ui->simple->blockSignals(false);
37 | }
38 |
39 | void Settings::setSimpleMode()
40 | {
41 | ui->advance->blockSignals(true);
42 | ui->simple->blockSignals(true);
43 | ui->advance->setChecked(false);
44 | ui->simple->setChecked(true);
45 | ui->advance->blockSignals(false);
46 | ui->simple->blockSignals(false);
47 | }
48 |
49 | Settings::~Settings()
50 | {
51 | delete ui;
52 | }
53 |
54 | void Settings::setTheme(const QString &themeName)
55 | {
56 | if (themeName.contains("Dark"))
57 | {
58 | ui->themeComboBox->setCurrentIndex(2);
59 | }
60 | else if (themeName.contains("Flat"))
61 | {
62 | ui->themeComboBox->setCurrentIndex(1);
63 | }
64 | else if (themeName.contains("System"))
65 | {
66 | ui->themeComboBox->setCurrentIndex(0);
67 | }
68 | }
69 |
70 | void Settings::on_clearColorsPushButton_clicked()
71 | {
72 | QFile file(setting_path + "/saved.colors");
73 | file.remove();
74 | emit empty_saved_table();
75 | }
76 |
77 | void Settings::on_donatePushButton_clicked()
78 | {
79 | QDesktopServices::openUrl(QUrl("https://paypal.me/keshavnrj/2"));
80 | }
81 |
82 | void Settings::on_girhubPushButton_clicked()
83 | {
84 | QDesktopServices::openUrl(QUrl("https://github.com/keshavbhatt/ColorPicker"));
85 | }
86 |
87 | void Settings::on_ratePushButton_clicked()
88 | {
89 | QDesktopServices::openUrl(QUrl("snap://color-picker"));
90 | }
91 |
92 | void Settings::on_themeComboBox_currentIndexChanged(const QString &arg1)
93 | {
94 | emit themeChanged(arg1);
95 | }
96 |
97 | void Settings::on_advance_toggled(bool checked)
98 | {
99 | emit switchAdvanceMode(checked);
100 | }
101 |
102 | void Settings::on_simple_toggled(bool checked)
103 | {
104 | emit switchSimpleMode(checked);
105 | }
106 |
107 | void Settings::showAbout()
108 | {
109 | QString mes = "
"
111 | "
"
113 | "
"
115 | "Designed and Developed
"
117 | "by Keshav Bhatt "
119 | "<keshavnrj@gmail.com>
"
120 | "Website: https://ktechpit.com
"
122 | "Runtime: Qt "
124 | QT_VERSION_STR
125 | "
"
126 | "Version: " +
128 | QApplication::applicationVersion() +
129 | "
"
130 | "
"
132 | "More Apps
";
135 |
136 | QGraphicsOpacityEffect *eff = new QGraphicsOpacityEffect(this);
137 | ui->message->setGraphicsEffect(eff);
138 | QPropertyAnimation *a = new QPropertyAnimation(eff, "opacity");
139 | a->setDuration(1000);
140 | a->setStartValue(0);
141 | a->setEndValue(1);
142 | a->setEasingCurve(QEasingCurve::InCurve);
143 | a->start(QPropertyAnimation::DeleteWhenStopped);
144 | ui->message->setText(mes);
145 | ui->message->show();
146 | }
147 |
148 | void Settings::on_message_linkActivated(const QString &link)
149 | {
150 | QDesktopServices::openUrl(QUrl(link));
151 | }
152 |
--------------------------------------------------------------------------------
/src/settings.h:
--------------------------------------------------------------------------------
1 | #ifndef SETTINGS_H
2 | #define SETTINGS_H
3 |
4 | #include
5 | #include
6 | #include
7 |
8 | namespace Ui
9 | {
10 | class Settings;
11 | }
12 |
13 | class Settings : public QWidget
14 | {
15 | Q_OBJECT
16 |
17 | public:
18 | explicit Settings(QWidget *parent = nullptr, const QString &setting_path = QString());
19 |
20 | virtual ~Settings();
21 |
22 | public slots:
23 | void setTheme(const QString &themeName);
24 |
25 | void setAdvanceMode();
26 |
27 | void setSimpleMode();
28 |
29 | void showAbout();
30 |
31 | signals:
32 | void empty_saved_table();
33 |
34 | void themeChanged(const QString &themeName);
35 |
36 | void switchAdvanceMode(bool checked);
37 |
38 | void switchSimpleMode(bool checked);
39 |
40 | protected:
41 | void keyPressEvent(QKeyEvent *e) override;
42 |
43 | private slots:
44 | void on_clearColorsPushButton_clicked();
45 |
46 | void on_donatePushButton_clicked();
47 |
48 | void on_girhubPushButton_clicked();
49 |
50 | void on_ratePushButton_clicked();
51 |
52 | void on_themeComboBox_currentIndexChanged(const QString &arg1);
53 |
54 | void on_advance_toggled(bool checked);
55 |
56 | void on_simple_toggled(bool checked);
57 |
58 | void on_message_linkActivated(const QString &link);
59 |
60 | private:
61 | Ui::Settings *ui;
62 | QString setting_path;
63 | };
64 |
65 | #endif // SETTINGS_H
66 |
--------------------------------------------------------------------------------
/src/settings.ui:
--------------------------------------------------------------------------------
1 |
2 |
3 | Settings
4 |
5 |
6 |
7 | 0
8 | 0
9 | 326
10 | 435
11 |
12 |
13 |
14 | Form
15 |
16 |
17 | -
18 |
19 |
20 | Settings
21 |
22 |
23 |
-
24 |
25 |
26 | Advance Mode
27 |
28 |
29 |
30 | -
31 |
32 |
33 | Simple Mode
34 |
35 |
36 |
37 | -
38 |
39 |
-
40 |
41 |
42 | Application Theme
43 |
44 |
45 |
46 | -
47 |
48 |
-
49 |
50 | System theme
51 |
52 |
53 | -
54 |
55 | Flat theme
56 |
57 |
58 | -
59 |
60 | Dark theme
61 |
62 |
63 |
64 |
65 |
66 |
67 | -
68 |
69 |
70 | Clear all saved Colors
71 |
72 |
73 |
74 | :/icons/32/remove2.png:/icons/32/remove2.png
75 |
76 |
77 |
78 |
79 |
80 |
81 | -
82 |
83 |
84 | About
85 |
86 |
87 |
-
88 |
89 |
-
90 |
91 |
92 |
93 | 0
94 | 0
95 |
96 |
97 |
98 | -
99 |
100 |
101 | Qt::AlignCenter
102 |
103 |
104 |
105 | -
106 |
107 |
108 | 0
109 |
110 |
-
111 |
112 |
113 | Donate
114 |
115 |
116 |
117 | :/icons/32/donate_paypal.png:/icons/32/donate_paypal.png
118 |
119 |
120 |
121 | -
122 |
123 |
124 | Github
125 |
126 |
127 |
128 | :/icons/20/url.png:/icons/20/url.png
129 |
130 |
131 |
132 | -
133 |
134 |
135 | Rate
136 |
137 |
138 |
139 | :/icons/32/rate.png:/icons/32/rate.png
140 |
141 |
142 |
143 |
144 |
145 |
146 |
147 |
148 |
149 |
150 |
151 |
152 |
153 |
154 |
155 |
156 |
157 |
--------------------------------------------------------------------------------