Browse Source

Fix inconsistent background of filters widget

PR #18956.
Fixes regression of #18918.
adaptive-webui-19844
Vladimir Golovnev 2 years ago committed by GitHub
parent
commit
34802362ad
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 34
      src/gui/transferlistfilterswidget.cpp
  2. 4
      src/gui/transferlistfilterswidget.h

34
src/gui/transferlistfilterswidget.cpp

@ -85,17 +85,19 @@ namespace
} }
TransferListFiltersWidget::TransferListFiltersWidget(QWidget *parent, TransferListWidget *transferList, const bool downloadFavicon) TransferListFiltersWidget::TransferListFiltersWidget(QWidget *parent, TransferListWidget *transferList, const bool downloadFavicon)
: QFrame(parent) : QWidget(parent)
, m_transferList(transferList) , m_transferList {transferList}
{ {
setBackgroundRole(QPalette::Base);
Preferences *const pref = Preferences::instance(); Preferences *const pref = Preferences::instance();
// Construct lists // Construct lists
auto *frame = new QFrame; auto *mainWidget = new QWidget;
auto *frameLayout = new QVBoxLayout(frame); auto *mainWidgetLayout = new QVBoxLayout(mainWidget);
frameLayout->setContentsMargins(0, 2, 0, 0); mainWidgetLayout->setContentsMargins(0, 2, 0, 0);
frameLayout->setSpacing(2); mainWidgetLayout->setSpacing(2);
frameLayout->setAlignment(Qt::AlignLeft | Qt::AlignTop); mainWidgetLayout->setAlignment(Qt::AlignLeft | Qt::AlignTop);
QFont font; QFont font;
font.setBold(true); font.setBold(true);
@ -105,18 +107,18 @@ TransferListFiltersWidget::TransferListFiltersWidget(QWidget *parent, TransferLi
statusLabel->setChecked(pref->getStatusFilterState()); statusLabel->setChecked(pref->getStatusFilterState());
statusLabel->setFont(font); statusLabel->setFont(font);
connect(statusLabel, &QCheckBox::toggled, pref, &Preferences::setStatusFilterState); connect(statusLabel, &QCheckBox::toggled, pref, &Preferences::setStatusFilterState);
frameLayout->addWidget(statusLabel); mainWidgetLayout->addWidget(statusLabel);
auto *statusFilters = new StatusFilterWidget(this, transferList); auto *statusFilters = new StatusFilterWidget(this, transferList);
connect(statusLabel, &QCheckBox::toggled, statusFilters, &StatusFilterWidget::toggleFilter); connect(statusLabel, &QCheckBox::toggled, statusFilters, &StatusFilterWidget::toggleFilter);
frameLayout->addWidget(statusFilters); mainWidgetLayout->addWidget(statusFilters);
QCheckBox *categoryLabel = new ArrowCheckBox(tr("Categories"), this); QCheckBox *categoryLabel = new ArrowCheckBox(tr("Categories"), this);
categoryLabel->setChecked(pref->getCategoryFilterState()); categoryLabel->setChecked(pref->getCategoryFilterState());
categoryLabel->setFont(font); categoryLabel->setFont(font);
connect(categoryLabel, &QCheckBox::toggled, this connect(categoryLabel, &QCheckBox::toggled, this
, &TransferListFiltersWidget::onCategoryFilterStateChanged); , &TransferListFiltersWidget::onCategoryFilterStateChanged);
frameLayout->addWidget(categoryLabel); mainWidgetLayout->addWidget(categoryLabel);
m_categoryFilterWidget = new CategoryFilterWidget(this); m_categoryFilterWidget = new CategoryFilterWidget(this);
connect(m_categoryFilterWidget, &CategoryFilterWidget::actionDeleteTorrentsTriggered connect(m_categoryFilterWidget, &CategoryFilterWidget::actionDeleteTorrentsTriggered
@ -128,13 +130,13 @@ TransferListFiltersWidget::TransferListFiltersWidget(QWidget *parent, TransferLi
connect(m_categoryFilterWidget, &CategoryFilterWidget::categoryChanged connect(m_categoryFilterWidget, &CategoryFilterWidget::categoryChanged
, transferList, &TransferListWidget::applyCategoryFilter); , transferList, &TransferListWidget::applyCategoryFilter);
toggleCategoryFilter(pref->getCategoryFilterState()); toggleCategoryFilter(pref->getCategoryFilterState());
frameLayout->addWidget(m_categoryFilterWidget); mainWidgetLayout->addWidget(m_categoryFilterWidget);
QCheckBox *tagsLabel = new ArrowCheckBox(tr("Tags"), this); QCheckBox *tagsLabel = new ArrowCheckBox(tr("Tags"), this);
tagsLabel->setChecked(pref->getTagFilterState()); tagsLabel->setChecked(pref->getTagFilterState());
tagsLabel->setFont(font); tagsLabel->setFont(font);
connect(tagsLabel, &QCheckBox::toggled, this, &TransferListFiltersWidget::onTagFilterStateChanged); connect(tagsLabel, &QCheckBox::toggled, this, &TransferListFiltersWidget::onTagFilterStateChanged);
frameLayout->addWidget(tagsLabel); mainWidgetLayout->addWidget(tagsLabel);
m_tagFilterWidget = new TagFilterWidget(this); m_tagFilterWidget = new TagFilterWidget(this);
connect(m_tagFilterWidget, &TagFilterWidget::actionDeleteTorrentsTriggered connect(m_tagFilterWidget, &TagFilterWidget::actionDeleteTorrentsTriggered
@ -146,23 +148,23 @@ TransferListFiltersWidget::TransferListFiltersWidget(QWidget *parent, TransferLi
connect(m_tagFilterWidget, &TagFilterWidget::tagChanged connect(m_tagFilterWidget, &TagFilterWidget::tagChanged
, transferList, &TransferListWidget::applyTagFilter); , transferList, &TransferListWidget::applyTagFilter);
toggleTagFilter(pref->getTagFilterState()); toggleTagFilter(pref->getTagFilterState());
frameLayout->addWidget(m_tagFilterWidget); mainWidgetLayout->addWidget(m_tagFilterWidget);
QCheckBox *trackerLabel = new ArrowCheckBox(tr("Trackers"), this); QCheckBox *trackerLabel = new ArrowCheckBox(tr("Trackers"), this);
trackerLabel->setChecked(pref->getTrackerFilterState()); trackerLabel->setChecked(pref->getTrackerFilterState());
trackerLabel->setFont(font); trackerLabel->setFont(font);
connect(trackerLabel, &QCheckBox::toggled, pref, &Preferences::setTrackerFilterState); connect(trackerLabel, &QCheckBox::toggled, pref, &Preferences::setTrackerFilterState);
frameLayout->addWidget(trackerLabel); mainWidgetLayout->addWidget(trackerLabel);
m_trackersFilterWidget = new TrackersFilterWidget(this, transferList, downloadFavicon); m_trackersFilterWidget = new TrackersFilterWidget(this, transferList, downloadFavicon);
connect(trackerLabel, &QCheckBox::toggled, m_trackersFilterWidget, &TrackersFilterWidget::toggleFilter); connect(trackerLabel, &QCheckBox::toggled, m_trackersFilterWidget, &TrackersFilterWidget::toggleFilter);
frameLayout->addWidget(m_trackersFilterWidget); mainWidgetLayout->addWidget(m_trackersFilterWidget);
auto *scroll = new QScrollArea(this); auto *scroll = new QScrollArea(this);
scroll->setWidgetResizable(true); scroll->setWidgetResizable(true);
scroll->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); scroll->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
scroll->setFrameShape(QFrame::NoFrame); scroll->setFrameShape(QFrame::NoFrame);
scroll->setWidget(frame); scroll->setWidget(mainWidget);
auto *vLayout = new QVBoxLayout(this); auto *vLayout = new QVBoxLayout(this);
vLayout->setContentsMargins(0, 0, 0, 0); vLayout->setContentsMargins(0, 0, 0, 0);

4
src/gui/transferlistfilterswidget.h

@ -30,8 +30,8 @@
#pragma once #pragma once
#include <QtContainerFwd> #include <QtContainerFwd>
#include <QFrame>
#include <QHash> #include <QHash>
#include <QWidget>
#include "base/bittorrent/torrent.h" #include "base/bittorrent/torrent.h"
#include "base/bittorrent/trackerentry.h" #include "base/bittorrent/trackerentry.h"
@ -42,7 +42,7 @@ class TagFilterWidget;
class TrackersFilterWidget; class TrackersFilterWidget;
class TransferListWidget; class TransferListWidget;
class TransferListFiltersWidget final : public QFrame class TransferListFiltersWidget final : public QWidget
{ {
Q_OBJECT Q_OBJECT
Q_DISABLE_COPY_MOVE(TransferListFiltersWidget) Q_DISABLE_COPY_MOVE(TransferListFiltersWidget)

Loading…
Cancel
Save