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.

This commit is contained in:
David Sansome 2012-01-04 22:29:26 +00:00
parent 76e6281af5
commit 527135abb1
2 changed files with 21 additions and 4 deletions

View File

@ -26,6 +26,7 @@
#include <QFileInfo>
#include <QMenu>
#include <QPushButton>
#include <QResizeEvent>
#include <QSettings>
#include <QSignalMapper>
#include <QtDebug>
@ -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);
}

View File

@ -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<OrganiseErrorDialog> error_dialog_;
bool resized_by_user_;
};
#endif // ORGANISEDIALOG_H