it's an example, move it where it belongs

svn path=/trunk/KDE/kdebase/runtime/; revision=1174551
This commit is contained in:
Aaron J. Seigo 2010-09-12 20:15:29 +00:00
parent df5a674561
commit fd9c5fd27f
12 changed files with 0 additions and 576 deletions

View File

@ -1,17 +0,0 @@
set(plasma_kpart_shell_SRCS
main.cpp
containmentshell.cpp
testshellpluginloader.cpp
appletselector.cpp
)
kde4_add_ui_files(plasma_kpart_shell_SRCS appletselector.ui)
kde4_add_executable(plasma-kpart-shell ${plasma_kpart_shell_SRCS})
target_link_libraries(plasma-kpart-shell ${KDE4_KDEUI_LIBS} ${KDE4_KPARTS_LIBS} ${KDE4_PLASMA_LIBS} )
########### install files ###############
install(TARGETS plasma-kpart-shell ${INSTALL_TARGETS_DEFAULT_ARGS} )
install( FILES plasma-kpart-shell.desktop DESTINATION ${XDG_APPS_INSTALL_DIR} )
install(FILES plasma-default-layoutrc DESTINATION ${DATA_INSTALL_DIR}/plasma-kpart-shell/)
install( FILES plasma-kpart-shellui.rc DESTINATION ${DATA_INSTALL_DIR}/plasma-kpart-shell/ )

View File

@ -1,67 +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());
}
#include "appletselector.moc"

View File

@ -1,44 +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,109 +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();
QVariantList args = QVariantList() << qVariantFromValue(loader) << "Online Services";
// now that the Part is loaded, we cast it to a Part to get
// our hands on it
m_part = service->createInstance<KParts::ReadOnlyPart>(0, args);
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();
}
#include "containmentshell.moc"

View File

@ -1,51 +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 "../plasmakpart.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,44 +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,24 +0,0 @@
[Desktop Entry]
Name=plasma-kpart-shell
Name[en_GB]=plasma-kpart-shell
Name[ia]=plasma-kpart-shell
Name[nl]=plasma-kpart-shell
Name[pt]=plasma-kpart-shell
Name[pt_BR]=plasma-kpart-shell
Name[sv]=Plasma-delprogramskal
Name[uk]=plasma-kpart-shell
Name[x-test]=xxplasma-kpart-shellxx
Exec=plasma-kpart-shell %i -caption "%c"
Icon=plasma-kpart-shell
Type=Application
X-DocPath=plasma-kpart-shell/index.html
GenericName=A KPart shell for Plasma
GenericName[en_GB]=A KPart shell for Plasma
GenericName[ia]=Un shell de KPart pro Plasma
GenericName[nl]=Een KPart-shell voor Plasma
GenericName[pt]=Uma consola de KParts para o Plasma
GenericName[pt_BR]=Uma shell de KPart para o Plasma
GenericName[sv]=Ett delprogramskal för Plasma
GenericName[uk]=Оболонка модулів для Плазми
GenericName[x-test]=xxA KPart shell for Plasmaxx
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