diff options
-rw-r--r-- | src/dialog.cpp | 43 | ||||
-rw-r--r-- | src/ui/dialog.ui | 167 |
2 files changed, 123 insertions, 87 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); + } } diff --git a/src/ui/dialog.ui b/src/ui/dialog.ui index 0e195ea..4e03ebc 100644 --- a/src/ui/dialog.ui +++ b/src/ui/dialog.ui @@ -35,73 +35,100 @@ <number>6</number> </property> <item> - <layout class="QHBoxLayout" name="title"> - <property name="spacing"> - <number>0</number> - </property> - <property name="bottomMargin"> - <number>0</number> + <widget class="QWidget" name="headerBg" native="true"> + <property name="styleSheet"> + <string notr="true">background: #fff;</string> </property> - <item> - <widget class="QLabel" name="label_l"> - <property name="minimumSize"> - <size> - <width>0</width> - <height>110</height> - </size> - </property> - <property name="styleSheet"> - <string notr="true">#label_l {background-color:#fff; -margin-left:1px; -margin-top:1px; -margin-bottom:0px;}</string> - </property> - <property name="frameShadow"> - <enum>QFrame::Plain</enum> - </property> - <property name="text"> - <string/> - </property> - <property name="pixmap"> - <pixmap>:/title_l</pixmap> - </property> - </widget> - </item> - <item> - <widget class="QLabel" name="label_r"> - <property name="minimumSize"> - <size> - <width>120</width> - <height>110</height> - </size> - </property> - <property name="maximumSize"> - <size> - <width>120</width> - <height>16777215</height> - </size> - </property> - <property name="styleSheet"> - <string notr="true">#label_r {background-color:#fff; -margin-top:1px; -margin-right:1px; -margin-bottom:0px;}</string> - </property> - <property name="frameShadow"> - <enum>QFrame::Plain</enum> - </property> - <property name="text"> - <string/> - </property> - <property name="pixmap"> - <pixmap>:/title_r</pixmap> - </property> - <property name="alignment"> - <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set> - </property> - </widget> - </item> - </layout> + <layout class="QHBoxLayout" name="horizontalLayout"> + <property name="spacing"> + <number>0</number> + </property> + <property name="leftMargin"> + <number>0</number> + </property> + <property name="topMargin"> + <number>0</number> + </property> + <property name="rightMargin"> + <number>0</number> + </property> + <property name="bottomMargin"> + <number>0</number> + </property> + <item> + <widget class="QLabel" name="label_l"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Preferred" vsizetype="Preferred"> + <horstretch>0</horstretch> + <verstretch>10</verstretch> + </sizepolicy> + </property> + <property name="minimumSize"> + <size> + <width>0</width> + <height>10</height> + </size> + </property> + <property name="frameShadow"> + <enum>QFrame::Plain</enum> + </property> + <property name="text"> + <string/> + </property> + <property name="pixmap"> + <pixmap resource="../images.qrc">:/title_l</pixmap> + </property> + </widget> + </item> + <item> + <spacer name="horizontalSpacer_3"> + <property name="orientation"> + <enum>Qt::Horizontal</enum> + </property> + <property name="sizeHint" stdset="0"> + <size> + <width>40</width> + <height>20</height> + </size> + </property> + </spacer> + </item> + <item> + <widget class="QLabel" name="label_r"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Preferred" vsizetype="Preferred"> + <horstretch>0</horstretch> + <verstretch>10</verstretch> + </sizepolicy> + </property> + <property name="minimumSize"> + <size> + <width>0</width> + <height>10</height> + </size> + </property> + <property name="maximumSize"> + <size> + <width>16777215</width> + <height>16777215</height> + </size> + </property> + <property name="frameShadow"> + <enum>QFrame::Plain</enum> + </property> + <property name="text"> + <string/> + </property> + <property name="pixmap"> + <pixmap resource="../images.qrc">:/title_r</pixmap> + </property> + <property name="alignment"> + <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set> + </property> + </widget> + </item> + </layout> + </widget> </item> <item> <layout class="QHBoxLayout" name="help_news"> @@ -219,7 +246,7 @@ li.checked::marker { content: "\2612"; } <string>Local</string> </property> <property name="icon"> - <iconset> + <iconset resource="../images.qrc"> <normaloff>:/linux</normaloff>:/linux</iconset> </property> <property name="iconSize"> @@ -261,7 +288,7 @@ li.checked::marker { content: "\2612"; } <string>All Classes</string> </property> <property name="icon"> - <iconset> + <iconset resource="../images.qrc"> <normaloff>:/vm-mix</normaloff>:/vm-mix</iconset> </property> <property name="iconSize"> @@ -685,6 +712,8 @@ li.checked::marker { content: "\2612"; } <header>src/vmtree.h</header> </customwidget> </customwidgets> - <resources/> + <resources> + <include location="../images.qrc"/> + </resources> <connections/> </ui> |