Skip to content

Commit 2560174

Browse files
committed
Extract noLibrariesWidget theme and use themed line assets
1 parent f65fd08 commit 2560174

14 files changed

Lines changed: 228 additions & 54 deletions

YACReaderLibrary/images.qrc

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242
<file>../images/flow3.png</file>
4343
<file>../images/flow4.png</file>
4444
<file>../images/flow5.png</file>
45-
<file>../images/glowLine.png</file>
45+
<file>../images/glowLine.svg</file>
4646
<file>../images/metadata_dialog/loadCustomCover.svg</file>
4747
<file>../images/import/coversToggle.svg</file>
4848
<file>../images/icon-new.svg</file>
@@ -74,7 +74,7 @@
7474
<file>../images/library_dialogs/new.svg</file>
7575
<file>../images/metadata_dialog/nextCoverPage.svg</file>
7676
<file>../images/noLibrariesIcon.svg</file>
77-
<file>../images/noLibrariesLine.png</file>
77+
<file>../images/noLibrariesLine.svg</file>
7878
<file>../images/notCover.png</file>
7979
<file>../images/library_dialogs/openLibrary.svg</file>
8080
<file>../images/metadata_dialog/previousCoverPage.svg</file>
@@ -111,13 +111,11 @@
111111
<file>../images/import/updatingIcon.svg</file>
112112
<file>../images/custom_dialog/custom_close_button.svg</file>
113113
<file>../images/whats_new/whatsnew_header.svg</file>
114-
115114
<file>../images/lists/default_0.svg</file>
116115
<file>../images/lists/default_1.svg</file>
117116
<file>../images/lists/default_2.svg</file>
118117
<file>../images/lists/label_template.svg</file>
119118
<file>../images/lists/list.svg</file>
120-
121119
<file>../images/clearSearchNew.svg</file>
122120
<file>../images/iconSearchNew.svg</file>
123121
</qresource>

YACReaderLibrary/import_widget.cpp

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ class YACReaderActivityIndicatorWidget : public QWidget
2323
{
2424
public:
2525
YACReaderActivityIndicatorWidget(QWidget *parent = 0);
26+
void setPixmaps(const QPixmap &normalLine, const QPixmap &glowLine);
27+
2628
public slots:
2729

2830
private:
@@ -31,16 +33,11 @@ public slots:
3133
};
3234

3335
YACReaderActivityIndicatorWidget::YACReaderActivityIndicatorWidget(QWidget *parent)
34-
: QWidget(parent)
36+
: QWidget(parent), normal(nullptr), glow(nullptr)
3537
{
36-
QPixmap line(":/images/noLibrariesLine.png");
37-
QPixmap glowLine(":/images/glowLine.png");
3838
normal = new QLabel(this);
3939
glow = new QLabel(this);
4040

41-
normal->setPixmap(line);
42-
glow->setPixmap(glowLine);
43-
4441
auto layout = new QHBoxLayout();
4542

4643
layout->addWidget(normal, 0, Qt::AlignVCenter);
@@ -50,11 +47,6 @@ YACReaderActivityIndicatorWidget::YACReaderActivityIndicatorWidget(QWidget *pare
5047
layout->setContentsMargins(4, 4, 4, 4);
5148
layout->setSpacing(0);
5249

53-
// setFixedHeight(3);
54-
// resize(579,3);
55-
glow->setGeometry(4, 4, glowLine.width(), glowLine.height());
56-
// normal->setGeometry(0,1,579,1);
57-
5850
auto effect = new QGraphicsOpacityEffect();
5951
// effect->setOpacity(1.0);
6052

@@ -80,6 +72,13 @@ YACReaderActivityIndicatorWidget::YACReaderActivityIndicatorWidget(QWidget *pare
8072
animation->start();
8173
}
8274

75+
void YACReaderActivityIndicatorWidget::setPixmaps(const QPixmap &normalLine, const QPixmap &glowLine)
76+
{
77+
normal->setPixmap(normalLine);
78+
glow->setPixmap(glowLine);
79+
glow->setGeometry(4, 4, glowLine.width(), glowLine.height());
80+
}
81+
8382
ImportWidget::ImportWidget(QWidget *parent)
8483
: QWidget(parent)
8584
{
@@ -88,7 +87,7 @@ ImportWidget::ImportWidget(QWidget *parent)
8887

8988
iconLabel = new QLabel();
9089

91-
auto activityIndicator = new YACReaderActivityIndicatorWidget();
90+
activityIndicator = new YACReaderActivityIndicatorWidget();
9291

9392
text = new QLabel();
9493
textDescription = new QLabel();
@@ -399,6 +398,9 @@ void ImportWidget::applyTheme(const Theme &theme)
399398
bottomDecorator->setPixmap(importTheme.bottomCoversDecoration);
400399
bottomDecorator->setFixedHeight(importTheme.bottomCoversDecoration.height());
401400

401+
const auto &noLibrariesWidget = theme.noLibrariesWidget;
402+
activityIndicator->setPixmaps(noLibrariesWidget.noLibrariesLinePixmap, importTheme.glowLinePixmap);
403+
402404
// Apply text colors
403405
updateTextColors();
404406
}

YACReaderLibrary/import_widget.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414
#include <QToolButton>
1515
#include <QWidget>
1616

17+
class YACReaderActivityIndicatorWidget;
18+
1719
class ImportWidget : public QWidget, protected Themable
1820
{
1921
Q_OBJECT
@@ -57,6 +59,7 @@ public slots:
5759
QToolButton *hideButton;
5860
QLabel *topDecorator;
5961
QLabel *bottomDecorator;
62+
YACReaderActivityIndicatorWidget *activityIndicator;
6063

6164
void resizeEvent(QResizeEvent *event) override;
6265
void updateTextColors();

YACReaderLibrary/no_libraries_widget.cpp

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,7 @@ NoLibrariesWidget::NoLibrariesWidget(QWidget *parent)
1313

1414
iconLabel = new QLabel();
1515

16-
QPixmap line(":/images/noLibrariesLine.png");
17-
QLabel *lineLabel = new QLabel();
18-
lineLabel->setPixmap(line);
16+
lineLabel = new QLabel();
1917

2018
text = new QLabel(tr("You don't have any libraries yet"));
2119
text->setStyleSheet("QLabel {font-size:25px;font-weight:bold;}");
@@ -75,19 +73,20 @@ NoLibrariesWidget::NoLibrariesWidget(QWidget *parent)
7573

7674
void NoLibrariesWidget::applyTheme(const Theme &theme)
7775
{
78-
auto emptyTheme = theme.emptyContainer;
76+
auto nlwTheme = theme.noLibrariesWidget;
7977

8078
QPalette p(palette());
81-
p.setColor(QPalette::Window, emptyTheme.backgroundColor);
79+
p.setColor(QPalette::Window, nlwTheme.backgroundColor);
8280
setPalette(p);
8381

8482
QPalette textPalette = text->palette();
85-
textPalette.setColor(QPalette::WindowText, emptyTheme.textColor);
83+
textPalette.setColor(QPalette::WindowText, nlwTheme.textColor);
8684
text->setPalette(textPalette);
8785

8886
QPalette descPalette = textDescription->palette();
89-
descPalette.setColor(QPalette::WindowText, emptyTheme.descriptionTextColor);
87+
descPalette.setColor(QPalette::WindowText, nlwTheme.descriptionTextColor);
9088
textDescription->setPalette(descPalette);
9189

92-
iconLabel->setPixmap(emptyTheme.noLibrariesIcon);
90+
iconLabel->setPixmap(nlwTheme.noLibrariesIcon);
91+
lineLabel->setPixmap(nlwTheme.noLibrariesLinePixmap);
9392
}

YACReaderLibrary/no_libraries_widget.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ public slots:
2525
QLabel *iconLabel;
2626
QLabel *text;
2727
QLabel *textDescription;
28+
QLabel *lineLabel;
2829
};
2930

3031
#endif // NO_LIBRARIES_WIDGET_H

YACReaderLibrary/themes/builtin_classic.json

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,7 @@
3939
},
4040
"emptyContainer": {
4141
"backgroundColor": "#2a2a2a",
42-
"descriptionTextColor": "#aaaaaa",
43-
"searchIconColor": "#4c4c4c",
44-
"textColor": "#cccccc",
42+
"iconColor": "#4c4c4c",
4543
"titleTextColor": "#cccccc"
4644
},
4745
"gridAndInfoView": {
@@ -97,6 +95,7 @@
9795
"coversViewBackgroundColor": "#3a3a3a",
9896
"currentComicTextColor": "#aaaaaa",
9997
"descriptionTextColor": "#aaaaaa",
98+
"glowLineColor": "#ffe100",
10099
"iconCheckedColor": "#aaaaaa",
101100
"iconColor": "#cccccc",
102101
"modeIconColor": "#4a4a4a",
@@ -179,6 +178,13 @@
179178
"selectionBackgroundColor": "#2e2e2e",
180179
"textColor": "#dddfdf"
181180
},
181+
"noLibrariesWidget": {
182+
"backgroundColor": "#2a2a2a",
183+
"descriptionTextColor": "#aaaaaa",
184+
"iconColor": "#4c4c4c",
185+
"noLibrariesLineColor": "#a8a8a8",
186+
"textColor": "#cccccc"
187+
},
182188
"readingListIcons": {
183189
"currentlyReadingMainColor": "#ffcc00",
184190
"currentlyReadingMainSelectedColor": "#ffcc00",

YACReaderLibrary/themes/builtin_dark.json

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,7 @@
3939
},
4040
"emptyContainer": {
4141
"backgroundColor": "#2a2a2a",
42-
"descriptionTextColor": "#aaaaaa",
43-
"searchIconColor": "#4c4c4c",
44-
"textColor": "#cccccc",
42+
"iconColor": "#4c4c4c",
4543
"titleTextColor": "#cccccc"
4644
},
4745
"gridAndInfoView": {
@@ -97,6 +95,7 @@
9795
"coversViewBackgroundColor": "#3a3a3a",
9896
"currentComicTextColor": "#aaaaaa",
9997
"descriptionTextColor": "#aaaaaa",
98+
"glowLineColor": "#ffe100",
10099
"iconCheckedColor": "#aaaaaa",
101100
"iconColor": "#cccccc",
102101
"modeIconColor": "#4a4a4a",
@@ -179,6 +178,13 @@
179178
"selectionBackgroundColor": "#2e2e2e",
180179
"textColor": "#dddfdf"
181180
},
181+
"noLibrariesWidget": {
182+
"backgroundColor": "#2a2a2a",
183+
"descriptionTextColor": "#aaaaaa",
184+
"iconColor": "#4c4c4c",
185+
"noLibrariesLineColor": "#a8a8a8",
186+
"textColor": "#cccccc"
187+
},
182188
"readingListIcons": {
183189
"currentlyReadingMainColor": "#ffcc00",
184190
"currentlyReadingMainSelectedColor": "#ffcc00",

YACReaderLibrary/themes/builtin_light.json

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,7 @@
3939
},
4040
"emptyContainer": {
4141
"backgroundColor": "#ffffff",
42-
"descriptionTextColor": "#565959",
43-
"searchIconColor": "#cccccc",
44-
"textColor": "#495252",
42+
"iconColor": "#cccccc",
4543
"titleTextColor": "#888888"
4644
},
4745
"gridAndInfoView": {
@@ -97,6 +95,7 @@
9795
"coversViewBackgroundColor": "#e6e6e6",
9896
"currentComicTextColor": "#565959",
9997
"descriptionTextColor": "#565959",
98+
"glowLineColor": "#ffe100",
10099
"iconCheckedColor": "#565959",
101100
"iconColor": "#495252",
102101
"modeIconColor": "#e6e6e6",
@@ -179,6 +178,13 @@
179178
"selectionBackgroundColor": "#333133",
180179
"textColor": "#000000"
181180
},
181+
"noLibrariesWidget": {
182+
"backgroundColor": "#ffffff",
183+
"descriptionTextColor": "#565959",
184+
"iconColor": "#cccccc",
185+
"noLibrariesLineColor": "#a8a8a8",
186+
"textColor": "#495252"
187+
},
182188
"readingListIcons": {
183189
"currentlyReadingMainColor": "#ffcc00",
184190
"currentlyReadingMainSelectedColor": "#ffcc00",

YACReaderLibrary/themes/theme.h

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -122,11 +122,6 @@ struct EmptyContainerTheme {
122122
QColor backgroundColor;
123123
QString titleLabelQSS;
124124

125-
// For NoLibrariesWidget
126-
QColor textColor;
127-
QColor descriptionTextColor;
128-
QPixmap noLibrariesIcon;
129-
130125
// Search-related icons (themed from search_result.svg)
131126
QPixmap searchingIcon; // For ClassicComicsView searching state
132127
QPixmap noSearchResultsIcon; // For NoSearchResultsWidget empty state
@@ -139,6 +134,14 @@ struct EmptyContainerTheme {
139134
QMap<int, QPixmap> emptyLabelIcons; // Keyed by YACReader::LabelColors enum value
140135
};
141136

137+
struct NoLibrariesWidgetTheme {
138+
QColor backgroundColor; // Background of the widget
139+
QColor textColor; // Main title text color
140+
QColor descriptionTextColor; // Description text color
141+
QPixmap noLibrariesIcon; // Icon displayed in the widget
142+
QPixmap noLibrariesLinePixmap; // Themed horizontal line separator
143+
};
144+
142145
struct SidebarTheme {
143146
QColor backgroundColor;
144147
QColor separatorColor;
@@ -172,6 +175,7 @@ struct ImportWidgetTheme {
172175
QPixmap importingIcon;
173176
QPixmap updatingIcon;
174177
QIcon coversToggleIcon;
178+
QPixmap glowLinePixmap; // Themed glow line animation
175179
};
176180

177181
struct NavigationTreeThemeTemplates {
@@ -491,6 +495,7 @@ struct Theme {
491495
HelpAboutDialogTheme helpAboutDialog;
492496
WhatsNewDialogTheme whatsNewDialog;
493497
EmptyContainerTheme emptyContainer;
498+
NoLibrariesWidgetTheme noLibrariesWidget;
494499
SidebarTheme sidebar;
495500
SidebarIconsTheme sidebarIcons;
496501
LibraryItemTheme libraryItem;

0 commit comments

Comments
 (0)