remove kpart related code

those were the last files licensed LGPL2 only
this code wasn't built or installed so in the end is just
removing dead code
This commit is contained in:
Marco Martin 2016-05-19 17:47:09 +02:00
parent 3bffad8c42
commit 92bad819e7
32 changed files with 0 additions and 3328 deletions

View File

@ -1,481 +0,0 @@
GNU LIBRARY GENERAL PUBLIC LICENSE
Version 2, June 1991
Copyright (C) 1991 Free Software Foundation, Inc.
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
[This is the first released version of the library GPL. It is
numbered 2 because it goes with version 2 of the ordinary GPL.]
Preamble
The licenses for most software are designed to take away your
freedom to share and change it. By contrast, the GNU General Public
Licenses are intended to guarantee your freedom to share and change
free software--to make sure the software is free for all its users.
This license, the Library General Public License, applies to some
specially designated Free Software Foundation software, and to any
other libraries whose authors decide to use it. You can use it for
your libraries, too.
When we speak of free software, we are referring to freedom, not
price. Our General Public Licenses are designed to make sure that you
have the freedom to distribute copies of free software (and charge for
this service if you wish), that you receive source code or can get it
if you want it, that you can change the software or use pieces of it
in new free programs; and that you know you can do these things.
To protect your rights, we need to make restrictions that forbid
anyone to deny you these rights or to ask you to surrender the rights.
These restrictions translate to certain responsibilities for you if
you distribute copies of the library, or if you modify it.
For example, if you distribute copies of the library, whether gratis
or for a fee, you must give the recipients all the rights that we gave
you. You must make sure that they, too, receive or can get the source
code. If you link a program with the library, you must provide
complete object files to the recipients so that they can relink them
with the library, after making changes to the library and recompiling
it. And you must show them these terms so they know their rights.
Our method of protecting your rights has two steps: (1) copyright
the library, and (2) offer you this license which gives you legal
permission to copy, distribute and/or modify the library.
Also, for each distributor's protection, we want to make certain
that everyone understands that there is no warranty for this free
library. If the library is modified by someone else and passed on, we
want its recipients to know that what they have is not the original
version, so that any problems introduced by others will not reflect on
the original authors' reputations.
Finally, any free program is threatened constantly by software
patents. We wish to avoid the danger that companies distributing free
software will individually obtain patent licenses, thus in effect
transforming the program into proprietary software. To prevent this,
we have made it clear that any patent must be licensed for everyone's
free use or not licensed at all.
Most GNU software, including some libraries, is covered by the ordinary
GNU General Public License, which was designed for utility programs. This
license, the GNU Library General Public License, applies to certain
designated libraries. This license is quite different from the ordinary
one; be sure to read it in full, and don't assume that anything in it is
the same as in the ordinary license.
The reason we have a separate public license for some libraries is that
they blur the distinction we usually make between modifying or adding to a
program and simply using it. Linking a program with a library, without
changing the library, is in some sense simply using the library, and is
analogous to running a utility program or application program. However, in
a textual and legal sense, the linked executable is a combined work, a
derivative of the original library, and the ordinary General Public License
treats it as such.
Because of this blurred distinction, using the ordinary General
Public License for libraries did not effectively promote software
sharing, because most developers did not use the libraries. We
concluded that weaker conditions might promote sharing better.
However, unrestricted linking of non-free programs would deprive the
users of those programs of all benefit from the free status of the
libraries themselves. This Library General Public License is intended to
permit developers of non-free programs to use free libraries, while
preserving your freedom as a user of such programs to change the free
libraries that are incorporated in them. (We have not seen how to achieve
this as regards changes in header files, but we have achieved it as regards
changes in the actual functions of the Library.) The hope is that this
will lead to faster development of free libraries.
The precise terms and conditions for copying, distribution and
modification follow. Pay close attention to the difference between a
"work based on the library" and a "work that uses the library". The
former contains code derived from the library, while the latter only
works together with the library.
Note that it is possible for a library to be covered by the ordinary
General Public License rather than by this special one.
GNU LIBRARY GENERAL PUBLIC LICENSE
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
0. This License Agreement applies to any software library which
contains a notice placed by the copyright holder or other authorized
party saying it may be distributed under the terms of this Library
General Public License (also called "this License"). Each licensee is
addressed as "you".
A "library" means a collection of software functions and/or data
prepared so as to be conveniently linked with application programs
(which use some of those functions and data) to form executables.
The "Library", below, refers to any such software library or work
which has been distributed under these terms. A "work based on the
Library" means either the Library or any derivative work under
copyright law: that is to say, a work containing the Library or a
portion of it, either verbatim or with modifications and/or translated
straightforwardly into another language. (Hereinafter, translation is
included without limitation in the term "modification".)
"Source code" for a work means the preferred form of the work for
making modifications to it. For a library, complete source code means
all the source code for all modules it contains, plus any associated
interface definition files, plus the scripts used to control compilation
and installation of the library.
Activities other than copying, distribution and modification are not
covered by this License; they are outside its scope. The act of
running a program using the Library is not restricted, and output from
such a program is covered only if its contents constitute a work based
on the Library (independent of the use of the Library in a tool for
writing it). Whether that is true depends on what the Library does
and what the program that uses the Library does.
1. You may copy and distribute verbatim copies of the Library's
complete source code as you receive it, in any medium, provided that
you conspicuously and appropriately publish on each copy an
appropriate copyright notice and disclaimer of warranty; keep intact
all the notices that refer to this License and to the absence of any
warranty; and distribute a copy of this License along with the
Library.
You may charge a fee for the physical act of transferring a copy,
and you may at your option offer warranty protection in exchange for a
fee.
2. You may modify your copy or copies of the Library or any portion
of it, thus forming a work based on the Library, and copy and
distribute such modifications or work under the terms of Section 1
above, provided that you also meet all of these conditions:
a) The modified work must itself be a software library.
b) You must cause the files modified to carry prominent notices
stating that you changed the files and the date of any change.
c) You must cause the whole of the work to be licensed at no
charge to all third parties under the terms of this License.
d) If a facility in the modified Library refers to a function or a
table of data to be supplied by an application program that uses
the facility, other than as an argument passed when the facility
is invoked, then you must make a good faith effort to ensure that,
in the event an application does not supply such function or
table, the facility still operates, and performs whatever part of
its purpose remains meaningful.
(For example, a function in a library to compute square roots has
a purpose that is entirely well-defined independent of the
application. Therefore, Subsection 2d requires that any
application-supplied function or table used by this function must
be optional: if the application does not supply it, the square
root function must still compute square roots.)
These requirements apply to the modified work as a whole. If
identifiable sections of that work are not derived from the Library,
and can be reasonably considered independent and separate works in
themselves, then this License, and its terms, do not apply to those
sections when you distribute them as separate works. But when you
distribute the same sections as part of a whole which is a work based
on the Library, the distribution of the whole must be on the terms of
this License, whose permissions for other licensees extend to the
entire whole, and thus to each and every part regardless of who wrote
it.
Thus, it is not the intent of this section to claim rights or contest
your rights to work written entirely by you; rather, the intent is to
exercise the right to control the distribution of derivative or
collective works based on the Library.
In addition, mere aggregation of another work not based on the Library
with the Library (or with a work based on the Library) on a volume of
a storage or distribution medium does not bring the other work under
the scope of this License.
3. You may opt to apply the terms of the ordinary GNU General Public
License instead of this License to a given copy of the Library. To do
this, you must alter all the notices that refer to this License, so
that they refer to the ordinary GNU General Public License, version 2,
instead of to this License. (If a newer version than version 2 of the
ordinary GNU General Public License has appeared, then you can specify
that version instead if you wish.) Do not make any other change in
these notices.
Once this change is made in a given copy, it is irreversible for
that copy, so the ordinary GNU General Public License applies to all
subsequent copies and derivative works made from that copy.
This option is useful when you wish to copy part of the code of
the Library into a program that is not a library.
4. You may copy and distribute the Library (or a portion or
derivative of it, under Section 2) in object code or executable form
under the terms of Sections 1 and 2 above provided that you accompany
it with the complete corresponding machine-readable source code, which
must be distributed under the terms of Sections 1 and 2 above on a
medium customarily used for software interchange.
If distribution of object code is made by offering access to copy
from a designated place, then offering equivalent access to copy the
source code from the same place satisfies the requirement to
distribute the source code, even though third parties are not
compelled to copy the source along with the object code.
5. A program that contains no derivative of any portion of the
Library, but is designed to work with the Library by being compiled or
linked with it, is called a "work that uses the Library". Such a
work, in isolation, is not a derivative work of the Library, and
therefore falls outside the scope of this License.
However, linking a "work that uses the Library" with the Library
creates an executable that is a derivative of the Library (because it
contains portions of the Library), rather than a "work that uses the
library". The executable is therefore covered by this License.
Section 6 states terms for distribution of such executables.
When a "work that uses the Library" uses material from a header file
that is part of the Library, the object code for the work may be a
derivative work of the Library even though the source code is not.
Whether this is true is especially significant if the work can be
linked without the Library, or if the work is itself a library. The
threshold for this to be true is not precisely defined by law.
If such an object file uses only numerical parameters, data
structure layouts and accessors, and small macros and small inline
functions (ten lines or less in length), then the use of the object
file is unrestricted, regardless of whether it is legally a derivative
work. (Executables containing this object code plus portions of the
Library will still fall under Section 6.)
Otherwise, if the work is a derivative of the Library, you may
distribute the object code for the work under the terms of Section 6.
Any executables containing that work also fall under Section 6,
whether or not they are linked directly with the Library itself.
6. As an exception to the Sections above, you may also compile or
link a "work that uses the Library" with the Library to produce a
work containing portions of the Library, and distribute that work
under terms of your choice, provided that the terms permit
modification of the work for the customer's own use and reverse
engineering for debugging such modifications.
You must give prominent notice with each copy of the work that the
Library is used in it and that the Library and its use are covered by
this License. You must supply a copy of this License. If the work
during execution displays copyright notices, you must include the
copyright notice for the Library among them, as well as a reference
directing the user to the copy of this License. Also, you must do one
of these things:
a) Accompany the work with the complete corresponding
machine-readable source code for the Library including whatever
changes were used in the work (which must be distributed under
Sections 1 and 2 above); and, if the work is an executable linked
with the Library, with the complete machine-readable "work that
uses the Library", as object code and/or source code, so that the
user can modify the Library and then relink to produce a modified
executable containing the modified Library. (It is understood
that the user who changes the contents of definitions files in the
Library will not necessarily be able to recompile the application
to use the modified definitions.)
b) Accompany the work with a written offer, valid for at
least three years, to give the same user the materials
specified in Subsection 6a, above, for a charge no more
than the cost of performing this distribution.
c) If distribution of the work is made by offering access to copy
from a designated place, offer equivalent access to copy the above
specified materials from the same place.
d) Verify that the user has already received a copy of these
materials or that you have already sent this user a copy.
For an executable, the required form of the "work that uses the
Library" must include any data and utility programs needed for
reproducing the executable from it. However, as a special exception,
the source code distributed need not include anything that is normally
distributed (in either source or binary form) with the major
components (compiler, kernel, and so on) of the operating system on
which the executable runs, unless that component itself accompanies
the executable.
It may happen that this requirement contradicts the license
restrictions of other proprietary libraries that do not normally
accompany the operating system. Such a contradiction means you cannot
use both them and the Library together in an executable that you
distribute.
7. You may place library facilities that are a work based on the
Library side-by-side in a single library together with other library
facilities not covered by this License, and distribute such a combined
library, provided that the separate distribution of the work based on
the Library and of the other library facilities is otherwise
permitted, and provided that you do these two things:
a) Accompany the combined library with a copy of the same work
based on the Library, uncombined with any other library
facilities. This must be distributed under the terms of the
Sections above.
b) Give prominent notice with the combined library of the fact
that part of it is a work based on the Library, and explaining
where to find the accompanying uncombined form of the same work.
8. You may not copy, modify, sublicense, link with, or distribute
the Library except as expressly provided under this License. Any
attempt otherwise to copy, modify, sublicense, link with, or
distribute the Library is void, and will automatically terminate your
rights under this License. However, parties who have received copies,
or rights, from you under this License will not have their licenses
terminated so long as such parties remain in full compliance.
9. You are not required to accept this License, since you have not
signed it. However, nothing else grants you permission to modify or
distribute the Library or its derivative works. These actions are
prohibited by law if you do not accept this License. Therefore, by
modifying or distributing the Library (or any work based on the
Library), you indicate your acceptance of this License to do so, and
all its terms and conditions for copying, distributing or modifying
the Library or works based on it.
10. Each time you redistribute the Library (or any work based on the
Library), the recipient automatically receives a license from the
original licensor to copy, distribute, link with or modify the Library
subject to these terms and conditions. You may not impose any further
restrictions on the recipients' exercise of the rights granted herein.
You are not responsible for enforcing compliance by third parties to
this License.
11. If, as a consequence of a court judgment or allegation of patent
infringement or for any other reason (not limited to patent issues),
conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not
excuse you from the conditions of this License. If you cannot
distribute so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you
may not distribute the Library at all. For example, if a patent
license would not permit royalty-free redistribution of the Library by
all those who receive copies directly or indirectly through you, then
the only way you could satisfy both it and this License would be to
refrain entirely from distribution of the Library.
If any portion of this section is held invalid or unenforceable under any
particular circumstance, the balance of the section is intended to apply,
and the section as a whole is intended to apply in other circumstances.
It is not the purpose of this section to induce you to infringe any
patents or other property right claims or to contest validity of any
such claims; this section has the sole purpose of protecting the
integrity of the free software distribution system which is
implemented by public license practices. Many people have made
generous contributions to the wide range of software distributed
through that system in reliance on consistent application of that
system; it is up to the author/donor to decide if he or she is willing
to distribute software through any other system and a licensee cannot
impose that choice.
This section is intended to make thoroughly clear what is believed to
be a consequence of the rest of this License.
12. If the distribution and/or use of the Library is restricted in
certain countries either by patents or by copyrighted interfaces, the
original copyright holder who places the Library under this License may add
an explicit geographical distribution limitation excluding those countries,
so that distribution is permitted only in or among countries not thus
excluded. In such case, this License incorporates the limitation as if
written in the body of this License.
13. The Free Software Foundation may publish revised and/or new
versions of the Library General Public License from time to time.
Such new versions will be similar in spirit to the present version,
but may differ in detail to address new problems or concerns.
Each version is given a distinguishing version number. If the Library
specifies a version number of this License which applies to it and
"any later version", you have the option of following the terms and
conditions either of that version or of any later version published by
the Free Software Foundation. If the Library does not specify a
license version number, you may choose any version ever published by
the Free Software Foundation.
14. If you wish to incorporate parts of the Library into other free
programs whose distribution conditions are incompatible with these,
write to the author to ask for permission. For software which is
copyrighted by the Free Software Foundation, write to the Free
Software Foundation; we sometimes make exceptions for this. Our
decision will be guided by the two goals of preserving the free status
of all derivatives of our free software and of promoting the sharing
and reuse of software generally.
NO WARRANTY
15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO
WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW.
EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR
OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY
KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE
LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME
THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN
WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY
AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU
FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR
CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE
LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING
RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A
FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF
SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
DAMAGES.
END OF TERMS AND CONDITIONS
How to Apply These Terms to Your New Libraries
If you develop a new library, and you want it to be of the greatest
possible use to the public, we recommend making it free software that
everyone can redistribute and change. You can do so by permitting
redistribution under these terms (or, alternatively, under the terms of the
ordinary General Public License).
To apply these terms, attach the following notices to the library. It is
safest to attach them to the start of each source file to most effectively
convey the exclusion of warranty; and each file should have at least the
"copyright" line and a pointer to where the full notice is found.
<one line to give the library's name and a brief idea of what it does.>
Copyright (C) <year> <name of author>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 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
Library General Public License for more details.
You should have received a copy of the GNU Library 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
Also add information on how to contact you by electronic and paper mail.
You should also get your employer (if you work as a programmer) or your
school, if any, to sign a "copyright disclaimer" for the library, if
necessary. Here is a sample; alter the names:
Yoyodyne, Inc., hereby disclaims all copyright interest in the
library `Frob' (a library for tweaking knobs) written by James Random Hacker.
<signature of Ty Coon>, 1 April 1990
Ty Coon, President of Vice
That's all there is to it!

View File

@ -1,17 +0,0 @@
set(plasma_example_kpart_shell_SRCS
main.cpp
containmentshell.cpp
testshellpluginloader.cpp
appletselector.cpp
)
ki18n_wrap_ui(plasma_example_kpart_shell_SRCS appletselector.ui)
add_executable(plasma-example-kpart-shell ${plasma_example_kpart_shell_SRCS})
target_link_libraries(plasma-example-kpart-shell KF5::Plasma KF5::Parts)
########### install files ###############
install(TARGETS plasma-example-kpart-shell ${KF5_INSTALL_TARGETS_DEFAULT_ARGS} )
install( PROGRAMS plasma-example-kpart-shell.desktop DESTINATION ${KDE_INSTALL_APPDIR} )
install(FILES plasma-default-layoutrc DESTINATION ${KDE_INSTALL_DATADIR}/plasma-example-kpart-shell/)
install( FILES plasma-kpart-shellui.rc DESTINATION ${KDE_INSTALL_DATADIR}/plasma-example-kpart-shell/ )

View File

@ -1,66 +0,0 @@
/*
* Copyright 2010 Aleix Pol Gonzalez <aleixpol@kde.org>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 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
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public License
* along with this library; see the file COPYING.LIB. If not, write to
* the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
#include "appletselector.h"
#include "ui_appletselector.h"
#include <plasma/applet.h>
#include <QStandardItemModel>
AppletSelector::AppletSelector(QObject *parent, const QVariantList &args)
: KDialog()
{
Q_UNUSED(args);
setButtons(Close);
QWidget *w = new QWidget(this);
m_ui = new Ui::AppletSelector;
m_ui->setupUi(w);
m_ui->plugins->header()->setSortIndicator(0, Qt::AscendingOrder);
setMainWidget(w);
QStandardItemModel *model = new QStandardItemModel(this);
const KPluginInfo::List list = Plasma::Applet::listAppletInfo();
foreach (const KPluginInfo &info, list) {
QStandardItem *item = new QStandardItem(KIcon(info.icon()), info.name());
item->setEditable(false);
item->setToolTip(info.comment());
item->setData(info.pluginName(), Qt::UserRole + 1);
model->appendRow(item);
}
m_ui->plugins->setModel(model);
connect(m_ui->plugins, SIGNAL(doubleClicked(QModelIndex)), SLOT(selected(QModelIndex)));
}
AppletSelector::~AppletSelector()
{
delete m_ui;
}
void AppletSelector::selected(const QModelIndex &idx)
{
emit addApplet(idx.data(Qt::UserRole + 1).toString());
}

View File

@ -1,47 +0,0 @@
/* This file is part of KDevelop
Copyright 2010 Aleix Pol Gonzalez <aleixpol@kde.org>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 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
Library General Public License for more details.
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
*/
#ifndef APPLETSELECTOR_H
#define APPLETSELECTOR_H
#include <KDE/KDialog>
class QModelIndex;
namespace Ui
{
class AppletSelector;
}
class AppletSelector : public KDialog
{
Q_OBJECT
public:
explicit AppletSelector(QObject *parent = 0, const QVariantList &args = QVariantList());
~AppletSelector();
public slots:
void selected(const QModelIndex &idx);
signals:
void addApplet(const QString &name);
private:
Ui::AppletSelector *m_ui;
};
#endif // APPLETSELECTOR_H

View File

@ -1,44 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>AppletSelector</class>
<widget class="QWidget" name="AppletSelector">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>400</width>
<height>300</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QLabel" name="label">
<property name="text">
<string>Double-click on the widget you want to add:</string>
</property>
</widget>
</item>
<item>
<widget class="QTreeView" name="plugins">
<property name="rootIsDecorated">
<bool>false</bool>
</property>
<property name="itemsExpandable">
<bool>false</bool>
</property>
<property name="sortingEnabled">
<bool>true</bool>
</property>
<attribute name="headerVisible">
<bool>false</bool>
</attribute>
<attribute name="headerVisible">
<bool>false</bool>
</attribute>
</widget>
</item>
</layout>
</widget>
<resources/>
<connections/>
</ui>

View File

@ -1,93 +0,0 @@
/*
* Copyright 2010 Ryan Rix <ry@n.rix.si>
* Copyright 2010 Siddharth Sharma <siddharth.kde@gmail.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Library General Public License version 2 as
* published by the Free Software Foundation
*
* 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 Library 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 "containmentshell.h"
#include "testshellpluginloader.h"
#include "appletselector.h"
#include <KService>
#include <KMessageBox>
#include <KDebug>
#include <KStandardAction>
#include <KActionCollection>
#include <Plasma/Containment>
#include <QApplication>
ContainmentShell::ContainmentShell()
: KParts::MainWindow(),
m_dialog(0)
{
setXMLFile("plasma-kpart-shellui.rc");
KAction *action = KStandardAction::quit(qApp, SLOT(quit()), actionCollection());
action = new KAction("&Configure", actionCollection());
connect(action, SIGNAL(triggered()), this, SLOT(optionsPreferences()));
actionCollection()->addAction("options_configure", action);
// this routine will find and load our Part. it finds the Part by
// name which is a bad idea usually.. but it's alright in this
// case since our Part is made for this Shell
KService::Ptr service = KService::serviceByDesktopPath("plasma-kpart.desktop");
if (service) {
Plasma::PluginLoader *loader = new TestShellPluginLoader();
m_part = service->createInstance<KParts::ReadOnlyPart>(0, QVariantList() << qVariantFromValue(loader));
if (m_part) {
// tell the KParts::MainWindow that this is indeed the main widget
setCentralWidget(m_part->widget());
// and integrate the part's GUI with the shell's
createGUI(m_part);
} else {
// For whatever reason the part didn't load
KMessageBox::error(this, "Could not instantiate our Part!");
qApp->quit();
}
} else {
// if we couldn't find our Part, we exit since the Shell by
// itself can't do anything useful
KMessageBox::error(this, "Could not find our Part!");
qApp->quit();
// we return here, cause qApp->quit() only means "exit the
// next time we enter the event loop...
return;
}
// apply the saved mainwindow settings, if any, and ask the mainwindow
// to automatically save settings if changed: window size, toolbar
// position, icon size, etc.
setAutoSaveSettings();
}
ContainmentShell::~ContainmentShell()
{
}
void ContainmentShell::optionsPreferences()
{
if (!m_dialog) {
m_dialog = new AppletSelector(m_part);
connect(m_dialog, SIGNAL(addApplet(QString)), m_part, SLOT(addApplet(QString)));
}
m_dialog->show();
}

View File

@ -1,49 +0,0 @@
/*
* Copyright 2010 Ryan Rix <ry@n.rix.si>
* Copyright 2010 Siddharth Sharma <siddharth.kde@gmail.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Library General Public License version 2 as
* published by the Free Software Foundation
*
* 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 Library 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 CONTAINMENTSHELL_H
#define CONTAINMENTSHELL_H
#include <kparts/mainwindow.h>
#include <KDialog>
/**
* This is the application "Shell". It has a menubar, toolbar, and
* statusbar but relies on the "Part" to do all the real work.
*
* @short Generic Application Shell
* @author Ryan Rix <ry@n.rix.si>
* @version 0.01
*/
class ContainmentShell : public KParts::MainWindow
{
Q_OBJECT
public:
ContainmentShell();
virtual ~ContainmentShell();
public Q_SLOTS:
void optionsPreferences();
private:
KParts::Part *m_part;
KDialog *m_dialog;
};
#endif // CONTAINMENTSHELL_H

View File

@ -1,43 +0,0 @@
/*
* Copyright 2010 Ryan Rix <ry@n.rix.si>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Library General Public License version 2 as
* published by the Free Software Foundation
*
* 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 Library 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 "containmentshell.h"
#include <KApplication>
#include <KAboutData>
#include <KCmdLineArgs>
static const char version[] = "0.1";
int main(int argc, char **argv)
{
KAboutData about("plasma-kpart-shell", 0, ki18n("Plasma KPart Shell"), version, ki18n("A KDE KPart Application"), KAboutData::License_GPL, ki18n("(C) 2010 Ryan Rix"), KLocalizedString(), 0, "ry@n.rix.si");
about.addAuthor(ki18n("Ryan Rix"), KLocalizedString(), "ry@n.rix.si");
KCmdLineArgs::init(argc, argv, &about);
KApplication app;
// see if we are starting with session management
if (app.isSessionRestored()) {
RESTORE(ContainmentShell)
} else {
ContainmentShell *widget = new ContainmentShell;
widget->show();
}
return app.exec();
}

View File

@ -1,61 +0,0 @@
[Containments][1]
activity=Newspaper
desktop=-1
formfactor=0
geometry=806,0,800,480
immutability=1
location=0
plugin=newspaper
screen=0
wallpaperplugin=image
wallpaperpluginmode=SingleImage
zvalue=0
[Containments][1][ToolBox]
corner=7
offset=0
[Containments][1][Applets][1]
geometry=14,38,343,236
immutability=1
plugin=news
zvalue=52
[Containments][1][Applets][1][LayoutInformation]
Column=0
Order=0
[Containments][1][Applets][2]
geometry=14,278,343,188
immutability=1
plugin=weather
zvalue=57
[Containments][1][Applets][2][LayoutInformation]
Column=0
Order=1
[Containments][1][Applets][3]
geometry=1000,38,424,241
immutability=1
plugin=opendesktop
zvalue=47
[Containments][1][Applets][3][LayoutInformation]
Column=1
Order=0
[Containments][1][Applets][4]
geometry=1000,283,424,182
immutability=1
plugin=knowledgebase
zvalue=47
[Containments][1][Applets][4][LayoutInformation]
Column=1
Order=1
[General]
immutability=1

View File

@ -1,81 +0,0 @@
[Desktop Entry]
Name=plasma-kpart-shell
Name[ast]=plasma-kpart-shell
Name[bs]=plasma-kpart-shell
Name[ca]=plasma-kpart-shell
Name[ca@valencia]=plasma-kpart-shell
Name[cs]=plasma-kpart-shell
Name[da]=plasma-kpart-shell
Name[de]=plasma-kpart-shell
Name[en_GB]=plasma-kpart-shell
Name[es]=plasma-kpart-shell
Name[fi]=plasma-kpart-shell
Name[fr]=plasma-kpart-shell
Name[gd]=plasma-kpart-shell
Name[gl]=plasma-kpart-shell
Name[hu]=plasma-kpart-shell
Name[ia]=plasma-kpart-shell
Name[it]=plasma-kpart-shell
Name[ko]=plasma-kpart-shell
Name[nb]=plasma-kpart-shell
Name[nds]=Plasma-KPart-Konsool
Name[nl]=plasma-kpart-shell
Name[nn]=plasma-kpart-shell
Name[pl]=plasma-kpart-shell
Name[pt]=plasma-kpart-shell
Name[pt_BR]=plasma-kpart-shell
Name[ru]=Консоль компонентов для Plasma
Name[sk]=plasma-kpart-shell
Name[sl]=plasma-kpart-shell
Name[sr]=plasma-kpart-shell
Name[sr@ijekavian]=plasma-kpart-shell
Name[sr@ijekavianlatin]=plasma-kpart-shell
Name[sr@latin]=plasma-kpart-shell
Name[sv]=Plasma-delprogramskal
Name[tr]=plasma-kpart-shell
Name[uk]=plasma-kpart-shell
Name[x-test]=xxplasma-kpart-shellxx
Name[zh_CN]=plasma-kpart-shell
Name[zh_TW]=plasma-kpart-shell
Exec=plasma-example-kpart-shell %i -caption "%c"
Icon=plasma-example-kpart-shell
Type=Application
X-DocPath=plasma-kpart-shell/index.html
GenericName=A KPart shell for Plasma
GenericName[ast]=Un shell KPart pa Plasma
GenericName[bs]=Kpart školjka za plazmu
GenericName[ca]=Una KPart d'intèrpret d'ordres pel Plasma
GenericName[ca@valencia]=Una KPart d'intèrpret d'ordes pel Plasma
GenericName[da]=En KPart-skal til Plasma
GenericName[de]=Eine KPart-Shell für Plasma
GenericName[en_GB]=A KPart shell for Plasma
GenericName[es]=Un KPart de intérprete para Plasma
GenericName[fi]=KPart-kuori Plasmalle
GenericName[fr]=Un interpréteur KPart pour Plasma
GenericName[gd]=Shell KPart airson Plasma
GenericName[gl]=Unha shell de KPart para Plasma
GenericName[hu]=KPart héj a Plasmához
GenericName[ia]=Un shell (concha) de KPart pro Plasma
GenericName[it]=Una shell KPart per Plasma
GenericName[ko]=Plasma KPart
GenericName[nb]=Et KPart-skall for Plasma
GenericName[nds]=En KPart-Konsool för Plasma
GenericName[nl]=Een KPart-shell voor Plasma
GenericName[nn]=Eit KPart-skal for Plasma
GenericName[pl]=Powłoka KPart dla Plazmy
GenericName[pt]=Uma consola de KPart para o Plasma
GenericName[pt_BR]=Shell KPart para o Plasma
GenericName[ru]=Консоль для встраивания компонентов KPart в Plasma
GenericName[sk]=KPart shell pre Plasma
GenericName[sl]=Lupina KPart za Plasmo
GenericName[sr]=Кдеона шкољка за Плазму
GenericName[sr@ijekavian]=Кдиона шкољка за Плазму
GenericName[sr@ijekavianlatin]=Kdiona školjka za Plasmu
GenericName[sr@latin]=Kdeona školjka za Plasmu
GenericName[sv]=Ett delprogramskal för Plasma
GenericName[tr]=Plasma için bir KPart kabuğu
GenericName[uk]=Оболонка модулів для Плазми
GenericName[x-test]=xxA KPart shell for Plasmaxx
GenericName[zh_CN]=Plasma KPart
GenericName[zh_TW]=Plasma KPart shell
Terminal=false

View File

@ -1,31 +0,0 @@
<!DOCTYPE kpartgui SYSTEM "kpartgui.dtd">
<kpartgui name="plasma-kpart-shell" version="2">
<MenuBar>
<Menu noMerge="1" name="file"><text>&amp;File</text>
<Action name="file_new"/>
<Action name="file_open"/>
<Separator/>
<Merge/>
<Separator/>
<Action name="file_quit"/>
</Menu>
<Menu noMerge="1" name="settings"><text>&amp;Settings</text>
<Action name="options_show_toolbar"/>
<Action name="options_show_statusbar"/>
<Merge name="show_merge"/>
<Separator/>
<Action name="options_configure_keybinding"/>
<Action name="options_configure_toolbars"/>
<Action name="options_configure"/>
<Merge name="configure_merge"/>
<Separator/>
<Merge/>
</Menu>
</MenuBar>
<ToolBar noMerge="1" name="mainToolBar"><text>Main Toolbar</text>
<Action name="file_new"/>
<Merge/>
<Action name="help"/>
</ToolBar>
</kpartgui>

View File

@ -1,49 +0,0 @@
/*
* Copyright 2010 Ryan Rix <ry@n.rix.si>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Library General Public License version 2 as
* published by the Free Software Foundation
*
* 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 Library 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 "testshellpluginloader.h"
#include <KDebug>
#include <Plasma/Plasma>
#include <Plasma/Applet>
#include <Plasma/Service>
#include <Plasma/DataEngine>
TestShellPluginLoader::~TestShellPluginLoader()
{
}
Plasma::Applet *TestShellPluginLoader::internalLoadApplet(const QString &name, uint appletId, const QVariantList &args)
{
kDebug() << "loadApplet called with" << name << appletId << args;
return 0;
}
Plasma::DataEngine *TestShellPluginLoader::internalLoadDataEngine(const QString &name)
{
kDebug() << "loadEngine called with" << name;
return 0;
}
Plasma::Service *TestShellPluginLoader::internalLoadService(const QString &name, const QVariantList &args, QObject *parent)
{
kDebug() << "loadService called with" << name << args << parent;
return 0;
}

View File

@ -1,35 +0,0 @@
/*
* Copyright 2010 Ryan Rix <ry@n.rix.si>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Library General Public License version 2 as
* published by the Free Software Foundation
*
* 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 Library 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 TESTSHELLPLUGINLOADER_H
#define TESTSHELLPLUGINLOADER_H
#include <plasma/pluginloader.h>
class TestShellPluginLoader : public Plasma::PluginLoader
{
public:
~TestShellPluginLoader();
Plasma::Applet *internalLoadApplet(const QString &name, uint appletId = 0,
const QVariantList &args = QVariantList());
Plasma::DataEngine *internalLoadDataEngine(const QString &name);
Plasma::Service *internalLoadService(const QString &name, const QVariantList &args, QObject *parent = 0);
};
#endif

View File

@ -1,7 +1,6 @@
add_subdirectory(desktoptheme)
add_subdirectory(plasma)
add_subdirectory(declarativeimports)
#add_subdirectory(kpart)
add_subdirectory(plasmapkg)
add_subdirectory(scriptengines)
add_subdirectory(plasmaquick)

View File

@ -1,22 +0,0 @@
set(plasma_kpartscripting_SRCS
scripting/layouttemplatepackagestructure.cpp
scripting/rect.cpp
scripting/scriptengine.cpp
scripting/widget.cpp
)
set(plasma_kpart_SRCS
${plasma_kpartscripting_SRCS}
plasmakpartcorona.cpp
plasmakpartview.cpp
plasmakpart.cpp
)
add_library(plasma-kpart MODULE ${plasma_kpart_SRCS})
target_link_libraries(plasma-kpart Qt5::Script KF5::Plasma KF5::KIOCore KF5::KIOWidgets ${X11_LIBRARIES} KF5::Parts )
install(TARGETS plasma-kpart DESTINATION ${KDE_INSTALL_PLUGINDIR})
install(FILES plasma-kpart.desktop DESTINATION ${KDE_INSTALL_KSERVICES5DIR})

View File

@ -1,7 +0,0 @@
=== What ===
This is a generic shell that can be embedded in any KDE application
which supports KParts to provide easy capabilities to add a plasma-based
dashboard to their application.
=== How can I use this code? ===
See http://techbase.kde.org/Development/Tutorials/Plasma/ApplicationShell

View File

@ -1,3 +0,0 @@
[Project]
Manager=KDevCMakeManager
Name=kpart

View File

@ -1,46 +0,0 @@
[Desktop Entry]
Name=plasma-kpart
Name[ast]=plasma-kpart
Name[bs]=plasma-kpart
Name[ca]=plasma-kpart
Name[ca@valencia]=plasma-kpart
Name[cs]=plasma-kpart
Name[da]=plasma-kpart
Name[de]=plasma-kpart
Name[en_GB]=plasma-kpart
Name[es]=plasma-kpart
Name[fi]=plasma-kpart
Name[fr]=plasma-kpart
Name[gd]=plasma-kpart
Name[gl]=plasma-kpart
Name[hu]=plasma-kpart
Name[ia]=plasma-kpart
Name[it]=plasma-kpart
Name[ko]=plasma-kpart
Name[lt]=plasma-kpart
Name[mr]=-kpart
Name[nb]=plasma-kpart
Name[nds]=Plasma-KPart
Name[nl]=plasma-kpart
Name[nn]=plasma-kpart
Name[pa]=plasma-kpart
Name[pl]=plasma-kpart
Name[pt]=plasma-kpart
Name[pt_BR]=plasma-kpart
Name[ru]=plasma-kpart
Name[sk]=plasma-kpart
Name[sl]=plasma-kpart
Name[sr]=plasma-kpart
Name[sr@ijekavian]=plasma-kpart
Name[sr@ijekavianlatin]=plasma-kpart
Name[sr@latin]=plasma-kpart
Name[sv]=Plasma-delprogram
Name[tr]=plasma-kpart
Name[ug]=plasma-kpart
Name[uk]=plasma-kpart
Name[x-test]=xxplasma-kpartxx
Name[zh_CN]=plasma-kpart
Name[zh_TW]=plasma-kpart
Type=Service
ServiceTypes=KParts/Part
X-KDE-Library=plasma-kpart

View File

@ -1,165 +0,0 @@
/*
* Copyright 2006-2008 Aaron Seigo <aseigo@kde.org>
* Copyright 2009 Marco Martin <notmart@gmail.com>
* Copyright 2010 Ryan Rix <ry@n.rix.si>
* Copyright 2010 Siddharth Sharma <siddharth.kde@gmail.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Library General Public License as
* published by the Free Software Foundation; either version 2, 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 Library 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 "plasmakpart.h"
#include <QCheckBox>
#include <QFile>
#include <QHash>
#include <QGraphicsProxyWidget>
#include <QGraphicsLinearLayout>
#include <QTimer>
#include <QDebug>
#include <KStandardDirs>
#include <Plasma/Containment>
#include <Plasma/Theme>
#include <Plasma/Applet>
#include <Plasma/Wallpaper>
#include <plasma/pluginloader.h>
#include "plasmakpartcorona.h"
#include "plasmakpartview.h"
K_PLUGIN_FACTORY(plasmaKPartFactory, registerPlugin<PlasmaKPart>();)
PlasmaKPart::PlasmaKPart(QWidget *parentWidget, QObject *parent, const QVariantList &args)
: KParts::ReadOnlyPart(parent),
m_corona(0),
m_view(new PlasmaKPartView(0, 1))
{
setComponentData(plasmaKPartFactory::componentData());
KGlobal::locale()->insertCatalog("libplasma");
KGlobal::locale()->insertCatalog("plasmagenericshell");
KGlobal::locale()->insertCatalog("plasma-kpart");
setThemeDefaults();
setWidget(m_view);
// initialize the plugin loader
if (args.length() > 0) {
Plasma::PluginLoader *loader = qVariantValue<Plasma::PluginLoader *>(args.first());
if (loader) {
Plasma::PluginLoader::setPluginLoader(loader);
}
}
setAutoDeletePart(false);
QTimer::singleShot(0, this, SLOT(initCorona()));
}
PlasmaKPart::~PlasmaKPart()
{
delete m_view;
m_view = 0;
if (!m_configFile.isEmpty()) {
m_corona->saveLayout();
}
delete m_corona;
m_corona = 0;
//TODO: This manual sync() should not be necessary?
syncConfig();
}
void PlasmaKPart::setThemeDefaults()
{
KConfigGroup cg(KSharedConfig::openConfig("plasmarc"), "Theme-plasma-kpart");
const QString themeName = cg.readEntry("name", "appdashboard");
Plasma::Theme::defaultTheme()->setUseGlobalSettings(false);
Plasma::Theme::defaultTheme()->setThemeName(themeName);
cg = KConfigGroup(KSharedConfig::openConfig(), "General");
Plasma::Theme::defaultTheme()->setFont(cg.readEntry("desktopFont", QFont("Sans")));
}
void PlasmaKPart::syncConfig()
{
KSharedConfig::openConfig()->sync();
}
void PlasmaKPart::initCorona()
{
if (m_corona) {
return;
}
m_corona = new PlasmaKPartCorona(this);
connect(m_corona, SIGNAL(containmentAdded(Plasma::Containment*)), this, SLOT(createView(Plasma::Containment*)));
connect(m_corona, SIGNAL(configSynced()), this, SLOT(syncConfig()));
m_corona->setItemIndexMethod(QGraphicsScene::NoIndex);
m_corona->initializeLayout(m_configFile);
m_view->show();
}
PlasmaKPartCorona *PlasmaKPart::corona() const
{
Q_ASSERT(m_corona);
return m_corona;
}
void PlasmaKPart::createView(Plasma::Containment *containment)
{
Q_ASSERT(containment);
m_view->setContainment(containment);
}
void PlasmaKPart::addApplet(const QString &name, const QVariantList &args, const QRectF &geometry)
{
Q_ASSERT(containment());
containment()->createApplet(name, args, geometry);
}
Plasma::Applet::List PlasmaKPart::listActiveApplets() const
{
return containment()->applets();
}
QString PlasmaKPart::configFile() const
{
return m_configFile;
}
void PlasmaKPart::setConfigFile(const QString &file)
{
m_configFile = file;
if (m_corona && QFile::exists(m_configFile)) {
m_corona->initializeLayout(m_configFile);
}
}
Plasma::Containment *PlasmaKPart::containment() const
{
Q_ASSERT(corona());
Q_ASSERT(!corona()->containments().isEmpty());
return corona()->containments().first();
}
#include "plasmakpart.moc"

View File

@ -1,100 +0,0 @@
/*
* Copyright 2006-2008 Aaron Seigo <aseigo@kde.org>
* Copyright 2009 Marco Martin <notmart@gmail.com>
* Copyright 2010 Ryan Rix <ry@n.rix.si>
* Copyright 2010 Siddharth Sharma <siddharth.kde@gmail.com>
*
* 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,
* 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 Library 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 PLASMAKPART_H
#define PLASMAKPART_H
class PlasmaKPartView;
class PlasmaKPartCorona;
#include <Plasma/Containment>
Q_DECLARE_METATYPE(Plasma::Containment *)
namespace Plasma
{
class Applet;
class PluginLoader;
}
#include <KDE/KParts/Part>
#include <QtCore/QHash>
class QVariant;
class QVBoxLayout;
class PlasmaKPart : public KParts::ReadOnlyPart
{
Q_OBJECT
Q_PROPERTY(Plasma::Applet::List activeApplets READ listActiveApplets)
Q_PROPERTY(QString configFile READ configFile WRITE setConfigFile)
public:
/**
* The default constructor.
* The args may contain a pointer to a Plasma::PluginLoader as the first parameter.
* Note that only one Plasma::PluginLoader can be active at a time, and that the
* prefered mechanism for registering the plugin loader is via
* Plasma::PluginLoader::setPluginLoader
*/
PlasmaKPart(QWidget *parentWidget, QObject *parent, const QVariantList &args);
~PlasmaKPart();
void notifyStartup(bool completed);
PlasmaKPartCorona *corona() const;
Plasma::Containment *containment() const;
/**
* Returns a list of active applets in the containment.
*
* @return A list of the containment's Applets
**/
Plasma::Applet::List listActiveApplets() const;
QString configFile() const;
void setConfigFile(const QString &file);
public Q_SLOTS:
/**
* Add an applet to the currently running containment.
*
* @short Add an applet to the containment
* @author Ryan Rix <ry@n.rix.si>
* @version 0.01
**/
void addApplet(const QString &pluginName, const QVariantList &args = QVariantList(), const QRectF &dimensions = QRectF());
private Q_SLOTS:
void initCorona();
void syncConfig();
void createView(Plasma::Containment *containment);
void setThemeDefaults();
private:
PlasmaKPartCorona *m_corona;
PlasmaKPartView *m_view;
QHash<QString, Plasma::Applet *> *m_appletList;
QVBoxLayout *m_configLayout;
QString m_configFile;
};
#endif // multiple inclusion guard

View File

@ -1,81 +0,0 @@
/*
* Copyright 2008 Aaron Seigo <aseigo@kde.org>
* Copyright 2010 Ryan Rix <ry@n.rix.si>
* Copyright 2010 Siddharth Sharma <siddharth.kde@gmail.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Library General Public License as
* published by the Free Software Foundation; either version 2, 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 Library 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 "plasmakpartcorona.h"
#include "plasmakpart.h"
#include <QDebug>
#include <Plasma/Containment>
#include <qaction.h>
#include <qfile.h>
#include "scripting/scriptengine.h"
PlasmaKPartCorona::PlasmaKPartCorona(QObject *parent)
: Plasma::Corona(parent)
{
enableAction("Lock Widgets", false);
enableAction("Shortcut Settings", false);
setDefaultContainmentPlugin("newspaper");
}
void PlasmaKPartCorona::loadDefaultLayout()
{
// used to force a save into the config file
Plasma::Containment *c = createContainment(QString());
if (!c) {
// do some error reporting?
return;
}
evaluateScripts(PlasmaKPartScripting::ScriptEngine::defaultLayoutScripts());
requestConfigSync();
}
void PlasmaKPartCorona::evaluateScripts(const QStringList &scripts)
{
foreach (const QString &script, scripts) {
PlasmaKPartScripting::ScriptEngine scriptEngine(this);
connect(&scriptEngine, SIGNAL(printError(QString)), this, SLOT(printScriptError(QString)));
connect(&scriptEngine, SIGNAL(print(QString)), this, SLOT(printScriptMessage(QString)));
QFile file(script);
if (file.open(QIODevice::ReadOnly | QIODevice::Text)) {
QString code = file.readAll();
// qDebug() << "evaluating startup script:" << script;
scriptEngine.evaluateScript(code);
}
}
}
void PlasmaKPartCorona::printScriptError(const QString &error)
{
qWarning() << "Startup script error:" << error;
}
void PlasmaKPartCorona::printScriptMessage(const QString &error)
{
// qDebug() << "Startup script: " << error;
}

View File

@ -1,53 +0,0 @@
/*
* Copyright 2008 Aaron Seigo <aseigo@kde.org>
* Copyright 2010 Ryan Rix <ry@n.rix.si>
* Copyright 2010 Siddharth Sharma <siddharth.kde@gmail.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Library General Public License as
* published by the Free Software Foundation; either version 2, 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 Library 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 PLASMAKPARTCORONA_H
#define PLASMAKPARTCORONA_H
#include <Plasma/Corona>
namespace Plasma
{
class Applet;
} // namespace Plasma
/**
* @short A Corona with dashboard-y considerations
*/
class PlasmaKPartCorona : public Plasma::Corona
{
Q_OBJECT
public:
PlasmaKPartCorona(QObject *parent);
protected:
void loadDefaultLayout();
void evaluateScripts(const QStringList &scripts);
private Q_SLOTS:
void printScriptError(const QString &error);
void printScriptMessage(const QString &error);
private:
Plasma::Applet *loadDefaultApplet(const QString &pluginName, Plasma::Containment *c);
};
#endif

View File

@ -1,87 +0,0 @@
/*
* Copyright 2007-2008 Aaron Seigo <aseigo@kde.org>
* Copyright 2010 Ryan Rix <ry@n.rix.si>
* Copyright 2010 Siddharth Sharma <siddharth.kde@gmail.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Library General Public License version 2 as
* published by the Free Software Foundation
*
* 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 Library 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 "plasmakpartview.h"
#include "plasmakpartcorona.h"
#include <QDebug>
#include <Plasma/Applet>
#include <Plasma/Containment>
PlasmaKPartView::PlasmaKPartView(Plasma::Containment *containment, int uid, QWidget *parent)
: Plasma::View(containment, uid, parent),
m_configurationMode(false)
{
setFocusPolicy(Qt::NoFocus);
connectContainment(containment);
setWallpaperEnabled(false);
viewport()->setAutoFillBackground(false);
setAutoFillBackground(false);
}
PlasmaKPartView::~PlasmaKPartView()
{
}
void PlasmaKPartView::connectContainment(Plasma::Containment *containment)
{
if (!containment) {
return;
}
connect(this, SIGNAL(sceneRectAboutToChange()), this, SLOT(updateGeometry()));
connect(containment, SIGNAL(toolBoxVisibilityChanged(bool)), this, SLOT(updateConfigurationMode(bool)));
}
void PlasmaKPartView::setContainment(Plasma::Containment *c)
{
if (containment()) {
disconnect(containment(), 0, this, 0);
}
Plasma::View::setContainment(c);
connectContainment(c);
updateGeometry();
}
void PlasmaKPartView::resizeEvent(QResizeEvent *event)
{
Q_UNUSED(event)
updateGeometry();
emit geometryChanged();
}
void PlasmaKPartView::updateGeometry()
{
Plasma::Containment *c = containment();
if (!c) {
return;
}
// qDebug() << "New containment geometry is" << c->geometry();
if (c->size().toSize() != size()) {
c->setMaximumSize(size());
c->setMinimumSize(size());
c->resize(size());
}
}

View File

@ -1,64 +0,0 @@
/*
* Copyright 2007-2008 Aaron Seigo <aseigo@kde.org>
* Copyright 2010 Ryan Rix <ry@n.rix.si>
* Copyright 2010 Siddharth Sharma <siddharth.kde@gmail.com>
*
* 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,
* 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 Library 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 PLASMAKPARTVIEW_H
#define PLASMAKPARTVIEW_H
#include <Plasma/Plasma>
#include <Plasma/View>
namespace Plasma
{
class Containment;
} // namespace Plasma
class PlasmaKPartView : public Plasma::View
{
Q_OBJECT
public:
typedef Plasma::Types::ImmutabilityType ImmutabilityType;
PlasmaKPartView(Plasma::Containment *containment, int uid, QWidget *parent = 0);
~PlasmaKPartView();
/**
* hook up all needed signals to a containment
*/
void connectContainment(Plasma::Containment *containment);
bool autoHide() const;
public Q_SLOTS:
void setContainment(Plasma::Containment *containment);
void updateGeometry();
Q_SIGNALS:
void containmentActivated();
void autoHideChanged(bool autoHide);
void geometryChanged();
protected:
void resizeEvent(QResizeEvent *event);
private:
bool m_configurationMode;
};
#endif // multiple inclusion guard

View File

@ -1,367 +0,0 @@
/****************************************************************************
**
** Copyright (C) 1992-2007 Trolltech ASA. All rights reserved.
**
** This file is part of the plugins of the Qt Toolkit.
**
** This file may be used under the terms of the GNU General Public
** License version 2.0 as published by the Free Software Foundation
** and appearing in the file LICENSE.GPL included in the packaging of
** this file. Please review the following information to ensure GNU
** General Public Licensing requirements will be met:
** http://trolltech.com/products/qt/licenses/licensing/opensource/
**
** If you are unsure which license is appropriate for your use, please
** review the following information:
** http://trolltech.com/products/qt/licenses/licensing/licensingoverview
** or contact the sales department at sales@trolltech.com.
**
** In addition, as a special exception, Trolltech gives you certain
** additional rights. These rights are described in the Trolltech GPL
** Exception version 1.0, which can be found at
** http://www.trolltech.com/products/qt/gplexception/ and in the file
** GPL_EXCEPTION.txt in this package.
**
** In addition, as a special exception, Trolltech, as the sole copyright
** holder for Qt Designer, grants users of the Qt/Eclipse Integration
** plug-in the right for the Qt/Eclipse Integration to link to
** functionality provided by Qt Designer and its related libraries.
**
** Trolltech reserves all rights not expressly granted herein.
**
** Trolltech ASA (c) 2007
**
** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
**
****************************************************************************/
#ifndef QTSCRIPTEXTENSIONS_GLOBAL_H
#define QTSCRIPTEXTENSIONS_GLOBAL_H
#include <QtCore/QSharedData>
#include <QScriptEngine>
#define DECLARE_SELF(Class, __fn__) \
Class* self = qscriptvalue_cast<Class*>(ctx->thisObject()); \
if (!self) { \
return ctx->throwError(QScriptContext::TypeError, \
QString::fromLatin1("%0.prototype.%1: this object is not a %0") \
.arg(#Class).arg(#__fn__)); \
}
#define DECLARE_SELF2(Class, __fn__, __ret__) \
Class* self = qscriptvalue_cast<Class*>(thisObject()); \
if (!self) { \
context()->throwError(QScriptContext::TypeError, \
QString::fromLatin1("%0.prototype.%1: this object is not a %0") \
.arg(#Class).arg(#__fn__)); \
return __ret__; \
}
#define ADD_METHOD(__p__, __f__) \
__p__.setProperty(#__f__, __p__.engine()->newFunction(__f__))
#define ADD_GET_METHOD(__p__, __get__) \
ADD_METHOD(__p__, __get__)
#define ADD_GET_SET_METHODS(__p__, __get__, __set__) \
do { \
ADD_METHOD(__p__, __get__); \
ADD_METHOD(__p__, __set__); \
} while (0);
#define ADD_CTOR_FUNCTION(__c__, __f__) ADD_METHOD(__c__, __f__)
#define ADD_ENUM_VALUE(__c__, __ns__, __v__) \
__c__.setProperty(#__v__, QScriptValue(__c__.engine(), __ns__::__v__))
#define BEGIN_DECLARE_METHOD(Class, __mtd__) \
static QScriptValue __mtd__(QScriptContext *ctx, QScriptEngine *eng) \
{ \
DECLARE_SELF(Class, __mtd__);
#define END_DECLARE_METHOD \
}
#define DECLARE_GET_METHOD(Class, __get__) \
BEGIN_DECLARE_METHOD(Class, __get__) { \
return qScriptValueFromValue(eng, self->__get__()); \
} END_DECLARE_METHOD
#define DECLARE_SET_METHOD(Class, T, __set__) \
BEGIN_DECLARE_METHOD(Class, __set__) { \
self->__set__(qscriptvalue_cast<T>(ctx->argument(0))); \
return eng->undefinedValue(); \
} END_DECLARE_METHOD
#define DECLARE_GET_SET_METHODS(Class, T, __get__, __set__) \
DECLARE_GET_METHOD(Class, /*T,*/ __get__) \
DECLARE_SET_METHOD(Class, T, __set__)
#define DECLARE_SIMPLE_GET_METHOD(Class, __get__) \
BEGIN_DECLARE_METHOD(Class, __get__) { \
return QScriptValue(eng, self->__get__()); \
} END_DECLARE_METHOD
#define DECLARE_SIMPLE_SET_METHOD(Class, ToType, __set__) \
BEGIN_DECLARE_METHOD(Class, __set__) { \
self->__set__(ctx->argument(0).ToType()); \
return eng->undefinedValue(); \
} END_DECLARE_METHOD
#define DECLARE_BOOLEAN_GET_METHOD(Class, __set__) \
DECLARE_SIMPLE_GET_METHOD(Class, __set__)
#define DECLARE_BOOLEAN_SET_METHOD(Class, __set__) \
DECLARE_SIMPLE_SET_METHOD(Class, toBoolean, __set__)
#define DECLARE_INT_GET_METHOD(Class, __set__) \
DECLARE_SIMPLE_GET_METHOD(Class, __set__)
#define DECLARE_INT_SET_METHOD(Class, __set__) \
DECLARE_SIMPLE_SET_METHOD(Class, toInt32, __set__)
#define DECLARE_NUMBER_GET_METHOD(Class, __set__) \
DECLARE_SIMPLE_GET_METHOD(Class, __set__)
#define DECLARE_NUMBER_SET_METHOD(Class, __set__) \
DECLARE_SIMPLE_SET_METHOD(Class, toNumber, __set__)
#define DECLARE_STRING_GET_METHOD(Class, __set__) \
DECLARE_SIMPLE_GET_METHOD(Class, __set__)
#define DECLARE_STRING_SET_METHOD(Class, __set__) \
DECLARE_SIMPLE_SET_METHOD(Class, toString, __set__)
#define DECLARE_QOBJECT_GET_METHOD(Class, __get__) \
BEGIN_DECLARE_METHOD(Class, __get__) { \
return eng->newQObject(self->__get__()); \
} END_DECLARE_METHOD
#define DECLARE_QOBJECT_SET_METHOD(Class, __set__) \
DECLARE_SIMPLE_SET_METHOD(Class, toQObject, __set__)
#define DECLARE_BOOLEAN_GET_SET_METHODS(Class, __get__, __set__) \
DECLARE_BOOLEAN_GET_METHOD(Class, __get__) \
DECLARE_BOOLEAN_SET_METHOD(Class, __set__)
#define DECLARE_NUMBER_GET_SET_METHODS(Class, __get__, __set__) \
DECLARE_NUMBER_GET_METHOD(Class, __get__) \
DECLARE_NUMBER_SET_METHOD(Class, __set__)
#define DECLARE_INT_GET_SET_METHODS(Class, __get__, __set__) \
DECLARE_INT_GET_METHOD(Class, __get__) \
DECLARE_INT_SET_METHOD(Class, __set__)
#define DECLARE_STRING_GET_SET_METHODS(Class, __get__, __set__) \
DECLARE_STRING_GET_METHOD(Class, __get__) \
DECLARE_STRING_SET_METHOD(Class, __set__)
#define DECLARE_QOBJECT_GET_SET_METHODS(Class, __get__, __set__) \
DECLARE_QOBJECT_GET_METHOD(Class, __get__) \
DECLARE_QOBJECT_SET_METHOD(Class, __set__)
#define DECLARE_VOID_METHOD(Class, __fun__) \
BEGIN_DECLARE_METHOD(Class, __fun__) { \
self->__fun__(); \
return eng->undefinedValue(); \
} END_DECLARE_METHOD
#define DECLARE_VOID_NUMBER_METHOD(Class, __fun__) \
BEGIN_DECLARE_METHOD(Class, __fun__) { \
self->__fun__(ctx->argument(0).toNumber()); \
return eng->undefinedValue(); \
} END_DECLARE_METHOD
#define DECLARE_VOID_NUMBER_NUMBER_METHOD(Class, __fun__) \
BEGIN_DECLARE_METHOD(Class, __fun__) { \
self->__fun__(ctx->argument(0).toNumber(), ctx->argument(1).toNumber()); \
return eng->undefinedValue(); \
} END_DECLARE_METHOD
#define DECLARE_VOID_QUAD_NUMBER_METHOD(Class, __fun__) \
BEGIN_DECLARE_METHOD(Class, __fun__) { \
self->__fun__(ctx->argument(0).toNumber(), ctx->argument(1).toNumber(), ctx->argument(2).toNumber(), ctx->argument(3).toNumber()); \
return eng->undefinedValue(); \
} END_DECLARE_METHOD
#define DECLARE_VOID_1ARG_METHOD(Class, ArgType, __fun__) \
BEGIN_DECLARE_METHOD(Class, __fun__) { \
self->__fun__(qscriptvalue_cast<ArgType>(ctx->argument(0))); \
return eng->undefinedValue(); \
} END_DECLARE_METHOD
#define DECLARE_BOOLEAN_1ARG_METHOD(Class, ArgType, __fun__) \
BEGIN_DECLARE_METHOD(Class, __fun__) { \
return QScriptValue(eng, self->__fun__(qscriptvalue_cast<ArgType>(ctx->argument(0)))); \
} END_DECLARE_METHOD
#define DECLARE_POINTER_METATYPE(T) \
Q_DECLARE_METATYPE(T*) \
Q_DECLARE_METATYPE(QScript::Pointer<T>::wrapped_pointer_type)
namespace QScript
{
enum {
UserOwnership = 1
};
template <typename T>
class Pointer : public QSharedData
{
public:
typedef T *pointer_type;
typedef QExplicitlySharedDataPointer<Pointer<T> > wrapped_pointer_type;
~Pointer()
{
if (!(m_flags & UserOwnership)) {
delete m_value;
}
}
operator T *()
{
return m_value;
}
operator const T *() const
{
return m_value;
}
static wrapped_pointer_type create(T *value, uint flags = 0)
{
return wrapped_pointer_type(new Pointer(value, flags));
}
static QScriptValue toScriptValue(QScriptEngine *engine, T *const &source)
{
if (!source) {
return engine->nullValue();
}
return engine->newVariant(qVariantFromValue(source));
}
static void fromScriptValue(const QScriptValue &value, T *&target)
{
if (value.isVariant()) {
QVariant var = value.toVariant();
if (qVariantCanConvert<T *>(var)) {
target = qvariant_cast<T *>(var);
} else if (qVariantCanConvert<wrapped_pointer_type>(var)) {
target = qvariant_cast<wrapped_pointer_type>(var)->operator T * ();
} else {
// look in prototype chain
target = 0;
int type = qMetaTypeId<T *>();
int pointerType = qMetaTypeId<wrapped_pointer_type>();
QScriptValue proto = value.prototype();
while (proto.isObject() && proto.isVariant()) {
int protoType = proto.toVariant().userType();
if ((type == protoType) || (pointerType == protoType)) {
QByteArray name = QMetaType::typeName(var.userType());
if (name.startsWith("QScript::Pointer<")) {
target = (*reinterpret_cast<wrapped_pointer_type *>(var.data()))->operator T * ();
break;
} else {
target = static_cast<T *>(var.data());
break;
}
}
proto = proto.prototype();
}
}
} else if (value.isQObject()) {
QObject *qobj = value.toQObject();
QByteArray typeName = QMetaType::typeName(qMetaTypeId<T *>());
target = reinterpret_cast<T *>(qobj->qt_metacast(typeName.left(typeName.size() - 1)));
} else {
target = 0;
}
}
uint flags() const
{
return m_flags;
}
void setFlags(uint flags)
{
m_flags = flags;
}
void unsetFlags(uint flags)
{
m_flags &= ~flags;
}
protected:
Pointer(T *value, uint flags)
: m_flags(flags), m_value(value)
{}
private:
uint m_flags;
T *m_value;
};
template <typename T>
int registerPointerMetaType(
QScriptEngine *eng,
const QScriptValue &prototype = QScriptValue(),
T * /* dummy */ = 0
)
{
QScriptValue(*mf)(QScriptEngine *, T * const &) = Pointer<T>::toScriptValue;
void (*df)(const QScriptValue &, T *&) = Pointer<T>::fromScriptValue;
const int id = qMetaTypeId<T *>();
qScriptRegisterMetaType_helper(
eng, id, reinterpret_cast<QScriptEngine::MarshalFunction>(mf),
reinterpret_cast<QScriptEngine::DemarshalFunction>(df),
prototype);
eng->setDefaultPrototype(qMetaTypeId<typename Pointer<T>::wrapped_pointer_type>(), prototype);
return id;
}
inline void maybeReleaseOwnership(const QScriptValue &value)
{
if (value.isVariant()) {
QVariant var = value.toVariant();
QByteArray name = QMetaType::typeName(var.userType());
if (name.startsWith("QScript::Pointer<")) {
(*reinterpret_cast<Pointer<void *>::wrapped_pointer_type *>(var.data()))->setFlags(UserOwnership);
}
}
}
inline void maybeTakeOwnership(const QScriptValue &value)
{
if (value.isVariant()) {
QVariant var = value.toVariant();
QByteArray name = QMetaType::typeName(var.userType());
if (name.startsWith("QScript::Pointer<")) {
(*reinterpret_cast<Pointer<void *>::wrapped_pointer_type *>(var.data()))->unsetFlags(UserOwnership);
}
}
}
template <class T>
inline QScriptValue wrapPointer(QScriptEngine *eng, T *ptr, uint flags = 0)
{
return eng->newVariant(qVariantFromValue(Pointer<T>::create(ptr, flags)));
}
} // namespace QScript
#ifdef QGRAPHICSITEM_H
namespace QScript
{
template <class T>
inline QScriptValue wrapGVPointer(QScriptEngine *eng, T *item)
{
uint flags = item->parentItem() ? UserOwnership : 0;
return wrapPointer<T>(eng, item, flags);
}
} // namespace QScript
#endif // QGRAPHICSITEM_H
#endif // QTSCRIPTEXTENSIONS_GLOBAL_H

View File

@ -1,41 +0,0 @@
/*
* Copyright 2010 Aaron Seigo <aseigo@kde.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Library General Public License as
* published by the Free Software Foundation; either version 2, 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 Library 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 "layouttemplatepackagestructure.h"
namespace PlasmaKPartScripting
{
LayoutTemplatePackageStructure::LayoutTemplatePackageStructure(QObject *parent)
: Plasma::PackageStructure(parent)
{
setServicePrefix("plasma-layout-template");
setDefaultPackageRoot(PLASMA_RELATIVE_DATA_INSTALL_DIR "/layout-templates");
addFileDefinition("mainscript", "layout.js", "Main Script File");
setRequired("mainscript", true);
}
LayoutTemplatePackageStructure::~LayoutTemplatePackageStructure()
{
}
}

View File

@ -1,40 +0,0 @@
/*
* Copyright 2010 Aaron Seigo <aseigo@kde.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Library General Public License as
* published by the Free Software Foundation; either version 2, 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 Library 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 TEMPLATETEMPLATEPACKAGE_H
#define TEMPLATETEMPLATEPACKAGE_H
#include <Plasma/PackageStructure>
namespace PlasmaKPartScripting
{
class LayoutTemplatePackageStructure : public Plasma::PackageStructure
{
Q_OBJECT
public:
LayoutTemplatePackageStructure(QObject *parent = 0);
~LayoutTemplatePackageStructure();
};
}
#endif

View File

@ -1,325 +0,0 @@
/*
* Copyright 2007 Richard J. Moore <rich@kde.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Library General Public License version 2 as
* published by the Free Software Foundation
*
* 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 Library 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 <QtCore/QRectF>
#include "backportglobal.h"
Q_DECLARE_METATYPE(QRectF *)
Q_DECLARE_METATYPE(QRectF)
static QScriptValue ctor(QScriptContext *ctx, QScriptEngine *eng)
{
if (ctx->argumentCount() == 4) {
qreal x = ctx->argument(0).toNumber();
qreal y = ctx->argument(1).toNumber();
qreal width = ctx->argument(2).toNumber();
qreal height = ctx->argument(3).toNumber();
return qScriptValueFromValue(eng, QRectF(x, y, width, height));
}
return qScriptValueFromValue(eng, QRectF());
}
static QScriptValue adjust(QScriptContext *ctx, QScriptEngine *)
{
DECLARE_SELF(QRectF, adjust);
qreal dx1 = ctx->argument(0).toNumber();
qreal dy1 = ctx->argument(1).toNumber();
qreal dx2 = ctx->argument(2).toNumber();
qreal dy2 = ctx->argument(3).toNumber();
self->adjust(dx1, dy1, dx2, dy2);
return QScriptValue();
}
static QScriptValue adjusted(QScriptContext *ctx, QScriptEngine *eng)
{
DECLARE_SELF(QRectF, adjusted);
qreal dx1 = ctx->argument(0).toNumber();
qreal dy1 = ctx->argument(1).toNumber();
qreal dx2 = ctx->argument(2).toNumber();
qreal dy2 = ctx->argument(3).toNumber();
QRectF tmp = self->adjusted(dx1, dy1, dx2, dy2);
return qScriptValueFromValue(eng, tmp);
}
static QScriptValue bottom(QScriptContext *ctx, QScriptEngine *eng)
{
DECLARE_SELF(QRectF, bottom);
if (ctx->argumentCount() > 0) {
int bottom = ctx->argument(0).toInt32();
self->setBottom(bottom);
}
return QScriptValue(eng, self->bottom());
}
static QScriptValue top(QScriptContext *ctx, QScriptEngine *eng)
{
DECLARE_SELF(QRectF, top);
if (ctx->argumentCount() > 0) {
int top = ctx->argument(0).toInt32();
self->setTop(top);
}
return QScriptValue(eng, self->top());
}
static QScriptValue contains(QScriptContext *ctx, QScriptEngine *eng)
{
DECLARE_SELF(QRectF, contains);
qreal x = ctx->argument(0).toNumber();
qreal y = ctx->argument(1).toNumber();
return QScriptValue(eng, self->contains(x, y));
}
static QScriptValue height(QScriptContext *ctx, QScriptEngine *eng)
{
DECLARE_SELF(QRectF, height);
if (ctx->argumentCount() > 0) {
int height = ctx->argument(0).toInt32();
self->setHeight(height);
}
return QScriptValue(eng, self->height());
}
static QScriptValue empty(QScriptContext *ctx, QScriptEngine *eng)
{
DECLARE_SELF(QRectF, empty);
return QScriptValue(eng, self->isEmpty());
}
static QScriptValue null(QScriptContext *ctx, QScriptEngine *eng)
{
DECLARE_SELF(QRectF, null);
return QScriptValue(eng, self->isNull());
}
static QScriptValue valid(QScriptContext *ctx, QScriptEngine *eng)
{
DECLARE_SELF(QRectF, valid);
return QScriptValue(eng, self->isValid());
}
static QScriptValue left(QScriptContext *ctx, QScriptEngine *eng)
{
DECLARE_SELF(QRectF, left);
if (ctx->argumentCount() > 0) {
int left = ctx->argument(0).toInt32();
self->setLeft(left);
}
return QScriptValue(eng, self->left());
}
static QScriptValue moveBottom(QScriptContext *ctx, QScriptEngine *)
{
DECLARE_SELF(QRectF, moveBottom);
qreal bottom = ctx->argument(0).toNumber();
self->moveBottom(bottom);
return QScriptValue();
}
static QScriptValue moveLeft(QScriptContext *ctx, QScriptEngine *)
{
DECLARE_SELF(QRectF, moveLeft);
qreal left = ctx->argument(0).toNumber();
self->moveBottom(left);
return QScriptValue();
}
static QScriptValue moveRight(QScriptContext *ctx, QScriptEngine *)
{
DECLARE_SELF(QRectF, moveRight);
qreal right = ctx->argument(0).toNumber();
self->moveBottom(right);
return QScriptValue();
}
static QScriptValue moveTo(QScriptContext *ctx, QScriptEngine *)
{
DECLARE_SELF(QRectF, moveTo);
qreal x = ctx->argument(0).toNumber();
qreal y = ctx->argument(1).toNumber();
self->moveTo(x, y);
return QScriptValue();
}
static QScriptValue moveTop(QScriptContext *ctx, QScriptEngine *)
{
DECLARE_SELF(QRectF, moveTop);
qreal top = ctx->argument(0).toNumber();
self->moveTop(top);
return QScriptValue();
}
static QScriptValue right(QScriptContext *ctx, QScriptEngine *eng)
{
DECLARE_SELF(QRectF, right);
if (ctx->argumentCount() > 0) {
int right = ctx->argument(0).toInt32();
self->setRight(right);
}
return QScriptValue(eng, self->right());
}
static QScriptValue setCoords(QScriptContext *ctx, QScriptEngine *)
{
DECLARE_SELF(QRectF, setCoords);
qreal x1 = ctx->argument(0).toNumber();
qreal y1 = ctx->argument(1).toNumber();
qreal x2 = ctx->argument(2).toNumber();
qreal y2 = ctx->argument(3).toNumber();
self->setCoords(x1, y1, x2, y2);
return QScriptValue();
}
static QScriptValue setRect(QScriptContext *ctx, QScriptEngine *)
{
DECLARE_SELF(QRectF, setRect);
qreal x = ctx->argument(0).toNumber();
qreal y = ctx->argument(1).toNumber();
qreal width = ctx->argument(2).toNumber();
qreal height = ctx->argument(3).toNumber();
self->setRect(x, y, width, height);
return QScriptValue();
}
static QScriptValue translate(QScriptContext *ctx, QScriptEngine *)
{
DECLARE_SELF(QRectF, translate);
qreal dx = ctx->argument(0).toNumber();
qreal dy = ctx->argument(1).toNumber();
self->translate(dx, dy);
return QScriptValue();
}
static QScriptValue width(QScriptContext *ctx, QScriptEngine *eng)
{
DECLARE_SELF(QRectF, width);
if (ctx->argumentCount() > 0) {
int width = ctx->argument(0).toInt32();
self->setWidth(width);
}
return QScriptValue(eng, self->width());
}
static QScriptValue x(QScriptContext *ctx, QScriptEngine *eng)
{
DECLARE_SELF(QRectF, x);
if (ctx->argumentCount() > 0) {
int x = ctx->argument(0).toInt32();
self->setX(x);
}
return QScriptValue(eng, self->x());
}
static QScriptValue y(QScriptContext *ctx, QScriptEngine *eng)
{
DECLARE_SELF(QRectF, y);
if (ctx->argumentCount() > 0) {
int y = ctx->argument(0).toInt32();
self->setY(y);
}
return QScriptValue(eng, self->y());
}
/* Not Implemented Yet */
// QPointF bottomLeft () const
// QPointF bottomRight () const
// QPointF center () const
// bool contains ( const QPointF & point ) const
// bool contains ( const QRectF & rectangle ) const
// void getCoords ( qreal * x1, qreal * y1, qreal * x2, qreal * y2 ) const
// void getRect ( qreal * x, qreal * y, qreal * width, qreal * height ) const
// QRectF intersected ( const QRectF & rectangle ) const
// bool intersects ( const QRectF & rectangle ) const
// void moveBottomLeft ( const QPointF & position )
// void moveBottomRight ( const QPointF & position )
// void moveCenter ( const QPointF & position )
// void moveTo ( const QPointF & position )
// void moveTopLeft ( const QPointF & position )
// void moveTopRight ( const QPointF & position )
// QRectF normalized () const
// void setBottomLeft ( const QPointF & position )
// void setBottomRight ( const QPointF & position )
// void setSize ( const QSizeF & size )
// void setTopLeft ( const QPointF & position )
// void setTopRight ( const QPointF & position )
// QSizeF size () const
// QRect toAlignedRect () const
// QRect toRect () const
// QPointF topLeft () const
// QPointF topRight () const
// void translate ( const QPointF & offset )
// QRectF translated ( qreal dx, qreal dy ) const
// QRectF translated ( const QPointF & offset ) const
// QRectF united ( const QRectF & rectangle ) const
QScriptValue constructQRectFClass(QScriptEngine *eng)
{
QScriptValue proto = qScriptValueFromValue(eng, QRectF());
QScriptValue::PropertyFlags getter = QScriptValue::PropertyGetter;
QScriptValue::PropertyFlags setter = QScriptValue::PropertySetter;
proto.setProperty("adjust", eng->newFunction(adjust));
proto.setProperty("adjusted", eng->newFunction(adjusted), getter);
proto.setProperty("translate", eng->newFunction(translate));
proto.setProperty("setCoords", eng->newFunction(setCoords));
proto.setProperty("setRect", eng->newFunction(setRect));
proto.setProperty("contains", eng->newFunction(contains));
proto.setProperty("moveBottom", eng->newFunction(moveBottom));
proto.setProperty("moveLeft", eng->newFunction(moveLeft));
proto.setProperty("moveRight", eng->newFunction(moveRight));
proto.setProperty("moveTo", eng->newFunction(moveTo));
proto.setProperty("moveTop", eng->newFunction(moveTop));
proto.setProperty("empty", eng->newFunction(empty), getter);
proto.setProperty("null", eng->newFunction(null), getter);
proto.setProperty("valid", eng->newFunction(valid), getter);
proto.setProperty("left", eng->newFunction(left), getter | setter);
proto.setProperty("top", eng->newFunction(top), getter | setter);
proto.setProperty("bottom", eng->newFunction(bottom), getter | setter);
proto.setProperty("right", eng->newFunction(right), getter | setter);
proto.setProperty("height", eng->newFunction(height), getter | setter);
proto.setProperty("width", eng->newFunction(width), getter | setter);
proto.setProperty("x", eng->newFunction(x), getter | setter);
proto.setProperty("y", eng->newFunction(y), getter | setter);
eng->setDefaultPrototype(qMetaTypeId<QRectF>(), proto);
eng->setDefaultPrototype(qMetaTypeId<QRectF *>(), proto);
return eng->newFunction(ctor, proto);
}

View File

@ -1,376 +0,0 @@
/*
* Copyright 2009 Aaron Seigo <aseigo@kde.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Library General Public License as
* published by the Free Software Foundation; either version 2, 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 Library 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 "scriptengine.h"
#include <QFile>
#include <QFileInfo>
#include <QDebug>
#include <kdeversion.h>
#include <KServiceTypeTrader>
#include <KShell>
#include <Plasma/Applet>
#include <Plasma/Containment>
#include <Plasma/Corona>
#include <Plasma/Package>
#include <Plasma/Theme>
#include <qstandardpaths.h>
#include "widget.h"
#include "layouttemplatepackagestructure.h"
QScriptValue constructQRectFClass(QScriptEngine *engine);
namespace PlasmaKPartScripting
{
ScriptEngine::ScriptEngine(Plasma::Corona *corona, QObject *parent)
: QScriptEngine(parent),
m_corona(corona)
{
Q_ASSERT(m_corona);
m_containment = m_corona->containments().first();
Q_ASSERT(m_containment);
setupEngine();
connect(this, SIGNAL(signalHandlerException(QScriptValue)), this, SLOT(exception(QScriptValue)));
}
ScriptEngine::~ScriptEngine()
{
}
QScriptValue ScriptEngine::wrap(Plasma::Applet *w)
{
Widget *wrapper = new Widget(w);
QScriptValue v = newQObject(wrapper, QScriptEngine::ScriptOwnership,
QScriptEngine::ExcludeSuperClassProperties |
QScriptEngine::ExcludeSuperClassMethods);
return v;
}
ScriptEngine *ScriptEngine::envFor(QScriptEngine *engine)
{
return static_cast<ScriptEngine *>(engine);
}
QScriptValue ScriptEngine::print(QScriptContext *context, QScriptEngine *engine)
{
if (context->argumentCount() < 1) {
return engine->undefinedValue();
}
const QString &msg = context->argument(0).toString();
if (!msg.isEmpty()) {
emit envFor(engine)->print(msg);
}
return engine->undefinedValue();
}
QScriptValue ScriptEngine::knownWidgetTypes(QScriptContext *context, QScriptEngine *engine)
{
Q_UNUSED(context)
Q_UNUSED(engine)
QStringList widgets;
KPluginInfo::List infos = PluginLoader::self()->listAppletInfo();
foreach (const KPluginInfo &info, infos) {
widgets.append(info.pluginName());
}
return qScriptValueFromValue(engine, widgets);
}
QScriptValue ScriptEngine::fileExists(QScriptContext *context, QScriptEngine *engine)
{
Q_UNUSED(engine)
if (context->argumentCount() == 0) {
return false;
}
const QString path = context->argument(0).toString();
if (path.isEmpty()) {
return false;
}
QFile f(KShell::tildeExpand(path));
return f.exists();
}
QScriptValue ScriptEngine::loadTemplate(QScriptContext *context, QScriptEngine *engine)
{
Q_UNUSED(engine)
if (context->argumentCount() == 0) {
// qDebug() << "no arguments";
return false;
}
const QString layout = context->argument(0).toString();
if (layout.isEmpty() || layout.contains("'")) {
// qDebug() << "layout is empty";
return false;
}
const QString constraint = QString("[X-Plasma-Shell] == '%1' and [X-KDE-PluginInfo-Name] == '%2'")
.arg(KGlobal::mainComponent().componentName(), layout);
KService::List offers = KServiceTypeTrader::self()->query("Plasma/LayoutTemplate", constraint);
if (offers.isEmpty()) {
// qDebug() << "offers fail" << constraint;
return false;
}
Plasma::PackageStructure::Ptr structure(new LayoutTemplatePackageStructure);
KPluginInfo info(offers.first());
const QString path = QStandardPaths::locate(QStandardPaths::GenericDataLocation,
structure->defaultPackageRoot() + '/' + info.pluginName() + '/',
QStandardPaths::LocateDirectory);
if (path.isEmpty()) {
// qDebug() << "script path is empty";
return false;
}
Plasma::Package package(path, structure);
const QString scriptFile = package.filePath("mainscript");
if (scriptFile.isEmpty()) {
// qDebug() << "scriptfile is empty";
return false;
}
QFile file(scriptFile);
if (!file.open(QIODevice::ReadOnly | QIODevice::Text)) {
qWarning() << QString("Unable to load script file: %1").arg(path);
return false;
}
QString script = file.readAll();
if (script.isEmpty()) {
// qDebug() << "script is empty";
return false;
}
ScriptEngine *env = envFor(engine);
env->globalObject().setProperty("templateName", env->newVariant(info.name()), QScriptValue::ReadOnly | QScriptValue::Undeletable);
env->globalObject().setProperty("templateComment", env->newVariant(info.comment()), QScriptValue::ReadOnly | QScriptValue::Undeletable);
env->evaluateScript(script, path);
return true;
}
void ScriptEngine::setupEngine()
{
QScriptValue v = globalObject();
v.setProperty("print", newFunction(ScriptEngine::print));
v.setProperty("QRectF", constructQRectFClass(this));
v.setProperty("knownWidgetTypes", newFunction(ScriptEngine::fileExists));
v.setProperty("fileExists", newFunction(ScriptEngine::fileExists));
v.setProperty("loadTemplate", newFunction(ScriptEngine::loadTemplate));
v.setProperty("widgets", newFunction(ScriptEngine::widgets));
v.setProperty("addWidget", newFunction(ScriptEngine::addWidget));
v.setProperty("applicationVersion", KGlobal::mainComponent().aboutData()->version(),
QScriptValue::PropertyGetter | QScriptValue::ReadOnly | QScriptValue::Undeletable);
v.setProperty("scriptingVersion", newVariant(PLASMA_KPART_SCRIPTING_VERSION),
QScriptValue::PropertyGetter | QScriptValue::ReadOnly | QScriptValue::Undeletable);
v.setProperty("platformVersion", KDE::versionString(),
QScriptValue::PropertyGetter | QScriptValue::ReadOnly | QScriptValue::Undeletable);
setGlobalObject(v);
}
bool ScriptEngine::evaluateScript(const QString &script, const QString &path)
{
//qDebug() << "evaluating" << m_editor->toPlainText();
evaluate(script, path);
if (hasUncaughtException()) {
//qDebug() << "catch the exception!";
QString error = QString("Error: %1 at line %2\n\nBacktrace:\n%3").arg(
uncaughtException().toString(),
QString::number(uncaughtExceptionLineNumber()),
uncaughtExceptionBacktrace().join("\n "));
emit printError(error);
return false;
}
return true;
}
void ScriptEngine::exception(const QScriptValue &value)
{
//qDebug() << "exception caught!" << value.toVariant();
emit printError(value.toVariant().toString());
}
QStringList ScriptEngine::pendingUpdateScripts()
{
const QString appName = KGlobal::activeComponent().aboutData()->appName();
QStringList scripts = KGlobal::dirs()->findAllResources("data", appName + "PLASMA_RELATIVE_DATA_INSTALL_DIR /layout/updates/*.js");
QStringList scriptPaths;
if (scripts.isEmpty()) {
//qDebug() << "no update scripts";
return scriptPaths;
}
KConfigGroup cg(KSharedConfig::openConfig(), "Updates");
QStringList performed = cg.readEntry("performed", QStringList());
const QString localDir = KGlobal::dirs()->localkdedir();
const QString localXdgDir = KGlobal::dirs()->localxdgdatadir();
foreach (const QString &script, scripts) {
if (performed.contains(script)) {
continue;
}
if (script.startsWith(localDir) || script.startsWith(localXdgDir)) {
// qDebug() << "skipping user local script: " << script;
continue;
}
scriptPaths.append(script);
performed.append(script);
}
cg.writeEntry("performed", performed);
KSharedConfig::openConfig()->sync();
return scriptPaths;
}
QStringList ScriptEngine::defaultLayoutScripts()
{
const QString appName = KGlobal::activeComponent().aboutData()->appName();
QStringList scripts = KGlobal::dirs()->findAllResources("data", appName + PLASMA_RELATIVE_DATA_INSTALL_DIR "/layout/init/*.js");
QStringList scriptPaths;
if (scripts.isEmpty()) {
//qDebug() << "no javascript based layouts";
return scriptPaths;
}
const QString localDir = KGlobal::dirs()->localkdedir();
const QString localXdgDir = KGlobal::dirs()->localxdgdatadir();
QSet<QString> scriptNames;
foreach (const QString &script, scripts) {
if (script.startsWith(localDir) || script.startsWith(localXdgDir)) {
// qDebug() << "skipping user local script: " << script;
continue;
}
QFileInfo f(script);
QString filename = f.fileName();
if (!scriptNames.contains(filename)) {
scriptNames.insert(filename);
scriptPaths.append(script);
}
}
return scriptPaths;
}
QScriptValue ScriptEngine::widgets(QScriptContext *context, QScriptEngine *engine)
{
ScriptEngine *env = ScriptEngine::envFor(engine);
const QString widgetType = context->argumentCount() > 0 ? context->argument(0).toString() : QString();
QScriptValue widgets = engine->newArray();
int count = 0;
foreach (Plasma::Applet *widget, env->m_containment->applets()) {
if (widgetType.isEmpty() || widget->pluginName() == widgetType) {
widgets.setProperty(count, env->wrap(widget));
++count;
}
}
widgets.setProperty("length", count);
return widgets;
}
QScriptValue ScriptEngine::addWidget(QScriptContext *context, QScriptEngine *engine)
{
if (context->argumentCount() == 0) {
return context->throwError("widgetById requires a name of a widget or a widget object");
}
quint16 row = 0;
quint16 column = 0;
ScriptEngine *env = ScriptEngine::envFor(engine);
if (context->argumentCount() == 3) {
QScriptValue v = context->argument(1);
if (v.isNumber()) {
row = v.toUInt16();
}
v = context->argument(2);
if (v.isNumber()) {
column = v.toUInt16();
}
// qDebug() << "Calculated position as" << row << column;
}
QScriptValue v = context->argument(0);
Plasma::Applet *applet = 0;
if (v.isString()) {
// FIXME: Using QMetaObject::invokeMethod until the newspaper's API is exported... Fuuuu
// applet = env->m_containment->addApplet(v.toString(), row, column);
QMetaObject::invokeMethod(env->m_containment, "addApplet",
Qt::DirectConnection,
Q_RETURN_ARG(Plasma::Applet *, applet),
Q_ARG(QString, v.toString()),
Q_ARG(int, row), Q_ARG(int, column));
if (applet) {
ScriptEngine *env = ScriptEngine::envFor(engine);
return env->wrap(applet);
}
} else if (Widget *widget = qobject_cast<Widget *>(v.toQObject())) {
applet = widget->applet();
// FIXME: Using QMetaObject::invokeMethod until the newspaper's API is exported... Fuuuu
// env->m_containment->addApplet(applet, row, column);
QMetaObject::invokeMethod(env->m_containment, "addApplet",
Qt::DirectConnection,
Q_RETURN_ARG(Plasma::Applet *, applet),
Q_ARG(QString, v.toString()),
Q_ARG(int, row), Q_ARG(int, column));
return v;
}
return engine->undefinedValue();
}
QScriptValue ScriptEngine::theme(QScriptContext *context, QScriptEngine *engine)
{
Q_UNUSED(engine)
if (context->argumentCount() > 0) {
const QString newTheme = context->argument(0).toString();
Plasma::Theme::defaultTheme()->setThemeName(newTheme);
}
return Plasma::Theme::defaultTheme()->themeName();
}
}

View File

@ -1,81 +0,0 @@
/*
* Copyright 2009 Aaron Seigo <aseigo@kde.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Library General Public License as
* published by the Free Software Foundation; either version 2, 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 Library 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 SCRIPTENGINE
#define SCRIPTENGINE
#include <QScriptEngine>
#include <QScriptValue>
namespace Plasma
{
class Applet;
class Containment;
class Corona;
} // namespace Plasma
namespace PlasmaKPartScripting
{
class ScriptEngine : public QScriptEngine
{
Q_OBJECT
public:
explicit ScriptEngine(Plasma::Corona *corona, QObject *parent = 0);
~ScriptEngine();
static QStringList pendingUpdateScripts();
static QStringList defaultLayoutScripts();
bool evaluateScript(const QString &script, const QString &path = QString());
QScriptValue wrap(Plasma::Applet *w);
static ScriptEngine *envFor(QScriptEngine *engine);
Q_SIGNALS:
void print(const QString &string);
void printError(const QString &string);
private:
void setupEngine();
static QScriptValue print(QScriptContext *context, QScriptEngine *engine);
static QScriptValue fileExists(QScriptContext *context, QScriptEngine *engine);
static QScriptValue loadTemplate(QScriptContext *context, QScriptEngine *engine);
static QScriptValue theme(QScriptContext *context, QScriptEngine *engine);
static QScriptValue widgets(QScriptContext *context, QScriptEngine *engine);
static QScriptValue addWidget(QScriptContext *context, QScriptEngine *engine);
static QScriptValue knownWidgetTypes(QScriptContext *context, QScriptEngine *engine);
private Q_SLOTS:
void exception(const QScriptValue &value);
private:
Plasma::Corona *m_corona;
Plasma::Containment *m_containment;
QScriptValue m_scriptSelf;
static const int PLASMA_KPART_SCRIPTING_VERSION = 3;
};
}
#endif

View File

@ -1,274 +0,0 @@
/*
* Copyright 2009 Aaron Seigo <aseigo@kde.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Library General Public License as
* published by the Free Software Foundation; either version 2, 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 Library 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 "widget.h"
#include <QGraphicsLinearLayout>
#include <KService>
#include <KServiceTypeTrader>
#include <Plasma/Applet>
#include <Plasma/Containment>
#include <Plasma/Corona>
namespace PlasmaKPartScripting
{
class Widget::Private
{
public:
Private()
: configDirty(false)
{
}
QWeakPointer<Plasma::Applet> applet;
KConfigGroup configGroup;
QStringList configGroupPath;
KConfigGroup globalConfigGroup;
QStringList globalConfigGroupPath;
bool configDirty : 1;
};
Widget::Widget(Plasma::Applet *applet, QObject *parent)
: QObject(parent),
d(new Widget::Private)
{
d->applet = applet;
}
Widget::~Widget()
{
if (d->configDirty) {
reloadConfig();
}
delete d;
}
void Widget::setCurrentConfigGroup(const QStringList &groupNames)
{
Plasma::Applet *app = applet();
if (!app) {
d->configGroup = KConfigGroup();
d->configGroupPath.clear();
return;
}
d->configGroup = app->config();
d->configGroupPath = groupNames;
foreach (const QString &groupName, groupNames) {
d->configGroup = KConfigGroup(&d->configGroup, groupName);
}
}
QStringList Widget::currentConfigGroup() const
{
return d->configGroupPath;
}
QStringList Widget::configKeys() const
{
if (d->configGroup.isValid()) {
return d->configGroup.keyList();
}
return QStringList();
}
QStringList Widget::configGroups() const
{
if (d->configGroup.isValid()) {
return d->configGroup.groupList();
}
return QStringList();
}
QVariant Widget::readConfig(const QString &key, const QVariant &def) const
{
if (d->configGroup.isValid()) {
return d->configGroup.readEntry(key, def);
} else {
return QVariant();
}
}
void Widget::writeConfig(const QString &key, const QVariant &value)
{
if (d->configGroup.isValid()) {
d->configGroup.writeEntry(key, value);
d->configDirty = true;
}
}
void Widget::setCurrentGlobalConfigGroup(const QStringList &groupNames)
{
Plasma::Applet *app = applet();
if (!app) {
d->globalConfigGroup = KConfigGroup();
d->globalConfigGroupPath.clear();
return;
}
d->globalConfigGroup = app->globalConfig();
d->globalConfigGroupPath = groupNames;
foreach (const QString &groupName, groupNames) {
d->globalConfigGroup = KConfigGroup(&d->globalConfigGroup, groupName);
}
}
QStringList Widget::currentGlobalConfigGroup() const
{
return d->globalConfigGroupPath;
}
QStringList Widget::globalConfigKeys() const
{
if (d->globalConfigGroup.isValid()) {
return d->globalConfigGroup.keyList();
}
return QStringList();
}
QStringList Widget::globalConfigGroups() const
{
if (d->globalConfigGroup.isValid()) {
return d->globalConfigGroup.groupList();
}
return QStringList();
}
QVariant Widget::readGlobalConfig(const QString &key, const QVariant &def) const
{
if (d->globalConfigGroup.isValid()) {
return d->globalConfigGroup.readEntry(key, def);
} else {
return QVariant();
}
}
void Widget::writeGlobalConfig(const QString &key, const QVariant &value)
{
if (d->globalConfigGroup.isValid()) {
d->globalConfigGroup.writeEntry(key, value);
d->configDirty = true;
}
}
void Widget::reloadConfig()
{
Plasma::Applet *app = applet();
if (app) {
KConfigGroup cg = app->config();
if (!app->isContainment()) {
app->restore(cg);
}
app->configChanged();
if (app->containment() && app->containment()->corona()) {
app->containment()->corona()->requestConfigSync();
}
d->configDirty = false;
}
}
QString Widget::version() const
{
Plasma::Applet *app = applet();
if (!app) {
return QString();
}
QString type = app->pluginName();
KService::List services = KServiceTypeTrader::self()->query("Plasma/Applet", "[X-KDE-PluginInfo-Name] == '" + type + '\'');
if (services.isEmpty()) {
return QString();
}
KPluginInfo info(services.first());
return info.version();
}
Plasma::Applet *Widget::applet() const
{
return d->applet.data();
}
uint Widget::id() const
{
if (d->applet) {
return d->applet.data()->id();
}
return 0;
}
QString Widget::type() const
{
if (d->applet) {
return d->applet.data()->pluginName();
}
return QString();
}
void Widget::remove()
{
if (d->applet) {
d->applet.data()->destroy();
d->applet.clear();
}
}
QRectF Widget::geometry() const
{
if (d->applet) {
return d->applet.data()->geometry();
}
return QRectF();
}
void Widget::setGeometry(const QRectF &geometry)
{
if (d->applet) {
d->applet.data()->setGeometry(geometry);
}
}
void Widget::showConfigurationInterface()
{
if (d->applet) {
d->applet.data()->showConfigurationInterface();
}
}
}

View File

@ -1,98 +0,0 @@
/*
* Copyright 2010 Aaron Seigo <aseigo@kde.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Library General Public License as
* published by the Free Software Foundation; either version 2, 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 Library 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 APPLET
#define APPLET
#include <QObject>
#include <QRectF>
#include <QVariant>
namespace Plasma
{
class Applet;
} // namespace Plasma
namespace PlasmaKPartScripting
{
class Widget : public QObject
{
Q_OBJECT
Q_PROPERTY(QString type READ type)
Q_PROPERTY(QString version READ version)
Q_PROPERTY(int id READ id)
Q_PROPERTY(QStringList configKeys READ configKeys)
Q_PROPERTY(QStringList configGroups READ configGroups)
Q_PROPERTY(QStringList globalConfigKeys READ globalConfigKeys)
Q_PROPERTY(QStringList globalConfigGroups READ globalConfigGroups)
//Q_PROPERTY(int index WRITE setIndex READ index)
Q_PROPERTY(QRectF geometry WRITE setGeometry READ geometry)
Q_PROPERTY(QStringList currentConfigGroup WRITE setCurrentConfigGroup READ currentConfigGroup)
public:
explicit Widget(Plasma::Applet *applet, QObject *parent = 0);
~Widget();
QStringList configKeys() const;
QStringList configGroups() const;
void setCurrentConfigGroup(const QStringList &groupNames);
QStringList currentConfigGroup() const;
QStringList globalConfigKeys() const;
QStringList globalConfigGroups() const;
void setCurrentGlobalConfigGroup(const QStringList &groupNames);
QStringList currentGlobalConfigGroup() const;
QRectF geometry() const;
void setGeometry(const QRectF &geometry);
QString version() const;
uint id() const;
QString type() const;
/**
FIXME: what should the index(es?) be given that we're in the newspaper containment
int index() const;
void setIndex(int index);
*/
virtual Plasma::Applet *applet() const;
public Q_SLOTS:
virtual QVariant readConfig(const QString &key, const QVariant &def = QString()) const;
virtual void writeConfig(const QString &key, const QVariant &value);
virtual QVariant readGlobalConfig(const QString &key, const QVariant &def = QString()) const;
virtual void writeGlobalConfig(const QString &key, const QVariant &value);
virtual void reloadConfig();
void remove();
void showConfigurationInterface();
private:
class Private;
Private *const d;
};
}
#endif