Changeset View
Changeset View
Standalone View
Standalone View
src/Gui/SettingsDialog/ShortcutsOptionsPage.cpp
1 | /* | ||||
---|---|---|---|---|---|
2 | * Copyright (C) 2019 David Redondo <kde@david-redondo.de> | ||||
3 | * | ||||
4 | * This program is free software; you can redistribute it and/or modify | ||||
5 | * it under the terms of the GNU General Public License as published by | ||||
6 | * the Free Software Foundation; either version 2 of the License, or | ||||
7 | * (at your option) any later version. | ||||
8 | * | ||||
9 | * This program is distributed in the hope that it will be useful, | ||||
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||||
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||||
12 | * GNU General Public License for more details. | ||||
13 | * | ||||
14 | * You should have received a copy of the GNU General Public License along | ||||
15 | * with this program; if not, write to the Free Software Foundation, Inc., | ||||
16 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. | ||||
17 | */ | ||||
18 | | ||||
1 | #include "ShortcutsOptionsPage.h" | 19 | #include "ShortcutsOptionsPage.h" | ||
2 | 20 | | |||
3 | #include "SpectacleConfig.h" | 21 | #include "ShortcutActions.h" | ||
4 | 22 | | |||
5 | #include <KShortcutsEditor> | 23 | #include <KShortcutsEditor> | ||
6 | 24 | | |||
7 | #include <QVBoxLayout> | 25 | #include <QVBoxLayout> | ||
8 | 26 | | |||
9 | ShortcutsOptionsPage::ShortcutsOptionsPage(QWidget* parent) : SettingsPage(parent) | 27 | ShortcutsOptionsPage::ShortcutsOptionsPage(QWidget* parent) : QWidget(parent) | ||
10 | { | 28 | { | ||
11 | QVBoxLayout *mainLayout = new QVBoxLayout(this); | 29 | QVBoxLayout *mainLayout = new QVBoxLayout(this); | ||
12 | setLayout(mainLayout); | 30 | setLayout(mainLayout); | ||
13 | 31 | mEditor = new KShortcutsEditor(ShortcutActions::self()->shortcutActions(), this, KShortcutsEditor::ActionType::GlobalAction); | |||
14 | mEditor = new KShortcutsEditor(SpectacleConfig::instance()->shortCutActions, this, KShortcutsEditor::ActionType::GlobalAction); | | |||
15 | mainLayout->addWidget(mEditor); | 32 | mainLayout->addWidget(mEditor); | ||
16 | connect(mEditor, &KShortcutsEditor::keyChange, this, &ShortcutsOptionsPage::markDirty); | 33 | connect(mEditor, &KShortcutsEditor::keyChange, this, &ShortcutsOptionsPage::shortCutsChanged); | ||
17 | } | 34 | } | ||
18 | 35 | | |||
19 | ShortcutsOptionsPage::~ShortcutsOptionsPage() | 36 | ShortcutsOptionsPage::~ShortcutsOptionsPage() | ||
20 | { | 37 | { | ||
21 | mEditor->undoChanges(); | 38 | mEditor->undoChanges(); | ||
22 | } | 39 | } | ||
23 | 40 | | |||
24 | 41 | | |||
25 | void ShortcutsOptionsPage::resetChanges() | 42 | void ShortcutsOptionsPage::resetChanges() | ||
26 | { | 43 | { | ||
27 | mEditor->undoChanges(); | 44 | mEditor->undoChanges(); | ||
28 | mChangesMade = false; | | |||
29 | } | 45 | } | ||
30 | 46 | | |||
31 | void ShortcutsOptionsPage::saveChanges() | 47 | void ShortcutsOptionsPage::saveChanges() | ||
32 | { | 48 | { | ||
33 | mEditor->commit(); | 49 | mEditor->commit(); | ||
34 | mChangesMade = false; | | |||
35 | } | 50 | } | ||
36 | 51 | | |||
37 | void ShortcutsOptionsPage::markDirty() | 52 | bool ShortcutsOptionsPage::isModified() | ||
53 | { | ||||
54 | return mEditor->isModified(); | ||||
55 | } | ||||
56 | | ||||
57 | void ShortcutsOptionsPage::defaults() | ||||
38 | { | 58 | { | ||
39 | mChangesMade = true; | 59 | mEditor->allDefault(); | ||
40 | } | 60 | } | ||
41 | 61 | | |||
62 | |