allow a subclass to define the default screen for the panel at runtime

CCBUG:262558
This commit is contained in:
Aaron Seigo 2011-11-22 19:12:50 +01:00 committed by Marco Martin
parent 365be18057
commit 13164dd664
2 changed files with 9 additions and 1 deletions

View File

@ -19,6 +19,8 @@
#include "scriptengine.h"
#include <QApplication>
#include <QDesktopWidget>
#include <QDir>
#include <QFile>
#include <QFileInfo>
@ -135,7 +137,7 @@ QScriptValue ScriptEngine::createContainment(const QString &type, const QString
if (c) {
if (type == "panel") {
// some defaults
c->setScreen(0);
c->setScreen(env->defaultPanelScreen());
c->setLocation(Plasma::TopEdge);
}
c->updateConstraints(Plasma::AllConstraints | Plasma::StartupCompletedConstraint);
@ -173,6 +175,11 @@ QScriptValue ScriptEngine::wrap(Containment *c)
return v;
}
int ScriptEngine::defaultPanelScreen() const
{
return qApp ? qApp->desktop()->primaryScreen() : 0;
}
ScriptEngine *ScriptEngine::envFor(QScriptEngine *engine)
{
QObject *object = engine->globalObject().toQObject();

View File

@ -53,6 +53,7 @@ public:
QScriptValue wrap(Plasma::Applet *w);
virtual QScriptValue wrap(Plasma::Containment *c);
QScriptValue wrap(Containment *c);
virtual int defaultPanelScreen() const;
static bool isPanel(const Plasma::Containment *c);
static ScriptEngine *envFor(QScriptEngine *engine);