diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -59,6 +59,9 @@ const QMap panelSettingMap {6, "Log"} }); +const char* BPS_TOOLTIP = "bits per second"; +const char* BPS_TOOLTIP_ERR = "Maximum baud rate may be reached!"; + MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow), @@ -233,7 +236,7 @@ MainWindow::MainWindow(QWidget *parent) // init bps (bits per second) counter bpsLabel.setText("0bps"); - bpsLabel.setToolTip(tr("bits per second")); + bpsLabel.setToolTip(tr(BPS_TOOLTIP)); ui->statusBar->addPermanentWidget(&bpsLabel); connect(&bpsTimer, &QTimer::timeout, this, &MainWindow::onBpsTimeout); @@ -372,6 +375,7 @@ void MainWindow::onPortToggled(bool open bpsTimer.stop(); // if not cleared last displayed value is stuck bpsLabel.setText("0bps"); + bpsLabel.setToolTip(tr(BPS_TOOLTIP)); spsLabel.setText("0sps"); } } @@ -404,7 +408,20 @@ void MainWindow::onSpsChanged(float sps) void MainWindow::onBpsTimeout() { unsigned bits = dataFormatPanel.getBytesRead() * 8; - bpsLabel.setText(QString("%1bps").arg(bits)); + unsigned maxBps = portControl.maxBitRate(); + QString str; + if (bits >= maxBps) + { + // TODO: an icon for bps warning + str = QString(tr("!%1/%2bps")).arg(bits).arg(maxBps); + bpsLabel.setToolTip(tr(BPS_TOOLTIP_ERR)); + } + else + { + str = QString(tr("%1bps")).arg(bits); + bpsLabel.setToolTip(tr(BPS_TOOLTIP)); + } + bpsLabel.setText(str); } bool MainWindow::isDemoRunning()