• Skip to content
  • Skip to link menu
KDE API Reference
  • KDE API Reference
  • kdeedu API Reference
  • KDE Home
  • Contact Us
 

kanagram

  • sources
  • kde-4.12
  • kdeedu
  • kanagram
  • src
  • plasma-active
  • src
kdeclarativeview.cpp
Go to the documentation of this file.
1 /***************************************************************************
2  * *
3  * Copyright 2011 Sebastian Kügler <sebas@kde.org> *
4  * Copyright 2011 Marco Martin <mart@kde.org> *
5  * *
6  * This program is free software; you can redistribute it and/or modify *
7  * it under the terms of the GNU General Public License as published by *
8  * the Free Software Foundation; either version 2 of the License, or *
9  * (at your option) any later version. *
10  * *
11  * This program is distributed in the hope that it will be useful, *
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
14  * GNU General Public License for more details. *
15  * *
16  * You should have received a copy of the GNU General Public License *
17  * along with this program; if not, write to the *
18  * Free Software Foundation, Inc., *
19  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA . *
20  ***************************************************************************/
21 
22 #include "kdeclarativeview.h"
23 
24 #include <QDeclarativeContext>
25 #include <QDeclarativeEngine>
26 #include <QDeclarativeItem>
27 #include <QGLWidget>
28 
29 #include <KDebug>
30 
31 #include <kdeclarative.h>
32 
33 #include <Plasma/Package>
34 
35 class KDeclarativeViewPrivate
36 {
37 public:
38  KDeclarativeViewPrivate()
39  : useGL(false)
40  {}
41 
42  KDeclarative kdeclarative;
43  Plasma::PackageStructure::Ptr structure;
44  Plasma::Package *package;
45  QString packageName;
46  bool useGL;
47 };
48 
49 KDeclarativeView::KDeclarativeView(QWidget *parent)
50  : QDeclarativeView(parent),
51  d(new KDeclarativeViewPrivate)
52 {
53  // avoid flicker on show
54  setAttribute(Qt::WA_OpaquePaintEvent);
55  setAttribute(Qt::WA_NoSystemBackground);
56  viewport()->setAttribute(Qt::WA_OpaquePaintEvent);
57  viewport()->setAttribute(Qt::WA_NoSystemBackground);
58 
59  setResizeMode(QDeclarativeView::SizeRootObjectToView);
60 
61  d->kdeclarative.setDeclarativeEngine(engine());
62  d->kdeclarative.initialize();
63  //binds things like kconfig and icons
64  d->kdeclarative.setupBindings();
65  QScriptEngine *scriptEngine = d->kdeclarative.scriptEngine();
66 
67  d->structure = Plasma::PackageStructure::load("Plasma/Generic");
68 
69  show();
70 }
71 
72 KDeclarativeView::~KDeclarativeView()
73 {
74 }
75 
76 
77 void KDeclarativeView::setPackageName(const QString &packageName)
78 {
79  d->package = new Plasma::Package(QString(), packageName, d->structure);
80  d->packageName = packageName;
81  setSource(QUrl(d->package->filePath("mainscript")));
82 }
83 
84 QString KDeclarativeView::packageName() const
85 {
86  return d->packageName;
87 }
88 
89 void KDeclarativeView::setPackage(Plasma::Package *package)
90 {
91  if (!package || package == d->package) {
92  return;
93  }
94 
95  d->package = package;
96  d->packageName = package->metadata().pluginName();
97  setSource(QUrl(d->package->filePath("mainscript")));
98 }
99 
100 Plasma::Package *KDeclarativeView::package() const
101 {
102  return d->package;
103 }
104 
105 void KDeclarativeView::setUseGL(const bool on)
106 {
107 #ifndef QT_NO_OPENGL
108  if (on) {
109  QGLWidget *glWidget = new QGLWidget;
110  glWidget->setAutoFillBackground(false);
111  setViewport(glWidget);
112  }
113 #endif
114  d->useGL = on;
115 }
116 
117 bool KDeclarativeView::useGL() const
118 {
119  return d->useGL;
120 }
121 
122 #include "kdeclarativeview.moc"
KDeclarativeView::useGL
bool useGL() const
Definition: kdeclarativeview.cpp:117
QDeclarativeView
KDeclarativeView::~KDeclarativeView
~KDeclarativeView()
Definition: kdeclarativeview.cpp:72
KDeclarativeView::setPackageName
void setPackageName(const QString &packageName)
Sets the package from where load the application QML UI The package must be of the type "Generic pack...
Definition: kdeclarativeview.cpp:77
QWidget
KDeclarativeView::packageName
QString packageName() const
Definition: kdeclarativeview.cpp:84
KDeclarativeView::setUseGL
void setUseGL(const bool on)
Sets wether the application uses opengl.
Definition: kdeclarativeview.cpp:105
kdeclarativeview.h
KDeclarativeView::KDeclarativeView
KDeclarativeView(QWidget *parent=0)
Definition: kdeclarativeview.cpp:49
KDeclarativeView::package
Plasma::Package * package() const
Definition: kdeclarativeview.cpp:100
KDeclarativeView::setPackage
void setPackage(Plasma::Package *package)
Sets the package used for the application QML UI.
Definition: kdeclarativeview.cpp:89
This file is part of the KDE documentation.
Documentation copyright © 1996-2014 The KDE developers.
Generated on Tue Oct 14 2014 22:35:35 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

kanagram

Skip menu "kanagram"
  • Main Page
  • Namespace List
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members
  • Related Pages

kdeedu API Reference

Skip menu "kdeedu API Reference"
  • Analitza
  •     lib
  • kalgebra
  • kalzium
  •   libscience
  • kanagram
  • kig
  •   lib
  • klettres
  • kstars
  • libkdeedu
  •   keduvocdocument
  • marble
  • parley
  • rocs
  •   App
  •   RocsCore
  •   VisualEditor
  •   stepcore

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal