void WeatherWallpaper::loadImage() { m_wallpaper = m_weatherMap.value(m_condition); if (m_wallpaper.isEmpty()) { QHashIterator<QString, QString> it(m_weatherMap); while (it.hasNext()) { it.next(); if (m_condition.startsWith(it.key())) { m_wallpaper = it.value(); break; } } } if (m_wallpaper.isEmpty()) { m_wallpaper = Plasma::Theme::defaultTheme()->wallpaperPath(); } QString img; Plasma::Package b(m_wallpaper, packageStructure(this)); img = b.filePath("preferred"); if (img.isEmpty()) { img = m_wallpaper; } if (!m_size.isEmpty()) { renderWallpaper(img); } }
GreeterWindow::GreeterWindow(QWidget *parent) : QDeclarativeView(parent), m_greeter(new GreeterWrapper(this)) { setResizeMode(QDeclarativeView::SizeRootObjectToView); KDeclarative kdeclarative; kdeclarative.setDeclarativeEngine(engine()); kdeclarative.initialize(); //binds things like kconfig and icons kdeclarative.setupBindings(); KConfig config(LIGHTDM_CONFIG_DIR "/lightdm-kde-greeter.conf"); KConfigGroup configGroup = config.group("greeter"); QString theme = configGroup.readEntry("theme-name", "userbar"); QStringList dirs = KGlobal::dirs()->findDirs("appdata", "themes/"); Plasma::PackageStructure::Ptr packageStructure(new LightDMPackageStructure(this)); Plasma::Package package(dirs.last() + "/" + theme, packageStructure); if (!package.isValid()) { kError() << theme << " is not a valid theme. Falling back to \"userbar\" theme."; package = Plasma::Package(dirs.last() + "/" + "userbar", packageStructure); } if (!package.isValid()) { kFatal() << "Cannot find QML file for \"userbar\" theme. Something is wrong with this installation. Aborting."; } KGlobal::locale()->insertCatalog("lightdm_theme_" + theme); rootContext()->setContextProperty("config", new ConfigWrapper(package.filePath("configfile"), this)); rootContext()->setContextProperty("greeter", m_greeter); setSource(package.filePath("mainscript")); // Prevent screen flickering when the greeter starts up. This really needs to be sorted out in QML/Qt... setAttribute(Qt::WA_OpaquePaintEvent); setAttribute(Qt::WA_NoSystemBackground); // Shortcut to take a screenshot of the screen. Handy because it is not // possible to take a screenshot of the greeter in test mode without // including the cursor. QShortcut* cut = new QShortcut(this); cut->setKey(Qt::CTRL + Qt::ALT + Qt::Key_S); connect(cut, SIGNAL(activated()), SLOT(screenshot())); connect(m_greeter, SIGNAL(aboutToLogin()), SLOT(setRootImage())); QRect screen = QApplication::desktop()->rect(); setGeometry(screen); new PowerManagement(this); }