From 9ce9f45cd37f4217dd8babf16e7944f5d07e2d08 Mon Sep 17 00:00:00 2001 From: Roman Telezhynskyi Date: Wed, 18 Nov 2015 11:03:19 +0200 Subject: [PATCH] Fixate size of the Tape 'Config dialog' only after first show. --HG-- branch : develop --- src/app/tape/dialogs/tapeconfigdialog.cpp | 26 ++++++++++++++++++++--- src/app/tape/dialogs/tapeconfigdialog.h | 2 ++ 2 files changed, 25 insertions(+), 3 deletions(-) diff --git a/src/app/tape/dialogs/tapeconfigdialog.cpp b/src/app/tape/dialogs/tapeconfigdialog.cpp index 1c1c3eff3..1af4ccd60 100644 --- a/src/app/tape/dialogs/tapeconfigdialog.cpp +++ b/src/app/tape/dialogs/tapeconfigdialog.cpp @@ -44,10 +44,9 @@ TapeConfigDialog::TapeConfigDialog(QWidget *parent) pathPage(nullptr), applyButton(nullptr), canselButton(nullptr), - okButton(nullptr) + okButton(nullptr), + isInitialized(false) { - this->setMaximumHeight(300); - contentsWidget = new QListWidget; contentsWidget->setViewMode(QListView::IconMode); contentsWidget->setIconSize(QSize(96, 84)); @@ -133,6 +132,27 @@ void TapeConfigDialog::changeEvent(QEvent *event) QDialog::changeEvent(event); } +//--------------------------------------------------------------------------------------------------------------------- +void TapeConfigDialog::showEvent(QShowEvent *event) +{ + QDialog::showEvent( event ); + if ( event->spontaneous() ) + { + return; + } + + if (isInitialized) + { + return; + } + // do your init stuff here + + setMaximumSize(size()); + setMinimumSize(size()); + + isInitialized = true;//first show windows are held +} + //--------------------------------------------------------------------------------------------------------------------- void TapeConfigDialog::createIcons() { diff --git a/src/app/tape/dialogs/tapeconfigdialog.h b/src/app/tape/dialogs/tapeconfigdialog.h index 7d24e0d9f..659b21613 100644 --- a/src/app/tape/dialogs/tapeconfigdialog.h +++ b/src/app/tape/dialogs/tapeconfigdialog.h @@ -49,6 +49,7 @@ signals: protected: virtual void closeEvent(QCloseEvent *event) Q_DECL_OVERRIDE; virtual void changeEvent(QEvent* event) Q_DECL_OVERRIDE; + virtual void showEvent(QShowEvent *event) Q_DECL_OVERRIDE; private: Q_DISABLE_COPY(TapeConfigDialog) QListWidget *contentsWidget; @@ -58,6 +59,7 @@ private: QPushButton *applyButton; QPushButton *canselButton; QPushButton *okButton; + bool isInitialized; void createIcons(); void createIcon(const QString &icon, const QString &text);