From 926894f20f6fcf2fc22ce4d5699320554aa2894a Mon Sep 17 00:00:00 2001 From: itsmattkc Date: Thu, 21 Mar 2019 21:12:44 +1100 Subject: [PATCH] finished documenting load dialog --- dialogs/loaddialog.cpp | 9 +++++---- dialogs/loaddialog.h | 35 ++++++++++++++++++++--------------- global/global.cpp | 2 +- 3 files changed, 26 insertions(+), 20 deletions(-) diff --git a/dialogs/loaddialog.cpp b/dialogs/loaddialog.cpp index d3399f4d5..dfcbb7f5b 100644 --- a/dialogs/loaddialog.cpp +++ b/dialogs/loaddialog.cpp @@ -45,10 +45,11 @@ LoadDialog::LoadDialog(QWidget *parent) : bar->setValue(0); layout->addWidget(bar); - cancel_button = new QPushButton(tr("Cancel"), this); + QPushButton* cancel_button = new QPushButton(tr("Cancel"), this); connect(cancel_button, SIGNAL(clicked(bool)), this, SIGNAL(cancel())); - hboxLayout = new QHBoxLayout(); + // Wrap cancel button in a horizontal layout so it can be centered + QHBoxLayout* hboxLayout = new QHBoxLayout(); hboxLayout->addStretch(); hboxLayout->addWidget(cancel_button); hboxLayout->addStretch(); @@ -56,7 +57,7 @@ LoadDialog::LoadDialog(QWidget *parent) : layout->addLayout(hboxLayout); } -QProgressBar *LoadDialog::progress_bar() +void LoadDialog::setValue(int i) { - return bar; + bar->setValue(i); } diff --git a/dialogs/loaddialog.h b/dialogs/loaddialog.h index f7b30798a..5fa357155 100644 --- a/dialogs/loaddialog.h +++ b/dialogs/loaddialog.h @@ -31,7 +31,7 @@ /** * @brief The LoadDialog class * - * Shows a modal dialog for loading a project and creates a LoadThread to load it. + * Shows a modal dialog for loading a project. Designed to be connected to a LoadThread object. */ class LoadDialog : public QDialog { @@ -43,27 +43,32 @@ public: * @param parent * * QWidget parent. Usually MainWindow. - * - * @param filename - * - * URL of the project file to load. - * - * @param autorecovery - * - * TRUE if this is an autorecovery project - * - * @param clear */ LoadDialog(QWidget* parent); - QProgressBar* progress_bar(); +public slots: + /** + * @brief Set the progress bar value + * + * Ideally, connect this to LoadThread::report_progress(). + * + * @param i + * + * Should be a value between 0-100. + */ + void setValue(int i); signals: + /** + * @brief Signal emitted when the cancel button is clicked. + * + * Ideally, connect this to LoadThread::cancel(); + */ void cancel(); private: + /** + * @brief Progress bar widget + */ QProgressBar* bar; - QPushButton* cancel_button; - QHBoxLayout* hboxLayout; - LoadThread* lt; }; #endif // LOADDIALOG_H diff --git a/global/global.cpp b/global/global.cpp index 5464ac30d..65ec8036e 100644 --- a/global/global.cpp +++ b/global/global.cpp @@ -182,7 +182,7 @@ void OliveGlobal::LoadProject(const QString &fn, bool autorecovery, bool clear) connect(lt, SIGNAL(success()), &ld, SLOT(accept())); connect(lt, SIGNAL(error()), &ld, SLOT(reject())); connect(lt, SIGNAL(error()), this, SLOT(new_project())); - connect(lt, SIGNAL(report_progress(int)), ld.progress_bar(), SLOT(setValue(int))); + connect(lt, SIGNAL(report_progress(int)), &ld, SLOT(setValue(int))); lt->start(); ld.exec();