1
0
mirror of https://bitbucket.org/librepilot/librepilot.git synced 2025-01-19 04:52:12 +01:00

OP-1628 Fixed button enablement glitch. Added style sheet to reboot page progress bar.

This commit is contained in:
m_thread 2014-12-29 18:03:20 +01:00
parent 9614397694
commit 61b2b0f07a
5 changed files with 35 additions and 3 deletions

View File

@ -8,7 +8,7 @@
AutoUpdatePage::AutoUpdatePage(SetupWizard *wizard, QWidget *parent) :
AbstractWizardPage(wizard, parent),
ui(new Ui::AutoUpdatePage)
ui(new Ui::AutoUpdatePage), m_isUpdating(false)
{
ui->setupUi(this);
ExtensionSystem::PluginManager *pm = ExtensionSystem::PluginManager::instance();
@ -25,6 +25,11 @@ AutoUpdatePage::~AutoUpdatePage()
delete ui;
}
bool AutoUpdatePage::isComplete() const
{
return !m_isUpdating;
}
void AutoUpdatePage::enableButtons(bool enable = false)
{
ui->startUpdate->setEnabled(enable);
@ -42,6 +47,7 @@ void AutoUpdatePage::autoUpdate()
Q_ASSERT(pm);
UploaderGadgetFactory *uploader = pm->getObject<UploaderGadgetFactory>();
Q_ASSERT(uploader);
m_isUpdating = true;
uploader->autoUpdate(ui->eraseSettings->isChecked());
}
@ -83,10 +89,12 @@ void AutoUpdatePage::updateStatus(uploader::ProgressStep status, QVariant value)
ui->statusLabel->setText(tr("Booting the board%1. Please wait").arg(value.toString()));
break;
case uploader::SUCCESS:
m_isUpdating = false;
enableButtons(true);
ui->statusLabel->setText(tr("Board updated, please press 'Next' to continue."));
break;
case uploader::FAILURE:
m_isUpdating = false;
enableButtons(true);
QString msg = value.toString();
if (msg.isEmpty()) {

View File

@ -44,6 +44,7 @@ class AutoUpdatePage : public AbstractWizardPage {
public:
explicit AutoUpdatePage(SetupWizard *wizard, QWidget *parent = 0);
~AutoUpdatePage();
bool isComplete() const;
private slots:
void updateStatus(uploader::ProgressStep, QVariant);
@ -56,6 +57,7 @@ private slots:
private:
Ui::AutoUpdatePage *ui;
bool m_isUpdating;
};
#endif // AUTOUPDATEPAGE_H

View File

@ -30,7 +30,7 @@
RebootPage::RebootPage(SetupWizard *wizard, QWidget *parent) :
AbstractWizardPage(wizard, parent),
ui(new Ui::RebootPage), m_toggl(false)
ui(new Ui::RebootPage), m_toggl(false), m_isRebooting(false)
{
ui->setupUi(this);
ui->yellowLabel->setVisible(false);
@ -63,7 +63,7 @@ void RebootPage::initializePage()
bool RebootPage::validatePage()
{
return true;
return !m_isRebooting;
}
void RebootPage::toggleLabel()
@ -89,6 +89,7 @@ void RebootPage::reboot()
QApplication::processEvents();
connect(m_uploader, SIGNAL(progressUpdate(uploader::ProgressStep, QVariant)), this, SLOT(progressUpdate(uploader::ProgressStep, QVariant)));
ui->messageLabel->setText(tr("Reboot in progress..."));
m_isRebooting = true;
m_uploader->reboot();
}
@ -104,8 +105,15 @@ void RebootPage::progressUpdate(uploader::ProgressStep progress, QVariant messag
} else {
ui->messageLabel->setText(tr("<font color='green'>Reboot complete!</font>"));
}
m_isRebooting= false;
enableButtons(true);
} else {
ui->rebootProgress->setValue(ui->rebootProgress->value() + 1);
}
}
bool RebootPage::isComplete() const
{
return !m_isRebooting;
}

View File

@ -46,6 +46,7 @@ public:
void initializePage();
bool validatePage();
bool isComplete() const;
void enableButtons(bool enable);
private:
@ -53,6 +54,7 @@ private:
QTimer m_timer;
bool m_toggl;
UploaderGadgetFactory *m_uploader;
bool m_isRebooting;
private slots:
void toggleLabel();

View File

@ -93,6 +93,18 @@ p, li { white-space: pre-wrap; }
</item>
<item>
<widget class="QProgressBar" name="rebootProgress">
<property name="styleSheet">
<string notr="true">QProgressBar {
border: 2px solid grey;
border-radius: 5px;
text-align: center;
}
QProgressBar::chunk {
background-color: #3D6699;
width: 10px;
margin: 0.5px;
}</string>
</property>
<property name="maximum">
<number>6</number>
</property>