-
Notifications
You must be signed in to change notification settings - Fork 0
/
settingspage.cpp
80 lines (65 loc) · 1.79 KB
/
settingspage.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
// Copyright (c) 2019 Ahmet Bilgili
// Licensed under the MIT licence
#include "settingspage.h"
#include "constants.h"
#include "settings.h"
#include "ui_settingspage.h"
#include <coreplugin/icore.h>
#include <cpptools/cpptoolsconstants.h>
#include <utils/pathchooser.h>
#include <QTextStream>
namespace CppInsightsPlugin
{
namespace Internal
{
SettingsPageWidget::SettingsPageWidget(
const QSharedPointer<Settings> &settings, QWidget *parent)
: QWidget(parent)
, ui(new Ui::OptionsPage)
, m_settings(settings) {
ui->setupUi(this);
ui->command->setExpectedKind(Utils::PathChooser::ExistingCommand);
ui->command->setCommandVersionArguments({"--version"});
ui->command->setPromptDialogTitle(tr("CppInsights"));
}
SettingsPageWidget::~SettingsPageWidget() {
delete ui;
}
void SettingsPageWidget::restore()
{
ui->command->setPath(m_settings->cppInsightsTool());
ui->mime->setText(m_settings->cppInsightsMimesAsString());
}
void SettingsPageWidget::apply()
{
m_settings->setCppInsightsTool(ui->command->path());
m_settings->setCppInsightsMimes(ui->mime->text());
m_settings->save();
}
SettingsPage::SettingsPage(const QSharedPointer<Settings> &settings, QObject *parent)
: IOptionsPage(parent)
, m_settings(settings)
{
setId(Constants::SETTINGS_GROUP);
setDisplayName("CppInsights");
setCategory(CppTools::Constants::CPP_SETTINGS_CATEGORY);
setDisplayCategory(QCoreApplication::translate("CppTools", CppTools::Constants::CPP_SETTINGS_NAME));
}
QWidget *SettingsPage::widget()
{
m_settings->read();
if (!m_widget)
m_widget = new SettingsPageWidget(m_settings);
m_widget->restore();
return m_widget;
}
void SettingsPage::apply()
{
if (m_widget)
m_widget->apply();
}
void SettingsPage::finish()
{
}
} // namespace Internal
} // namespace CppInsightsPlugin