1
0
mirror of https://github.com/d47081/qBittorrent.git synced 2025-01-10 23:07:59 +00:00

Fix possible status filters widget height problem

This commit is contained in:
Christophe Dumez 2011-06-11 13:00:33 +00:00
parent 83ce77b398
commit 8b2f7c4661
2 changed files with 8 additions and 28 deletions

View File

@ -711,9 +711,6 @@ void MainWindow::on_actionAbout_triggered() {
void MainWindow::showEvent(QShowEvent *e) { void MainWindow::showEvent(QShowEvent *e) {
qDebug("** Show Event **"); qDebug("** Show Event **");
// Update status filters list height
transferListFilters->getStatusFilters()->updateHeight();
if(getCurrentTabWidget() == transferList) { if(getCurrentTabWidget() == transferList) {
properties->loadDynamicData(); properties->loadDynamicData();
} }

View File

@ -154,35 +154,18 @@ class StatusFiltersWidget : public QListWidget {
public: public:
StatusFiltersWidget(QWidget *parent) : QListWidget(parent), m_shown(false) { StatusFiltersWidget(QWidget *parent) : QListWidget(parent), m_shown(false) {
//setFixedHeight(120); setUniformItemSizes(true);
setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Minimum);
}
public slots:
void updateHeight() {
qDebug("Adjusting statuslist widget height...");
m_shown = true;
setVerticalScrollBarPolicy(Qt::ScrollBarAsNeeded);
int cur_height = 50;
do {
setFixedHeight(cur_height);
cur_height += 10;
}while(verticalScrollBar()->isVisible());
setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff); setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
// Height is fixed (sizeHint().height() is used)
setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Fixed);
} }
protected: protected:
void changeEvent(QEvent *e) { QSize sizeHint() const {
QListWidget::changeEvent(e); QSize size = QListWidget::sizeHint();
switch (e->type()) { // Height should be exactly the height of the content
case QEvent::StyleChange: size.setHeight(contentsSize().height() + 2 * frameWidth());
qDebug("Style has changed, adapting the statusfilters widget height"); return size;
if(m_shown)
updateHeight();
break;
default:
break;
}
} }
private: private: