IconThemesConfig::IconThemesConfig(QWidget *parent, const char *name) : KCModule(parent, name) { QVBoxLayout *topLayout = new QVBoxLayout(this, KDialog::marginHint(), KDialog::spacingHint()); QFrame *m_preview=new QFrame(this); m_preview->setMinimumHeight(50); QHBoxLayout *lh2=new QHBoxLayout( m_preview ); m_previewExec=new QLabel(m_preview); m_previewExec->setPixmap(DesktopIcon("exec")); m_previewFolder=new QLabel(m_preview); m_previewFolder->setPixmap(DesktopIcon("folder")); m_previewDocument=new QLabel(m_preview); m_previewDocument->setPixmap(DesktopIcon("document")); lh2->addStretch(10); lh2->addWidget(m_previewExec); lh2->addStretch(1); lh2->addWidget(m_previewFolder); lh2->addStretch(1); lh2->addWidget(m_previewDocument); lh2->addStretch(10); m_iconThemes=new KListView(this,"IconThemeList"); m_iconThemes->addColumn(i18n("Name")); m_iconThemes->addColumn(i18n("Description")); m_iconThemes->setAllColumnsShowFocus( true ); m_iconThemes->setFullWidth(true); connect(m_iconThemes,SIGNAL(selectionChanged(QListViewItem *)), SLOT(themeSelected(QListViewItem *))); QPushButton *installButton=new QPushButton( i18n("Install New Theme..."), this, "InstallNewTheme"); connect(installButton,SIGNAL(clicked()),SLOT(installNewTheme())); m_removeButton=new QPushButton( i18n("Remove Theme"), this, "RemoveTheme"); connect(m_removeButton,SIGNAL(clicked()),SLOT(removeSelectedTheme())); topLayout->addWidget( new QLabel(i18n("Select the icon theme you want to use:"), this)); topLayout->addWidget(m_preview); topLayout->addWidget(m_iconThemes); QHBoxLayout *lg = new QHBoxLayout(topLayout, KDialog::spacingHint()); lg->addWidget(installButton); lg->addWidget(m_removeButton); loadThemes(); load(); m_iconThemes->setFocus(); }
void ThemesDlg::getNewStuff() { if (!m_newStuffInitialized) { KDirWatch *dirWatch = KDirWatch::self(); connect(dirWatch, SIGNAL(created(QString)), SLOT(installNewTheme(QString))); QString destDir = KStandardDirs::locateLocal("appdata", "themes/"); dirWatch->addDir(destDir, KDirWatch::WatchFiles); m_newStuffInitialized = true; } KNS::Engine::download(); }
KDMThemeWidget::KDMThemeWidget(QWidget *parent) : QWidget(parent) { QGridLayout *ml = new QGridLayout(this); ml->setSizeConstraint(QLayout::SetMinAndMaxSize); ml->setSpacing(KDialog::spacingHint()); ml->setMargin(KDialog::marginHint()); themeWidget = new QTreeWidget(this); themeWidget->setHeaderLabels(QStringList() << i18nc("@title:column", "Theme") << i18nc("@title:column", "Author")); themeWidget->setSortingEnabled(true); themeWidget->sortItems(0, Qt::AscendingOrder); themeWidget->setRootIsDecorated(false); themeWidget->setWhatsThis(i18n("This is a list of installed themes.\n" "Click the one to be used.")); ml->addWidget(themeWidget, 0, 0, 2, 4); preview = new QLabel(this); preview->setFixedSize(QSize(200, 150)); preview->setScaledContents(true); preview->setWhatsThis(i18n("This is a screen shot of what KDM will look like.")); ml->addWidget(preview, 0, 4); info = new QLabel(this); info->setMaximumWidth(200); info->setAlignment(Qt::AlignTop); info->setWordWrap(true); info->setWhatsThis(i18n("This contains information about the selected theme.")); ml->addWidget(info, 1, 4); bInstallTheme = new QPushButton(i18nc("@action:button", "Install &new theme"), this); bInstallTheme->setWhatsThis(i18n("This will install a theme into the theme directory.")); ml->addWidget(bInstallTheme, 2, 0); bRemoveTheme = new QPushButton(i18nc("@action:button", "&Remove theme"), this); bRemoveTheme->setWhatsThis(i18n("This will remove the selected theme.")); ml->addWidget(bRemoveTheme, 2, 1); bGetNewThemes = new QPushButton(i18nc("@action:button", "&Get New Themes"), this); ml->addWidget(bGetNewThemes, 2, 2); connect(themeWidget, SIGNAL(itemSelectionChanged()), SLOT(themeSelected())); connect(bInstallTheme, SIGNAL(clicked()), SLOT(installNewTheme())); connect(bRemoveTheme, SIGNAL(clicked()), SLOT(removeSelectedThemes())); connect(bGetNewThemes, SIGNAL(clicked()), SLOT(getNewStuff())); themeDir = KStandardDirs::installPath("data") + "kdm/themes/"; defaultTheme = 0; foreach (const QString &ent, QDir(themeDir).entryList(QDir::Dirs | QDir::NoDotAndDotDot, QDir::Unsorted)) insertTheme(themeDir + ent); }