1 | // SPDX-FileCopyrightText: 2023 UnionTech Software Technology Co., Ltd. |
---|---|
2 | // |
3 | // SPDX-License-Identifier: GPL-3.0-or-later |
4 | |
5 | #include "generaloptionwidget.h" |
6 | #include "environmentwidget.h" |
7 | #include "shortcutsettingwidget.h" |
8 | #include "profilesettingwidget.h" |
9 | |
10 | #include <QHBoxLayout> |
11 | #include <QTabWidget> |
12 | |
13 | class GeneralOptionWidgetPrivate { |
14 | QTabWidget* tabWidget = nullptr; |
15 | |
16 | friend class GeneralOptionWidget; |
17 | }; |
18 | |
19 | GeneralOptionWidget::GeneralOptionWidget(QWidget *parent) |
20 | : PageWidget(parent) |
21 | , d(new GeneralOptionWidgetPrivate()) |
22 | { |
23 | QHBoxLayout *layout = new QHBoxLayout(); |
24 | d->tabWidget = new QTabWidget(); |
25 | layout->addWidget(d->tabWidget); |
26 | |
27 | d->tabWidget->addTab(new EnvironmentWidget(), tr("Environment")); |
28 | d->tabWidget->addTab(new ShortcutSettingWidget(), tr("Commands")); |
29 | d->tabWidget->addTab(new ProfileSettingWidget(), tr("Interface")); |
30 | setLayout(layout); |
31 | } |
32 | |
33 | GeneralOptionWidget::~GeneralOptionWidget() |
34 | { |
35 | if (d) |
36 | delete d; |
37 | } |
38 | |
39 | void GeneralOptionWidget::saveConfig() |
40 | { |
41 | PageWidget *pageWidget = qobject_cast<PageWidget*>(d->tabWidget->currentWidget()); |
42 | if (pageWidget) { |
43 | pageWidget->saveConfig(); |
44 | } |
45 | } |
46 | |
47 | void GeneralOptionWidget::readConfig() |
48 | { |
49 | PageWidget *pageWidget = qobject_cast<PageWidget*>(d->tabWidget->currentWidget()); |
50 | if (pageWidget) { |
51 | pageWidget->readConfig(); |
52 | } |
53 | } |
54 |