[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: Mass cleanup: do not load QML
From: Aurélien Gâteau <agateau () kde ! org>
Date: 2012-05-10 16:32:16
Message-ID: 20120510163216.98E1AA60A9 () git ! kde ! org
[Download RAW message or body]
Git commit 0010826746b16634b5bd20de72d3e378e210f04d by Aurélien Gâteau.
Committed on 10/05/2012 at 18:27.
Pushed by gateau into branch 'plasma/sreich/sal-qml'.
Mass cleanup: do not load QML through an applet anymore
This is simpler and makes it possible to communicate between the QML and
the C++ side (see next commit).
M +0 -2 plasma/netbook/containments/sal/package/contents/ui/main.qml
M +8 -2 plasma/netbook/containments/sal/shell/CMakeLists.txt
M +23 -88 plasma/netbook/containments/sal/shell/fullview.cpp
M +2 -24 plasma/netbook/containments/sal/shell/fullview.h
M +0 -24 plasma/netbook/containments/sal/shell/main.cpp
http://commits.kde.org/kde-workspace/0010826746b16634b5bd20de72d3e378e210f04d
diff --git a/plasma/netbook/containments/sal/package/contents/ui/main.qml \
b/plasma/netbook/containments/sal/package/contents/ui/main.qml index 264ca5a..9fce3ae \
100644
--- a/plasma/netbook/containments/sal/package/contents/ui/main.qml
+++ b/plasma/netbook/containments/sal/package/contents/ui/main.qml
@@ -25,8 +25,6 @@ import org.kde.plasma.core 0.1 as PlasmaCore
import org.kde.plasma.components 0.1 as PlasmaComponents
import org.kde.qtextracomponents 0.1 as QtExtra
-import "plasmapackage:/code/LayoutManager.js" as LayoutManager
-
Item {
id: main
diff --git a/plasma/netbook/containments/sal/shell/CMakeLists.txt \
b/plasma/netbook/containments/sal/shell/CMakeLists.txt index 430ecdb..89d210b 100644
--- a/plasma/netbook/containments/sal/shell/CMakeLists.txt
+++ b/plasma/netbook/containments/sal/shell/CMakeLists.txt
@@ -6,12 +6,18 @@ set(salviewer_SRCS
qt4_add_dbus_adaptor(salviewer_SRCS org.kde.salviewer.xml
fullview.h FullView)
+find_package(KDeclarative REQUIRED)
kde4_add_executable(salviewer ${salviewer_SRCS})
-target_link_libraries(salviewer ${KDE4_KDEUI_LIBS} ${KDE4_PLASMA_LIBS})
+target_link_libraries(salviewer
+ ${KDE4_KDEUI_LIBS}
+ ${KDE4_PLASMA_LIBS}
+ ${KDECLARATIVE_LIBRARIES}
+ ${QT_QTDECLARATIVE_LIBRARY}
+ )
install(TARGETS salviewer ${INSTALL_TARGETS_DEFAULT_ARGS})
-install(FILES salviewer.desktop DESTINATION ${SERVICES_INSTALL_DIR})
\ No newline at end of file
+install(FILES salviewer.desktop DESTINATION ${SERVICES_INSTALL_DIR})
diff --git a/plasma/netbook/containments/sal/shell/fullview.cpp \
b/plasma/netbook/containments/sal/shell/fullview.cpp index f1b641b..338155c 100644
--- a/plasma/netbook/containments/sal/shell/fullview.cpp
+++ b/plasma/netbook/containments/sal/shell/fullview.cpp
@@ -30,64 +30,35 @@
#include "salvieweradaptor.h"
-#include <QApplication>
-#include <QDir>
-#include <QFileInfo>
-#include <QResizeEvent>
-#include <QTimer>
#include <QDesktopWidget>
-#include <QPushButton>
-#include <QGraphicsView>
+#include <QKeyEvent>
-#include <KCmdLineArgs>
-#include <KIconLoader>
+#include <kdeclarative.h>
+
+#include <KDebug>
+#include <KStandardDirs>
+#include <KUrl>
#include <KWindowSystem>
-#include <Plasma/AccessManager>
-#include <Plasma/AccessAppletJob>
-#include <Plasma/Containment>
-#include <Plasma/ContainmentActions>
-#include <Plasma/Package>
-#include <Plasma/Wallpaper>
#include <Plasma/WindowEffects>
-#include <Plasma/PushButton>
-using namespace Plasma;
FullView::FullView(const QString &ff, const QString &loc, bool persistent, QWidget \
*parent)
- : QGraphicsView(),
- m_containment(0),
- m_corona(0),
- m_applet(0),
- m_closeButton(0)
+: QDeclarativeView()
{
new SalViewerAdaptor(this);
QDBusConnection dbus = QDBusConnection::sessionBus();
dbus.registerObject("/SalViewer", this);
dbus.registerService("org.kde.salViewer");
- m_corona = new Plasma::Corona(this);
- setScene(m_corona);
-
- m_applet = Plasma::Applet::load("org.kde.sal");
-
- if (!m_applet) {
- kDebug() << "failed to load SAL";
- return;
- }
-
- m_containment = m_corona->addContainment("null");
- m_containment->addApplet(m_applet, QPointF(-1, -1), false);
- m_containment->resize(QWIDGETSIZE_MAX, QWIDGETSIZE_MAX);
+ KDeclarative kdeclarative;
+ kdeclarative.setDeclarativeEngine(engine());
+ kdeclarative.initialize();
+ //binds things like kconfig and icons
+ kdeclarative.setupBindings();
- m_applet->setPos(0, 0);
- m_applet->setFlag(QGraphicsItem::ItemIsMovable, false);
- m_applet->setBackgroundHints(Plasma::Applet::NoBackground);
- setSceneRect(m_applet->sceneBoundingRect());
- setWindowTitle(m_applet->name());
- setWindowIcon(SmallIcon(m_applet->icon()));
setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
- setFrameStyle(QFrame::NoFrame);
+ setResizeMode(SizeRootObjectToView);
setWindowFlags(Qt::FramelessWindowHint);
setAttribute(Qt::WA_TranslucentBackground);
@@ -97,15 +68,9 @@ FullView::FullView(const QString &ff, const QString &loc, bool \
persistent, QWidg viewport()->setAttribute(Qt::WA_NoSystemBackground);
Plasma::WindowEffects::overrideShadow(winId(), true);
- m_closeButton = new Plasma::PushButton(m_containment);
- m_closeButton->setText(i18n("Close"));
- m_closeButton->setIcon(KIcon("dialog-close"));
- m_closeButton->setMinimumSize(64, 64);
- m_corona->addItem(m_closeButton);
+ KUrl source = KGlobal::dirs()->locate("data", \
"plasma/plasmoids/org.kde.sal/contents/ui/main.qml"); + setSource(source);
-// m_applet->addAction(QString("remove"), KStandardAction::quit(this, \
SLOT(hide()), m_applet));
- // enforce the applet being our size
- connect(m_applet, SIGNAL(geometryChanged()), this, SLOT(updateGeometry()));
updateGeometry();
}
@@ -123,13 +88,7 @@ void FullView::focusOutEvent(QFocusEvent* event)
FullView::~FullView()
{
- m_containment->destroy(false);
kDebug() << "DTOR HIT";
- delete m_closeButton;
-}
-
-void FullView::showEvent(QShowEvent *event)
-{
}
void FullView::toggle(int screen)
@@ -160,7 +119,7 @@ void FullView::keyPressEvent(QKeyEvent *event)
event->accept();
}
- QGraphicsView::keyPressEvent(event);
+ QDeclarativeView::keyPressEvent(event);
}
void FullView::closeEvent(QCloseEvent *event)
@@ -168,45 +127,21 @@ void FullView::closeEvent(QCloseEvent *event)
kDebug() << "CLOSE EVENT";
}
-void FullView::setContainment(Plasma::Containment *c)
-{
- if (m_containment) {
- disconnect(m_containment, 0, this, 0);
- }
-
- m_containment = c;
- updateGeometry();
-}
-
void FullView::resizeEvent(QResizeEvent *event)
{
- Q_UNUSED(event)
+ QDeclarativeView::resizeEvent(event);
updateGeometry();
-// emit geometryChanged();
}
void FullView::updateGeometry()
{
- if (!m_containment) {
- return;
- }
-
- if (m_applet) {
- if (m_applet->size().toSize() != size()) {
- m_applet->resize(size());
- }
+ /*
+ // TODO: Use the background's mask for blur
+ QRegion mask;
+ mask += QRect(QPoint(), size());
- setSceneRect(m_applet->sceneBoundingRect());
- }
-
- if ((windowFlags() & Qt::FramelessWindowHint) && m_applet->backgroundHints() != \
Plasma::Applet::NoBackground) {
-
- // TODO: Use the background's mask for blur
- QRegion mask;
- mask += QRect(QPoint(), size());
-
- Plasma::WindowEffects::enableBlurBehind(winId(), true, mask);
- }
+ Plasma::WindowEffects::enableBlurBehind(winId(), true, mask);
+ */
}
#include "fullview.moc"
diff --git a/plasma/netbook/containments/sal/shell/fullview.h \
b/plasma/netbook/containments/sal/shell/fullview.h index 2b7d23f..317fef9 100644
--- a/plasma/netbook/containments/sal/shell/fullview.h
+++ b/plasma/netbook/containments/sal/shell/fullview.h
@@ -27,23 +27,9 @@
#ifndef FULLVIEW_H
#define FULLVIEW_H
-#include <KMainWindow>
+#include <QDeclarativeView>
-#include <Plasma/Applet>
-
-#include <Plasma/Corona>
-
-#include <QGraphicsView>
-
-class QTimer;
-
-namespace Plasma
-{
- class AccessAppletJob;
-class PushButton;
-}
-
-class FullView : public QGraphicsView
+class FullView : public QDeclarativeView
{
Q_OBJECT
Q_CLASSINFO("D-Bus Interface", "org.kde.salViewer")
@@ -54,22 +40,14 @@ public:
public Q_SLOTS:
void toggle(int screen);
- void setContainment(Plasma::Containment *containment);
void updateGeometry();
protected:
- void showEvent(QShowEvent *event);
virtual void focusInEvent(QFocusEvent *event);
virtual void focusOutEvent(QFocusEvent *event);
virtual void keyPressEvent(QKeyEvent *event);
virtual void closeEvent(QCloseEvent *event);
virtual void resizeEvent(QResizeEvent *event);
-private:
-
- Plasma::Corona *m_corona;
- Plasma::Containment *m_containment;
- Plasma::Applet *m_applet;
- Plasma::PushButton *m_closeButton;
};
#endif
diff --git a/plasma/netbook/containments/sal/shell/main.cpp \
b/plasma/netbook/containments/sal/shell/main.cpp index 11d7586..49a6748 100644
--- a/plasma/netbook/containments/sal/shell/main.cpp
+++ b/plasma/netbook/containments/sal/shell/main.cpp
@@ -177,11 +177,6 @@ int main(int argc, char **argv)
return 0;
}
- if (args->isSet("list-containments")) {
- listPlugins(Plasma::Containment::listContainments());
- return 0;
- }
-
if (args->isSet("list-themes")) {
listPlugins(Plasma::Theme::listThemeInfo());
return 0;
@@ -218,25 +213,6 @@ appletFound:
kDebug() << "setting Location to" << args->getOption("location");
QString containment = args->getOption("containment");
- if (args->isSet("containment")) {
-
- kDebug() << "setting containment to" << containment;
-
- KPluginInfo::List containmentList = Plasma::Containment::listContainments();
-
- foreach (const KPluginInfo& info, containmentList) {
-
- if (info.pluginName() == containment) {
- goto containmentFound;
- }
- }
-
- kError() << "Fatal error. Containment: " + containment +
- " is invalid. Did you run kbuildsycoca4? List known containments through \
--list-containments";
- kError() << "Note: only accepts containment Plugin Name (visible through \
--list-containments), not user-visible name";
- return 1;
-
- }
containmentFound:
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic