Browse Source

Use a single scrollbar for all filters in the sidepanel.

adaptive-webui-19844
sledgehammer999 10 years ago
parent
commit
e378f28fb7
  1. 71
      src/gui/transferlistfilterswidget.cpp
  2. 6
      src/gui/transferlistfilterswidget.h

71
src/gui/transferlistfilterswidget.cpp

@ -35,9 +35,9 @@
#include <QIcon> #include <QIcon>
#include <QVBoxLayout> #include <QVBoxLayout>
#include <QMenu> #include <QMenu>
#include <QResizeEvent>
#include <QMessageBox> #include <QMessageBox>
#include <QCheckBox> #include <QCheckBox>
#include <QScrollArea>
#include "transferlistdelegate.h" #include "transferlistdelegate.h"
#include "transferlistwidget.h" #include "transferlistwidget.h"
@ -72,17 +72,18 @@ FiltersBase::FiltersBase(QWidget *parent, TransferListWidget *transferList)
QSize FiltersBase::sizeHint() const QSize FiltersBase::sizeHint() const
{ {
QSize size = QListWidget::sizeHint(); QSize size;
// Height should be exactly the height of the content // Height should be exactly the height of the content
size.setHeight((sizeHintForRow(0) * count()) + (2 * frameWidth()) + 6); size.setHeight((sizeHintForRow(0) * count()) + (2 * frameWidth()) + 6);
// Width should be exactly the height of the content
size.setWidth(sizeHintForColumn(0) + (2 * frameWidth()));
return size; return size;
} }
QSize FiltersBase::minimumSizeHint() const QSize FiltersBase::minimumSizeHint() const
{ {
QSize size = QListWidget::minimumSizeHint(); QSize size = sizeHint();
// Minimum height should be exactly the sticky labels height size.setWidth(6);
size.setHeight((sizeHintForRow(0) * 2) + (2 * frameWidth()) + 6);
return size; return size;
} }
@ -738,39 +739,62 @@ QStringList TrackerFiltersList::getHashes(int row)
TransferListFiltersWidget::TransferListFiltersWidget(QWidget *parent, TransferListWidget *transferList) TransferListFiltersWidget::TransferListFiltersWidget(QWidget *parent, TransferListWidget *transferList)
: QFrame(parent) : QFrame(parent)
, statusFilters(0)
, trackerFilters(0) , trackerFilters(0)
, trackerLabel(0)
{ {
Preferences* const pref = Preferences::instance(); Preferences* const pref = Preferences::instance();
// Construct lists // Construct lists
QVBoxLayout *vLayout = new QVBoxLayout(this); QVBoxLayout *vLayout = new QVBoxLayout(this);
vLayout->setContentsMargins(0, 4, 0, 0); QScrollArea *scroll = new QScrollArea(this);
QFrame *frame = new QFrame(scroll);
QVBoxLayout *frameLayout = new QVBoxLayout(frame);
QFont font; QFont font;
font.setBold(true); font.setBold(true);
font.setCapitalization(QFont::SmallCaps); font.setCapitalization(QFont::SmallCaps);
frame->setFrameShadow(QFrame::Plain);
frame->setFrameShape(QFrame::NoFrame);
scroll->setFrameShadow(QFrame::Plain);
scroll->setFrameShape(QFrame::NoFrame);
scroll->setStyleSheet("QFrame { background: transparent; }");
scroll->setWidgetResizable(true);
scroll->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
vLayout->setContentsMargins(0, 4, 0, 0);
frameLayout->setContentsMargins(0, 4, 0, 0);
frameLayout->setSpacing(2);
frame->setLayout(frameLayout);
scroll->setWidget(frame);
vLayout->addWidget(scroll);
setLayout(vLayout);
setContentsMargins(0,0,0,0);
QCheckBox * statusLabel = new QCheckBox(tr("Status"), this); QCheckBox * statusLabel = new QCheckBox(tr("Status"), this);
statusLabel->setChecked(pref->getStatusFilterState()); statusLabel->setChecked(pref->getStatusFilterState());
statusLabel->setFont(font); statusLabel->setFont(font);
vLayout->addWidget(statusLabel); frameLayout->addWidget(statusLabel);
statusFilters = new StatusFiltersWidget(this, transferList);
vLayout->addWidget(statusFilters); StatusFiltersWidget *statusFilters = new StatusFiltersWidget(this, transferList);
frameLayout->addWidget(statusFilters);
QCheckBox *labelLabel = new QCheckBox(tr("Labels"), this); QCheckBox *labelLabel = new QCheckBox(tr("Labels"), this);
labelLabel->setChecked(pref->getLabelFilterState()); labelLabel->setChecked(pref->getLabelFilterState());
labelLabel->setFont(font); labelLabel->setFont(font);
vLayout->addWidget(labelLabel); frameLayout->addWidget(labelLabel);
LabelFiltersList *labelFilters = new LabelFiltersList(this, transferList); LabelFiltersList *labelFilters = new LabelFiltersList(this, transferList);
vLayout->addWidget(labelFilters); frameLayout->addWidget(labelFilters);
trackerLabel = new QCheckBox(tr("Trackers"), this);
QCheckBox *trackerLabel = new QCheckBox(tr("Trackers"), this);
trackerLabel->setChecked(pref->getTrackerFilterState()); trackerLabel->setChecked(pref->getTrackerFilterState());
trackerLabel->setFont(font); trackerLabel->setFont(font);
vLayout->addWidget(trackerLabel); frameLayout->addWidget(trackerLabel);
trackerFilters = new TrackerFiltersList(this, transferList); trackerFilters = new TrackerFiltersList(this, transferList);
vLayout->addWidget(trackerFilters); frameLayout->addWidget(trackerFilters);
setLayout(vLayout);
setContentsMargins(0,0,0,0); frameLayout->addStretch();
vLayout->setSpacing(2);
vLayout->addStretch();
connect(statusLabel, SIGNAL(toggled(bool)), statusFilters, SLOT(toggleFilter(bool))); connect(statusLabel, SIGNAL(toggled(bool)), statusFilters, SLOT(toggleFilter(bool)));
connect(statusLabel, SIGNAL(toggled(bool)), pref, SLOT(setStatusFilterState(const bool))); connect(statusLabel, SIGNAL(toggled(bool)), pref, SLOT(setStatusFilterState(const bool)));
@ -783,13 +807,6 @@ TransferListFiltersWidget::TransferListFiltersWidget(QWidget *parent, TransferLi
connect(this, SIGNAL(trackerWarning(const QString &, const QString &)), trackerFilters, SLOT(trackerWarning(const QString &, const QString &))); connect(this, SIGNAL(trackerWarning(const QString &, const QString &)), trackerFilters, SLOT(trackerWarning(const QString &, const QString &)));
} }
void TransferListFiltersWidget::resizeEvent(QResizeEvent *event)
{
int height = event->size().height();
int minHeight = statusFilters->height() + (3 * trackerLabel->height());
trackerFilters->setMinimumHeight((height - minHeight) / 2);
}
void TransferListFiltersWidget::addTrackers(const QStringList &trackers, const QString &hash) void TransferListFiltersWidget::addTrackers(const QStringList &trackers, const QString &hash)
{ {
foreach (const QString &tracker, trackers) foreach (const QString &tracker, trackers)

6
src/gui/transferlistfilterswidget.h

@ -180,14 +180,8 @@ signals:
void trackerError(const QString &hash, const QString &tracker); void trackerError(const QString &hash, const QString &tracker);
void trackerWarning(const QString &hash, const QString &tracker); void trackerWarning(const QString &hash, const QString &tracker);
protected:
virtual void resizeEvent(QResizeEvent *event);
private: private:
StatusFiltersWidget *statusFilters;
TrackerFiltersList *trackerFilters; TrackerFiltersList *trackerFilters;
//for use in resizeEvent()
QCheckBox *trackerLabel;
}; };
#endif // TRANSFERLISTFILTERSWIDGET_H #endif // TRANSFERLISTFILTERSWIDGET_H

Loading…
Cancel
Save