Changeset View
Changeset View
Standalone View
Standalone View
plugins/clazy/config/globalconfigpage.cpp
- This file was added.
1 | /* This file is part of KDevelop | ||||
---|---|---|---|---|---|
2 | | ||||
3 | Copyright 2018 Anton Anikin <anton@anikin.xyz> | ||||
4 | | ||||
5 | This program is free software; you can redistribute it and/or | ||||
6 | modify it under the terms of the GNU General Public | ||||
7 | License as published by the Free Software Foundation; either | ||||
8 | version 2 of the License, or (at your option) any later version. | ||||
9 | | ||||
10 | This program is distributed in the hope that it will be useful, | ||||
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||||
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||||
13 | General Public License for more details. | ||||
14 | | ||||
15 | You should have received a copy of the GNU General Public License | ||||
16 | along with this program; see the file COPYING. If not, write to | ||||
17 | the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | ||||
18 | Boston, MA 02110-1301, USA. | ||||
19 | */ | ||||
20 | | ||||
21 | #include "globalconfigpage.h" | ||||
22 | #include "ui_globalconfigpage.h" | ||||
23 | | ||||
24 | #include "checksdb.h" | ||||
25 | #include "globalsettings.h" | ||||
26 | | ||||
27 | namespace Clazy | ||||
28 | { | ||||
29 | | ||||
30 | GlobalConfigPage::GlobalConfigPage(KDevelop::IPlugin* plugin, QWidget* parent) | ||||
31 | : ConfigPage(plugin, GlobalSettings::self(), parent) | ||||
32 | { | ||||
33 | Ui::GlobalConfigPage ui; | ||||
34 | ui.setupUi(this); | ||||
35 | | ||||
36 | auto checkPaths = [ui]() { | ||||
37 | ChecksDB db(ui.kcfg_docsPath->url()); | ||||
38 | ui.checksInfoLabel->setText(i18np("1 check detected", "%1 checks detected", db.checks().size())); | ||||
39 | | ||||
pino: This must be i18np(), since there is a variable number. | |||||
40 | JobGlobalParameters params(ui.kcfg_executablePath->url(), ui.kcfg_docsPath->url()); | ||||
41 | if (!params.isValid()) { | ||||
42 | ui.errorWidget->setText(params.error()); | ||||
43 | ui.errorWidget->setVisible(true); | ||||
44 | return; | ||||
45 | } | ||||
46 | | ||||
47 | if (!db.isValid()) { | ||||
48 | ui.errorWidget->setText(db.error()); | ||||
49 | ui.errorWidget->setVisible(true); | ||||
50 | return; | ||||
51 | } | ||||
52 | | ||||
53 | ui.errorWidget->setVisible(false); | ||||
54 | }; | ||||
55 | | ||||
56 | connect(ui.kcfg_executablePath, &KUrlRequester::textChanged, this, checkPaths); | ||||
57 | connect(ui.kcfg_docsPath, &KUrlRequester::textChanged, this, checkPaths); | ||||
58 | | ||||
59 | checkPaths(); | ||||
60 | ui.kcfg_executablePath->setPlaceholderText(ui.kcfg_executablePath->toolTip()); | ||||
61 | ui.kcfg_docsPath->setPlaceholderText(ui.kcfg_docsPath->toolTip()); | ||||
62 | | ||||
63 | auto checkJobs = [ui]() { | ||||
64 | const bool jobsEnabled = ui.kcfg_parallelJobsEnabled->checkState() == Qt::Checked; | ||||
65 | const bool autoEnabled = ui.kcfg_parallelJobsAutoCount->checkState() == Qt::Checked; | ||||
66 | | ||||
67 | ui.kcfg_parallelJobsAutoCount->setEnabled(jobsEnabled); | ||||
68 | | ||||
69 | ui.kcfg_parallelJobsFixedCount->setEnabled(jobsEnabled && !autoEnabled); | ||||
70 | ui.parallelJobsFixedCountLabel->setEnabled(jobsEnabled && !autoEnabled); | ||||
71 | }; | ||||
72 | | ||||
73 | connect(ui.kcfg_parallelJobsEnabled, &QCheckBox::stateChanged, this, checkJobs); | ||||
74 | connect(ui.kcfg_parallelJobsAutoCount, &QCheckBox::stateChanged, this, checkJobs); | ||||
75 | | ||||
76 | checkJobs(); | ||||
77 | } | ||||
78 | | ||||
79 | KDevelop::ConfigPage::ConfigPageType GlobalConfigPage::configPageType() const | ||||
80 | { | ||||
81 | return KDevelop::ConfigPage::AnalyzerConfigPage; | ||||
82 | } | ||||
83 | | ||||
84 | QString GlobalConfigPage::name() const | ||||
85 | { | ||||
86 | return i18n("Clazy"); | ||||
87 | } | ||||
88 | | ||||
89 | QString GlobalConfigPage::fullName() const | ||||
90 | { | ||||
91 | return i18n("Configure Clazy Settings"); | ||||
92 | } | ||||
93 | | ||||
94 | QIcon GlobalConfigPage::icon() const | ||||
95 | { | ||||
96 | return QIcon::fromTheme(QStringLiteral("clazy")); | ||||
97 | } | ||||
Please use the same icon across all the places. This helps to more quickly find the config pages for the tool. Sadly clazy has no own icon yet to use here, filed that now as bug https://bugs.kde.org/show_bug.cgi?id=396904 :) Guess "dialog-ok" might be fine for now, no other plugin uses that as visual id yet :) kossebau: Please use the same icon across all the places. This helps to more quickly find the config… | |||||
98 | | ||||
99 | } |
This must be i18np(), since there is a variable number.