mirror of
https://github.com/YACReader/yacreader
synced 2026-04-12 15:49:53 -04:00
Make Themable pass the current Theme through applyTheme
This reduces boilerplate code and remove the ThemeManager dependency at Thamable subclasses level.
This commit is contained in:
@ -27,8 +27,6 @@
|
||||
#include "db_helper.h"
|
||||
#include "response_parser.h"
|
||||
|
||||
#include "theme_manager.h"
|
||||
|
||||
#include "QsLog.h"
|
||||
|
||||
ComicVineDialog::ComicVineDialog(QWidget *parent)
|
||||
@ -657,9 +655,9 @@ void ComicVineDialog::launchSearchComic()
|
||||
searchVolume({ volumeInfo, 1, exactMatch });
|
||||
}
|
||||
|
||||
void ComicVineDialog::applyTheme()
|
||||
void ComicVineDialog::applyTheme(const Theme &theme)
|
||||
{
|
||||
auto comicVineTheme = ThemeManager::instance().getCurrentTheme().comicVine;
|
||||
auto comicVineTheme = theme.comicVine;
|
||||
|
||||
setStyleSheet(comicVineTheme.dialogQSS);
|
||||
|
||||
|
||||
@ -129,7 +129,7 @@ private:
|
||||
QString currentVolumeId;
|
||||
|
||||
protected:
|
||||
void applyTheme() override;
|
||||
void applyTheme(const Theme &theme) override;
|
||||
};
|
||||
|
||||
#endif // COMIC_VINE_DIALOG_H
|
||||
|
||||
@ -1,16 +1,14 @@
|
||||
#include "scraper_checkbox.h"
|
||||
|
||||
#include "theme_manager.h"
|
||||
|
||||
ScraperCheckBox::ScraperCheckBox(const QString &text, QWidget *parent)
|
||||
: QCheckBox(text, parent)
|
||||
{
|
||||
initTheme(this);
|
||||
}
|
||||
|
||||
void ScraperCheckBox::applyTheme()
|
||||
void ScraperCheckBox::applyTheme(const Theme &theme)
|
||||
{
|
||||
auto comicVineTheme = ThemeManager::instance().getCurrentTheme().comicVine;
|
||||
auto comicVineTheme = theme.comicVine;
|
||||
|
||||
setStyleSheet(comicVineTheme.checkBoxQSS);
|
||||
}
|
||||
|
||||
@ -11,7 +11,7 @@ public:
|
||||
ScraperCheckBox(const QString &text, QWidget *parent = nullptr);
|
||||
|
||||
protected:
|
||||
void applyTheme() override;
|
||||
void applyTheme(const Theme &theme) override;
|
||||
};
|
||||
|
||||
#endif // SCRAPER_CHECKBOX_H
|
||||
|
||||
@ -1,7 +1,5 @@
|
||||
#include "scraper_lineedit.h"
|
||||
|
||||
#include "theme_manager.h"
|
||||
|
||||
#include <QLabel>
|
||||
|
||||
ScraperLineEdit::ScraperLineEdit(const QString &title, QWidget *widget)
|
||||
@ -20,9 +18,9 @@ void ScraperLineEdit::resizeEvent(QResizeEvent *)
|
||||
titleLabel->move(6, (rect().bottom() + 1 - szl.height()) / 2);
|
||||
}
|
||||
|
||||
void ScraperLineEdit::applyTheme()
|
||||
void ScraperLineEdit::applyTheme(const Theme &theme)
|
||||
{
|
||||
auto comicVineTheme = ThemeManager::instance().getCurrentTheme().comicVine;
|
||||
auto comicVineTheme = theme.comicVine;
|
||||
|
||||
titleLabel->setStyleSheet(comicVineTheme.scraperLineEditTitleLabelQSS);
|
||||
setStyleSheet(comicVineTheme.scraperLineEditQSS.arg(titleLabel->sizeHint().width() + 6));
|
||||
|
||||
@ -15,7 +15,7 @@ public:
|
||||
|
||||
protected:
|
||||
void resizeEvent(QResizeEvent *) override;
|
||||
void applyTheme() override;
|
||||
void applyTheme(const Theme &theme) override;
|
||||
|
||||
private:
|
||||
QLabel *titleLabel;
|
||||
|
||||
@ -1,6 +1,5 @@
|
||||
#include "scraper_results_paginator.h"
|
||||
#include "response_parser.h"
|
||||
#include "theme_manager.h"
|
||||
|
||||
#include <QHBoxLayout>
|
||||
#include <QLabel>
|
||||
@ -62,9 +61,9 @@ void ScraperResultsPaginator::setCustomLabel(const QString &label)
|
||||
customLabel = label;
|
||||
}
|
||||
|
||||
void ScraperResultsPaginator::applyTheme()
|
||||
void ScraperResultsPaginator::applyTheme(const Theme &theme)
|
||||
{
|
||||
auto comicVineTheme = ThemeManager::instance().getCurrentTheme().comicVine;
|
||||
auto comicVineTheme = theme.comicVine;
|
||||
|
||||
numElements->setStyleSheet(comicVineTheme.defaultLabelQSS);
|
||||
numPages->setStyleSheet(comicVineTheme.defaultLabelQSS);
|
||||
|
||||
@ -31,7 +31,7 @@ private:
|
||||
QString customLabel;
|
||||
|
||||
protected:
|
||||
void applyTheme() override;
|
||||
void applyTheme(const Theme &theme) override;
|
||||
};
|
||||
|
||||
#endif // SCRAPER_RESULTS_PAGINATOR_H
|
||||
|
||||
@ -1,7 +1,5 @@
|
||||
#include "scraper_scroll_label.h"
|
||||
|
||||
#include "theme_manager.h"
|
||||
|
||||
#include <QLabel>
|
||||
#include <QDesktopServices>
|
||||
#include <QUrl>
|
||||
@ -41,9 +39,9 @@ void ScraperScrollLabel::openLink(const QString &link)
|
||||
QDesktopServices::openUrl(QUrl("http://www.comicvine.com" + link));
|
||||
}
|
||||
|
||||
void ScraperScrollLabel::applyTheme()
|
||||
void ScraperScrollLabel::applyTheme(const Theme &theme)
|
||||
{
|
||||
auto comicVineTheme = ThemeManager::instance().getCurrentTheme().comicVine;
|
||||
auto comicVineTheme = theme.comicVine;
|
||||
|
||||
textLabel->setStyleSheet(comicVineTheme.scraperScrollLabelTextQSS);
|
||||
setStyleSheet(comicVineTheme.scraperScrollLabelScrollAreaQSS);
|
||||
|
||||
@ -23,7 +23,7 @@ private:
|
||||
QLabel *textLabel;
|
||||
|
||||
protected:
|
||||
void applyTheme() override;
|
||||
void applyTheme(const Theme &theme) override;
|
||||
};
|
||||
|
||||
#endif // SCRAPER_SCROLL_LABEL_H
|
||||
|
||||
@ -1,7 +1,5 @@
|
||||
#include "scraper_tableview.h"
|
||||
|
||||
#include "theme_manager.h"
|
||||
|
||||
#include <QHeaderView>
|
||||
|
||||
ScraperTableView::ScraperTableView(QWidget *parent)
|
||||
@ -44,9 +42,9 @@ ScraperTableView::ScraperTableView(QWidget *parent)
|
||||
initTheme(this);
|
||||
}
|
||||
|
||||
void ScraperTableView::applyTheme()
|
||||
void ScraperTableView::applyTheme(const Theme &theme)
|
||||
{
|
||||
auto comicVineTheme = ThemeManager::instance().getCurrentTheme().comicVine;
|
||||
auto comicVineTheme = theme.comicVine;
|
||||
|
||||
setStyleSheet(comicVineTheme.scraperTableViewQSS);
|
||||
}
|
||||
|
||||
@ -12,7 +12,7 @@ public:
|
||||
explicit ScraperTableView(QWidget *parent = nullptr);
|
||||
|
||||
protected:
|
||||
void applyTheme() override;
|
||||
void applyTheme(const Theme &theme) override;
|
||||
};
|
||||
|
||||
#endif // SCRAPPER_TABLEVIEW_H
|
||||
|
||||
@ -1,7 +1,6 @@
|
||||
#include "search_single_comic.h"
|
||||
|
||||
#include "scraper_lineedit.h"
|
||||
#include "theme_manager.h"
|
||||
|
||||
#include <QLabel>
|
||||
#include <QVBoxLayout>
|
||||
@ -73,9 +72,9 @@ void SearchSingleComic::clean()
|
||||
volumeEdit->clear();
|
||||
}
|
||||
|
||||
void SearchSingleComic::applyTheme()
|
||||
void SearchSingleComic::applyTheme(const Theme &theme)
|
||||
{
|
||||
auto comicVineTheme = ThemeManager::instance().getCurrentTheme().comicVine;
|
||||
auto comicVineTheme = theme.comicVine;
|
||||
|
||||
label->setStyleSheet(comicVineTheme.defaultLabelQSS);
|
||||
}
|
||||
|
||||
@ -29,6 +29,6 @@ private:
|
||||
QLabel *label;
|
||||
|
||||
protected:
|
||||
void applyTheme() override;
|
||||
void applyTheme(const Theme &theme) override;
|
||||
};
|
||||
#endif // SEARCH_SINGLE_COMIC_H
|
||||
|
||||
@ -2,7 +2,6 @@
|
||||
|
||||
#include "scraper_lineedit.h"
|
||||
#include "scraper_checkbox.h"
|
||||
#include "theme_manager.h"
|
||||
|
||||
#include <QLabel>
|
||||
#include <QVBoxLayout>
|
||||
@ -48,9 +47,9 @@ QString SearchVolume::getVolumeInfo() const
|
||||
return volumeEdit->text();
|
||||
}
|
||||
|
||||
void SearchVolume::applyTheme()
|
||||
void SearchVolume::applyTheme(const Theme &theme)
|
||||
{
|
||||
auto comicVineTheme = ThemeManager::instance().getCurrentTheme().comicVine;
|
||||
auto comicVineTheme = theme.comicVine;
|
||||
|
||||
label->setStyleSheet(comicVineTheme.defaultLabelQSS);
|
||||
}
|
||||
|
||||
@ -24,7 +24,7 @@ private:
|
||||
QLabel *label;
|
||||
|
||||
protected:
|
||||
void applyTheme() override;
|
||||
void applyTheme(const Theme &theme) override;
|
||||
};
|
||||
|
||||
#endif // SEARCH_VOLUME_H
|
||||
|
||||
@ -4,7 +4,6 @@
|
||||
#include "scraper_scroll_label.h"
|
||||
#include "scraper_tableview.h"
|
||||
#include "volume_comics_model.h"
|
||||
#include "theme_manager.h"
|
||||
|
||||
#include <QJsonDocument>
|
||||
#include <QJsonParseError>
|
||||
@ -164,9 +163,9 @@ QString SelectComic::getSelectedComicId()
|
||||
return model->getComicId(tableComics->currentIndex());
|
||||
}
|
||||
|
||||
void SelectComic::applyTheme()
|
||||
void SelectComic::applyTheme(const Theme &theme)
|
||||
{
|
||||
auto comicVineTheme = ThemeManager::instance().getCurrentTheme().comicVine;
|
||||
auto comicVineTheme = theme.comicVine;
|
||||
|
||||
label->setStyleSheet(comicVineTheme.defaultLabelQSS);
|
||||
cover->setStyleSheet(comicVineTheme.coverLabelQSS);
|
||||
|
||||
@ -44,7 +44,7 @@ private:
|
||||
ScraperResultsPaginator *paginator;
|
||||
|
||||
protected:
|
||||
void applyTheme() override;
|
||||
void applyTheme(const Theme &theme) override;
|
||||
};
|
||||
|
||||
#endif // SELECT_COMIC_H
|
||||
|
||||
@ -25,7 +25,6 @@
|
||||
#include "scraper_results_paginator.h"
|
||||
|
||||
#include "selected_volume_info.h"
|
||||
#include "theme_manager.h"
|
||||
|
||||
SelectVolume::SelectVolume(QWidget *parent)
|
||||
: QWidget(parent), model(0)
|
||||
@ -218,9 +217,9 @@ SelectedVolumeInfo SelectVolume::getSelectedVolumeInfo()
|
||||
return { volumeId, numIssues, publisher, selectedVolumeDescription };
|
||||
}
|
||||
|
||||
void SelectVolume::applyTheme()
|
||||
void SelectVolume::applyTheme(const Theme &theme)
|
||||
{
|
||||
auto comicVineTheme = ThemeManager::instance().getCurrentTheme().comicVine;
|
||||
auto comicVineTheme = theme.comicVine;
|
||||
|
||||
label->setStyleSheet(comicVineTheme.defaultLabelQSS);
|
||||
cover->setStyleSheet(comicVineTheme.coverLabelQSS);
|
||||
|
||||
@ -53,7 +53,7 @@ private:
|
||||
ScraperResultsPaginator *paginator;
|
||||
|
||||
protected:
|
||||
void applyTheme() override;
|
||||
void applyTheme(const Theme &theme) override;
|
||||
};
|
||||
|
||||
#endif // SELECT_VOLUME_H
|
||||
|
||||
@ -1,7 +1,5 @@
|
||||
#include "series_question.h"
|
||||
|
||||
#include "theme_manager.h"
|
||||
|
||||
#include <QRadioButton>
|
||||
#include <QVBoxLayout>
|
||||
#include <QLabel>
|
||||
@ -40,9 +38,9 @@ void SeriesQuestion::setYes(bool y)
|
||||
yes->setChecked(y);
|
||||
}
|
||||
|
||||
void SeriesQuestion::applyTheme()
|
||||
void SeriesQuestion::applyTheme(const Theme &theme)
|
||||
{
|
||||
auto comicVineTheme = ThemeManager::instance().getCurrentTheme().comicVine;
|
||||
auto comicVineTheme = theme.comicVine;
|
||||
|
||||
questionLabel->setStyleSheet(comicVineTheme.defaultLabelQSS);
|
||||
yes->setStyleSheet(comicVineTheme.radioButtonQSS);
|
||||
|
||||
@ -23,7 +23,7 @@ private:
|
||||
QRadioButton *no;
|
||||
|
||||
protected:
|
||||
void applyTheme() override;
|
||||
void applyTheme(const Theme &theme) override;
|
||||
};
|
||||
|
||||
#endif // SERIES_QUESTION_H
|
||||
|
||||
@ -45,9 +45,9 @@ void ScrapperToolButton::paintEvent(QPaintEvent *e)
|
||||
QPushButton::paintEvent(e);
|
||||
}
|
||||
|
||||
void ScrapperToolButton::applyTheme()
|
||||
void ScrapperToolButton::applyTheme(const Theme &theme)
|
||||
{
|
||||
auto comicVineTheme = ThemeManager::instance().getCurrentTheme().comicVine;
|
||||
auto comicVineTheme = theme.comicVine;
|
||||
setStyleSheet(comicVineTheme.scraperToolButtonQSS);
|
||||
fillColor = comicVineTheme.scraperToolButtonFillColor;
|
||||
update();
|
||||
@ -265,9 +265,9 @@ QList<QPair<ComicDB, QString>> SortVolumeComics::getMatchingInfo()
|
||||
return l;
|
||||
}
|
||||
|
||||
void SortVolumeComics::applyTheme()
|
||||
void SortVolumeComics::applyTheme(const Theme &theme)
|
||||
{
|
||||
auto comicVineTheme = ThemeManager::instance().getCurrentTheme().comicVine;
|
||||
auto comicVineTheme = theme.comicVine;
|
||||
|
||||
label->setStyleSheet(comicVineTheme.defaultLabelQSS);
|
||||
sortLabel->setStyleSheet(comicVineTheme.defaultLabelQSS);
|
||||
|
||||
@ -32,7 +32,7 @@ public:
|
||||
|
||||
protected:
|
||||
void paintEvent(QPaintEvent *e) override;
|
||||
void applyTheme() override;
|
||||
void applyTheme(const Theme &theme) override;
|
||||
|
||||
private:
|
||||
Appearance appearance;
|
||||
@ -85,7 +85,7 @@ private:
|
||||
ScraperResultsPaginator *paginator;
|
||||
|
||||
protected:
|
||||
void applyTheme() override;
|
||||
void applyTheme(const Theme &theme) override;
|
||||
};
|
||||
|
||||
#endif // SORT_VOLUME_COMICS_H
|
||||
|
||||
@ -1,7 +1,5 @@
|
||||
#include "title_header.h"
|
||||
|
||||
#include "theme_manager.h"
|
||||
|
||||
#include <QLabel>
|
||||
#include <QHBoxLayout>
|
||||
#include <QVBoxLayout>
|
||||
@ -49,9 +47,9 @@ void TitleHeader::showButtons(bool show)
|
||||
}
|
||||
}
|
||||
|
||||
void TitleHeader::applyTheme()
|
||||
void TitleHeader::applyTheme(const Theme &theme)
|
||||
{
|
||||
auto comicVineTheme = ThemeManager::instance().getCurrentTheme().comicVine;
|
||||
auto comicVineTheme = theme.comicVine;
|
||||
|
||||
mainTitleLabel->setStyleSheet(comicVineTheme.titleLabelQSS);
|
||||
subTitleLabel->setStyleSheet(comicVineTheme.defaultLabelQSS);
|
||||
|
||||
@ -22,7 +22,7 @@ private:
|
||||
QLabel *subTitleLabel;
|
||||
|
||||
protected:
|
||||
void applyTheme() override;
|
||||
void applyTheme(const Theme &theme) override;
|
||||
};
|
||||
|
||||
#endif // TITLE_HEADER_H
|
||||
|
||||
Reference in New Issue
Block a user