diff options
author | Simon Rettberg | 2024-07-09 11:10:57 +0200 |
---|---|---|
committer | Simon Rettberg | 2024-07-09 11:10:57 +0200 |
commit | da74b8b4e7a622706ab9e9d9cacabd1662f0d74b (patch) | |
tree | 3a0ffe3d88219c0c00c3456751e58a35acb91143 /src/dialog.cpp | |
parent | Support CoW, and selecting between edit and copy (diff) | |
download | vmchooser2-da74b8b4e7a622706ab9e9d9cacabd1662f0d74b.tar.gz vmchooser2-da74b8b4e7a622706ab9e9d9cacabd1662f0d74b.tar.xz vmchooser2-da74b8b4e7a622706ab9e9d9cacabd1662f0d74b.zip |
- Make image bg transparent, so the configured one can be seen with PNGs
- Allow specifying the header background as QSS using "background="
Diffstat (limited to 'src/dialog.cpp')
-rw-r--r-- | src/dialog.cpp | 43 |
1 files changed, 25 insertions, 18 deletions
diff --git a/src/dialog.cpp b/src/dialog.cpp index 9dfff00..3eeaf7e 100644 --- a/src/dialog.cpp +++ b/src/dialog.cpp @@ -428,16 +428,19 @@ void Dialog::startSession(const QString& name) { } void Dialog::setTheme() { - QString label_l_style, label_r_style; - QString backgroundColor, imageLeft, imageRight; + QString backgroundColor, imageLeft, imageRight, backgroundStyle; QString themePathBase, themePathIni, themePathImgLeft, themePathImgRight; if (!Config::isSet(Config::THEME)) return; QString theme(Config::get(Config::THEME)); - themePathBase = QString("%1/%2/").arg(VMCHOOSER_THEME_BASE).arg(theme); - themePathIni = QString("%1%2.ini").arg(themePathBase).arg(theme); + if (theme.startsWith(QStringLiteral("/"))) { + themePathBase = theme + QStringLiteral("/"); + } else { + themePathBase = QStringLiteral("%1/%2/").arg(VMCHOOSER_THEME_BASE).arg(theme); + } + themePathIni = themePathBase + theme + QStringLiteral(".ini"); if (!QFile::exists(themePathIni)) { qDebug() << "Theme config" << themePathIni << "does not exist"; @@ -445,24 +448,28 @@ void Dialog::setTheme() { } QSettings themeSettings(themePathIni, QSettings::IniFormat); + themeSettings.setIniCodec("UTF-8"); backgroundColor = themeSettings.value("background-color").toString(); + backgroundStyle = themeSettings.value("background").toString(); imageLeft = themeSettings.value("image-left").toString(); imageRight = themeSettings.value("image-right").toString(); - themePathImgLeft = QString("%1%2").arg(themePathBase).arg(imageLeft); - themePathImgRight = QString("%1%2").arg(themePathBase).arg(imageRight); - - QRegExp re("(.*background-color:)#[^;]*(;.*)"); - - ui->label_l->setPixmap(QPixmap(themePathImgLeft)); - ui->label_r->setPixmap(QPixmap(themePathImgRight)); - label_l_style = ui->label_l->styleSheet(); - label_r_style = ui->label_r->styleSheet(); - backgroundColor.prepend("\\1").append("\\2"); - label_l_style.replace(re, backgroundColor); - label_r_style.replace(re, backgroundColor); - ui->label_l->setStyleSheet(label_l_style); - ui->label_r->setStyleSheet(label_r_style); + themePathImgLeft = themePathBase + imageLeft; + themePathImgRight = themePathBase + imageRight; + + QPixmap imgLeft(themePathImgLeft); + QPixmap imgRight(themePathImgRight); + ui->label_l->setPixmap(imgLeft); + ui->label_r->setPixmap(imgRight); + ui->label_l->setMinimumSize(imgLeft.size()); + ui->label_r->setMinimumSize(imgRight.size()); + if (!backgroundStyle.isEmpty()) { + qDebug() << "Setting background to" << (backgroundStyle); + ui->headerBg->setStyleSheet(QStringLiteral("#headerBg { %1 }").arg(backgroundStyle)); + } else { + backgroundColor = QStringLiteral("background:") + backgroundColor; + ui->headerBg->setStyleSheet(backgroundColor); + } } |