[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    [kde-workspace/plasma/sreich/sal-qml] plasma/netbook/containments/sal/shell: Rewrite main.cpp, much
From:       Aurélien Gâteau <agateau () kde ! org>
Date:       2012-05-11 9:46:29
Message-ID: 20120511094629.0E048A60A9 () git ! kde ! org
[Download RAW message or body]

Git commit a9288c9bffad6312c4bd6394ff3a0363594cc955 by Aurélien Gâteau.
Committed on 11/05/2012 at 11:46.
Pushed by gateau into branch 'plasma/sreich/sal-qml'.

Rewrite main.cpp, much shorter now

M  +1    -1    plasma/netbook/containments/sal/shell/fullview.cpp
M  +1    -1    plasma/netbook/containments/sal/shell/fullview.h
M  +28   -257  plasma/netbook/containments/sal/shell/main.cpp

http://commits.kde.org/kde-workspace/a9288c9bffad6312c4bd6394ff3a0363594cc955

diff --git a/plasma/netbook/containments/sal/shell/fullview.cpp \
b/plasma/netbook/containments/sal/shell/fullview.cpp index 635fecf..91513c2 100644
--- a/plasma/netbook/containments/sal/shell/fullview.cpp
+++ b/plasma/netbook/containments/sal/shell/fullview.cpp
@@ -42,7 +42,7 @@
 
 #include <Plasma/WindowEffects>
 
-FullView::FullView(const QString &ff, const QString &loc, bool persistent, QWidget \
*parent) +FullView::FullView()
 : QDeclarativeView()
 {
     new SalViewerAdaptor(this);
diff --git a/plasma/netbook/containments/sal/shell/fullview.h \
b/plasma/netbook/containments/sal/shell/fullview.h index 317fef9..046edac 100644
--- a/plasma/netbook/containments/sal/shell/fullview.h
+++ b/plasma/netbook/containments/sal/shell/fullview.h
@@ -35,7 +35,7 @@ class FullView : public QDeclarativeView
     Q_CLASSINFO("D-Bus Interface", "org.kde.salViewer")
 
 public:
-    explicit FullView(const QString &formfactor = "planar", const QString &location \
= "floating", bool persistentConfig = false, QWidget *parent = 0); +    FullView();
     ~FullView();
 
 public Q_SLOTS:
diff --git a/plasma/netbook/containments/sal/shell/main.cpp \
b/plasma/netbook/containments/sal/shell/main.cpp index 49a6748..c032552 100644
--- a/plasma/netbook/containments/sal/shell/main.cpp
+++ b/plasma/netbook/containments/sal/shell/main.cpp
@@ -1,282 +1,53 @@
 /*
- * Copyright 2007 Frerich Raabe <raabe@kde.org>
- * Copyright 2007-2008 Aaron Seigo <aseigo@kde.org>
+ *   Copyright 2012 Aurélien Gâteau <agateau@kde.org>
  *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
+ *   This program is free software; you can redistribute it and/or modify
+ *   it under the terms of the GNU Library General Public License as
+ *   published by the Free Software Foundation; either version 2, or
+ *   (at your option) any later version.
  *
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU Library General Public License for more details
  *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *   You should have received a copy of the GNU Library General Public
+ *   License along with this program; if not, write to the
+ *   Free Software Foundation, Inc.,
+ *   51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
  */
-
-#include "fullview.h"
-
-#include <iostream>
-
-#include <QPixmapCache>
-
-#include <KUniqueApplication>
 #include <KAboutData>
-#include <KAction>
 #include <KCmdLineArgs>
+#include <KDebug>
 #include <KLocale>
-#include <KStandardAction>
-
-// for --list
-#include <Plasma/Applet>
-#include <Plasma/Theme>
-#include <Plasma/AccessManager>
-#include <Plasma/AuthorizationManager>
-#include <Plasma/Wallpaper>
-
-using namespace Plasma;
-
-static const char description[] = I18N_NOOP("Run Plasma widgets in their own \
                window");
-
-class RemotePlasmoidWatcher : public QObject
-{
-Q_OBJECT
-
-public:
-    RemotePlasmoidWatcher(AccessManager *manager)
-        : QObject(manager)
-    {
-        kDebug();
-        connect(manager, SIGNAL(remoteAppletAnnounced(Plasma::PackageMetadata)),
-                this, SLOT(slotServiceAdded(Plasma::PackageMetadata)));
-        connect(manager, SIGNAL(remoteAppletUnannounced(Plasma::PackageMetadata)),
-                this, SLOT(slotServiceRemoved(Plasma::PackageMetadata)));
-    }
-
-    ~RemotePlasmoidWatcher() {}
-
-public Q_SLOTS:
-    void slotServiceAdded(Plasma::PackageMetadata metadata) {
-        std::cout << "New service published:" << std::endl;
-        std::cout << metadata.remoteLocation().prettyUrl().toLocal8Bit().data() << \
                std::endl;
-        std::cout << metadata.name().toLocal8Bit().data() << " - "
-                  << metadata.description().toLocal8Bit().data() << std::endl;
-    }
+#include <KUniqueApplication>
 
-    void slotServiceRemoved(Plasma::PackageMetadata metadata) {
-        std::cout << "Service removed:" << std::endl;
-        std::cout << metadata.remoteLocation().prettyUrl().toLocal8Bit().data() << \
                std::endl;
-    }
-};
+#include "fullview.h"
 
-void listPlugins(const KPluginInfo::List & plugins)
+int main(int argc, char *argv[])
 {
-    int maxLen = 0;
-    QMap<QString, QString> applets;
-    foreach (const KPluginInfo &info, plugins) {
-        if (info.property("NoDisplay").toBool()) {
-            continue;
-        }
-
-        int len = info.pluginName().length();
-        if (len > maxLen) {
-            maxLen = len;
-        }
+    KAboutData aboutData(
+        "salviewer",                  // appName
+        0,                            // catalogName
+        ki18n("Search and Launch"),   // programName
+        "0.0.0");                     // version
+    aboutData.setLicense(KAboutData::License_GPL);
+    aboutData.setCopyrightStatement(ki18n("(C) 2012 Blue Systems"));
 
-        QString name = info.pluginName();
-        QString comment = info.comment();
-
-        if (comment.isEmpty()) {
-            comment = i18n("No description available");
-        }
-
-        applets.insert(name, comment);
-    }
-
-    QMap<QString, QString>::const_iterator it;
-    for (it = applets.constBegin(); it != applets.constEnd(); ++it) {
-        QString applet("%1 - %2");
-
-        applet = applet.arg(it.key().leftJustified(maxLen, ' ')).arg(it.value());
-        std::cout << applet.toLocal8Bit().data() << std::endl;
-    }
-}
-
-int main(int argc, char **argv)
-{
-    KAboutData aboutData("plasmoidviewer", 0, ki18n("Plasma Widget Viewer"),
-                         "1.0", ki18n(description), KAboutData::License_BSD,
-                         ki18n("2007-2008, Frerich Raabe"));
-    aboutData.setProgramIconName("plasma");
-    aboutData.addAuthor(ki18n("Frerich Raabe"),
-                         ki18n("Original author"),
-                        "raabe@kde.org");
+    aboutData.addAuthor(ki18n("Shaun Reich"), ki18n("Developer"), \
"shaun.reich@blue-systems.com"); +    aboutData.addAuthor(ki18n("Aurélien Gâteau"), \
ki18n("Developer"), "agateau@kde.org");  
     KCmdLineArgs::init(argc, argv, &aboutData);
-
     KCmdLineOptions options;
-    options.add("c");
-    options.add("containment <name>", ki18n("Name of the containment plugin"), \
                "null");
-    options.add("f");
-    options.add("formfactor <name>", ki18nc("Do not translate horizontal, vertical, \
mediacenter nor planar", "The formfactor to use (horizontal, vertical, mediacenter or \
                planar)"), "planar");
-    options.add("la");
-    options.add("list", ki18n("Displays a list of known applets"));
-    options.add("lw");
-    options.add("list-wallpapers", ki18n("Displays a list of known wallpapers"));
-    options.add("lc");
-    options.add("list-containments", ki18n("Displays a list of known \
                containments"));
-    options.add("lt");
-    options.add("list-themes", ki18n("Displays a list of known themes"));
-    options.add("nosaveconfig", ki18n("Disables save and restore of the config \
                between runs"));
-    options.add("l");
-    options.add("location <name>", ki18nc("Do not translate floating, desktop, \
fullscreen, top, bottom, left nor right", "The location constraint to start the \
Containment with (floating, desktop, fullscreen, top, bottom, left, right)"), \
                "floating");
-    options.add("p");
-    options.add("pixmapcache <size>", ki18n("The size in kB to set the pixmap cache \
                to"));
-    options.add("s");
-    options.add("screenshot", ki18n("Takes a screenshot of the widget and saves it \
                the working directory as <pluginname>.png"));
-    options.add("sa");
-    options.add("screenshot-all", ki18n("Takes a screenshot of each widget and saves \
                it the working directory as <pluginname>.png"));
-    options.add("t");
-    options.add("theme <name>", ki18n("Desktop SVG theme to use"));
-    options.add("w");
-    options.add("wallpaper <name>", ki18n("Name of the wallpaper plugin. Requires a \
                containment plugin to be specified."), QByteArray());
-    options.add("+applet", ki18n("Name of applet to view; may refer to the plugin \
                name or be a path "
-                                "(absolute or relative) to a package. If not \
                provided, then an "
-                                "attempt is made to load a package from the current \
                directory."));
-    options.add("+[args]", ki18n("Optional arguments of the applet to add"));
-    options.add("list-remote", ki18n("List zeroconf announced remote widgets"));
     KCmdLineArgs::addCmdLineOptions(options);
 
     if (!KUniqueApplication::start()) {
-
-        kDebug() << "ALREADY RUNNING!";
+        kError() << "Already running.";
         return 0;
     }
 
     KUniqueApplication app;
-
-    KCmdLineArgs *args = KCmdLineArgs::parsedArgs() ;
-
-    if (args->isSet("list")) {
-        listPlugins(Plasma::Applet::listAppletInfo());
-        return 0;
-    }
-
-    if (args->isSet("list-wallpapers")) {
-        listPlugins(Plasma::Wallpaper::listWallpaperInfo());
-        return 0;
-    }
-
-    if (args->isSet("list-themes")) {
-        listPlugins(Plasma::Theme::listThemeInfo());
-        return 0;
-    }
-
-    QString pluginName;
-    if (args->count() > 0) {
-        pluginName = args->arg(0);
-
-        kDebug() << "setting applet to" << pluginName;
-
-        KPluginInfo::List appletList = Plasma::Applet::listAppletInfo();
-
-        foreach (const KPluginInfo& info, appletList) {
-
-            if (info.pluginName() == pluginName) {
-                goto appletFound;
-            }
-        }
-
-        kError() << "Fatal error. Applet: " + pluginName +
-            " is invalid. Did you run kbuildsycoca4? List known containments through \
                --list";
-        kError() << "Note: only accepts applet Plugin Name (visible through --list), \
                not user-visible name";
-        return 1;
-
-    }
-
-appletFound:
-
-    QString formfactor = args->getOption("formfactor");
-    kDebug() << "setting FormFactor to" << args->getOption("formfactor");
-
-    QString location = args->getOption("location");
-    kDebug() << "setting Location to" << args->getOption("location");
-
-    QString containment = args->getOption("containment");
-
-containmentFound:
-
-    if (args->isSet("theme")) {
-        QString themeName = args->getOption("theme");
-
-        kDebug() << "setting theme to" << themeName;
-
-        KPluginInfo::List themeList = Plasma::Theme::listThemeInfo();
-
-        foreach (const KPluginInfo& info, themeList) {
-
-            if (info.pluginName() == themeName) {
-
-                Plasma::Theme *defaultTheme = Plasma::Theme::defaultTheme();
-                defaultTheme->setUseGlobalSettings(false);
-                defaultTheme->setThemeName(themeName);
-
-
-                goto themeFound;
-            }
-        }
-
-        kError() << "Fatal error. Theme: " + themeName +
-            " is invalid. Did you run kbuildsycoca4? List known themes through \
                --list-themes";
-        kError() << "Note: only accepts theme Plugin Name (visible through \
                --list-themes), not user-visible name";
-        return 1;
-
-    }
-
-themeFound:
-
-    QString wallpaper;
-    if (args->isSet("wallpaper")) {
-        wallpaper = args->getOption("wallpaper");
-        kDebug() << "setting wallpaper to" << wallpaper;
-    }
-
-    if (args->isSet("pixmapcache")) {
-        kDebug() << "setting pixmap cache to" << \
                args->getOption("pixmapcache").toInt();
-        QPixmapCache::setCacheLimit(args->getOption("pixmapcache").toInt());
-    }
-
-    QVariantList appletArgs;
-    for (int i = 1; i < args->count(); ++i) {
-        appletArgs << args->arg(i);
-    }
-    kDebug() << "setting auth policy";
-    Plasma::AuthorizationManager::self()->setAuthorizationPolicy(Plasma::AuthorizationManager::PinPairing);
                
-
-    const bool persistentConfig = args->isSet("saveconfig");
-    if (!persistentConfig) {
-        kWarning() << "&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& WARNING: Applet \
                configuration will not be restored or saved.";
-    }
-
-    FullView view(formfactor, location, persistentConfig);
-
-    QAction *action = KStandardAction::quit(&app, SLOT(quit()), &view);
-    view.addAction(action);
-
+    FullView view;
     app.setQuitOnLastWindowClosed(false);
-
     return app.exec();
 }
-
-#include "main.moc"
-


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic