1 #include "progresswidget.h"
2 #include "ui_progresswidget.h"
8 ProgressWidget::ProgressWidget(QWidget
*parent
):
10 ui(new Ui::ProgressWidget
)
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
);
27 ProgressWidget::~ProgressWidget()
32 void ProgressWidget::forceOpen()
38 void ProgressWidget::setInfo(const QString
&text
)
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
);
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
)
110 void ProgressWidget::shrink()
112 emit
detailsToggled();