From 51b7e299b4ef672243feb3bae200a57a332bedb3 Mon Sep 17 00:00:00 2001 From: Chocobo1 Date: Mon, 15 Feb 2016 15:15:40 +0800 Subject: [PATCH] Simplify resize actions for AddNewTorrentDialog --- src/gui/addnewtorrentdialog.cpp | 15 ++++----------- src/gui/addnewtorrentdialog.h | 1 - 2 files changed, 4 insertions(+), 12 deletions(-) diff --git a/src/gui/addnewtorrentdialog.cpp b/src/gui/addnewtorrentdialog.cpp index 27dfafa78..70c57f415 100644 --- a/src/gui/addnewtorrentdialog.cpp +++ b/src/gui/addnewtorrentdialog.cpp @@ -256,6 +256,8 @@ void AddNewTorrentDialog::showEvent(QShowEvent *event) void AddNewTorrentDialog::showAdvancedSettings(bool show) { + const int minimumW = minimumWidth(); + setMinimumWidth(width()); // to remain the same width if (show) { ui->adv_button->setText(QString::fromUtf8(C_UP)); ui->settings_group->setVisible(true); @@ -274,7 +276,8 @@ void AddNewTorrentDialog::showAdvancedSettings(bool show) ui->infoGroup->setVisible(false); ui->buttonsHLayout->insertWidget(0, layout()->takeAt(layout()->indexOf(ui->never_show_cb) + 1)->widget()); } - relayout(); + adjustSize(); + setMinimumWidth(minimumW); } void AddNewTorrentDialog::saveSavePathHistory() const @@ -347,7 +350,6 @@ void AddNewTorrentDialog::onSavePathChanged(int index) // Toggle default save path setting checkbox visibility ui->default_save_path_cb->setChecked(false); ui->default_save_path_cb->setVisible(QDir(ui->save_path_combo->itemData(ui->save_path_combo->currentIndex()).toString()) != QDir(Preferences::instance()->getSavePath())); - relayout(); // Remember index m_oldIndex = index; @@ -404,15 +406,6 @@ void AddNewTorrentDialog::browseButton_clicked() connect(ui->save_path_combo, SIGNAL(currentIndexChanged(int)), SLOT(onSavePathChanged(int))); } -void AddNewTorrentDialog::relayout() -{ - qApp->processEvents(); - int min_width = minimumWidth(); - setMinimumWidth(width()); - adjustSize(); - setMinimumWidth(min_width); -} - void AddNewTorrentDialog::renameSelectedFile() { const QModelIndexList selectedIndexes = ui->content_tree->selectionModel()->selectedRows(0); diff --git a/src/gui/addnewtorrentdialog.h b/src/gui/addnewtorrentdialog.h index 8b1cd2576..5de761b87 100644 --- a/src/gui/addnewtorrentdialog.h +++ b/src/gui/addnewtorrentdialog.h @@ -68,7 +68,6 @@ private slots: void displayContentTreeMenu(const QPoint&); void updateDiskSpaceLabel(); void onSavePathChanged(int); - void relayout(); void renameSelectedFile(); void setdialogPosition(); void updateMetadata(const BitTorrent::TorrentInfo &info);