From 527135abb1662cd2ecf5a9a0943b77267059dffc Mon Sep 17 00:00:00 2001 From: David Sansome Date: Wed, 4 Jan 2012 22:29:26 +0000 Subject: [PATCH] Stop the organise files dialog from resizing only after a manual resize has been done by the user - otherwise the dialog doesn't grow/shrink automatically when you select a new destination. --- src/ui/organisedialog.cpp | 20 +++++++++++++++++--- src/ui/organisedialog.h | 5 ++++- 2 files changed, 21 insertions(+), 4 deletions(-) diff --git a/src/ui/organisedialog.cpp b/src/ui/organisedialog.cpp index ea0324166..28f516ffc 100644 --- a/src/ui/organisedialog.cpp +++ b/src/ui/organisedialog.cpp @@ -26,6 +26,7 @@ #include #include #include +#include #include #include #include @@ -39,7 +40,8 @@ OrganiseDialog::OrganiseDialog(TaskManager* task_manager, QWidget *parent) : QDialog(parent), ui_(new Ui_OrganiseDialog), task_manager_(task_manager), - total_size_(0) + total_size_(0), + resized_by_user_(false) { ui_->setupUi(this); connect(ui_->buttonBox->button(QDialogButtonBox::Reset), SIGNAL(clicked()), SLOT(Reset())); @@ -238,7 +240,9 @@ void OrganiseDialog::UpdatePreviews() { } } - adjustSize(); + if (!resized_by_user_) { + adjustSize(); + } } QSize OrganiseDialog::sizeHint() const { @@ -254,7 +258,9 @@ void OrganiseDialog::Reset() { ui_->eject_after->setChecked(false); } -void OrganiseDialog::showEvent(QShowEvent *) { +void OrganiseDialog::showEvent(QShowEvent*) { + resized_by_user_ = false; + QSettings s; s.beginGroup(kSettingsGroup); ui_->naming->setPlainText(s.value("format", kDefaultFormat).toString()); @@ -309,3 +315,11 @@ void OrganiseDialog::OrganiseFinished(const QStringList& files_with_errors) { error_dialog_.reset(new OrganiseErrorDialog); error_dialog_->Show(OrganiseErrorDialog::Type_Copy, files_with_errors); } + +void OrganiseDialog::resizeEvent(QResizeEvent* e) { + if (e->spontaneous()) { + resized_by_user_ = true; + } + + QDialog::resizeEvent(e); +} diff --git a/src/ui/organisedialog.h b/src/ui/organisedialog.h index 502a8db47..30b6dfba1 100644 --- a/src/ui/organisedialog.h +++ b/src/ui/organisedialog.h @@ -58,7 +58,8 @@ public slots: void accept(); protected: - void showEvent(QShowEvent *); + void showEvent(QShowEvent*); + void resizeEvent(QResizeEvent*); private slots: void Reset(); @@ -80,6 +81,8 @@ private: quint64 total_size_; boost::scoped_ptr error_dialog_; + + bool resized_by_user_; }; #endif // ORGANISEDIALOG_H