Use a message box with color red and a timer to click on ok after 5 secs.
This commit is contained in:
parent
cdb045b72b
commit
329c770aa0
@ -160,29 +160,51 @@ void MainWindow::onAppendText(QString text, QString suffix) {
|
|||||||
|
|
||||||
QStringList lines = editText.split('\n');
|
QStringList lines = editText.split('\n');
|
||||||
for (int i=0; i<lines.size(); ++i) {
|
for (int i=0; i<lines.size(); ++i) {
|
||||||
qDebug() << lines.at(i);
|
qInfo() << lines.at(i);
|
||||||
} qDebug() << ""; qDebug() << "";
|
} qInfo() << ""; qInfo() << "";
|
||||||
|
|
||||||
ui->updateStatus->setPlainText(editText);
|
ui->updateStatus->setPlainText(editText.trimmed());
|
||||||
ui->updateStatus->setEnabled(true);
|
ui->updateStatus->setEnabled(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::onReplaceLast(QString text, QString suffix) {
|
void MainWindow::onReplaceLast(QString text, QString suffix) {
|
||||||
|
qInfo() << "REPL TEXT" << text << "SUFFIX" << suffix;
|
||||||
|
|
||||||
QString editText = ui->updateStatus->toPlainText();
|
QString editText = ui->updateStatus->toPlainText();
|
||||||
QStringList lines = editText.split('\n');
|
QStringList lines = editText.split('\n');
|
||||||
if (lines.size() > 0) {
|
if (lines.size() > 0) {
|
||||||
lines.removeLast();
|
lines.removeLast();
|
||||||
lines += text.leftJustified(m_width-10) + suffix;
|
if (!suffix.isNull() && suffix.size() > 0 && suffix != "\n") {
|
||||||
|
lines += text.leftJustified(m_width-10) + suffix;
|
||||||
|
} else {
|
||||||
|
lines += text.leftJustified(m_width-10);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int i=0; i<lines.size(); ++i) {
|
for (int i=0; i<lines.size(); ++i) {
|
||||||
qDebug() << lines.at(i);
|
qInfo() << lines.at(i);
|
||||||
} qDebug() << ""; qDebug() << "";
|
} qInfo() << ""; qInfo() << "";
|
||||||
|
|
||||||
ui->updateStatus->setText(lines.join('\n'));
|
ui->updateStatus->setText(lines.join('\n').trimmed());
|
||||||
ui->updateStatus->setEnabled(true);
|
ui->updateStatus->setEnabled(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::onShowErrorMessage(QString title, QString text) {
|
void MainWindow::onShowErrorMessage(QString title, QString text) {
|
||||||
QMessageBox::critical(this, title, text, QMessageBox::Ok);
|
text = text.leftJustified(50, ' ');
|
||||||
|
QMessageBox msgBox(QMessageBox::NoIcon, title,
|
||||||
|
text, QMessageBox::Ok,
|
||||||
|
nullptr, Qt::FramelessWindowHint);
|
||||||
|
msgBox.setDefaultButton(QMessageBox::Ok);
|
||||||
|
msgBox.setStyleSheet("QDialog {background-color: red;}"
|
||||||
|
"QPushButton {background-color: blue;}");
|
||||||
|
QTimer *t = new QTimer(this);
|
||||||
|
connect(t, SIGNAL(timeout()), msgBox.defaultButton(), SLOT(click()));
|
||||||
|
t->setSingleShot(true);
|
||||||
|
t->start(5 * 1000);
|
||||||
|
|
||||||
|
if(msgBox.exec() == QMessageBox::Ok) {
|
||||||
|
// do something
|
||||||
|
} else {
|
||||||
|
// do something else
|
||||||
|
}
|
||||||
|
disconnect(t, SIGNAL(timeout()), msgBox.defaultButton(), SLOT(click()));
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user