* applet browser's add button works
svn path=/trunk/KDE/kdebase/workspace/libs/plasma/; revision=717892
This commit is contained in:
parent
ad15bab8c4
commit
8a811e46f7
@ -52,6 +52,20 @@ set(plasma_LIB_SRCS
|
|||||||
widgets/widget.cpp
|
widgets/widget.cpp
|
||||||
widgets/signalplotter.cpp
|
widgets/signalplotter.cpp
|
||||||
widgets/meter.cpp
|
widgets/meter.cpp
|
||||||
|
|
||||||
|
appletbrowser.cpp
|
||||||
|
appletbrowser/appletbrowserwindow.cpp
|
||||||
|
appletbrowser/kcategorizeditemsview.cpp
|
||||||
|
appletbrowser/kcategorizeditemsviewdelegate.cpp
|
||||||
|
appletbrowser/kcategorizeditemsviewmodels.cpp
|
||||||
|
appletbrowser/plasmaappletitemmodel.cpp
|
||||||
|
|
||||||
|
)
|
||||||
|
|
||||||
|
kde4_add_ui_files (
|
||||||
|
plasma_LIB_SRCS
|
||||||
|
appletbrowser/kcategorizeditemsviewbase.ui
|
||||||
|
appletbrowser/appletbrowserwindowbase.ui
|
||||||
)
|
)
|
||||||
|
|
||||||
set(krunner_xml ${KDEBASE_WORKSPACE_SOURCE_DIR}/krunner/org.kde.krunner.Interface.xml)
|
set(krunner_xml ${KDEBASE_WORKSPACE_SOURCE_DIR}/krunner/org.kde.krunner.Interface.xml)
|
||||||
@ -92,6 +106,7 @@ set(plasma_LIB_INCLUDES
|
|||||||
abstractrunner.h
|
abstractrunner.h
|
||||||
animator.h
|
animator.h
|
||||||
applet.h
|
applet.h
|
||||||
|
appletbrowser.h
|
||||||
configxml.h
|
configxml.h
|
||||||
containment.h
|
containment.h
|
||||||
corona.h
|
corona.h
|
||||||
|
@ -36,6 +36,8 @@ AppletBrowserWindow::AppletBrowserWindow(Plasma::Containment * containment, QWid
|
|||||||
void AppletBrowserWindow::init() {
|
void AppletBrowserWindow::init() {
|
||||||
setupUi(this);
|
setupUi(this);
|
||||||
|
|
||||||
|
connect(buttonAdd, SIGNAL(clicked()), this, SLOT(buttonAddClicked()));
|
||||||
|
|
||||||
QAction* quit = KStandardAction::quit(qApp, SLOT(quit()), this);
|
QAction* quit = KStandardAction::quit(qApp, SLOT(quit()), this);
|
||||||
this->addAction(quit);
|
this->addAction(quit);
|
||||||
|
|
||||||
@ -78,4 +80,20 @@ AppletBrowserWindow::~AppletBrowserWindow()
|
|||||||
delete m_proxyModel;*/
|
delete m_proxyModel;*/
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void AppletBrowserWindow::buttonAddClicked() {
|
||||||
|
kDebug() << "Button ADD clicked\n";
|
||||||
|
|
||||||
|
foreach (AbstractItem * item, appletList->selectedItems()) {
|
||||||
|
PlasmaAppletItem * selectedItem = (PlasmaAppletItem *) item;
|
||||||
|
kDebug() << "Adding applet " << selectedItem->name();
|
||||||
|
if (m_corona) {
|
||||||
|
kDebug() << " to corona\n";
|
||||||
|
m_corona->addApplet(selectedItem->pluginName());
|
||||||
|
} else if (m_containment) {
|
||||||
|
kDebug() << " to conatainment\n";
|
||||||
|
m_containment->addApplet(selectedItem->pluginName());
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
#include "appletbrowserwindow.moc"
|
#include "appletbrowserwindow.moc"
|
||||||
|
@ -33,12 +33,15 @@
|
|||||||
|
|
||||||
class AppletBrowserWindow: public QDialog, public Ui::AppletBrowserWindowBase
|
class AppletBrowserWindow: public QDialog, public Ui::AppletBrowserWindowBase
|
||||||
{
|
{
|
||||||
//Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
explicit AppletBrowserWindow(Plasma::Corona * corona, QWidget * parent = 0, Qt::WindowFlags f = 0);
|
explicit AppletBrowserWindow(Plasma::Corona * corona, QWidget * parent = 0, Qt::WindowFlags f = 0);
|
||||||
explicit AppletBrowserWindow(Plasma::Containment * containment, QWidget * parent = 0, Qt::WindowFlags f = 0);
|
explicit AppletBrowserWindow(Plasma::Containment * containment, QWidget * parent = 0, Qt::WindowFlags f = 0);
|
||||||
virtual ~AppletBrowserWindow();
|
virtual ~AppletBrowserWindow();
|
||||||
|
|
||||||
|
private slots:
|
||||||
|
void buttonAddClicked();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void init();
|
void init();
|
||||||
Plasma::Corona * m_corona;
|
Plasma::Corona * m_corona;
|
||||||
|
@ -118,5 +118,21 @@ void KCategorizedItemsView::clearEmblems() {
|
|||||||
m_emblems.clear();
|
m_emblems.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
AbstractItem * KCategorizedItemsView::getItemByProxyIndex(const QModelIndex & index) const {
|
||||||
|
return (AbstractItem *) m_modelItems->itemFromIndex(
|
||||||
|
m_modelFilterItems->mapToSource(index)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
QList < AbstractItem * > KCategorizedItemsView::selectedItems() const {
|
||||||
|
QList < AbstractItem * > items;
|
||||||
|
foreach (QModelIndex index, itemsView->selectionModel()->selectedIndexes()) {
|
||||||
|
if (index.column() == 0) {
|
||||||
|
items << getItemByProxyIndex(index);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return items;
|
||||||
|
}
|
||||||
#include "kcategorizeditemsview.moc"
|
#include "kcategorizeditemsview.moc"
|
||||||
|
|
||||||
|
@ -58,6 +58,8 @@ public:
|
|||||||
void addEmblem(const QString & title, QIcon * icon, const Filter & filter);
|
void addEmblem(const QString & title, QIcon * icon, const Filter & filter);
|
||||||
void clearEmblems();
|
void clearEmblems();
|
||||||
|
|
||||||
|
QList < AbstractItem * > selectedItems() const;
|
||||||
|
|
||||||
protected slots:
|
protected slots:
|
||||||
void searchTermChanged(const QString &text);
|
void searchTermChanged(const QString &text);
|
||||||
void filterChanged(int index);
|
void filterChanged(int index);
|
||||||
@ -82,6 +84,7 @@ private:
|
|||||||
int m_viewWidth;
|
int m_viewWidth;
|
||||||
|
|
||||||
QMap < QString, QPair < Filter, QIcon * > > m_emblems;
|
QMap < QString, QPair < Filter, QIcon * > > m_emblems;
|
||||||
|
AbstractItem * getItemByProxyIndex(const QModelIndex & index) const;
|
||||||
|
|
||||||
friend class KCategorizedItemsViewDelegate;
|
friend class KCategorizedItemsViewDelegate;
|
||||||
};
|
};
|
||||||
|
@ -49,6 +49,8 @@
|
|||||||
#include "ksmserver_interface.h"
|
#include "ksmserver_interface.h"
|
||||||
#include "screensaver_interface.h"
|
#include "screensaver_interface.h"
|
||||||
|
|
||||||
|
#include "appletbrowser.h"
|
||||||
|
|
||||||
namespace Plasma
|
namespace Plasma
|
||||||
{
|
{
|
||||||
|
|
||||||
@ -84,12 +86,14 @@ public:
|
|||||||
QPixmap* bitmapBackground;
|
QPixmap* bitmapBackground;
|
||||||
QString wallpaperPath;
|
QString wallpaperPath;
|
||||||
QAction *engineExplorerAction;
|
QAction *engineExplorerAction;
|
||||||
|
QAction *appletBrowserAction;
|
||||||
QAction *runCommandAction;
|
QAction *runCommandAction;
|
||||||
QAction *lockAction;
|
QAction *lockAction;
|
||||||
QAction *logoutAction;
|
QAction *logoutAction;
|
||||||
QSize size;
|
QSize size;
|
||||||
int screen;
|
int screen;
|
||||||
bool immutable;
|
bool immutable;
|
||||||
|
AppletBrowser *appletBrowser;
|
||||||
};
|
};
|
||||||
|
|
||||||
Containment::Containment(QGraphicsItem* parent,
|
Containment::Containment(QGraphicsItem* parent,
|
||||||
@ -98,16 +102,19 @@ Containment::Containment(QGraphicsItem* parent,
|
|||||||
: Applet(parent, serviceId, containmentId),
|
: Applet(parent, serviceId, containmentId),
|
||||||
d(new Private)
|
d(new Private)
|
||||||
{
|
{
|
||||||
|
d->appletBrowser = new AppletBrowser(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
Containment::Containment(QObject* parent, const QVariantList& args)
|
Containment::Containment(QObject* parent, const QVariantList& args)
|
||||||
: Applet(parent, args),
|
: Applet(parent, args),
|
||||||
d(new Private)
|
d(new Private)
|
||||||
{
|
{
|
||||||
|
d->appletBrowser = new AppletBrowser(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
Containment::~Containment()
|
Containment::~Containment()
|
||||||
{
|
{
|
||||||
|
delete d->appletBrowser;
|
||||||
delete d;
|
delete d;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -187,6 +194,13 @@ void Containment::launchExplorer()
|
|||||||
KRun::run("plasmaengineexplorer", KUrl::List(), 0);
|
KRun::run("plasmaengineexplorer", KUrl::List(), 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Containment::launchAppletBrowser()
|
||||||
|
{
|
||||||
|
d->appletBrowser->show();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void Containment::runCommand()
|
void Containment::runCommand()
|
||||||
{
|
{
|
||||||
if (!KAuthorized::authorizeKAction("run_command")) {
|
if (!KAuthorized::authorizeKAction("run_command")) {
|
||||||
@ -244,10 +258,13 @@ QList<QAction*> Containment::contextActions()
|
|||||||
// - pretty up the menu with separators
|
// - pretty up the menu with separators
|
||||||
// - should we offer "Switch User" here?
|
// - should we offer "Switch User" here?
|
||||||
|
|
||||||
if (!d->engineExplorerAction) {
|
if (!d->appletBrowserAction) {
|
||||||
d->engineExplorerAction = new QAction(i18n("Engine Explorer"), this);
|
d->engineExplorerAction = new QAction(i18n("Engine Explorer"), this);
|
||||||
connect(d->engineExplorerAction, SIGNAL(triggered(bool)), this, SLOT(launchExplorer()));
|
connect(d->engineExplorerAction, SIGNAL(triggered(bool)), this, SLOT(launchExplorer()));
|
||||||
|
|
||||||
|
d->appletBrowserAction = new QAction(i18n("Add applet"), this);
|
||||||
|
connect(d->appletBrowserAction, SIGNAL(triggered(bool)), this, SLOT(launchAppletBrowser()));
|
||||||
|
|
||||||
d->runCommandAction = new QAction(i18n("Run Command..."), this);
|
d->runCommandAction = new QAction(i18n("Run Command..."), this);
|
||||||
connect(d->runCommandAction, SIGNAL(triggered(bool)), this, SLOT(runCommand()));
|
connect(d->runCommandAction, SIGNAL(triggered(bool)), this, SLOT(runCommand()));
|
||||||
|
|
||||||
@ -263,6 +280,7 @@ QList<QAction*> Containment::contextActions()
|
|||||||
QList<QAction*> actions;
|
QList<QAction*> actions;
|
||||||
|
|
||||||
actions.append(d->engineExplorerAction);
|
actions.append(d->engineExplorerAction);
|
||||||
|
actions.append(d->appletBrowserAction);
|
||||||
|
|
||||||
if (KAuthorized::authorizeKAction("run_command")) {
|
if (KAuthorized::authorizeKAction("run_command")) {
|
||||||
actions.append(d->runCommandAction);
|
actions.append(d->runCommandAction);
|
||||||
|
@ -229,6 +229,7 @@ class PLASMA_EXPORT Containment : public Applet
|
|||||||
*/
|
*/
|
||||||
void appletDestroyed(QObject*);
|
void appletDestroyed(QObject*);
|
||||||
void launchExplorer();
|
void launchExplorer();
|
||||||
|
void launchAppletBrowser();
|
||||||
void runCommand();
|
void runCommand();
|
||||||
void lockScreen();
|
void lockScreen();
|
||||||
void logout();
|
void logout();
|
||||||
|
Loading…
Reference in New Issue
Block a user