* 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/signalplotter.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)
|
||||
@ -92,6 +106,7 @@ set(plasma_LIB_INCLUDES
|
||||
abstractrunner.h
|
||||
animator.h
|
||||
applet.h
|
||||
appletbrowser.h
|
||||
configxml.h
|
||||
containment.h
|
||||
corona.h
|
||||
|
@ -36,6 +36,8 @@ AppletBrowserWindow::AppletBrowserWindow(Plasma::Containment * containment, QWid
|
||||
void AppletBrowserWindow::init() {
|
||||
setupUi(this);
|
||||
|
||||
connect(buttonAdd, SIGNAL(clicked()), this, SLOT(buttonAddClicked()));
|
||||
|
||||
QAction* quit = KStandardAction::quit(qApp, SLOT(quit()), this);
|
||||
this->addAction(quit);
|
||||
|
||||
@ -78,4 +80,20 @@ AppletBrowserWindow::~AppletBrowserWindow()
|
||||
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"
|
||||
|
@ -33,12 +33,15 @@
|
||||
|
||||
class AppletBrowserWindow: public QDialog, public Ui::AppletBrowserWindowBase
|
||||
{
|
||||
//Q_OBJECT
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit AppletBrowserWindow(Plasma::Corona * corona, QWidget * parent = 0, Qt::WindowFlags f = 0);
|
||||
explicit AppletBrowserWindow(Plasma::Containment * containment, QWidget * parent = 0, Qt::WindowFlags f = 0);
|
||||
virtual ~AppletBrowserWindow();
|
||||
|
||||
private slots:
|
||||
void buttonAddClicked();
|
||||
|
||||
private:
|
||||
void init();
|
||||
Plasma::Corona * m_corona;
|
||||
|
@ -118,5 +118,21 @@ void KCategorizedItemsView::clearEmblems() {
|
||||
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"
|
||||
|
||||
|
@ -58,6 +58,8 @@ public:
|
||||
void addEmblem(const QString & title, QIcon * icon, const Filter & filter);
|
||||
void clearEmblems();
|
||||
|
||||
QList < AbstractItem * > selectedItems() const;
|
||||
|
||||
protected slots:
|
||||
void searchTermChanged(const QString &text);
|
||||
void filterChanged(int index);
|
||||
@ -82,6 +84,7 @@ private:
|
||||
int m_viewWidth;
|
||||
|
||||
QMap < QString, QPair < Filter, QIcon * > > m_emblems;
|
||||
AbstractItem * getItemByProxyIndex(const QModelIndex & index) const;
|
||||
|
||||
friend class KCategorizedItemsViewDelegate;
|
||||
};
|
||||
|
@ -49,6 +49,8 @@
|
||||
#include "ksmserver_interface.h"
|
||||
#include "screensaver_interface.h"
|
||||
|
||||
#include "appletbrowser.h"
|
||||
|
||||
namespace Plasma
|
||||
{
|
||||
|
||||
@ -84,12 +86,14 @@ public:
|
||||
QPixmap* bitmapBackground;
|
||||
QString wallpaperPath;
|
||||
QAction *engineExplorerAction;
|
||||
QAction *appletBrowserAction;
|
||||
QAction *runCommandAction;
|
||||
QAction *lockAction;
|
||||
QAction *logoutAction;
|
||||
QSize size;
|
||||
int screen;
|
||||
bool immutable;
|
||||
AppletBrowser *appletBrowser;
|
||||
};
|
||||
|
||||
Containment::Containment(QGraphicsItem* parent,
|
||||
@ -98,16 +102,19 @@ Containment::Containment(QGraphicsItem* parent,
|
||||
: Applet(parent, serviceId, containmentId),
|
||||
d(new Private)
|
||||
{
|
||||
d->appletBrowser = new AppletBrowser(this);
|
||||
}
|
||||
|
||||
Containment::Containment(QObject* parent, const QVariantList& args)
|
||||
: Applet(parent, args),
|
||||
d(new Private)
|
||||
{
|
||||
d->appletBrowser = new AppletBrowser(this);
|
||||
}
|
||||
|
||||
Containment::~Containment()
|
||||
{
|
||||
delete d->appletBrowser;
|
||||
delete d;
|
||||
}
|
||||
|
||||
@ -187,6 +194,13 @@ void Containment::launchExplorer()
|
||||
KRun::run("plasmaengineexplorer", KUrl::List(), 0);
|
||||
}
|
||||
|
||||
void Containment::launchAppletBrowser()
|
||||
{
|
||||
d->appletBrowser->show();
|
||||
}
|
||||
|
||||
|
||||
|
||||
void Containment::runCommand()
|
||||
{
|
||||
if (!KAuthorized::authorizeKAction("run_command")) {
|
||||
@ -244,10 +258,13 @@ QList<QAction*> Containment::contextActions()
|
||||
// - pretty up the menu with separators
|
||||
// - should we offer "Switch User" here?
|
||||
|
||||
if (!d->engineExplorerAction) {
|
||||
if (!d->appletBrowserAction) {
|
||||
d->engineExplorerAction = new QAction(i18n("Engine Explorer"), this);
|
||||
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);
|
||||
connect(d->runCommandAction, SIGNAL(triggered(bool)), this, SLOT(runCommand()));
|
||||
|
||||
@ -263,6 +280,7 @@ QList<QAction*> Containment::contextActions()
|
||||
QList<QAction*> actions;
|
||||
|
||||
actions.append(d->engineExplorerAction);
|
||||
actions.append(d->appletBrowserAction);
|
||||
|
||||
if (KAuthorized::authorizeKAction("run_command")) {
|
||||
actions.append(d->runCommandAction);
|
||||
|
@ -229,6 +229,7 @@ class PLASMA_EXPORT Containment : public Applet
|
||||
*/
|
||||
void appletDestroyed(QObject*);
|
||||
void launchExplorer();
|
||||
void launchAppletBrowser();
|
||||
void runCommand();
|
||||
void lockScreen();
|
||||
void logout();
|
||||
|
Loading…
Reference in New Issue
Block a user