Changeset View
Changeset View
Standalone View
Standalone View
kcmodule/profiles/EditPage.cpp
Show All 18 Lines | |||||
19 | 19 | | |||
20 | #include "EditPage.h" | 20 | #include "EditPage.h" | ||
21 | 21 | | |||
22 | #include "actioneditwidget.h" | 22 | #include "actioneditwidget.h" | ||
23 | #include "ErrorOverlay.h" | 23 | #include "ErrorOverlay.h" | ||
24 | 24 | | |||
25 | #include <powerdevilactionconfig.h> | 25 | #include <powerdevilactionconfig.h> | ||
26 | #include <powerdevilprofilegenerator.h> | 26 | #include <powerdevilprofilegenerator.h> | ||
27 | #include <powerdevilpowermanagement.h> | ||||
27 | 28 | | |||
28 | #include <powerdevil_debug.h> | 29 | #include <powerdevil_debug.h> | ||
29 | 30 | | |||
30 | #include <QCheckBox> | 31 | #include <QCheckBox> | ||
31 | #include <QFormLayout> | 32 | #include <QFormLayout> | ||
32 | #include <QLabel> | 33 | #include <QLabel> | ||
33 | 34 | | |||
34 | #include <QtDBus/QDBusMessage> | 35 | #include <QtDBus/QDBusMessage> | ||
Show All 10 Lines | |||||
45 | #include <KPluginFactory> | 46 | #include <KPluginFactory> | ||
46 | #include <KSharedConfig> | 47 | #include <KSharedConfig> | ||
47 | #include <KServiceTypeTrader> | 48 | #include <KServiceTypeTrader> | ||
48 | #include <KLocalizedString> | 49 | #include <KLocalizedString> | ||
49 | #include <KRun> | 50 | #include <KRun> | ||
50 | 51 | | |||
51 | #include <Solid/Battery> | 52 | #include <Solid/Battery> | ||
52 | #include <Solid/Device> | 53 | #include <Solid/Device> | ||
53 | #include <Solid/PowerManagement> | | |||
54 | 54 | | |||
55 | K_PLUGIN_FACTORY(PowerDevilProfilesKCMFactory, | 55 | K_PLUGIN_FACTORY(PowerDevilProfilesKCMFactory, | ||
56 | registerPlugin<EditPage>(); | 56 | registerPlugin<EditPage>(); | ||
57 | ) | 57 | ) | ||
58 | 58 | | |||
59 | EditPage::EditPage(QWidget *parent, const QVariantList &args) | 59 | EditPage::EditPage(QWidget *parent, const QVariantList &args) | ||
60 | : KCModule(0, parent, args) | 60 | : KCModule(0, parent, args) | ||
61 | { | 61 | { | ||
Show All 12 Lines | |||||
74 | // setAboutData(about); | 74 | // setAboutData(about); | ||
75 | 75 | | |||
76 | setupUi(this); | 76 | setupUi(this); | ||
77 | 77 | | |||
78 | m_profilesConfig = KSharedConfig::openConfig("powermanagementprofilesrc", KConfig::SimpleConfig | KConfig::CascadeConfig); | 78 | m_profilesConfig = KSharedConfig::openConfig("powermanagementprofilesrc", KConfig::SimpleConfig | KConfig::CascadeConfig); | ||
79 | 79 | | |||
80 | if (m_profilesConfig->groupList().isEmpty()) { | 80 | if (m_profilesConfig->groupList().isEmpty()) { | ||
81 | // Use the generator | 81 | // Use the generator | ||
82 | QSet <Solid::PowerManagement::SleepState > methods = Solid::PowerManagement::supportedSleepStates(); | | |||
83 | PowerDevil::ProfileGenerator::generateProfiles( | 82 | PowerDevil::ProfileGenerator::generateProfiles( | ||
84 | methods.contains(Solid::PowerManagement::SuspendState), | 83 | PowerDevil::PowerManagement::instance()->canSuspend(), | ||
85 | methods.contains(Solid::PowerManagement::HibernateState) | 84 | PowerDevil::PowerManagement::instance()->canHibernate() | ||
86 | ); | 85 | ); | ||
87 | m_profilesConfig->reparseConfiguration(); | 86 | m_profilesConfig->reparseConfiguration(); | ||
88 | } | 87 | } | ||
89 | 88 | | |||
90 | qCDebug(POWERDEVIL) << m_profilesConfig.data()->groupList() << m_profilesConfig.data()->entryMap().keys(); | 89 | qCDebug(POWERDEVIL) << m_profilesConfig.data()->groupList() << m_profilesConfig.data()->entryMap().keys(); | ||
91 | 90 | | |||
92 | // Create widgets for each profile | 91 | // Create widgets for each profile | ||
93 | ActionEditWidget *editWidget = new ActionEditWidget("AC", tabWidget); | 92 | ActionEditWidget *editWidget = new ActionEditWidget("AC", tabWidget); | ||
▲ Show 20 Lines • Show All 96 Lines • ▼ Show 20 Line(s) | |||||
190 | { | 189 | { | ||
191 | // Confirm | 190 | // Confirm | ||
192 | int ret = KMessageBox::warningContinueCancel(this, i18n("The KDE Power Management System will now generate a set of defaults " | 191 | int ret = KMessageBox::warningContinueCancel(this, i18n("The KDE Power Management System will now generate a set of defaults " | ||
193 | "based on your computer's capabilities. This will also erase " | 192 | "based on your computer's capabilities. This will also erase " | ||
194 | "all existing modifications you made. " | 193 | "all existing modifications you made. " | ||
195 | "Are you sure you want to continue?"), i18n("Restore Default Profiles")); | 194 | "Are you sure you want to continue?"), i18n("Restore Default Profiles")); | ||
196 | if (ret == KMessageBox::Continue) { | 195 | if (ret == KMessageBox::Continue) { | ||
197 | qCDebug(POWERDEVIL) << "Restoring defaults."; | 196 | qCDebug(POWERDEVIL) << "Restoring defaults."; | ||
198 | QSet <Solid::PowerManagement::SleepState > methods = Solid::PowerManagement::supportedSleepStates(); | | |||
199 | PowerDevil::ProfileGenerator::generateProfiles( | 197 | PowerDevil::ProfileGenerator::generateProfiles( | ||
200 | methods.contains(Solid::PowerManagement::SuspendState), | 198 | PowerDevil::PowerManagement::instance()->canSuspend(), | ||
201 | methods.contains(Solid::PowerManagement::HibernateState) | 199 | PowerDevil::PowerManagement::instance()->canHibernate() | ||
202 | ); | 200 | ); | ||
203 | 201 | | |||
204 | load(); | 202 | load(); | ||
205 | 203 | | |||
206 | notifyDaemon(); | 204 | notifyDaemon(); | ||
207 | } | 205 | } | ||
208 | } | 206 | } | ||
209 | 207 | | |||
▲ Show 20 Lines • Show All 71 Lines • Show Last 20 Lines |