Skip to content

Commit

Permalink
Add link to user themes directory to LookConfig
Browse files Browse the repository at this point in the history
  • Loading branch information
hacst committed Sep 8, 2015
1 parent 3576e52 commit 426edb6
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 8 deletions.
19 changes: 13 additions & 6 deletions src/mumble/LookConfig.cpp
Expand Up @@ -81,6 +81,13 @@ LookConfig::LookConfig(Settings &st) : ConfigWidget(st) {
qcbChannelDrag->insertItem(Settings::Ask, tr("Ask"), Settings::Ask);
qcbChannelDrag->insertItem(Settings::DoNothing, tr("Do Nothing"), Settings::DoNothing);
qcbChannelDrag->insertItem(Settings::Move, tr("Move"), Settings::Move);

QDir userThemeDirectory = Themes::getUserThemesDirectory();
if (userThemeDirectory.exists()) {
QUrl userThemeDirectoryUrl = QUrl::fromLocalFile(userThemeDirectory.path());
qlThemesDirectory->setText(tr("<a href=\"%1\">Browse</a>").arg(userThemeDirectoryUrl.toString()));
qlThemesDirectory->setOpenExternalLinks(true);
}
}

QString LookConfig::title() const {
Expand Down Expand Up @@ -148,17 +155,17 @@ void LookConfig::load(const Settings &r) {
theme != themes.end();
++theme) {

for (ThemeInfo::StylesMap::const_iterator style = theme->styles.begin();
style != theme->styles.end();
++style) {
for (ThemeInfo::StylesMap::const_iterator styleit = theme->styles.begin();
styleit != theme->styles.end();
++styleit) {

if (configuredStyle
&& configuredStyle->themeName == style->themeName
&& configuredStyle->name == style->name) {
&& configuredStyle->themeName == styleit->themeName
&& configuredStyle->name == styleit->name) {
selectedThemeEntry = qcbTheme->count();
}

qcbTheme->addItem(theme->name + QLatin1String(" - ") + style->name, QVariant::fromValue(*style));
qcbTheme->addItem(theme->name + QLatin1String(" - ") + styleit->name, QVariant::fromValue(*styleit));
}
}

Expand Down
12 changes: 11 additions & 1 deletion src/mumble/LookConfig.ui
Expand Up @@ -6,7 +6,7 @@
<rect>
<x>0</x>
<y>0</y>
<width>644</width>
<width>702</width>
<height>611</height>
</rect>
</property>
Expand Down Expand Up @@ -93,6 +93,16 @@
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QLabel" name="qlThemesDirectory">
<property name="text">
<string/>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
</layout>
</widget>
</item>
Expand Down
6 changes: 5 additions & 1 deletion src/mumble/Themes.cpp
Expand Up @@ -124,6 +124,10 @@ ThemeMap Themes::getThemes() {
return ThemeInfo::scanDirectories(getSearchDirectories());
}

QDir Themes::getUserThemesDirectory() {
return QDir(g.qdBasePath.absolutePath() + QLatin1String("/Themes"));
}

QVector<QDir> Themes::getSearchDirectories() {
QVector<QDir> themeSearchDirectories;

Expand All @@ -132,7 +136,7 @@ QVector<QDir> Themes::getSearchDirectories() {
// Next come themes found in the applications Themes directory
themeSearchDirectories << QDir(MumbleApplication::instance()->applicationVersionRootPath() + QLatin1String("/Themes"));
// Highest priorty have themes located in the user directory
themeSearchDirectories << QDir(g.qdBasePath.absolutePath() + QLatin1String("/Themes"));
themeSearchDirectories << getUserThemesDirectory();

return themeSearchDirectories;
}
Expand Down
3 changes: 3 additions & 0 deletions src/mumble/Themes.h
Expand Up @@ -58,6 +58,9 @@ class Themes {
/// Return a theme name to theme map
static ThemeMap getThemes();

/// Returns the per user themes directory
static QDir getUserThemesDirectory();

private:
/// Applies the fallback stylesheet
static void applyFallback();
Expand Down

0 comments on commit 426edb6

Please sign in to comment.