From: dsarrut Date: Thu, 22 Jul 2010 05:54:40 +0000 (+0000) Subject: add cancel button X-Git-Tag: v1.2.0~508 X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=commitdiff_plain;h=1ca4351488359c003d2c335d9a023c07963b3671;p=clitk.git add cancel button --- 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