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

List:       kde-commits
Subject:    KDE/kdebase/workspace/plasma/shells/mid
From:       Aaron J. Seigo <aseigo () kde ! org>
Date:       2008-08-25 13:26:42
Message-ID: 1219670802.743795.16486.nullmailer () svn ! kde ! org
[Download RAW message or body]

SVN commit 852182 by aseigo:

* setup and show the midview properly
* change width/height params to "screen" to be more xnest/xephyr like
* set a default value for the screen parameter (the real fix for that crash, btw =)
* don't tie the view/containment so tightly to the screen geometry, as that will be \
                managed by the app itself
* remove unused actions, add a quit action when it isn't a desktop


 M  +1 -2      main.cpp  
 M  +9 -35     midcorona.cpp  
 M  +13 -34    midview.cpp  
 M  +7 -1      midview.h  
 M  +2 -22     plasmaapp.cpp  


--- trunk/KDE/kdebase/workspace/plasma/shells/mid/main.cpp #852181:852182
@@ -43,8 +43,7 @@
 
     KCmdLineOptions options;
     options.add("desktop",ki18n("Registers the application as the primary user \
                interface"));
-    options.add("width", ki18n("The width of the screen"), "800");
-    options.add("height", ki18n("The width of the screen"), "480");
+    options.add("screen <geometry>", ki18n("The geometry of the screen"), \
"800x480");  KCmdLineArgs::addCmdLineOptions(options);
 
     PlasmaApp *app = PlasmaApp::self();
--- trunk/KDE/kdebase/workspace/plasma/shells/mid/midcorona.cpp #852181:852182
@@ -45,33 +45,6 @@
     QObject::connect(desktop, SIGNAL(resized(int)), this, SLOT(screenResized(int)));
 }
 
-void MidCorona::checkScreens()
-{
-    // quick sanity check to ensure we have containments for each screen!
-    int numScreens = QApplication::desktop()->numScreens();
-    for (int i = 0; i < numScreens; ++i) {
-        if (!containmentForScreen(i)) {
-            //TODO: should we look for containments that aren't asigned but already \
                exist?
-            Plasma::Containment* c = addContainment("desktop");
-            c->setScreen(i);
-            c->setFormFactor(Plasma::Planar);
-            c->flushPendingConstraintsEvents();
-        } else if (i >= m_numScreens) {
-            // now ensure that if our screen count changed we actually get views
-            // for them, even if the Containment already existed for that screen
-            // so we "lie" and emit a containmentAdded signal for every new screen
-            // regardless of whether it actually already existed, or just got added
-            // and therefore had this signal emitted. plasma can handle such
-            // multiple emissions of the signal, and this is simply the most
-            // straightforward way of accomplishing this
-            kDebug() << "Notifying of new screen: " << i;
-            emit containmentAdded(containmentForScreen(i));
-        }
-    }
-
-    m_numScreens = numScreens;
-}
-
 void MidCorona::loadDefaultLayout()
 {
     QString defaultConfig = KStandardDirs::locate("appdata", \
"plasma-default-layoutrc"); @@ -81,10 +54,6 @@
         return;
     }
 
-    QDesktopWidget *desktop = QApplication::desktop();
-
-    // find our "top left" screen, use it as the primary
-
     // used to force a save into the config file
     KConfigGroup invalidConfig;
 
@@ -104,10 +73,15 @@
 
     if (isDesktop) {
         c->setScreen(0);
-    } else if( args->isSet("height") && args->isSet("width") ){
-        int width = qMax(400, args->getOption("width").toInt());
-        int height = qMax(200, args->getOption("height").toInt());
-        c->resize(width, height);
+    } else {
+        QString geom = args->getOption("screen");
+        int x = geom.indexOf('x');
+
+        if (x > 0)  {
+            int width = qMax(400, geom.left(x).toInt());
+            int height = qMax(200, geom.right(geom.length() - x - 1).toInt());
+            c->resize(width, height);
+        }
     }
 
     c->setWallpaper("image", "SingleImage");
--- trunk/KDE/kdebase/workspace/plasma/shells/mid/midview.cpp #852181:852182
@@ -18,28 +18,19 @@
 
 #include "midview.h"
 
-#include <QAction>
-#include <QDesktopWidget>
-#include <QFile>
-#include <QWheelEvent>
 #include <QCoreApplication>
+#include <QDesktopWidget>
 
-#include <KAuthorized>
-#include <KMenu>
-#include <KRun>
-#include <KToggleAction>
+#include <KAction>
+#include <KStandardAction>
 #include <KWindowSystem>
 
 #include "plasma/applet.h"
 #include "plasma/corona.h"
 #include "plasma/containment.h"
 
-#include "plasmaapp.h"
-
-static const int MIDVIEWID = 1;
-
 MidView::MidView(Plasma::Containment *containment, QWidget *parent)
-    : Plasma::View(containment, MIDVIEWID, parent)
+    : Plasma::View(containment, defaultId(), parent)
 {
     setFocusPolicy(Qt::NoFocus);
 
@@ -71,6 +62,9 @@
     pt.end();
     QBrush b(tile);
     setBackgroundBrush(tile);
+
+    kDebug() << "goin' in!" << containment->geometry().size().toSize();
+    resize(containment->geometry().size().toSize());
 }
 
 MidView::~MidView()
@@ -86,47 +80,32 @@
     }
 }
 
-void MidView::adjustSize()
+void MidView::setContainment(Plasma::Containment *containment)
 {
-    // adapt to screen resolution changes
-    QDesktopWidget *desktop = QApplication::desktop();
-    QRect geom = desktop->screenGeometry(screen());
-    setGeometry(geom);
-    containment()->resize(geom.size());
+    Plasma::View::setContainment(containment);
+    kDebug() << "goin' in!" << containment->geometry().size().toSize();
+    resize(containment->geometry().size().toSize());
 }
 
 void MidView::setIsDesktop(bool isDesktop)
 {
     if (isDesktop) {
-#ifdef Q_WS_WIN
-        setWindowFlags(Qt::FramelessWindowHint);
-        SetWindowPos(winId(), HWND_BOTTOM, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE);
-        HWND hwndDesktop = ::FindWindowW(L"Progman", NULL);
-        SetParent(winId(),hwndDesktop);
-#else
         setWindowFlags(windowFlags() | Qt::FramelessWindowHint);
-#endif
-
         KWindowSystem::setOnAllDesktops(winId(), true);
         KWindowSystem::setType(winId(), NET::Desktop);
         lower();
-
-        adjustSize();
     } else {
         setWindowFlags(windowFlags() & ~Qt::FramelessWindowHint);
-
         KWindowSystem::setOnAllDesktops(winId(), false);
         KWindowSystem::setType(winId(), NET::Normal);
+        QAction *action = KStandardAction::quit(qApp, SLOT(quit()), this);
+        addAction(action);
     }
 }
 
 bool MidView::isDesktop() const
 {
-#ifndef Q_WS_WIN
     return KWindowInfo(winId(), NET::WMWindowType).windowType(NET::Desktop);
-#else
-    return true;
-#endif
 }
 
 void MidView::configureContainment()
--- trunk/KDE/kdebase/workspace/plasma/shells/mid/midview.h #852181:852182
@@ -59,10 +59,16 @@
      */
     bool isDesktop() const;
 
+    static int defaultId() { return 1; }
+
 public slots:
     void showAppletBrowser();
-    void adjustSize();
 
+    /**
+     * reimplemented from Plasma::View
+     */
+    void setContainment(Plasma::Containment *containment);
+
     void screenOwnerChanged(int wasScreen, int isScreen, Plasma::Containment* \
containment);  
     /**
--- trunk/KDE/kdebase/workspace/plasma/shells/mid/plasmaapp.cpp #852181:852182
@@ -104,7 +104,6 @@
     KGlobal::locale()->insertCatalog("libplasma");
 
     bool isDesktop = KCmdLineArgs::parsedArgs()->isSet("desktop");
-
     if (isDesktop) {
         notifyStartup(false);
     }
@@ -137,13 +136,6 @@
 
     setIsDesktop(isDesktop);
 
-    //TODO: Make the shortcut configurable
-    KAction *showAction = new KAction( this );
-    showAction->setText( i18n( "Show Dashboard" ) );
-    showAction->setObjectName( "Show Dashboard" ); // NO I18N
-    showAction->setGlobalShortcut( KShortcut( Qt::CTRL + Qt::Key_F12 ) );
-    connect( showAction, SIGNAL( triggered() ), this, SLOT( toggleDashboard() ) );
-
     // this line initializes the corona.
     corona();
 
@@ -200,7 +192,7 @@
     Q_UNUSED(screen)
 
     if (m_mainView) {
-        m_mainView->adjustSize();
+        //TODO: change size to be size of screen - the height of the panel \
m_mainView->adjustSize();  }
 }
 
@@ -229,7 +221,6 @@
 
         c->setItemIndexMethod(QGraphicsScene::NoIndex);
         c->initializeLayout();
-        c->checkScreens();
         m_corona = c;
     }
 
@@ -255,23 +246,13 @@
 
 void PlasmaApp::createView(Plasma::Containment *containment)
 {
-    if (m_mainView) {
-        kDebug() << "We already have a containment for our screen!";
-        return;
-    }
-
     kDebug() << "Containment name:" << containment->name()
              << "| type" << containment->containmentType()
              <<  "| screen:" << containment->screen()
              << "| geometry:" << containment->geometry()
              << "| zValue:" << containment->zValue();
 
-    if (containment->screen() > -1 &&
-        containment->screen() < QApplication::desktop()->numScreens()) {
-        kDebug() << "creating a view for" << containment->screen() << "and we have"
-                 << QApplication::desktop()->numScreens() << "screens";
-
-        // we have a new screen. neat.
+    if (!m_mainView && containment->id() == MidView::defaultId()) {
         m_mainView = new MidView(containment);
 
         if (m_corona) {
@@ -279,7 +260,6 @@
                     m_mainView, \
SLOT(screenOwnerChanged(int,int,Plasma::Containment*)));  }
 
-        m_mainView->setGeometry(QApplication::desktop()->screenGeometry(containment->screen()));
  m_mainView->setIsDesktop(m_isDesktop);
         m_mainView->show();
 


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

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