diff options
author | Rainer Keller <rainer.keller@theqtcompany.com> | 2014-11-13 15:47:11 +0100 |
---|---|---|
committer | Rainer Keller <rainer.keller@theqtcompany.com> | 2014-11-14 15:58:46 +0200 |
commit | 6010e69aa3ac3e94c0fabf16a28e682e35a07a68 (patch) | |
tree | 80ea47c2880607fc2a16e24a96ce30effe3ce6ff | |
parent | 1f0de42b9d5a8ef665e6799019eed898b0396586 (diff) |
b2qt-flashing-wizard: Make all buttons functional
Change-Id: Ie2cc222f689a937f1f175fd678d7ae441273171e
Reviewed-by: Rainer Keller <rainer.keller@theqtcompany.com>
-rw-r--r-- | src/b2qt-flashing-wizard/progress_page.cpp | 38 | ||||
-rw-r--r-- | src/b2qt-flashing-wizard/progress_page.h | 5 |
2 files changed, 37 insertions, 6 deletions
diff --git a/src/b2qt-flashing-wizard/progress_page.cpp b/src/b2qt-flashing-wizard/progress_page.cpp index 7986df9..9c87d2d 100644 --- a/src/b2qt-flashing-wizard/progress_page.cpp +++ b/src/b2qt-flashing-wizard/progress_page.cpp @@ -19,6 +19,8 @@ #include "progress_page.h" #include "actor.h" +#include <QApplication> +#include <QClipboard> #include <QDebug> #include <QLabel> #include <QLayout> @@ -32,19 +34,25 @@ ProgressPage::ProgressPage(QWidget *parent) , mActor(0) , mFinished(false) , mTextEdit(new QTextEdit(this)) + , mToggleDetailsButton(new QPushButton(this)) + , mCopyToClipboardButton(new QPushButton(this)) { setTitle("Disk creation"); setSubTitle("Progress of writing the disk"); setLayout(new QVBoxLayout(this)); mProgress->setText(tr("Starting")); layout()->addWidget(mProgress); - QPushButton *button = new QPushButton(this); - button->setText("Show details"); - layout()->addWidget(button); + mToggleDetailsButton->setText("Show details"); + layout()->addWidget(mToggleDetailsButton); layout()->addWidget(mTextEdit); - QPushButton *copy = new QPushButton(this); - copy->setText("Copy to clipboard"); - layout()->addWidget(copy); + mCopyToClipboardButton->setText("Copy to clipboard"); + layout()->addWidget(mCopyToClipboardButton); + + mTextEdit->hide(); + mCopyToClipboardButton->hide(); + + connect(mToggleDetailsButton, &QPushButton::clicked, this, &ProgressPage::toggleDetails); + connect(mCopyToClipboardButton, &QPushButton::clicked, this, &ProgressPage::copyDetailsToClipboard); } ProgressPage::~ProgressPage() @@ -88,3 +96,21 @@ void ProgressPage::addDetails(QByteArray newData) newData.replace(0x08 /* backspace */, ' '); mTextEdit->append(QString::fromLocal8Bit(newData)); } + +void ProgressPage::toggleDetails() +{ + if (mTextEdit->isHidden()) { + mTextEdit->show(); + mCopyToClipboardButton->show(); + mToggleDetailsButton->setText("Hide details"); + } else { + mTextEdit->hide(); + mCopyToClipboardButton->hide(); + mToggleDetailsButton->setText("Show details"); + } +} + +void ProgressPage::copyDetailsToClipboard() +{ + QApplication::clipboard()->setText(mTextEdit->toPlainText()); +} diff --git a/src/b2qt-flashing-wizard/progress_page.h b/src/b2qt-flashing-wizard/progress_page.h index d0a3b79..3169e3f 100644 --- a/src/b2qt-flashing-wizard/progress_page.h +++ b/src/b2qt-flashing-wizard/progress_page.h @@ -24,6 +24,7 @@ class QLabel; class Actor; class QTextEdit; +class QPushButton; class ProgressPage : public QWizardPage { @@ -39,12 +40,16 @@ public slots: void progress(const QString &step); void finished(); void addDetails(QByteArray newData); + void toggleDetails(); + void copyDetailsToClipboard(); private: QLabel *mProgress; Actor *mActor; bool mFinished; QTextEdit *mTextEdit; + QPushButton *mToggleDetailsButton; + QPushButton *mCopyToClipboardButton; }; #endif // PROGRESS_PAGE_H |