[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: KDE/kdebase/workspace/plasma/containments/panel
From: Aaron J. Seigo <aseigo () kde ! org>
Date: 2009-04-03 0:50:20
Message-ID: 1238719820.482910.25158.nullmailer () svn ! kde ! org
[Download RAW message or body]
SVN commit 948434 by aseigo:
support for chosing between multiple panel types; duplicated from Desktop, but i'm \
not overly worried because if get the context menu plugin SoC project approved, this \
code will unduplicate itself into one of those plugins :)
M +44 -10 panel.cpp
M +2 -0 panel.h
--- trunk/KDE/kdebase/workspace/plasma/containments/panel/panel.cpp #948433:948434
@@ -21,19 +21,20 @@
#include <limits>
+#include <QAction>
#include <QApplication>
-#include <QGraphicsLinearLayout>
-#include <QPainter>
#include <QBitmap>
+#include <QComboBox>
#include <QDesktopWidget>
+#include <QGraphicsLinearLayout>
#include <QGridLayout>
-#include <QLabel>
-#include <QComboBox>
-#include <QAction>
#include <QGraphicsLayout>
#include <QGraphicsSceneDragDropEvent>
+#include <QLabel>
+#include <QMenu>
+#include <QPainter>
+#include <QSignalMapper>
-
#include <KDebug>
#include <KIcon>
#include <KDialog>
@@ -88,6 +89,7 @@
Panel::Panel(QObject *parent, const QVariantList &args)
: Containment(parent, args),
+ m_addPanelsMenu(0),
m_configureAction(0),
m_addPanelAction(0),
m_currentSize(QSize(Kephal::ScreenUtils::screenSize(screen()).width(), 35)),
@@ -113,6 +115,7 @@
Panel::~Panel()
{
+ delete m_addPanelsMenu;
}
void Panel::init()
@@ -144,8 +147,31 @@
m_configureAction->setIcon(KIcon("configure"));
connect(m_configureAction, SIGNAL(triggered()), this, \
SIGNAL(toolBoxToggled()));
- m_addPanelAction = new QAction(i18n("Add Panel"), this);
- connect(m_addPanelAction, SIGNAL(triggered(bool)), this, SLOT(addPanel()));
+ KPluginInfo::List panelPlugins = listContainmentsOfType("panel");
+
+ if (panelPlugins.size() == 1) {
+ m_addPanelAction = new QAction(i18n("Add Panel"), this);
+ connect(m_addPanelAction, SIGNAL(triggered(bool)), this, \
SLOT(addPanel())); + } else if (!panelPlugins.isEmpty()) {
+ m_addPanelsMenu = new QMenu();
+ m_addPanelAction = m_addPanelsMenu->menuAction();
+ m_addPanelAction->setText(i18n("Add Panel"));
+
+ QSignalMapper *mapper = new QSignalMapper(this);
+ connect(mapper, SIGNAL(mapped(QString)), this, SLOT(addPanel(QString)));
+
+ foreach (const KPluginInfo &plugin, panelPlugins) {
+ QAction *action = new QAction(plugin.name(), this);
+ if (!plugin.icon().isEmpty()) {
+ action->setIcon(KIcon(plugin.icon()));
+ }
+
+ mapper->setMapping(action, plugin.pluginName());
+ connect(action, SIGNAL(triggered(bool)), mapper, SLOT(map()));
+ m_addPanelsMenu->addAction(action);
+ }
+ }
+
m_addPanelAction->setIcon(KIcon("list-add"));
constraintsEvent(Plasma::ImmutableConstraint);
}
@@ -264,10 +290,18 @@
void Panel::addPanel()
{
+ KPluginInfo::List panelPlugins = listContainments("panel");
+
+ if (!panelPlugins.isEmpty()) {
+ addPanel(panelPlugins.first().pluginName());
+ }
+}
+
+void Panel::addPanel(const QString &plugin)
+{
if (corona()) {
- Containment* panel = corona()->addContainment("panel");
+ Containment* panel = corona()->addContainment(plugin);
panel->showConfigurationInterface();
-
panel->setScreen(screen());
QList<Plasma::Location> freeEdges = corona()->freeEdges(screen());
--- trunk/KDE/kdebase/workspace/plasma/containments/panel/panel.h #948433:948434
@@ -61,6 +61,7 @@
void appletRemoved(Plasma::Applet* applet);
void updateSize();
void addPanel();
+ void addPanel(const QString &plugin);
private:
/**
@@ -74,6 +75,7 @@
void updateBorders(const QRect &geom);
Plasma::FrameSvg *m_background;
+ QMenu *m_addPanelsMenu;
QAction* m_configureAction;
QAction* m_addPanelAction;
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic