Skip to content

Commit b0b5157

Browse files
committed
init stylesheet before mainwindow is shown
1 parent a5a9b32 commit b0b5157

File tree

12 files changed

+15
-62
lines changed

12 files changed

+15
-62
lines changed

src/core/theme.cpp

Lines changed: 0 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -258,7 +258,6 @@ QString Theme::fetchQtStyleSheet() const
258258
translateStyleByPalette(m_palette, style);
259259
translateUrlToAbsolute(m_themeFolderPath, style);
260260
translateFontFamilyList(style);
261-
translateScaledSize(WidgetUtils::calculateScaleFactor(), style);
262261
return style;
263262
}
264263

@@ -355,40 +354,6 @@ void Theme::translateFontFamilyList(QString &p_style)
355354
}
356355
}
357356

358-
void Theme::translateScaledSize(qreal p_factor, QString &p_style)
359-
{
360-
QRegularExpression scaleRe("(\\s|:)\\$([+-]?)(\\d+)(?=\\D)");
361-
const int prefixCapturedIdx = 1;
362-
const int signCapturedIdx = 2;
363-
const int numCapturedIdx = 3;
364-
365-
qDebug() << "translateScaledSize of Qt style sheet" << p_factor;
366-
367-
int pos = 0;
368-
QRegularExpressionMatch match;
369-
while (pos < p_style.size()) {
370-
int idx = p_style.indexOf(scaleRe, pos, &match);
371-
if (idx == -1) {
372-
break;
373-
}
374-
375-
auto numStr = match.captured(numCapturedIdx);
376-
bool ok = false;
377-
int val = numStr.toInt(&ok);
378-
if (!ok) {
379-
pos = idx + match.capturedLength();
380-
continue;
381-
}
382-
383-
val = val * p_factor + 0.5;
384-
auto newStr = QStringLiteral("%1%2%3").arg(match.captured(prefixCapturedIdx),
385-
match.captured(signCapturedIdx),
386-
QString::number(val));
387-
p_style.replace(idx, match.capturedLength(), newStr);
388-
pos = idx + newStr.size();
389-
}
390-
}
391-
392357
QString Theme::paletteColor(const QString &p_name) const
393358
{
394359
auto val = findValueByKeyPath(m_palette, p_name).toString();

src/core/theme.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -113,8 +113,6 @@ namespace vnotex
113113
// Thus we need to choose one available font from the list.
114114
static void translateFontFamilyList(QString &p_style);
115115

116-
static void translateScaledSize(qreal p_factor, QString &p_style);
117-
118116
static QJsonObject readJsonFile(const QString &p_filePath);
119117

120118
static QJsonObject readPaletteFile(const QString &p_folder);

src/data/extra/themes/moonlight/interface.qss

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
* same specificity and the rule that appears last takes precedence.
66
* VNote specific syntax:
77
* - @widgets#toolbox#title#border: reference to a color defined in palette.ini;
8-
* - $2px: 2 will be scaled by multiplying current display scaled factor.
98
*/
109

1110
QWidget {
@@ -586,7 +585,7 @@ QTabBar::close-button:hover {
586585
}
587586

588587
QTabBar::scroller {
589-
width: $20px;
588+
width: 20px;
590589
}
591590

592591
QTabBar QToolButton {

src/data/extra/themes/native/interface.qss

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
* same specificity and the rule that appears last takes precedence.
66
* VNote specific syntax:
77
* - @widgets#toolbox#title#border: reference to a color defined in palette.ini;
8-
* - $2px: 2 will be scaled by multiplying current display scaled factor.
98
*/
109

1110
QWidget[HitSettingWidget="true"] {

src/data/extra/themes/pure/interface.qss

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
* same specificity and the rule that appears last takes precedence.
66
* VNote specific syntax:
77
* - @widgets#toolbox#title#border: reference to a color defined in palette.ini;
8-
* - $2px: 2 will be scaled by multiplying current display scaled factor.
98
*/
109

1110
QWidget {
@@ -624,7 +623,7 @@ QTabBar::close-button:hover {
624623
}
625624

626625
QTabBar::scroller {
627-
width: $20px;
626+
width: 20px;
628627
}
629628

630629
QTabBar QToolButton {

src/data/extra/themes/solarized-dark/interface.qss

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
* same specificity and the rule that appears last takes precedence.
66
* VNote specific syntax:
77
* - @widgets#toolbox#title#border: reference to a color defined in palette.ini;
8-
* - $2px: 2 will be scaled by multiplying current display scaled factor.
98
*/
109

1110
QWidget {
@@ -582,7 +581,7 @@ QTabBar::close-button:hover {
582581
}
583582

584583
QTabBar::scroller {
585-
width: $20px;
584+
width: 20px;
586585
}
587586

588587
QTabBar QToolButton {

src/data/extra/themes/solarized-light/interface.qss

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
* same specificity and the rule that appears last takes precedence.
66
* VNote specific syntax:
77
* - @widgets#toolbox#title#border: reference to a color defined in palette.ini;
8-
* - $2px: 2 will be scaled by multiplying current display scaled factor.
98
*/
109

1110
QWidget {
@@ -582,7 +581,7 @@ QTabBar::close-button:hover {
582581
}
583582

584583
QTabBar::scroller {
585-
width: $20px;
584+
width: 20px;
586585
}
587586

588587
QTabBar QToolButton {

src/data/extra/themes/vscode-dark/interface.qss

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
* same specificity and the rule that appears last takes precedence.
66
* VNote specific syntax:
77
* - @widgets#toolbox#title#border: reference to a color defined in palette.ini;
8-
* - $2px: 2 will be scaled by multiplying current display scaled factor.
98
*/
109

1110
QWidget {
@@ -582,7 +581,7 @@ QTabBar::close-button:hover {
582581
}
583582

584583
QTabBar::scroller {
585-
width: $20px;
584+
width: 20px;
586585
}
587586

588587
QTabBar QToolButton {

src/data/extra/themes/vue-dark/interface.qss

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
* same specificity and the rule that appears last takes precedence.
66
* VNote specific syntax:
77
* - @widgets#toolbox#title#border: reference to a color defined in palette.ini;
8-
* - $2px: 2 will be scaled by multiplying current display scaled factor.
98
*/
109

1110
QWidget {
@@ -587,7 +586,7 @@ QTabBar::close-button:hover {
587586
}
588587

589588
QTabBar::scroller {
590-
width: $20px;
589+
width: 20px;
591590
}
592591

593592
QTabBar QToolButton {

src/data/extra/themes/vue-light/interface.qss

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
* same specificity and the rule that appears last takes precedence.
66
* VNote specific syntax:
77
* - @widgets#toolbox#title#border: reference to a color defined in palette.ini;
8-
* - $2px: 2 will be scaled by multiplying current display scaled factor.
98
*/
109

1110
QWidget {
@@ -624,7 +623,7 @@ QTabBar::close-button:hover {
624623
}
625624

626625
QTabBar::scroller {
627-
width: $20px;
626+
width: 20px;
628627
}
629628

630629
QTabBar QToolButton {

0 commit comments

Comments
 (0)