Changeset View
Changeset View
Standalone View
Standalone View
kcms/solid_actions/SolidActions.cpp
Show All 22 Lines | |||||
23 | #include <KAboutData> | 23 | #include <KAboutData> | ||
24 | #include <KMessageBox> | 24 | #include <KMessageBox> | ||
25 | #include <KDesktopFile> | 25 | #include <KDesktopFile> | ||
26 | #include <KPluginFactory> | 26 | #include <KPluginFactory> | ||
27 | #include <KBuildSycocaProgressDialog> | 27 | #include <KBuildSycocaProgressDialog> | ||
28 | #include <KConfigGroup> | 28 | #include <KConfigGroup> | ||
29 | #include <KStandardGuiItem> | 29 | #include <KStandardGuiItem> | ||
30 | 30 | | |||
31 | #include <KIO/Global> | ||||
32 | | ||||
31 | #include <QComboBox> | 33 | #include <QComboBox> | ||
32 | #include <QPushButton> | 34 | #include <QPushButton> | ||
33 | #include <QDebug> | 35 | #include <QDebug> | ||
34 | 36 | | |||
35 | #include <Solid/DeviceInterface> | 37 | #include <Solid/DeviceInterface> | ||
36 | #include <Solid/Predicate> | 38 | #include <Solid/Predicate> | ||
37 | 39 | | |||
38 | K_PLUGIN_FACTORY( SolidActionsFactory, registerPlugin<SolidActions>(); ) | 40 | K_PLUGIN_FACTORY( SolidActionsFactory, registerPlugin<SolidActions>(); ) | ||
▲ Show 20 Lines • Show All 75 Lines • ▼ Show 20 Line(s) | |||||
114 | void SolidActions::addAction() | 116 | void SolidActions::addAction() | ||
115 | { | 117 | { | ||
116 | const QString enteredName = addUi.LeActionName->text(); | 118 | const QString enteredName = addUi.LeActionName->text(); | ||
117 | KDesktopFile templateDesktop(QStandardPaths::GenericDataLocation, QStringLiteral("kcmsolidactions/solid-action-template.desktop")); // Lets get the template | 119 | KDesktopFile templateDesktop(QStandardPaths::GenericDataLocation, QStringLiteral("kcmsolidactions/solid-action-template.desktop")); // Lets get the template | ||
118 | 120 | | |||
119 | // Lets get a desktop file | 121 | // Lets get a desktop file | ||
120 | QString internalName = enteredName; // copy the name the user entered -> we will be making mods | 122 | QString internalName = enteredName; // copy the name the user entered -> we will be making mods | ||
121 | internalName.replace(QChar(' '), QChar('-'), Qt::CaseSensitive); // replace spaces with dashes | 123 | internalName.replace(QChar(' '), QChar('-'), Qt::CaseSensitive); // replace spaces with dashes | ||
124 | internalName = KIO::encodeFileName(internalName); | ||||
122 | 125 | | |||
123 | QString filePath = QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation) + "/solid/actions/"; // Get the location on disk for "data" | 126 | QString filePath = QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation) + "/solid/actions/"; // Get the location on disk for "data" | ||
124 | if (!QDir().exists(filePath)) { | 127 | if (!QDir().exists(filePath)) { | ||
125 | QDir().mkpath(filePath); | 128 | QDir().mkpath(filePath); | ||
126 | } | 129 | } | ||
127 | filePath += internalName + ".desktop"; | 130 | filePath += internalName + ".desktop"; | ||
128 | 131 | | |||
129 | // Fill in an initial template | 132 | // Fill in an initial template | ||
▲ Show 20 Lines • Show All 106 Lines • Show Last 20 Lines |