status_t ThemeInterfaceView::AddScreenshot() { status_t err; ThemeManager* tman = GetThemeManager(); int32 id; ThemeItem *item; BMessage theme; // find selected theme id = fThemeList->CurrentSelection(0); if (id < 0) return B_OK; item = dynamic_cast<ThemeItem *>(fThemeList->ItemAt(id)); if (!item) return AError(__FUNCTION__, ENOENT); id = item->ThemeId(); if (id < 0) return AError(__FUNCTION__, ENOENT); // then apply err = tman->MakeThemeScreenShot(id); if (err) return AError(__FUNCTION__, err); err = tman->SaveTheme(id); if (err) return AError(__FUNCTION__, err); ThemeSelected(); // force reload of description for selected theme. return err; }
status_t ThemeInterfaceView::DeleteSelected() { status_t err; ThemeManager* tman = GetThemeManager(); int32 id; ThemeItem *item; BMessage theme; // find selected theme id = fThemeList->CurrentSelection(0); if (id < 0) return B_OK; item = dynamic_cast<ThemeItem *>(fThemeList->ItemAt(id)); if (!item) return AError(__FUNCTION__, ENOENT); if (item->IsReadOnly()) return AError(__FUNCTION__, B_READ_ONLY_DEVICE); id = item->ThemeId(); if (id < 0) return AError(__FUNCTION__, ENOENT); // then apply err = tman->DeleteTheme(id); if (err) return AError(__FUNCTION__, err); fThemeList->RemoveItem(item); delete item; //err = tman->ApplyTheme(theme); return err; }
void ThemePreview::doPreview() { if (!themedView) return; ThemeItem *page = themedView->findItem(m_name, ThemedView::Page); if (page) m_preview = QPixmap::grabWidget(themedView, page->rect()); emit previewReady(m_preview.scaledToWidth((int)(m_width * 0.55), Qt::SmoothTransformation)); }
status_t ThemeInterfaceView::ThemeSelected() { status_t err; ThemeManager* tman = GetThemeManager(); int32 id; ThemeItem *item; BString desc; BBitmap *sshot = NULL; // find selected theme id = fThemeList->CurrentSelection(0); if (id < 0) { fScreenshotPane->ClearViewBitmap(); fScreenshotPane->Invalidate(fScreenshotPane->Bounds()); while(true == fScreenshotText->IsHidden()) fScreenshotText->Show(); fScreenshotText->SetText(B_TRANSLATE("No theme selected")); return ENOENT; } item = dynamic_cast<ThemeItem *>(fThemeList->ItemAt(id)); if (!item) return ENOENT; id = item->ThemeId(); if (id < 0) return ENOENT; // then apply err = tman->ThemeScreenShot(id, &sshot); if (err) sshot = NULL; if (sshot == NULL) { SetScreenshot(NULL); fprintf(stderr, "ThemeManager: no screenshot; error 0x%08lx\n", err); while(true == fScreenshotText->IsHidden()) fScreenshotText->Show(); fScreenshotText->SetText(B_TRANSLATE("No screenshot")); return err; } SetScreenshot(sshot); while(false == fScreenshotText->IsHidden()) fScreenshotText->Hide(); //err = tman->ApplyTheme(theme); return err; }
void chargingStateChanged() { if (!vsoCharging.value(QByteArray(), false).toBool()) { ThemeItem *item = findItem("battery", ThemedView::Item); if (item) item->setActive(false); item = findItem("poweroff", ThemedView::Item); if (item) item->setActive(true); repaint(); QtopiaServerApplication::instance()->shutdown(QtopiaServerApplication::ShutdownSystem); } }
void ThemeItemPreview::getPixmap(QPixmap *pixmap, int width, int height, QSoftMenuBar::LabelType labelType) { m_themedView->loadSource(m_xmlSourcePath); m_themedView->resize(width, height); if (labelType != QSoftMenuBar::LabelType(-1)) { bool useIcon = (labelType == QSoftMenuBar::IconLabel); QList<QSoftMenuBar::StandardLabel> labels; if (QApplication::isLeftToRight()) labels << QSoftMenuBar::Options << QSoftMenuBar::Select << QSoftMenuBar::Back; else labels << QSoftMenuBar::Back << QSoftMenuBar::Select << QSoftMenuBar::Options; for (int i=0; i<labels.size(); i++) resetButton(useIcon, i, labels[i]); } ThemeItem *page = m_themedView->findItem(m_pageItemName, ThemedView::Page); if (page) *pixmap = QPixmap::grabWidget(m_themedView, page->rect()); }
status_t ThemeInterfaceView::ApplySelected() { status_t err; ThemeManager* tman = GetThemeManager(); int32 id; ThemeItem *item; // find selected theme id = fThemeList->CurrentSelection(0); if (id < 0) return ENOENT; item = dynamic_cast<ThemeItem *>(fThemeList->ItemAt(id)); if (!item) return ENOENT; id = item->ThemeId(); if (id < 0) return ENOENT; SetIsRevertable(); err = tman->ApplyTheme(id); return err; }