File plasma-new-default-panel.diff of Package kdebase4
Index: plasma/applets/folderview/folderview.h
===================================================================
--- apps/plasma/applets/folderview/folderview.h (revision 1011425)
+++ apps/plasma/applets/folderview/folderview.h (working copy)
@@ -29,11 +29,13 @@
#include <QBasicTimer>
#include <KActionCollection>
+#include <KMessageBox>
#include <KMimeType>
#include <Solid/Networking>
#include <plasma/containment.h>
+#include "plasma/dataenginemanager.h"
#include "iconview.h"
@@ -150,6 +152,8 @@
void updateScreenRegion();
void showPreviewConfigDialog();
+ void saveDefaultSetup();
+
private:
void addActions(AbstractItemView *view);
void setupIconView();
@@ -165,6 +169,8 @@
void showContextMenu(QWidget *widget, const QPoint &pos, const QModelIndexList &indexes);
void timerEvent(QTimerEvent *event);
+ Plasma::Applet *loadDefaultApplet(const QString &pluginName, Plasma::Containment *c);
+
private:
KFileItemDelegate *m_delegate;
QPointer<KFilePreviewGenerator> m_previewGenerator;
Index: plasma/applets/folderview/folderview.cpp
===================================================================
--- apps/plasma/applets/folderview/folderview.cpp (revision 1011425)
+++ apps/plasma/applets/folderview/folderview.cpp (working copy)
@@ -1487,12 +1487,24 @@
void FolderView::addPanel(const QString &plugin)
{
if (corona()) {
+ bool default_panel = false;
+ if (corona()->containments().count()==1) {
+ int answer = KMessageBox::questionYesNoCancel(0, i18n("Do you want a panel with the default widgets or an empty panel?"),
+ i18n("Add Panel"), KGuiItem(i18n("Default Panel")), KGuiItem(i18n("Empty Panel")));
+ if (answer==KMessageBox::Cancel) {
+ return;
+ } else if (answer==KMessageBox::Yes) {
+ default_panel = true;
+ }
+ }
+
// make a panel at the top
Containment* panel = corona()->addContainment(plugin);
panel->showConfigurationInterface();
panel->setScreen(screen());
+ if (!default_panel) {
QList<Plasma::Location> freeEdges = corona()->freeEdges(screen());
//kDebug() << freeEdges;
Plasma::Location destination;
@@ -1542,35 +1554,127 @@
panel->setMaximumSize(w, h);
panel->resize(w, h);
}
+ else {
+ panel->setLocation(Plasma::BottomEdge);
+
+ const int newHeight = 28;
+ panel->resize(QSize((int)panel->size().width(), newHeight));
+ panel->setMinimumSize(QSize((int)panel->minimumSize().width(), newHeight));
+ panel->setMaximumSize(QSize((int)panel->maximumSize().width(), newHeight));
+
+ panel->updateConstraints(Plasma::StartupCompletedConstraint);
+ panel->flushPendingConstraintsEvents();
+
+ // some default applets to get a usable UI
+ Plasma::Applet *applet = loadDefaultApplet("launcher", panel);
+ if (applet) {
+ applet->setGlobalShortcut(KShortcut("Alt+F1"));
+ }
+
+ if (QFile::exists("/usr/share/kde4/services/plasma-applet-showdashboard.desktop"))
+ loadDefaultApplet("showdashboard", panel);
+
+ QVariantList args;
+ if (QFile::exists("/usr/share/applications/MozillaFirefox.desktop")) {
+ args << "/usr/share/applications/MozillaFirefox.desktop";
+ panel->addApplet("icon", args);
+ }
+ else if (QFile::exists("/usr/share/applications/kde4/konqbrowser.desktop")) {
+ args << "/usr/share/applications/kde4/konqbrowser.desktop";
+ panel->addApplet("icon", args);
+ }
+
+ args.clear();
+ if (QFile::exists("/usr/share/applications/kde4/dolphin.desktop")) {
+ args << "/usr/share/applications/kde4/dolphin.desktop";
+ panel->addApplet("icon", args);
+ }
+
+ loadDefaultApplet("notifier", panel);
+ loadDefaultApplet("pager", panel);
+ loadDefaultApplet("tasks", panel);
+ loadDefaultApplet("systemtray", panel);
+
+ Plasma::DataEngineManager *engines = Plasma::DataEngineManager::self();
+ Plasma::DataEngine *power = engines->loadEngine("powermanagement");
+ if (power) {
+ const QStringList &batteries = power->query("Battery")["sources"].toStringList();
+ if (!batteries.isEmpty()) {
+ loadDefaultApplet("battery", panel);
+ }
+ }
+ engines->unloadEngine("powermanagement");
+
+ if (QFile::exists("/usr/share/kde4/services/plasma-applet-networkmanagement.desktop")) {
+ loadDefaultApplet("networkmanagement", panel);
+ }
+
+ loadDefaultApplet("digital-clock", panel);
+ loadDefaultApplet("lockout", panel);
+
+ QTimer::singleShot(1000, this, SLOT(saveDefaultSetup()));
+ }
+ }
}
+Plasma::Applet *FolderView::loadDefaultApplet(const QString &pluginName, Plasma::Containment *c)
+{
+ QVariantList args;
+ Plasma::Applet *applet = Plasma::Applet::load(pluginName, 0, args);
+
+ if (applet) {
+ c->addApplet(applet);
+ }
+
+ return applet;
+}
+
+void FolderView::saveDefaultSetup()
+{
+ // a "null" KConfigGroup is used to force a save into the config file
+ KConfigGroup invalidConfig;
+
+ foreach (Plasma::Containment *containment, corona()->containments()) {
+ containment->save(invalidConfig);
+
+ foreach (Plasma::Applet* applet, containment->applets()) {
+ applet->init();
+ applet->updateConstraints(Plasma::AllConstraints | Plasma::StartupCompletedConstraint);
+ applet->flushPendingConstraintsEvents();
+ applet->save(invalidConfig);
+ }
+ }
+
+ corona()->requestConfigSync();
+}
+
void FolderView::runCommand()
-{
+{
if (!KAuthorized::authorizeKAction("run_command")) {
return;
- }
-
+ }
+
QDBusInterface krunner("org.kde.krunner", "/App", "org.kde.krunner.App", QDBusConnection::sessionBus());
krunner.call("display");
-}
-
+}
+
void FolderView::lockScreen()
-{
+{
if (!KAuthorized::authorizeKAction("lock_screen")) {
return;
- }
-
+ }
+
#ifndef Q_OS_WIN
QDBusInterface screensaver("org.freedesktop.ScreenSaver", "/ScreenSaver",
"org.freedesktop.ScreenSaver", QDBusConnection::sessionBus());
if (screensaver.isValid()) {
screensaver.call("Lock");
- }
-#else
+ }
+#else
LockWorkStation();
-#endif
-}
-
+#endif
+}
+
void FolderView::logout()
{
if (!KAuthorized::authorizeKAction("logout")) {