[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: [gluon] player/active/src: Use standard Plasma Active application template
From: Shantanu Tushar <shaan7in () gmail ! com>
Date: 2012-01-29 12:23:27
Message-ID: 20120129122327.C2510A60A6 () git ! kde ! org
[Download RAW message or body]
Git commit 7ad9b8b4a5553af96c1e3c4ed437df95b020b2a5 by Shantanu Tushar.
Committed on 29/01/2012 at 13:23.
Pushed by shantanu into branch 'master'.
Use standard Plasma Active application template
M +2 -1 player/active/src/CMakeLists.txt
D +0 -101 player/active/src/appview.cpp
D +0 -66 player/active/src/appview.h
A +152 -0 player/active/src/kdeclarativemainwindow.cpp [License: GPL (v2+)]
A +95 -0 player/active/src/kdeclarativemainwindow.h [License: GPL (v2+)]
A +122 -0 player/active/src/kdeclarativeview.cpp [License: GPL (v2+)]
A +81 -0 player/active/src/kdeclarativeview.h [License: GPL (v2+)]
M +2 -13 player/active/src/main.cpp
M +11 -45 player/active/src/mainwindow.cpp
M +2 -12 player/active/src/mainwindow.h
http://commits.kde.org/gluon/7ad9b8b4a5553af96c1e3c4ed437df95b020b2a5
diff --git a/player/active/src/CMakeLists.txt b/player/active/src/CMakeLists.txt
index 7d4e0a8..0faf8dc 100644
--- a/player/active/src/CMakeLists.txt
+++ b/player/active/src/CMakeLists.txt
@@ -2,7 +2,8 @@
include_directories( ${KDE4_INCLUDES} ${QT_INCLUDES} ${CMAKE_CURRENT_BINARY_DIR} )
set(gluonplayer-active_SRCS
- appview.cpp
+ kdeclarativemainwindow.cpp
+ kdeclarativeview.cpp
main.cpp
mainwindow.cpp
)
diff --git a/player/active/src/appview.cpp b/player/active/src/appview.cpp
deleted file mode 100644
index 90417b4..0000000
--- a/player/active/src/appview.cpp
+++ /dev/null
@@ -1,101 +0,0 @@
-/******************************************************************************
- * This file is part of the Gluon Development Platform
- * Copyright 2011 Shantanu Tushar <shaan7in@gmail.com>
- * Copyright 2011 Sebastian Kügler <sebas@kde.org>
- * Copyright 2011 Marco Martin <mart@kde.org>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library 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
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-#include "appview.h"
-
-#include <lib/gamemanager.h>
-#include <lib/gamemetadata.h>
-
-#include <Plasma/Package>
-#include <kdeclarative.h>
-#include <KShell>
-#include <KStandardDirs>
-#include <KDebug>
-
-#include <QDeclarativeContext>
-#include <QDeclarativeEngine>
-#include <QDeclarativeItem>
-#include <QFileInfo>
-#include <QScriptValue>
-#include <QGLWidget>
-
-AppView::AppView( QWidget* parent )
- : QDeclarativeView( parent ),
- m_useGL( false )
-{
- // avoid flicker on show
- setAttribute( Qt::WA_OpaquePaintEvent );
- setAttribute( Qt::WA_NoSystemBackground );
- viewport()->setAttribute( Qt::WA_OpaquePaintEvent );
- viewport()->setAttribute( Qt::WA_NoSystemBackground );
-
- setResizeMode( QDeclarativeView::SizeRootObjectToView );
-
- KDeclarative kdeclarative;
- kdeclarative.setDeclarativeEngine( engine() );
- kdeclarative.initialize();
- //binds things like kconfig and icons
- kdeclarative.setupBindings();
-
- Plasma::PackageStructure::Ptr structure = Plasma::PackageStructure::load( \
"Plasma/Generic" );
- m_package = new Plasma::Package( QString(), "org.kde.gluon.player", structure );
-
- rootContext()->setContextProperty( "installedGamesModel", \
GluonPlayer::GameManager::instance()->installedGamesModel() );
- rootContext()->setContextProperty( "downloadableGamesModel", \
GluonPlayer::GameManager::instance()->downloadableGamesModel() );
- qmlRegisterType<GluonPlayer::GameMetadata>( "org.kde.gluon", 1, 0, \
"GameMetadata" );
-
- setSource( QUrl( m_package->filePath( "mainscript" ) ) );
- show();
-
- onStatusChanged( status() );
-
- connect( this, SIGNAL(statusChanged(QDeclarativeView::Status)),
- this, SLOT(onStatusChanged(QDeclarativeView::Status)) );
-}
-
-AppView::~AppView()
-{
-}
-
-void AppView::setUseGL( const bool on )
-{
-#ifndef QT_NO_OPENGL
- if( on )
- {
- QGLWidget* glWidget = new QGLWidget;
- glWidget->setAutoFillBackground( false );
- setViewport( glWidget );
- }
-#endif
- m_useGL = on;
-}
-
-bool AppView::useGL() const
-{
- return m_useGL;
-}
-
-void AppView::onStatusChanged( QDeclarativeView::Status status )
-{
- kDebug() << "STATUS " << status;
-}
-
-#include "appview.moc"
diff --git a/player/active/src/appview.h b/player/active/src/appview.h
deleted file mode 100644
index 3afc5e4..0000000
--- a/player/active/src/appview.h
+++ /dev/null
@@ -1,66 +0,0 @@
-/******************************************************************************
- * This file is part of the Gluon Development Platform
- * Copyright 2011 Shantanu Tushar <shaan7in@gmail.com>
- * Copyright 2011 Sebastian Kügler <sebas@kde.org>
- * Copyright 2011 Marco Martin <mart@kde.org>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library 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
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-#ifndef VIEW_H
-#define VIEW_H
-
-#include <QDeclarativeView>
-#include <QAction>
-
-#include <KActionCollection>
-#include <KMainWindow>
-#include <KPluginInfo>
-
-class KMainWindow;
-class QDeclarativeItem;
-class QProgressBar;
-class QSignalMapper;
-class Page;
-class ScriptApi;
-class DirModel;
-;
-namespace Plasma
-{
-class Package;
-}
-
-class AppView : public QDeclarativeView
-{
- Q_OBJECT
-
-public:
- AppView( QWidget *parent = 0 );
- ~AppView();
-
- QString name() const;
-
- void setUseGL(const bool on);
- bool useGL() const;
-
-private Q_SLOTS:
- void onStatusChanged(QDeclarativeView::Status status);
-
-private:
- Plasma::Package *m_package;
- bool m_useGL;
-};
-
-#endif // VIEW_H
diff --git a/player/active/src/kdeclarativemainwindow.cpp \
b/player/active/src/kdeclarativemainwindow.cpp new file mode 100644
index 0000000..b1a20d1
--- /dev/null
+++ b/player/active/src/kdeclarativemainwindow.cpp
@@ -0,0 +1,152 @@
+/***************************************************************************
+ * *
+ * Copyright 2011 Sebastian Kügler <sebas@kde.org> *
+ * Copyright 2011 Marco Martin <mart@kde.org> *
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ * 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 General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU 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 "kdeclarativemainwindow.h"
+#include "kdeclarativeview.h"
+
+#include <QApplication>
+#include <QDeclarativeContext>
+
+#include <KAction>
+#include <KCmdLineArgs>
+#include <KStandardAction>
+
+#include <Plasma/Theme>
+
+
+
+class KDeclarativeMainWindowPrivate
+{
+public:
+ KDeclarativeMainWindowPrivate(KDeclarativeMainWindow *window)
+ : q(window)
+ {}
+
+ void statusChanged(QDeclarativeView::Status status);
+
+ KDeclarativeMainWindow *q;
+ KDeclarativeView *view;
+ KCmdLineArgs *args;
+ QStringList arguments;
+ QString caption;
+};
+
+void KDeclarativeMainWindowPrivate::statusChanged(QDeclarativeView::Status status)
+{
+ if (status == QDeclarativeView::Ready) {
+ view->rootContext()->setContextProperty("application", q);
+ }
+}
+
+
+
+KDeclarativeMainWindow::KDeclarativeMainWindow()
+ : KMainWindow(),
+ d(new KDeclarativeMainWindowPrivate(this))
+{
+ setAcceptDrops(true);
+ KConfigGroup cg(KSharedConfig::openConfig("plasmarc"), "Theme-plasma-mobile");
+ const QString themeName = cg.readEntry("name", "air-mobile");
+ Plasma::Theme::defaultTheme()->setUseGlobalSettings(false);
+ Plasma::Theme::defaultTheme()->setThemeName(themeName);
+ addAction(KStandardAction::close(this, SLOT(close()), this));
+ addAction(KStandardAction::quit(this, SLOT(close()), this));
+
+ d->view = new KDeclarativeView(this);
+ connect(d->view, SIGNAL(statusChanged(QDeclarativeView::Status)), this, \
SLOT(statusChanged(QDeclarativeView::Status))); +
+ setCentralWidget(d->view);
+ restoreWindowSize(config("Window"));
+
+ setWindowIcon(KIcon(KCmdLineArgs::aboutData()->programIconName()));
+
+ d->args = KCmdLineArgs::parsedArgs();
+ for (int i = 0; i < d->args->count(); i++) {
+ d->arguments << d->args->arg(i);
+ }
+
+ bool useGL = d->args->isSet("opengl");
+ if (!useGL) {
+ //use plasmarc to share this with plasma-windowed
+ KConfigGroup cg(KSharedConfig::openConfig("plasmarc"), "General");
+ useGL = cg.readEntry("UseOpenGl", true);
+ }
+ d->view->setUseGL(useGL);
+
+ connect(d->view, SIGNAL(titleChanged(QString)), SLOT(setCaption(QString)));
+}
+
+KDeclarativeMainWindow::~KDeclarativeMainWindow()
+{
+ saveWindowSize(config("Window"));
+}
+
+
+KDeclarativeView *KDeclarativeMainWindow::declarativeView() const
+{
+ return d->view;
+}
+
+KConfigGroup KDeclarativeMainWindow::config(const QString &group)
+{
+ return KConfigGroup(KSharedConfig::openConfig(qApp->applicationName() + "rc"), \
group); +}
+
+QStringList KDeclarativeMainWindow::startupArguments() const
+{
+ return d->arguments;
+}
+
+QString KDeclarativeMainWindow::startupOption(const QString &option) const
+{
+ return d->args->getOption(option.toLatin1());
+}
+
+QString KDeclarativeMainWindow::caption() const
+{
+ return d->caption;
+}
+
+void KDeclarativeMainWindow::setCaption(const QString &caption)
+{
+ if (d->caption == caption) {
+ return;
+ }
+
+ d->caption = caption;
+ emit captionChanged();
+ KMainWindow::setCaption(caption);
+}
+
+void KDeclarativeMainWindow::setCaption(const QString &caption, bool modified)
+{
+ Q_UNUSED(modified)
+
+ if (d->caption == caption) {
+ return;
+ }
+
+ d->caption = caption;
+ emit captionChanged();
+ KMainWindow::setCaption(caption, true);
+}
+
+#include "kdeclarativemainwindow.moc"
diff --git a/player/active/src/kdeclarativemainwindow.h \
b/player/active/src/kdeclarativemainwindow.h new file mode 100644
index 0000000..0dfe2c1
--- /dev/null
+++ b/player/active/src/kdeclarativemainwindow.h
@@ -0,0 +1,95 @@
+/***************************************************************************
+ * *
+ * Copyright 2011 Sebastian Kügler <sebas@kde.org> *
+ * Copyright 2011 Marco Martin <mart@kde.org> *
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ * 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 General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU 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 . *
+ ***************************************************************************/
+
+
+#ifndef KDECLARATIVEMAINWINDOW_H
+#define KDECLARATIVEMAINWINDOW_H
+
+#include <KMainWindow>
+
+
+class KDeclarativeView;
+
+class KDeclarativeMainWindowPrivate;
+
+class KDeclarativeMainWindow : public KMainWindow
+{
+ Q_OBJECT
+ /**
+ * the list of all startup arguments, such as urls to open
+ */
+ Q_PROPERTY(QStringList startupArguments READ startupArguments CONSTANT)
+ /**
+ * The caption of the main window. Do not include the application name in this \
string. It will be added automatically according to the KDE standard. + */
+ Q_PROPERTY(QString caption READ caption WRITE setCaption NOTIFY captionChanged)
+
+public:
+ KDeclarativeMainWindow();
+ ~KDeclarativeMainWindow();
+
+ /**
+ * The main kconfiggroup to be used for this application
+ * The configuration file name is derived from the application name
+ *
+ * @arg QString group the kconfigugroup name
+ */
+ KConfigGroup config(const QString &group = "Default");
+
+ /**
+ * @returns the declarative view that will contain the application UI
+ * It loads a Plasma::Package rather than an absolute path
+ * @see KDeclarativeView
+ * @see Plasma::Package
+ */
+ KDeclarativeView *declarativeView() const;
+
+ //propertyies & methods for QML
+ QStringList startupArguments() const;
+
+ QString caption() const;
+
+ /**
+ * Read out a string option.
+ * The option must have a corresponding KCmdLineOptions entry of the form:
+ <code>
+ options.add("option <argument>", ki18n("Description"), "default");
+ </code>
+ * You cannot test for the presence of an alias - you must always test for the \
full option. + * @arg QString option The name of the option without '-'.
+ * @returns The value of the option. If the option was not present on the \
command line the default is returned. If the option was present more than once, the \
value of the last occurrence is used. + */
+ Q_INVOKABLE QString startupOption(const QString &option) const;
+
+public Q_SLOTS:
+ void setCaption(const QString &caption);
+ //FIXME: this exists only to not hide the superclass method
+ void setCaption(const QString &caption, bool modified);
+
+Q_SIGNALS:
+ void captionChanged();
+
+private:
+ KDeclarativeMainWindowPrivate * const d;
+ Q_PRIVATE_SLOT(d, void statusChanged(QDeclarativeView::Status))
+};
+
+#endif // KDECLARATIVEMAINWINDOW_H
diff --git a/player/active/src/kdeclarativeview.cpp \
b/player/active/src/kdeclarativeview.cpp new file mode 100644
index 0000000..432e3e1
--- /dev/null
+++ b/player/active/src/kdeclarativeview.cpp
@@ -0,0 +1,122 @@
+/***************************************************************************
+ * *
+ * Copyright 2011 Sebastian Kügler <sebas@kde.org> *
+ * Copyright 2011 Marco Martin <mart@kde.org> *
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ * 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 General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU 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 "kdeclarativeview.h"
+
+#include <QDeclarativeContext>
+#include <QDeclarativeEngine>
+#include <QDeclarativeItem>
+#include <QGLWidget>
+
+#include <KDebug>
+
+#include <kdeclarative.h>
+
+#include <Plasma/Package>
+
+class KDeclarativeViewPrivate
+{
+public:
+ KDeclarativeViewPrivate()
+ : useGL(false)
+ {}
+
+ KDeclarative kdeclarative;
+ Plasma::PackageStructure::Ptr structure;
+ Plasma::Package *package;
+ QString packageName;
+ bool useGL;
+};
+
+KDeclarativeView::KDeclarativeView(QWidget *parent)
+ : QDeclarativeView(parent),
+ d(new KDeclarativeViewPrivate)
+{
+ // avoid flicker on show
+ setAttribute(Qt::WA_OpaquePaintEvent);
+ setAttribute(Qt::WA_NoSystemBackground);
+ viewport()->setAttribute(Qt::WA_OpaquePaintEvent);
+ viewport()->setAttribute(Qt::WA_NoSystemBackground);
+
+ setResizeMode(QDeclarativeView::SizeRootObjectToView);
+
+ d->kdeclarative.setDeclarativeEngine(engine());
+ d->kdeclarative.initialize();
+ //binds things like kconfig and icons
+ d->kdeclarative.setupBindings();
+ QScriptEngine *scriptEngine = d->kdeclarative.scriptEngine();
+
+ d->structure = Plasma::PackageStructure::load("Plasma/Generic");
+
+ show();
+}
+
+KDeclarativeView::~KDeclarativeView()
+{
+}
+
+
+void KDeclarativeView::setPackageName(const QString &packageName)
+{
+ d->package = new Plasma::Package(QString(), packageName, d->structure);
+ d->packageName = packageName;
+ setSource(QUrl(d->package->filePath("mainscript")));
+}
+
+QString KDeclarativeView::packageName() const
+{
+ return d->packageName;
+}
+
+void KDeclarativeView::setPackage(Plasma::Package *package)
+{
+ if (!package || package == d->package) {
+ return;
+ }
+
+ d->package = package;
+ d->packageName = package->metadata().pluginName();
+ setSource(QUrl(d->package->filePath("mainscript")));
+}
+
+Plasma::Package *KDeclarativeView::package() const
+{
+ return d->package;
+}
+
+void KDeclarativeView::setUseGL(const bool on)
+{
+#ifndef QT_NO_OPENGL
+ if (on) {
+ QGLWidget *glWidget = new QGLWidget;
+ glWidget->setAutoFillBackground(false);
+ setViewport(glWidget);
+ }
+#endif
+ d->useGL = on;
+}
+
+bool KDeclarativeView::useGL() const
+{
+ return d->useGL;
+}
+
+#include "kdeclarativeview.moc"
diff --git a/player/active/src/kdeclarativeview.h \
b/player/active/src/kdeclarativeview.h new file mode 100644
index 0000000..649f78f
--- /dev/null
+++ b/player/active/src/kdeclarativeview.h
@@ -0,0 +1,81 @@
+/***************************************************************************
+ * *
+ * Copyright 2011 Sebastian Kügler <sebas@kde.org> *
+ * Copyright 2011 Marco Martin <mart@kde.org> *
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ * 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 General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU 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 . *
+ ***************************************************************************/
+
+#ifndef KDECLARATIVEVIEW_H
+#define KDECLARATIVEVIEW_H
+
+#include <QDeclarativeView>
+
+
+namespace Plasma
+{
+ class Package;
+}
+
+class KDeclarativeViewPrivate;
+
+class KDeclarativeView : public QDeclarativeView
+{
+ Q_OBJECT
+
+public:
+ KDeclarativeView(QWidget *parent = 0);
+ ~KDeclarativeView();
+
+ /**
+ * Sets wether the application uses opengl
+ * @arg bool on if true the declarative view will use opengl for its viewport()
+ */
+ void setUseGL(const bool on);
+ /**
+ * @returns true if the declarative view uses opengl
+ */
+ bool useGL() const;
+
+ /**
+ * Sets the package from where load the application QML UI
+ * The package must be of the type "Generic package"
+ * it must provide a qml file as "mainscript"
+ * @arg QString packageName the plugin name of the package
+ */
+ void setPackageName(const QString &packageName);
+ /**
+ * @returns the plugin name of the package
+ */
+ QString packageName() const;
+
+ /**
+ * Sets the package used for the application QML UI.
+ * You usually don't need to use this, rather use setPackageName
+ * @see setPackageName
+ */
+ //FIXME: remove this function?
+ void setPackage(Plasma::Package *package);
+ /**
+ * @returns the plugin name of the package that holds the application QML UI
+ */
+ Plasma::Package *package() const;
+
+private:
+ KDeclarativeViewPrivate *const d;
+};
+
+#endif //KDECLARATIVEVIEW_H
diff --git a/player/active/src/main.cpp b/player/active/src/main.cpp
index 7069e1b..0568684 100644
--- a/player/active/src/main.cpp
+++ b/player/active/src/main.cpp
@@ -23,9 +23,6 @@
#include <KApplication>
#include <KAboutData>
#include <KCmdLineArgs>
-#include <KDebug>
-#include <KDE/KLocale>
-#include <KToolBar>
// Own
#include "mainwindow.h"
@@ -50,17 +47,9 @@ int main(int argc, char **argv)
KCmdLineArgs *args = KCmdLineArgs::parsedArgs();
- bool useGL = args->isSet("opengl");
+ MainWindow mainWindow;
+ mainWindow.show();
- if (!useGL) {
- //use plasmarc to share this with plasma-windowed
- KConfigGroup cg(KSharedConfig::openConfig("plasmarc"), "General");
- useGL = cg.readEntry("UseOpenGl", true);
- }
-
- MainWindow *mainWindow = new MainWindow();
- mainWindow->setUseGL(useGL);
- mainWindow->show();
args->clear();
return app.exec();
}
diff --git a/player/active/src/mainwindow.cpp b/player/active/src/mainwindow.cpp
index 902846d..7887900 100644
--- a/player/active/src/mainwindow.cpp
+++ b/player/active/src/mainwindow.cpp
@@ -21,56 +21,22 @@
#include "mainwindow.h"
-#include <Plasma/Theme>
+#include <lib/gamemetadata.h>
+#include <lib/gamemanager.h>
-#include <KDE/KAction>
-#include <KDE/KIcon>
-#include <KDE/KStandardAction>
+#include "kdeclarativeview.h"
-MainWindow::MainWindow()
- : KMainWindow()
-{
- setAcceptDrops(true);
- KConfigGroup cg(KSharedConfig::openConfig("plasmarc"), "Theme-plasma-mobile");
- const QString themeName = cg.readEntry("name", "air-mobile");
- Plasma::Theme::defaultTheme()->setUseGlobalSettings(false);
- Plasma::Theme::defaultTheme()->setThemeName(themeName);
- addAction(KStandardAction::close(this, SLOT(close()), this));
- addAction(KStandardAction::quit(this, SLOT(close()), this));
- m_widget = new AppView(this);
-
- restoreWindowSize(config("Window"));
- setCentralWidget(m_widget);
-}
-
-MainWindow::~MainWindow()
-{
- saveWindowSize(config("Window"));
-}
-
-KConfigGroup MainWindow::config(const QString &group)
-{
- return KConfigGroup(KSharedConfig::openConfig("gluonplayeractiverc"), group);
-}
+#include <QtDeclarative/QtDeclarative>
-QString MainWindow::name()
-{
- return "Gluon Player";
-}
-
-QIcon MainWindow::icon()
-{
- return KIcon("gluon-install");
-}
-
-void MainWindow::setUseGL(const bool on)
+MainWindow::MainWindow()
{
- m_widget->setUseGL(on);
-}
+ declarativeView()->rootContext()->setContextProperty( "installedGamesModel",
+ \
GluonPlayer::GameManager::instance()->installedGamesModel() ); + \
declarativeView()->rootContext()->setContextProperty( "downloadableGamesModel", + \
GluonPlayer::GameManager::instance()->downloadableGamesModel() ); + \
qmlRegisterType<GluonPlayer::GameMetadata>( "org.kde.gluon", 1, 0, "GameMetadata" ); \
-bool MainWindow::useGL() const
-{
- return m_widget->useGL();
+ declarativeView()->setPackageName("org.kde.gluon.player");
}
#include "mainwindow.moc"
diff --git a/player/active/src/mainwindow.h b/player/active/src/mainwindow.h
index 24aab79..9116510 100644
--- a/player/active/src/mainwindow.h
+++ b/player/active/src/mainwindow.h
@@ -23,23 +23,13 @@
#ifndef MAINWINDOW_H
#define MAINWINDOW_H
-#include "appview.h"
+#include "kdeclarativemainwindow.h"
-class MainWindow : public KMainWindow
+class MainWindow : public KDeclarativeMainWindow
{
Q_OBJECT
public:
MainWindow();
- virtual ~MainWindow();
- QString name();
- QIcon icon();
- KConfigGroup config(const QString &group = "Default");
-
- void setUseGL(const bool on);
- bool useGL() const;
-
-private:
- AppView *m_widget;
};
#endif // MAINWINDOW_H
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic