removed PrefixPath debug line
[opentx.git] / companion / src / progresswidget.cpp
blob9c19aa01e71873f28ee8d41240985a6fb5e5066f
1 #include "progresswidget.h"
2 #include "ui_progresswidget.h"
3 #include "appdata.h"
4 #include <QDebug>
5 #include <QTimer>
6 #include <QScrollBar>
8 ProgressWidget::ProgressWidget(QWidget *parent):
9 QWidget(parent),
10 ui(new Ui::ProgressWidget)
12 ui->setupUi(this);
13 ui->info->hide();
14 ui->checkBox->hide();
15 ui->textEdit->hide();
17 #ifdef __APPLE__
18 QFont newFont("Courier", 13);
19 ui->textEdit->setFont(newFont);
20 ui->textEdit->setAttribute(Qt::WA_MacNormalSize);
21 #elif defined WIN32 || !defined __GNUC__
22 QFont newFont("Courier", 9);
23 ui->textEdit->setFont(newFont);
24 #endif
27 ProgressWidget::~ProgressWidget()
29 delete ui;
32 void ProgressWidget::forceOpen()
34 ui->checkBox->hide();
35 ui->textEdit->show();
38 void ProgressWidget::setInfo(const QString &text)
40 ui->info->show();
41 ui->info->setText(text);
44 void ProgressWidget::setMaximum(int value)
46 ui->progressBar->setMaximum(value);
49 int ProgressWidget::maximum()
51 return ui->progressBar->maximum();
54 void ProgressWidget::setValue(int value)
56 ui->progressBar->setValue(value);
59 void ProgressWidget::addText(const QString &text)
61 ui->checkBox->setVisible(true);
63 if (g.outputDisplayDetails()) {
64 ui->checkBox->setChecked(true);
65 ui->textEdit->setVisible(true);
68 QTextCursor cursor(ui->textEdit->textCursor());
70 // is the scrollbar at the end?
71 bool atEnd = (ui->textEdit->verticalScrollBar()->value() == ui->textEdit->verticalScrollBar()->maximum());
73 cursor.movePosition(QTextCursor::End, QTextCursor::MoveAnchor, 1);
74 cursor.insertText(text);
76 if (atEnd) {
77 ui->textEdit->verticalScrollBar()->triggerAction(QAbstractSlider::SliderToMaximum);
81 QString ProgressWidget::getText()
83 return ui->textEdit->toPlainText();
86 void ProgressWidget::setProgressColor(const QColor &color)
88 ui->progressBar->setStyleSheet(QString("QProgressBar {text-align: center;} QProgressBar::chunk { background-color: %1; text-align:center;}:").arg(color.name()));
91 #define HLINE_SEPARATOR "================================================================================="
93 void ProgressWidget::addSeparator()
95 addText("\n" HLINE_SEPARATOR "\n");
98 void ProgressWidget::on_checkBox_toggled(bool checked)
100 g.outputDisplayDetails(checked);
101 ui->textEdit->setVisible(checked);
102 QTimer::singleShot(0, this, SLOT(shrink()));
105 void ProgressWidget::lock(bool lock)
107 emit locked(lock);
110 void ProgressWidget::shrink()
112 emit detailsToggled();