From kde-commits Fri Apr 30 21:34:40 2010 From: Chani Armitage Date: Fri, 30 Apr 2010 21:34:40 +0000 To: kde-commits Subject: KDE/kdebase/workspace/plasma/desktop/shell Message-Id: <20100430213440.24861AC8AA () svn ! kde ! org> X-MARC-Message: https://marc.info/?l=kde-commits&m=127266305431636 SVN commit 1121228 by chani: turn m_view into a Dialog and reduce m_containment use this coincidentally fixes my mystery geometry bug... although it introduces a funny double-border at the bottom of the window. M +23 -54 controllerwindow.cpp M +2 -4 controllerwindow.h --- trunk/KDE/kdebase/workspace/plasma/desktop/shell/controllerwindow.cpp #1121227:1121228 @@ -23,6 +23,7 @@ #include #include +#include #include #include @@ -32,7 +33,7 @@ #include #include #include -#include +#include #include #include "widgetsexplorer/widgetexplorer.h" @@ -87,8 +88,8 @@ //FIXME the qt4.6 comment below applies here too } if (m_widgetExplorer) { - if (m_containment) { - m_widgetExplorer->corona()->removeOffscreenWidget(m_widgetExplorer); + if (m_corona) { + m_corona->removeOffscreenWidget(m_widgetExplorer); } if (m_widgetExplorer->scene()) { @@ -112,19 +113,23 @@ void ControllerWindow::setContainment(Plasma::Containment *containment) { - if (!containment) { + if (containment == m_containment) { return; } + m_containment = containment; if (m_containment) { disconnect(m_containment, 0, this, 0); } - m_containment = containment; + if (!containment) { + return; + } m_corona = m_containment->corona(); if (m_view) { - m_view->setScreen(m_containment->screen(), m_containment->desktop()); + //FIXME + //m_view->setScreen(m_containment->screen(), m_containment->desktop()); } if (m_widgetExplorer) { @@ -139,12 +144,13 @@ QSize ControllerWindow::sizeHint() const { - if (!m_containment) { + if (!m_view) { return QWidget::sizeHint(); } + //FIXME is this right? + int screen = QApplication::desktop()->screenNumber(m_view); + QRect screenGeom = Kephal::ScreenUtils::screenGeometry(screen); - QRect screenGeom = Kephal::ScreenUtils::screenGeometry(m_containment->screen()); - switch (m_location) { case Plasma::LeftEdge: case Plasma::RightEdge: @@ -244,16 +250,11 @@ void ControllerWindow::initView() { if (!m_view) { - m_view = new Plasma::View(0, this); + m_view = new Plasma::Dialog(0); m_view->setFocus(); - m_view->setScene(m_containment->corona()); - m_view->setScreen(m_containment->screen(), m_containment->desktop()); - m_view->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); - m_view->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff); m_view->setStyleSheet("background: transparent; border: none;"); - m_view->installEventFilter(this); m_layout->addWidget(m_view); } } @@ -265,25 +266,25 @@ } initView(); + //FIXME + //m_view->setScreen(m_containment->screen(), m_containment->desktop()); if (!m_widgetExplorer) { m_widgetExplorer = new Plasma::WidgetExplorer(orientation()); m_watchedWidget = m_widgetExplorer; m_widgetExplorer->setContainment(m_containment); m_widgetExplorer->populateWidgetList(); - m_widgetExplorer->resize(m_view->size()); m_containment->corona()->addOffscreenWidget(m_widgetExplorer); - m_view->setSceneRect(m_widgetExplorer->geometry()); + m_view->setGraphicsWidget(m_widgetExplorer); - m_widgetExplorer->installEventFilter(this); m_widgetExplorer->setIconSize(KIconLoader::SizeHuge); connect(m_widgetExplorer, SIGNAL(closeClicked()), this, SLOT(close())); } else { m_widgetExplorer->setOrientation(orientation()); m_watchedWidget = m_widgetExplorer; - m_view->setSceneRect(m_widgetExplorer->geometry()); + m_view->setGraphicsWidget(m_widgetExplorer); } if (orientation() == Qt::Horizontal) { @@ -297,27 +298,22 @@ void ControllerWindow::showActivityManager() { - if (!m_containment) { - return; - } initView(); if (!m_activityManager) { m_activityManager = new ActivityManager(orientation()); m_watchedWidget = m_activityManager; - m_activityManager->resize(m_view->size()); - m_containment->corona()->addOffscreenWidget(m_activityManager); - m_view->setSceneRect(m_activityManager->geometry()); + m_corona->addOffscreenWidget(m_activityManager); + m_view->setGraphicsWidget(m_activityManager); - m_activityManager->installEventFilter(this); m_activityManager->setIconSize(KIconLoader::SizeHuge); connect(m_activityManager, SIGNAL(closeClicked()), this, SLOT(close())); } else { m_activityManager->setOrientation(orientation()); m_watchedWidget = m_activityManager; - m_view->setSceneRect(m_activityManager->geometry()); + m_view->setGraphicsWidget(m_activityManager); } if (orientation() == Qt::Horizontal) { @@ -401,31 +397,4 @@ } } -bool ControllerWindow::eventFilter(QObject *watched, QEvent *event) -{ - //if widgetsExplorer moves or resizes, then the view has to adjust - if ((watched == (QObject*)m_watchedWidget) && (event->type() == QEvent::GraphicsSceneResize || event->type() == QEvent::GraphicsSceneMove)) { - m_view->resize(m_watchedWidget->size().toSize()); - m_view->setSceneRect(m_watchedWidget->geometry()); - //kDebug() << "sizes are:" << m_widgetExplorer->size() << m_view->size() << size(); - } - - //if the view resizes, then the widgetexplorer has to be resized - if (watched == m_view && event->type() == QEvent::Resize) { - QResizeEvent *resizeEvent = static_cast(event); - m_watchedWidget->resize(resizeEvent->size()); - m_view->setSceneRect(m_watchedWidget->geometry()); - - QSize borderSize = size() - m_layout->contentsRect().size(); - - if (orientation() == Qt::Horizontal) { - resize(width(), m_view->height() + borderSize.height()); - } else { - resize(m_view->width() + borderSize.width(), height()); - } - } - - return false; -} - #include "controllerwindow.moc" --- trunk/KDE/kdebase/workspace/plasma/desktop/shell/controllerwindow.h #1121227:1121228 @@ -33,7 +33,7 @@ class Corona; class FrameSvg; class WidgetExplorer; - class View; + class Dialog; } // namespace Plasma class ActivityManager; @@ -62,8 +62,6 @@ Plasma::FrameSvg *background() const; - bool eventFilter(QObject *watched, QEvent *event); - protected: void resizeEvent(QResizeEvent *event); void paintEvent(QPaintEvent *event); @@ -81,7 +79,7 @@ Plasma::FrameSvg *m_background; Plasma::Containment *m_containment; Plasma::Corona *m_corona; - Plasma::View *m_view; + Plasma::Dialog *m_view; QGraphicsWidget *m_watchedWidget; ActivityManager *m_activityManager; Plasma::WidgetExplorer *m_widgetExplorer;