Changeset View
Changeset View
Standalone View
Standalone View
components/shellprivate/widgetexplorer/widgetexplorer.cpp
Context not available. | |||||
28 | 28 | | |||
---|---|---|---|---|---|
29 | #include <KAuthorized> | 29 | #include <KAuthorized> | ||
30 | #include <klocalizedstring.h> | 30 | #include <klocalizedstring.h> | ||
31 | #include <KNewStuff3/KNS3/DownloadDialog> | | |||
32 | #include <KWindowSystem> | | |||
33 | 31 | | |||
34 | #include <Plasma/Applet> | 32 | #include <Plasma/Applet> | ||
35 | #include <Plasma/Corona> | 33 | #include <Plasma/Corona> | ||
Context not available. | |||||
43 | #include <KPackage/PackageStructure> | 41 | #include <KPackage/PackageStructure> | ||
44 | #include <KPackage/PackageLoader> | 42 | #include <KPackage/PackageLoader> | ||
45 | 43 | | |||
44 | #include "widgetexplorerassistant.h" | ||||
46 | #include "kcategorizeditemsviewmodels_p.h" | 45 | #include "kcategorizeditemsviewmodels_p.h" | ||
47 | #include "plasmaappletitemmodel_p.h" | 46 | #include "plasmaappletitemmodel_p.h" | ||
48 | #include "openwidgetassistant_p.h" | | |||
49 | #include "config-workspace.h" | 47 | #include "config-workspace.h" | ||
50 | 48 | | |||
51 | using namespace KActivities; | 49 | using namespace KActivities; | ||
Context not available. | |||||
101 | QHash<QString, int> runningApplets; // applet name => count | 99 | QHash<QString, int> runningApplets; // applet name => count | ||
102 | //extra hash so we can look up the names of deleted applets | 100 | //extra hash so we can look up the names of deleted applets | ||
103 | QHash<Plasma::Applet *,QString> appletNames; | 101 | QHash<Plasma::Applet *,QString> appletNames; | ||
104 | QPointer<Plasma::OpenWidgetAssistant> openAssistant; | | |||
105 | KPackage::Package *package; | 102 | KPackage::Package *package; | ||
106 | 103 | | |||
107 | PlasmaAppletItemModel itemModel; | 104 | PlasmaAppletItemModel itemModel; | ||
108 | KCategorizedItemsViewModels::DefaultFilterModel filterModel; | 105 | KCategorizedItemsViewModels::DefaultFilterModel filterModel; | ||
109 | bool showSpecialFilters = true; | 106 | bool showSpecialFilters = true; | ||
110 | DefaultItemFilterProxyModel filterItemModel; | 107 | DefaultItemFilterProxyModel filterItemModel; | ||
111 | QPointer<KNS3::DownloadDialog> newStuffDialog; | 108 | | ||
109 | QPointer <WidgetExplorerAssistant> assistant; | ||||
112 | 110 | | |||
113 | QScopedPointer<KActivities::Consumer> activitiesConsumer; | 111 | QScopedPointer<KActivities::Consumer> activitiesConsumer; | ||
114 | }; | 112 | }; | ||
Context not available. | |||||
214 | if (KAuthorized::authorize(QStringLiteral("ghns"))) { | 212 | if (KAuthorized::authorize(QStringLiteral("ghns"))) { | ||
215 | action = new WidgetAction(QIcon::fromTheme(QStringLiteral("internet-services")), | 213 | action = new WidgetAction(QIcon::fromTheme(QStringLiteral("internet-services")), | ||
216 | i18n("Download New Plasma Widgets"), this); | 214 | i18n("Download New Plasma Widgets"), this); | ||
217 | connect(action, &QAction::triggered, this, &WidgetExplorer::downloadWidgets); | 215 | connect(action, &QAction::triggered, [this] { openWidgetDialog(WidgetSource::Network); }); | ||
218 | actionList << action; | 216 | actionList << action; | ||
219 | } | 217 | } | ||
220 | 218 | | |||
Context not available. | |||||
224 | 222 | | |||
225 | action = new WidgetAction(QIcon::fromTheme(QStringLiteral("package-x-generic")), | 223 | action = new WidgetAction(QIcon::fromTheme(QStringLiteral("package-x-generic")), | ||
226 | i18n("Install Widget From Local File..."), this); | 224 | i18n("Install Widget From Local File..."), this); | ||
227 | QObject::connect(action, &QAction::triggered, this, &WidgetExplorer::openWidgetFile); | 225 | QObject::connect(action, &QAction::triggered, [this] { openWidgetDialog(WidgetSource::Filesystem); }); | ||
228 | actionList << action; | 226 | actionList << action; | ||
229 | 227 | | |||
230 | return actionList; | 228 | return actionList; | ||
Context not available. | |||||
438 | } | 436 | } | ||
439 | } | 437 | } | ||
440 | 438 | | |||
441 | 439 | void WidgetExplorer::setExternalAssistant(WidgetExplorerAssistant *assistant) | |||
442 | | ||||
443 | void WidgetExplorer::downloadWidgets() | | |||
444 | { | 440 | { | ||
445 | if (!d->newStuffDialog) { | 441 | d->assistant = assistant; | ||
446 | d->newStuffDialog = new KNS3::DownloadDialog(QLatin1String("plasmoids.knsrc")); | | |||
447 | d->newStuffDialog.data()->setWindowTitle(i18n("Download New Plasma Widgets")); | | |||
448 | d->newStuffDialog.data()->setAttribute(Qt::WA_DeleteOnClose); | | |||
449 | } | | |||
450 | d->newStuffDialog.data()->show(); | | |||
451 | | ||||
452 | emit shouldClose(); | | |||
453 | } | 442 | } | ||
454 | 443 | | |||
455 | void WidgetExplorer::openWidgetFile() | 444 | void WidgetExplorer::openWidgetDialog(WidgetExplorer::WidgetSource source) | ||
456 | { | 445 | { | ||
457 | 446 | if (d->assistant.isNull()) { | |||
458 | Plasma::OpenWidgetAssistant *assistant = d->openAssistant.data(); | 447 | d->assistant = new WidgetExplorerAssistant(this); | ||
459 | if (!assistant) { | | |||
460 | assistant = new Plasma::OpenWidgetAssistant(nullptr); | | |||
461 | d->openAssistant = assistant; | | |||
462 | } | 448 | } | ||
463 | 449 | | |||
464 | KWindowSystem::setOnDesktop(assistant->winId(), KWindowSystem::currentDesktop()); | 450 | d->assistant->openWidgetDialog(source); | ||
465 | assistant->setAttribute(Qt::WA_DeleteOnClose, true); | | |||
466 | assistant->show(); | | |||
467 | assistant->raise(); | | |||
468 | assistant->setFocus(); | | |||
469 | | ||||
470 | emit shouldClose(); | 451 | emit shouldClose(); | ||
471 | } | 452 | } | ||
472 | 453 | | |||
Context not available. |