finished documenting load dialog

This commit is contained in:
itsmattkc
2019-03-21 21:12:44 +11:00
parent 3e74d3dccb
commit 926894f20f
3 changed files with 26 additions and 20 deletions
+5 -4
View File
@@ -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);
}
+20 -15
View File
@@ -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
+1 -1
View File
@@ -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();