From 1ca4351488359c003d2c335d9a023c07963b3671 Mon Sep 17 00:00:00 2001 From: dsarrut Date: Thu, 22 Jul 2010 05:54:40 +0000 Subject: [PATCH] add cancel button --- vv/vvProgressDialog.cxx | 21 +++++++++++++++++++++ vv/vvProgressDialog.h | 3 +++ 2 files changed, 24 insertions(+) diff --git a/vv/vvProgressDialog.cxx b/vv/vvProgressDialog.cxx index 7288f65..d15ac1c 100644 --- a/vv/vvProgressDialog.cxx +++ b/vv/vvProgressDialog.cxx @@ -24,6 +24,7 @@ vvProgressDialog::vvProgressDialog(std::string message, bool show_progress) { setupUi(this); connect(mCancelButton, SIGNAL(rejected()), this, SLOT(reject())); + SetCancelButtonEnabled(false); textLabel->setText(message.c_str()); if (show_progress) progressBar->show(); @@ -34,6 +35,26 @@ vvProgressDialog::vvProgressDialog(std::string message, bool show_progress) //------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ +void vvProgressDialog::SetCancelButtonEnabled(bool b) +{ + if (b) { + mCancelButton->show(); + //setMaximumHeight(500); + //setMinimumHeight(80); + //QSizePolicy sizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred); + // sizePolicy.setHorizontalStretch(0); + // sizePolicy.setVerticalStretch(0); + // sizePolicy.setHeightForWidth(sizePolicy().hasHeightForWidth()); + //setSizePolicy(sizePolicy); + } + else { + mCancelButton->hide(); + // setFixedHeight(80); // fixe the size when no cancel button + } +} +//------------------------------------------------------------------------------ + //------------------------------------------------------------------------------ void vvProgressDialog::SetText(std::string message) { diff --git a/vv/vvProgressDialog.h b/vv/vvProgressDialog.h index 9906041..1105320 100644 --- a/vv/vvProgressDialog.h +++ b/vv/vvProgressDialog.h @@ -22,6 +22,7 @@ // vv #include "ui_vvProgressDialog.h" +//------------------------------------------------------------------------------ class vvProgressDialog : public QDialog, private Ui::vvProgressDialog @@ -31,9 +32,11 @@ class vvProgressDialog : public: vvProgressDialog(std::string message,bool show_progress=false); ~vvProgressDialog() {} + void SetCancelButtonEnabled(bool b); void SetText(std::string message); void AddToText(std::string message); void SetProgress(unsigned int current,unsigned int max); }; +//------------------------------------------------------------------------------ #endif -- 2.47.1