Mercurial > minori
changeset 68:2417121d894e
*: normalize usage of layouts
before, I used them two ways, once was by setting the layout later
by using setLayout(QWidget), and the other was just using the constructor.
I find the constructor to be easier to read, so I chose that one.
author | Paper <mrpapersonic@gmail.com> |
---|---|
date | Mon, 02 Oct 2023 21:33:25 -0400 |
parents | 442065432549 |
children | 27a19dd6cba1 893ad99b174d |
files | include/gui/dialog/settings.h src/gui/dialog/information.cpp src/gui/dialog/settings.cpp src/gui/dialog/settings/application.cpp src/gui/dialog/settings/services.cpp src/gui/pages/anime_list.cpp src/gui/pages/now_playing.cpp src/gui/widgets/poster.cpp src/gui/widgets/sidebar.cpp src/gui/window.cpp |
diffstat | 10 files changed, 95 insertions(+), 101 deletions(-) [+] |
line wrap: on
line diff
--- a/include/gui/dialog/settings.h Mon Oct 02 07:06:44 2023 -0400 +++ b/include/gui/dialog/settings.h Mon Oct 02 21:33:25 2023 -0400 @@ -1,15 +1,13 @@ #ifndef __gui__dialog__settings_h #define __gui__dialog__settings_h #include "core/anime.h" -#include "gui/widgets/sidebar.h" -#include <QComboBox> #include <QDialog> -#include <QHBoxLayout> -#include <QLabel> -#include <QLineEdit> -#include <QTabWidget> #include <QWidget> +class QLabel; +class QTabWidget; +class SideBar; + class SettingsPage : public QWidget { Q_OBJECT @@ -59,7 +57,6 @@ void OnOK(); private: - QHBoxLayout* layout; SideBar* sidebar; }; #endif // __gui__dialog__settings_h
--- a/src/gui/dialog/information.cpp Mon Oct 02 07:06:44 2023 -0400 +++ b/src/gui/dialog/information.cpp Mon Oct 02 21:33:25 2023 -0400 @@ -57,7 +57,6 @@ sidebar_layout->addWidget(poster); sidebar_layout->setContentsMargins(0, 0, 0, 0); sidebar_layout->addStretch(); - sidebar->setFixedWidth(175); /* main widget */ QWidget* main_widget = new QWidget(widget); @@ -83,18 +82,17 @@ AnimeInfoWidget* main_information_widget = new AnimeInfoWidget(anime, tabbed_widget); QWidget* settings_widget = new QWidget(tabbed_widget); - settings_widget->setLayout(new QVBoxLayout); settings_widget->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Maximum); - settings_widget->layout()->addWidget(new TextWidgets::Header(tr("Anime list"), settings_widget)); + QVBoxLayout* settings_layout = new QVBoxLayout(settings_widget); + settings_layout->addWidget(new TextWidgets::Header(tr("Anime list"), settings_widget)); QWidget* sg_anime_list_content = new QWidget(settings_widget); - settings_widget->layout()->addWidget(sg_anime_list_content); - sg_anime_list_content->setLayout(new QVBoxLayout); - sg_anime_list_content->layout()->setSpacing(5); - sg_anime_list_content->layout()->setContentsMargins(12, 0, 0, 0); -/* these macros make this a lot easier to edit */ + QVBoxLayout* al_layout = new QVBoxLayout(sg_anime_list_content); + al_layout->setSpacing(5); + al_layout->setContentsMargins(12, 0, 0, 0); + #define LAYOUT_HORIZ_SPACING 25 #define LAYOUT_VERT_SPACING 5 #define LAYOUT_ITEM_WIDTH 175 @@ -102,17 +100,14 @@ #define CREATE_FULL_WIDTH_SUBSECTION(x) \ { \ QWidget* subsection = new QWidget(section); \ - subsection->setLayout(new QVBoxLayout); \ subsection->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred); \ - subsection->layout()->setSpacing(LAYOUT_VERT_SPACING); \ - subsection->layout()->setContentsMargins(0, 0, 0, 0); \ + QVBoxLayout* subsection_layout = new QVBoxLayout(subsection); \ + subsection_layout->setSpacing(LAYOUT_VERT_SPACING); \ + subsection_layout->setContentsMargins(0, 0, 0, 0); \ x; \ layout->addWidget(subsection); \ } -/* Creates a subsection with a width of 175 */ -#define CREATE_SUBSECTION(x) CREATE_FULL_WIDTH_SUBSECTION(x subsection->setFixedWidth(LAYOUT_ITEM_WIDTH);) - /* Creates a section in the parent `a` */ #define CREATE_FULL_WIDTH_SECTION(a, x) \ { \ @@ -124,35 +119,37 @@ a->layout()->addWidget(section); \ } +/* Creates a subsection with a width of 175 */ +#define CREATE_SUBSECTION(x) CREATE_FULL_WIDTH_SUBSECTION(x subsection->setFixedWidth(LAYOUT_ITEM_WIDTH);) /* Creates a section in the parent `a` */ #define CREATE_SECTION(a, x) CREATE_FULL_WIDTH_SECTION(a, x layout->addStretch();) CREATE_SECTION(sg_anime_list_content, { /* Episodes watched section */ CREATE_SUBSECTION({ - subsection->layout()->addWidget(new QLabel(tr("Episodes watched:"), subsection)); + subsection_layout->addWidget(new QLabel(tr("Episodes watched:"), subsection)); QSpinBox* spin_box = new QSpinBox(subsection); connect(spin_box, QOverload<int>::of(&QSpinBox::valueChanged), this, [this](int i) { progress = i; }); spin_box->setRange(0, anime.GetEpisodes()); spin_box->setSingleStep(1); spin_box->setValue(progress = anime.GetUserProgress()); - subsection->layout()->addWidget(spin_box); + subsection_layout->addWidget(spin_box); }); CREATE_SUBSECTION({ - subsection->layout()->addWidget(new QLabel(tr(" "), subsection)); + subsection_layout->addWidget(new QLabel(tr(" "), subsection)); QCheckBox* checkbox = new QCheckBox(tr("Rewatching")); connect(checkbox, QOverload<int>::of(&QCheckBox::stateChanged), this, [this](int state) { rewatching = (state == Qt::Checked); }); checkbox->setCheckState(anime.GetUserIsRewatching() ? Qt::Checked : Qt::Unchecked); - subsection->layout()->addWidget(checkbox); + subsection_layout->addWidget(checkbox); }); }); CREATE_SECTION(sg_anime_list_content, { /* Status & score section */ CREATE_SUBSECTION({ - subsection->layout()->addWidget(new QLabel(tr("Status:"), subsection)); + subsection_layout->addWidget(new QLabel(tr("Status:"), subsection)); QStringList string_list; for (unsigned int i = 0; i < ARRAYSIZE(Anime::ListStatuses); i++) @@ -163,23 +160,23 @@ connect(combo_box, QOverload<int>::of(&QComboBox::currentIndexChanged), this, [this](int i) { status = Anime::ListStatuses[i]; }); combo_box->setCurrentIndex(static_cast<int>(status = anime.GetUserStatus()) - 1); - subsection->layout()->addWidget(combo_box); + subsection_layout->addWidget(combo_box); }); CREATE_SUBSECTION({ - subsection->layout()->addWidget(new QLabel(tr("Score:"), subsection)); + subsection_layout->addWidget(new QLabel(tr("Score:"), subsection)); QSpinBox* spin_box = new QSpinBox(subsection); connect(spin_box, QOverload<int>::of(&QSpinBox::valueChanged), this, [this](int i) { score = i; }); spin_box->setRange(0, 100); spin_box->setSingleStep(5); spin_box->setValue(score = anime.GetUserScore()); - subsection->layout()->addWidget(spin_box); + subsection_layout->addWidget(spin_box); }); }); CREATE_FULL_WIDTH_SECTION(sg_anime_list_content, { /* Notes section */ CREATE_FULL_WIDTH_SUBSECTION({ - subsection->layout()->addWidget(new QLabel(tr("Notes:"), subsection)); + subsection_layout->addWidget(new QLabel(tr("Notes:"), subsection)); QLineEdit* line_edit = new QLineEdit(subsection); connect(line_edit, &QLineEdit::textChanged, this, [this](const QString& text) { @@ -188,13 +185,13 @@ }); line_edit->setText(Strings::ToQString(notes = anime.GetUserNotes())); line_edit->setPlaceholderText(tr("Enter your notes about this anime")); - subsection->layout()->addWidget(line_edit); + subsection_layout->addWidget(line_edit); }); }); CREATE_SECTION(sg_anime_list_content, { /* Dates section */ CREATE_SUBSECTION({ - subsection->layout()->addWidget(new QLabel(tr("Date started:"), subsection)); + subsection_layout->addWidget(new QLabel(tr("Date started:"), subsection)); OptionalDate* date = new OptionalDate(true, subsection); connect(date, &OptionalDate::DataChanged, this, @@ -205,10 +202,10 @@ started = anime.GetAirDate(); } date->SetDate(started); - subsection->layout()->addWidget(date); + subsection_layout->addWidget(date); }); CREATE_SUBSECTION({ - subsection->layout()->addWidget(new QLabel(tr("Date completed:"), subsection)); + subsection_layout->addWidget(new QLabel(tr("Date completed:"), subsection)); OptionalDate* date = new OptionalDate(true, subsection); connect(date, &OptionalDate::DataChanged, this, @@ -219,30 +216,31 @@ completed = anime.GetAirDate(); } date->SetDate(completed); - subsection->layout()->addWidget(date); + subsection_layout->addWidget(date); }); }); - settings_widget->layout()->addWidget(new TextWidgets::Header(tr("Local settings"), settings_widget)); + settings_layout->addWidget(sg_anime_list_content); + + settings_layout->addWidget(new TextWidgets::Header(tr("Local settings"), settings_widget)); QWidget* sg_local_content = new QWidget(settings_widget); - settings_widget->layout()->addWidget(sg_local_content); - sg_local_content->setLayout(new QVBoxLayout); - sg_local_content->layout()->setSpacing(5); - sg_local_content->layout()->setContentsMargins(12, 0, 0, 0); + QVBoxLayout* sg_local_layout = new QVBoxLayout(sg_local_content); + sg_local_layout->setSpacing(5); + sg_local_layout->setContentsMargins(12, 0, 0, 0); CREATE_FULL_WIDTH_SECTION(sg_local_content, { /* Alternative titles */ CREATE_FULL_WIDTH_SUBSECTION({ - subsection->layout()->addWidget(new QLabel(tr("Alternative titles:"), subsection)); + subsection_layout->addWidget(new QLabel(tr("Alternative titles:"), subsection)); QLineEdit* line_edit = new QLineEdit(Strings::ToQString(anime.GetUserNotes()), subsection); line_edit->setPlaceholderText( tr("Enter alternative titles here, separated by a semicolon (i.e. Title 1; Title 2)")); - subsection->layout()->addWidget(line_edit); + subsection_layout->addWidget(line_edit); QCheckBox* checkbox = new QCheckBox(tr("Use the first alternative title to search for torrents")); - subsection->layout()->addWidget(checkbox); + subsection_layout->addWidget(checkbox); }); }); #undef CREATE_SECTION @@ -250,21 +248,21 @@ #undef CREATE_FULL_WIDTH_SECTION #undef CREATE_FULL_WIDTH_SUBSECTION - reinterpret_cast<QBoxLayout*>(settings_widget->layout())->addStretch(); + settings_layout->addWidget(sg_local_content); + settings_layout->addStretch(); tabbed_widget->addTab(main_information_widget, tr("Main information")); tabbed_widget->addTab(settings_widget, tr("My list and settings")); - QVBoxLayout* main_layout = new QVBoxLayout; + QVBoxLayout* main_layout = new QVBoxLayout(main_widget); main_layout->addWidget(anime_title); main_layout->addWidget(tabbed_widget); main_layout->setContentsMargins(0, 0, 0, 0); - main_widget->setLayout(main_layout); - QHBoxLayout* layout = new QHBoxLayout; + QHBoxLayout* layout = new QHBoxLayout(widget); layout->addWidget(sidebar); layout->addWidget(main_widget); - widget->setLayout(layout); + layout->setSpacing(12); QDialogButtonBox* button_box = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel, this); connect(button_box, &QDialogButtonBox::accepted, this, [this, accept] { @@ -274,10 +272,9 @@ }); connect(button_box, &QDialogButtonBox::rejected, this, &QDialog::reject); - QVBoxLayout* buttons_layout = new QVBoxLayout; + QVBoxLayout* buttons_layout = new QVBoxLayout(this); buttons_layout->addWidget(widget); buttons_layout->addWidget(button_box, 0, Qt::AlignBottom); - setLayout(buttons_layout); } #include "gui/dialog/moc_information.cpp"
--- a/src/gui/dialog/settings.cpp Mon Oct 02 07:06:44 2023 -0400 +++ b/src/gui/dialog/settings.cpp Mon Oct 02 21:33:25 2023 -0400 @@ -1,14 +1,10 @@ #include "gui/dialog/settings.h" #include "gui/widgets/sidebar.h" #include "gui/widgets/text.h" -#include <QComboBox> #include <QDialogButtonBox> -#include <QGroupBox> -#include <QHBoxLayout> -#include <QPlainTextDocumentLayout> -#include <QPlainTextEdit> #include <QStackedWidget> #include <QVBoxLayout> +#include <QHBoxLayout> #include <QWidget> SettingsPage::SettingsPage(QWidget* parent, QString title) : QWidget(parent) { @@ -36,11 +32,10 @@ tab_widget = new QTabWidget(this); tab_widget->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Expanding); - QVBoxLayout* layout = new QVBoxLayout; + QVBoxLayout* layout = new QVBoxLayout(this); layout->setContentsMargins(0, 0, 0, 0); layout->addWidget(page_title); layout->addWidget(tab_widget); - setLayout(layout); } void SettingsPage::SetTitle(QString title) { @@ -56,7 +51,7 @@ } void SettingsDialog::OnOK() { - QStackedWidget* stacked = reinterpret_cast<QStackedWidget*>(layout->itemAt(1)->widget()); + QStackedWidget* stacked = reinterpret_cast<QStackedWidget*>(layout()->itemAt(1)->widget()); for (int i = 0; i < stacked->count(); i++) { reinterpret_cast<SettingsPage*>(stacked->widget(i))->SaveInfo(); } @@ -84,25 +79,24 @@ font.setPointSize(9); sidebar->setFont(font); - QPalette pal; - pal.setColor(QPalette::Window, Qt::white); + QPalette pal(sidebar->palette()); + pal.setColor(QPalette::Base, pal.color(QPalette::Window)); sidebar->setPalette(pal); sidebar->setFixedWidth(158); sidebar->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Expanding); - QStackedWidget* stacked = new QStackedWidget; + QStackedWidget* stacked = new QStackedWidget(this); stacked->addWidget(new SettingsPageServices(stacked)); stacked->addWidget(new SettingsPageApplication(stacked)); stacked->setCurrentIndex(0); connect(sidebar, &QListWidget::currentRowChanged, stacked, &QStackedWidget::setCurrentIndex); - layout = new QHBoxLayout; + QHBoxLayout* layout = new QHBoxLayout(widget); layout->addWidget(sidebar); layout->addWidget(stacked); layout->setContentsMargins(0, 0, 0, 0); - widget->setLayout(layout); QDialogButtonBox* button_box = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel, this); connect(button_box, &QDialogButtonBox::accepted, this, &SettingsDialog::OnOK); @@ -111,7 +105,6 @@ QVBoxLayout* buttons_layout = new QVBoxLayout(this); buttons_layout->addWidget(widget); buttons_layout->addWidget(button_box); - setLayout(buttons_layout); } #include "gui/dialog/moc_settings.cpp"
--- a/src/gui/dialog/settings/application.cpp Mon Oct 02 07:06:44 2023 -0400 +++ b/src/gui/dialog/settings/application.cpp Mon Oct 02 21:33:25 2023 -0400 @@ -3,8 +3,11 @@ #include <QCheckBox> #include <QComboBox> #include <QGroupBox> +#include <QHBoxLayout> +#include <QLabel> #include <QPushButton> #include <QSizePolicy> +#include <QVBoxLayout> QWidget* SettingsPageApplication::CreateAnimeListWidget() { QWidget* result = new QWidget(this); @@ -19,11 +22,10 @@ QComboBox* dc_combo_box = new QComboBox(double_click_widget); dc_combo_box->addItem(tr("View anime info")); - QVBoxLayout* double_click_layout = new QVBoxLayout; + QVBoxLayout* double_click_layout = new QVBoxLayout(double_click_widget); double_click_layout->addWidget(dc_combo_box_label); double_click_layout->addWidget(dc_combo_box); double_click_layout->setContentsMargins(0, 0, 0, 0); - double_click_widget->setLayout(double_click_layout); /* Actions/Middle click */ QWidget* middle_click_widget = new QWidget(actions_group_box); @@ -31,17 +33,15 @@ QComboBox* mc_combo_box = new QComboBox(middle_click_widget); mc_combo_box->addItem(tr("Play next episode")); - QVBoxLayout* middle_click_layout = new QVBoxLayout; + QVBoxLayout* middle_click_layout = new QVBoxLayout(middle_click_widget); middle_click_layout->addWidget(mc_combo_box_label); middle_click_layout->addWidget(mc_combo_box); middle_click_layout->setContentsMargins(0, 0, 0, 0); - middle_click_widget->setLayout(middle_click_layout); /* Actions */ - QHBoxLayout* actions_layout = new QHBoxLayout; + QHBoxLayout* actions_layout = new QHBoxLayout(actions_group_box); actions_layout->addWidget(double_click_widget); actions_layout->addWidget(middle_click_widget); - actions_group_box->setLayout(actions_layout); QGroupBox* appearance_group_box = new QGroupBox(tr("Appearance"), result); appearance_group_box->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Maximum); @@ -59,23 +59,22 @@ new QCheckBox(tr("Highlight anime if next episode is available in library folders"), appearance_group_box); QCheckBox* hl_above_anime_box = new QCheckBox(tr("Display highlighted anime above others"), appearance_group_box); connect(hl_anime_box, &QCheckBox::stateChanged, this, [this, hl_above_anime_box](int state) { - highlight_anime_if_available = (state == Qt::Unchecked) ? false : true; + highlight_anime_if_available = !(state == Qt::Unchecked); hl_above_anime_box->setEnabled(state); }); connect(hl_above_anime_box, &QCheckBox::stateChanged, this, - [this](int state) { highlight_anime_if_available = (state == Qt::Unchecked) ? false : true; }); + [this](int state) { highlight_anime_if_available = !(state == Qt::Unchecked); }); hl_anime_box->setCheckState(highlight_anime_if_available ? Qt::Checked : Qt::Unchecked); hl_above_anime_box->setCheckState(highlighted_anime_above_others ? Qt::Checked : Qt::Unchecked); hl_above_anime_box->setEnabled(hl_anime_box->checkState() != Qt::Unchecked); hl_above_anime_box->setContentsMargins(10, 0, 0, 0); /* Appearance */ - QVBoxLayout* appearance_layout = new QVBoxLayout; + QVBoxLayout* appearance_layout = new QVBoxLayout(appearance_group_box); appearance_layout->addWidget(lang_combo_box_label); appearance_layout->addWidget(lang_combo_box); appearance_layout->addWidget(hl_anime_box); appearance_layout->addWidget(hl_above_anime_box); - appearance_group_box->setLayout(appearance_layout); QGroupBox* progress_group_box = new QGroupBox(tr("Progress"), result); progress_group_box->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Maximum); @@ -83,27 +82,26 @@ QCheckBox* progress_display_aired_episodes = new QCheckBox(tr("Display aired episodes (estimated)"), progress_group_box); connect(progress_display_aired_episodes, &QCheckBox::stateChanged, this, - [this](int state) { display_aired_episodes = (state == Qt::Unchecked) ? false : true; }); + [this](int state) { display_aired_episodes = !(state == Qt::Unchecked); }); progress_display_aired_episodes->setCheckState(display_aired_episodes ? Qt::Checked : Qt::Unchecked); QCheckBox* progress_display_available_episodes = new QCheckBox(tr("Display available episodes in library folders"), progress_group_box); connect(progress_display_available_episodes, &QCheckBox::stateChanged, this, - [this](int state) { display_available_episodes = (state == Qt::Unchecked) ? false : true; }); + [this](int state) { display_available_episodes = !(state == Qt::Unchecked); }); progress_display_available_episodes->setCheckState(display_available_episodes ? Qt::Checked : Qt::Unchecked); - QVBoxLayout* progress_layout = new QVBoxLayout; + QVBoxLayout* progress_layout = new QVBoxLayout(progress_group_box); progress_layout->addWidget(progress_display_aired_episodes); progress_layout->addWidget(progress_display_available_episodes); - progress_group_box->setLayout(progress_layout); - QVBoxLayout* full_layout = new QVBoxLayout; + QVBoxLayout* full_layout = new QVBoxLayout(result); full_layout->addWidget(actions_group_box); full_layout->addWidget(appearance_group_box); full_layout->addWidget(progress_group_box); full_layout->setSpacing(10); full_layout->addStretch(); - result->setLayout(full_layout); + return result; }
--- a/src/gui/dialog/settings/services.cpp Mon Oct 02 07:06:44 2023 -0400 +++ b/src/gui/dialog/settings/services.cpp Mon Oct 02 21:33:25 2023 -0400 @@ -7,6 +7,10 @@ #include <QGroupBox> #include <QPushButton> #include <QSizePolicy> +#include <QVBoxLayout> +#include <QLabel> +#include <QPushButton> +#include <QLineEdit> QWidget* SettingsPageServices::CreateMainPage() { QWidget* result = new QWidget(this); @@ -26,17 +30,16 @@ QLabel* sync_note_label = new QLabel(tr("Note: Minori is unable to synchronize multiple services at the same time."), sync_group_box); - QVBoxLayout* sync_layout = new QVBoxLayout; + QVBoxLayout* sync_layout = new QVBoxLayout(sync_group_box); sync_layout->addWidget(sync_combo_box_label); sync_layout->addWidget(sync_combo_box); sync_layout->addWidget(sync_note_label); - sync_group_box->setLayout(sync_layout); - QVBoxLayout* full_layout = new QVBoxLayout; + QVBoxLayout* full_layout = new QVBoxLayout(result); full_layout->addWidget(sync_group_box); full_layout->setSpacing(10); full_layout->addStretch(); - result->setLayout(full_layout); + return result; } @@ -60,27 +63,24 @@ connect(auth_button, &QPushButton::clicked, this, [] { Services::AniList::AuthorizeUser(); }); auth_button->setText(session.config.anilist.auth_token.empty() ? tr("Authorize...") : tr("Re-authorize...")); - QHBoxLayout* auth_layout = new QHBoxLayout; + QHBoxLayout* auth_layout = new QHBoxLayout(auth_widget); auth_layout->addWidget(username_entry); auth_layout->addWidget(auth_button); - auth_widget->setLayout(auth_layout); QLabel* note_label = new QLabel(tr("<a href=\"http://anilist.co/\">Create a new AniList account</a>"), group_box); note_label->setTextFormat(Qt::RichText); note_label->setTextInteractionFlags(Qt::TextBrowserInteraction); note_label->setOpenExternalLinks(true); - QVBoxLayout* layout = new QVBoxLayout; + QVBoxLayout* layout = new QVBoxLayout(group_box); layout->addWidget(username_entry_label); layout->addWidget(auth_widget); layout->addWidget(note_label); - group_box->setLayout(layout); - QVBoxLayout* full_layout = new QVBoxLayout; + QVBoxLayout* full_layout = new QVBoxLayout(result); full_layout->addWidget(group_box); full_layout->setSpacing(10); full_layout->addStretch(); - result->setLayout(full_layout); return result; }
--- a/src/gui/pages/anime_list.cpp Mon Oct 02 07:06:44 2023 -0400 +++ b/src/gui/pages/anime_list.cpp Mon Oct 02 21:33:25 2023 -0400 @@ -451,10 +451,9 @@ } tree_view->setModel(sort_models[0]); - QHBoxLayout* layout = new QHBoxLayout; + QHBoxLayout* layout = new QHBoxLayout(tree_widget); layout->addWidget(tree_view); layout->setContentsMargins(0, 0, 0, 0); - tree_widget->setLayout(layout); /* Double click stuff */ connect(tree_view, &QAbstractItemView::doubleClicked, this, &AnimeListPage::ItemDoubleClicked);
--- a/src/gui/pages/now_playing.cpp Mon Oct 02 07:06:44 2023 -0400 +++ b/src/gui/pages/now_playing.cpp Mon Oct 02 21:33:25 2023 -0400 @@ -36,7 +36,7 @@ Playing::Playing(QWidget* parent) : QWidget(parent) { QHBoxLayout* layout = new QHBoxLayout(this); - + layout->setContentsMargins(0, 0, 0, 0); } @@ -68,7 +68,6 @@ stack->addWidget(new NowPlayingPages::Playing(stack)); layout->addWidget(stack); - layout->addStretch(); SetDefault(); }
--- a/src/gui/widgets/poster.cpp Mon Oct 02 07:06:44 2023 -0400 +++ b/src/gui/widgets/poster.cpp Mon Oct 02 21:33:25 2023 -0400 @@ -56,6 +56,7 @@ QPixmap pixmap = QPixmap::fromImage(img); label = new ClickableLabel(this); + label->setAlignment(Qt::AlignCenter); connect(label, &ClickableLabel::clicked, this, [anime]{ QDesktopServices::openUrl(Strings::ToQString(anime.GetServiceUrl())); }); @@ -63,7 +64,7 @@ } void Poster::resizeEvent(QResizeEvent*) { - QPixmap pixmap = QPixmap::fromImage(img).scaled(size(), Qt::KeepAspectRatioByExpanding, Qt::SmoothTransformation); + QPixmap pixmap = QPixmap::fromImage(img).scaled(label->size(), Qt::KeepAspectRatioByExpanding, Qt::SmoothTransformation); label->setPixmap(pixmap); }
--- a/src/gui/widgets/sidebar.cpp Mon Oct 02 07:06:44 2023 -0400 +++ b/src/gui/widgets/sidebar.cpp Mon Oct 02 21:33:25 2023 -0400 @@ -53,14 +53,9 @@ line->setMouseTracking(true); line->setEnabled(false); - /* - QPalette pal; - pal.setColor(QPalette::Window, Qt::transparent); - line->setPalette(pal); - */ - setItemWidget(item, line); item->setFlags(Qt::NoItemFlags); + item->setBackground(QBrush(Qt::transparent)); return item; }
--- a/src/gui/window.cpp Mon Oct 02 07:06:44 2023 -0400 +++ b/src/gui/window.cpp Mon Oct 02 21:33:25 2023 -0400 @@ -22,11 +22,13 @@ #include <QFile> #include <QMainWindow> #include <QMenuBar> +#include <QToolBar> #include <QMessageBox> #include <QPlainTextEdit> #include <QStackedWidget> #include <QTextStream> #include <QTimer> +#include <QHBoxLayout> #if MACOSX # include "sys/osx/dark_theme.h" #elif defined(WIN32) @@ -194,6 +196,19 @@ setMenuBar(menubar); + /* Toolbar */ + QToolBar* toolbar = new QToolBar(this); + toolbar->addAction(QIcon(":/icons/24x24/arrow-circle-double-135.png"), tr("&Synchronize"), [stack] { + Services::Synchronize(); + reinterpret_cast<AnimeListPage*>(stack->widget(static_cast<int>(Pages::ANIME_LIST)))->Refresh(); + }); + toolbar->addSeparator(); + toolbar->addAction(QIcon(":/icons/24x24/gear.png"), tr("S&ettings"), [this]{ + SettingsDialog dialog(this); + dialog.exec(); + }); + addToolBar(toolbar); + QHBoxLayout* layout = new QHBoxLayout(main_widget); layout->addWidget(sidebar); layout->addWidget(stack);