void Panel::setLocation(const QString &locationString) { Plasma::Containment *c = containment(); if (!c) { return; } const QString lower = locationString.toLower(); Plasma::Types::Location loc = Plasma::Types::Floating; Plasma::Types::FormFactor ff = Plasma::Types::Planar; if (lower == "desktop") { loc = Plasma::Types::Desktop; } else if (lower == "fullscreen") { loc = Plasma::Types::FullScreen; } else if (lower == "top") { loc = Plasma::Types::TopEdge; ff = Plasma::Types::Horizontal; } else if (lower == "bottom") { loc = Plasma::Types::BottomEdge; ff = Plasma::Types::Horizontal; } else if (lower == "left") { loc = Plasma::Types::LeftEdge; ff = Plasma::Types::Vertical; } else if (lower == "right") { loc = Plasma::Types::RightEdge; ff = Plasma::Types::Vertical; } c->setLocation(loc); c->setFormFactor(ff); }
int PlasmaApp::newInstance() { KCmdLineArgs* args = KCmdLineArgs::parsedArgs(); if (args->count() == 0) { KCmdLineArgs::usage(); return 0; } QString pluginName; if (args->count() > 0) { pluginName = args->arg(0); } //is the applet already running? if (m_viewForPlugin.contains(pluginName)) { m_viewForPlugin.value(pluginName)->activateWindow(); m_viewForPlugin.value(pluginName)->raise(); return 0; } QVariantList appletArgs; for (int i = 1; i < args->count(); ++i) { appletArgs << args->arg(i); } int appletId; Plasma::Containment *containment = m_corona->addContainment("null"); containment->setFormFactor(Plasma::Planar); containment->setLocation(Plasma::Floating); appletId = ++m_maxId; if (m_storedApplets.contains(pluginName)) { int storedAppletId = m_storedApplets.values(pluginName).first(); KConfigGroup config = storedConfig(storedAppletId); KConfigGroup actualConfig(containment->config()); actualConfig = KConfigGroup(&actualConfig, "Applets"); actualConfig = KConfigGroup(&actualConfig, QString::number(appletId)); config.copyTo(&actualConfig); config.deleteGroup(); m_storedApplets.remove(pluginName, storedAppletId); } SingleView *view = new SingleView(m_corona, containment, pluginName, appletId, appletArgs); if (!view->applet()) { delete view; return 0; } connect(view, SIGNAL(storeApplet(Plasma::Applet*)), this, SLOT(storeApplet(Plasma::Applet*))); connect(view, SIGNAL(destroyed(QObject*)), this, SLOT(viewDestroyed(QObject*))); if (args->isSet("border")) { view->setBackgroundBrush(KColorUtils::mix(Plasma::Theme::defaultTheme()->color(Plasma::Theme::BackgroundColor), Plasma::Theme::defaultTheme()->color(Plasma::Theme::TextColor), 0.15)); connect(Plasma::Theme::defaultTheme(), SIGNAL(themeChanged()), SLOT(themeChanged())); view->applet()->setBackgroundHints(Plasma::Applet::NoBackground); } else { view->setWindowFlags(Qt::FramelessWindowHint); view->setAttribute(Qt::WA_TranslucentBackground); view->setAutoFillBackground(false); view->viewport()->setAutoFillBackground(false); view->setAttribute(Qt::WA_NoSystemBackground); view->viewport()->setAttribute(Qt::WA_NoSystemBackground); Plasma::WindowEffects::overrideShadow(view->winId(), true); } if (args->isSet("fullscreen")) { view->setWindowState(Qt::WindowFullScreen); } args->clear(); m_viewForPlugin[pluginName] = view; m_pluginForView[view] = pluginName; KWindowSystem::setOnDesktop(view->winId(), KWindowSystem::currentDesktop()); view->show(); view->raise(); return 0; }