//------------------------------------------------------------------------------ //! void ComboBox::onClick( const Event& ev ) { // Set minimum width of menu to the current combobox. Vec2f nsize = Vec2f( CGM::max( actualSize().x - 2.0f*_offset.x, _menu->actualBaseSize().x ), _menu->size().y ); _menu->size( nsize ); Vec2f pos = _menuAbove ? Vec2f( 0.0f, actualSize().y ) : -Vec2f( 0.0f, _menu->actualBaseSize().y ); Core::desktop()->popup( _menu, globalPosition() + pos + _offset, nullptr ); Widget::onClick( ev ); }
KSMShutdownDlg::KSMShutdownDlg( QWindow* parent, bool maysd, bool choose, KWorkSpace::ShutdownType sdtype, const QString& theme) : QQuickView(parent), m_result(false) // this is a WType_Popup on purpose. Do not change that! Not // having a popup here has severe side effects. { // window stuff setClearBeforeRendering(true); setColor(QColor(Qt::transparent)); setFlags(Qt::FramelessWindowHint | Qt::BypassWindowManagerHint); QPoint globalPosition(QCursor::pos()); foreach (QScreen *s, QGuiApplication::screens()) { if (s->geometry().contains(globalPosition)) { setScreen(s); break; } } // Qt doesn't set this on unmanaged windows //FIXME: or does it? XChangeProperty( QX11Info::display(), winId(), XInternAtom( QX11Info::display(), "WM_WINDOW_ROLE", False ), XA_STRING, 8, PropModeReplace, (unsigned char *)"logoutdialog", strlen( "logoutdialog" )); //QQuickView *windowContainer = QQuickView::createWindowContainer(m_view, this); //windowContainer->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred); QQmlContext *context = rootContext(); context->setContextProperty(QStringLiteral("maysd"), maysd); context->setContextProperty(QStringLiteral("choose"), choose); context->setContextProperty(QStringLiteral("sdtype"), sdtype); QQmlPropertyMap *mapShutdownType = new QQmlPropertyMap(this); mapShutdownType->insert(QStringLiteral("ShutdownTypeDefault"), QVariant::fromValue<int>(KWorkSpace::ShutdownTypeDefault)); mapShutdownType->insert(QStringLiteral("ShutdownTypeNone"), QVariant::fromValue<int>(KWorkSpace::ShutdownTypeNone)); mapShutdownType->insert(QStringLiteral("ShutdownTypeReboot"), QVariant::fromValue<int>(KWorkSpace::ShutdownTypeReboot)); mapShutdownType->insert(QStringLiteral("ShutdownTypeHalt"), QVariant::fromValue<int>(KWorkSpace::ShutdownTypeHalt)); mapShutdownType->insert(QStringLiteral("ShutdownTypeLogout"), QVariant::fromValue<int>(KWorkSpace::ShutdownTypeLogout)); context->setContextProperty(QStringLiteral("ShutdownType"), mapShutdownType); QQmlPropertyMap *mapSpdMethods = new QQmlPropertyMap(this); QSet<Solid::PowerManagement::SleepState> spdMethods = Solid::PowerManagement::supportedSleepStates(); mapSpdMethods->insert(QStringLiteral("StandbyState"), QVariant::fromValue(spdMethods.contains(Solid::PowerManagement::StandbyState))); mapSpdMethods->insert(QStringLiteral("SuspendState"), QVariant::fromValue(spdMethods.contains(Solid::PowerManagement::SuspendState))); mapSpdMethods->insert(QStringLiteral("HibernateState"), QVariant::fromValue(spdMethods.contains(Solid::PowerManagement::HibernateState))); context->setContextProperty(QStringLiteral("spdMethods"), mapSpdMethods); QString bootManager = KConfig(QStringLiteral(KDE_CONFDIR "/kdm/kdmrc"), KConfig::SimpleConfig) .group("Shutdown") .readEntry("BootManager", "None"); context->setContextProperty(QStringLiteral("bootManager"), bootManager); QStringList options; int def, cur; if ( KDisplayManager().bootOptions( rebootOptions, def, cur ) ) { if ( cur > -1 ) { def = cur; } } QQmlPropertyMap *rebootOptionsMap = new QQmlPropertyMap(this); rebootOptionsMap->insert(QStringLiteral("options"), QVariant::fromValue(rebootOptions)); rebootOptionsMap->insert(QStringLiteral("default"), QVariant::fromValue(def)); context->setContextProperty(QStringLiteral("rebootOptions"), rebootOptionsMap); context->setContextProperty(QStringLiteral("screenGeometry"), screen()->geometry()); setModality(Qt::ApplicationModal); // engine stuff KDeclarative::KDeclarative kdeclarative; kdeclarative.setDeclarativeEngine(engine()); kdeclarative.initialize(); kdeclarative.setupBindings(); // windowContainer->installEventFilter(this); QString fileName; if(theme.isEmpty()) { KPackage::Package package = KPackage::PackageLoader::self()->loadPackage(QStringLiteral("Plasma/LookAndFeel")); KConfigGroup cg(KSharedConfig::openConfig(QStringLiteral("kdeglobals")), "KDE"); const QString packageName = cg.readEntry("LookAndFeelPackage", QString()); if (!packageName.isEmpty()) { package.setPath(packageName); } fileName = package.filePath("logoutmainscript"); } else fileName = theme; if (QFile::exists(fileName)) { //qCDebug(KSMSERVER) << "Using QML theme" << fileName; setSource(QUrl::fromLocalFile(fileName)); } else { qWarning() << "Couldn't find a theme for the Shutdown dialog" << fileName; return; } setPosition(screen()->virtualGeometry().center().x() - width() / 2, screen()->virtualGeometry().center().y() - height() / 2); if(!errors().isEmpty()) { qWarning() << errors(); } connect(rootObject(), SIGNAL(logoutRequested()), SLOT(slotLogout())); connect(rootObject(), SIGNAL(haltRequested()), SLOT(slotHalt())); connect(rootObject(), SIGNAL(suspendRequested(int)), SLOT(slotSuspend(int)) ); connect(rootObject(), SIGNAL(rebootRequested()), SLOT(slotReboot())); connect(rootObject(), SIGNAL(rebootRequested2(int)), SLOT(slotReboot(int)) ); connect(rootObject(), SIGNAL(cancelRequested()), SLOT(reject())); connect(rootObject(), SIGNAL(lockScreenRequested()), SLOT(slotLockScreen())); show(); requestActivate(); KWindowSystem::setState(winId(), NET::SkipTaskbar|NET::SkipPager); }