Skip to content

Commit 525a538

Browse files
author
Mich
committed
Fixed color switching on Linux
1 parent a47003b commit 525a538

File tree

2 files changed

+30
-41
lines changed

2 files changed

+30
-41
lines changed

src/mainwindow.cpp

Lines changed: 28 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -145,10 +145,6 @@ void MainWindow::setupGUI()
145145
ui->comboBoxExternalTimeFormat->addItem("[ms]");
146146
ui->comboBoxExternalTimeFormat->setCurrentIndex(0);
147147

148-
ui->comboBoxLoggingMode->addItem("Log Text");
149-
ui->comboBoxLoggingMode->addItem("Log Parsed Data");
150-
ui->comboBoxLoggingMode->setCurrentIndex(0);
151-
152148
ui->comboBoxRAMSaveMode->addItem("Save Data Only");
153149
ui->comboBoxRAMSaveMode->addItem("Save Data & Text");
154150
ui->comboBoxRAMSaveMode->setCurrentIndex(0);
@@ -1497,30 +1493,6 @@ void MainWindow::on_pushButtonClearHistory_clicked()
14971493
ui->comboBoxSend->clear();
14981494
}
14991495

1500-
void MainWindow::on_comboBoxGraphDisplayMode_currentIndexChanged(const QString &arg1)
1501-
{
1502-
clearGraphs(true);
1503-
loadFromRAM(0);
1504-
1505-
QPalette *paletteRed = new QPalette();
1506-
QPalette *paletteBlack = new QPalette();
1507-
paletteRed->setColor(QPalette::Text, Qt::GlobalColor::red);
1508-
paletteBlack->setColor(QPalette::Text, Qt::GlobalColor::black);
1509-
1510-
if (arg1.contains("Auto", Qt::CaseSensitivity::CaseInsensitive))
1511-
{
1512-
ui->lineEditCustomParsingRules->setEnabled(false);
1513-
ui->labelParsingRules->setEnabled(false);
1514-
ui->comboBoxGraphDisplayMode->setPalette(*paletteBlack);
1515-
}
1516-
else if (arg1.contains("Custom", Qt::CaseSensitivity::CaseInsensitive))
1517-
{
1518-
ui->lineEditCustomParsingRules->setEnabled(true);
1519-
ui->labelParsingRules->setEnabled(true);
1520-
ui->comboBoxGraphDisplayMode->setPalette(*paletteRed);
1521-
}
1522-
}
1523-
15241496
void MainWindow::on_pushButtonClearGraphs_clicked()
15251497
{
15261498
clearGraphData(true);
@@ -1537,14 +1509,12 @@ void MainWindow::on_lineEditCustomParsingRules_editingFinished()
15371509
void MainWindow::on_spinBoxMaxGraphs_valueChanged(int arg1)
15381510
{
15391511
QPalette *paletteRed = new QPalette();
1540-
QPalette *paletteBlack = new QPalette();
15411512
paletteRed->setColor(QPalette::Text, Qt::GlobalColor::red);
1542-
paletteBlack->setColor(QPalette::Text, Qt::GlobalColor::black);
15431513

15441514
if (arg1 > 10)
15451515
ui->spinBoxMaxGraphs->setPalette(*paletteRed);
15461516
else
1547-
ui->spinBoxMaxGraphs->setPalette(*paletteBlack);
1517+
ui->spinBoxMaxGraphs->setPalette(QPalette());
15481518

15491519
this->clearGraphs(false);
15501520
this->loadFromRAM(false);
@@ -1573,22 +1543,18 @@ void MainWindow::on_checkBoxAutoTrack_toggled(bool checked)
15731543

15741544
void MainWindow::on_spinBoxProcessingDelay_valueChanged(int arg1)
15751545
{
1576-
int newInterval = arg1;
1577-
if (newInterval < 1)
1578-
newInterval = 1; // Never 0 ! Couses CPU run like crazy !
1546+
int newInterval = qMax(1, arg1); // Never 0 ! Couses CPU run like crazy !
15791547

1580-
serialStringProcessingTimer->setInterval(arg1);
1581-
udpStringProcessingTimer->setInterval(arg1);
1548+
serialStringProcessingTimer->setInterval(newInterval);
1549+
udpStringProcessingTimer->setInterval(newInterval);
15821550

15831551
QPalette *paletteRed = new QPalette();
1584-
QPalette *paletteBlack = new QPalette();
15851552
paletteRed->setColor(QPalette::Text, Qt::GlobalColor::red);
1586-
paletteBlack->setColor(QPalette::Text, Qt::GlobalColor::black);
15871553

1588-
if (arg1 > ui->spinBoxProcessingDelay->minimum())
1554+
if (newInterval > ui->spinBoxProcessingDelay->minimum())
15891555
ui->spinBoxProcessingDelay->setPalette(*paletteRed);
15901556
else
1591-
ui->spinBoxProcessingDelay->setPalette(*paletteBlack);
1557+
ui->spinBoxProcessingDelay->setPalette(QPalette());
15921558
}
15931559

15941560
void MainWindow::on_comboBoxTracerStyle_currentIndexChanged(const QString &arg1)
@@ -2315,3 +2281,25 @@ void MainWindow::on_comboBoxLogFormat_currentIndexChanged(int index)
23152281
else if (ui->comboBoxLogFormat->currentText().contains("csv"))
23162282
ui->lineEditSaveFileName->setText(ui->lineEditSaveFileName->text().replace("txt", "csv"));
23172283
}
2284+
2285+
void MainWindow::on_comboBoxGraphDisplayMode_currentIndexChanged(int index)
2286+
{
2287+
clearGraphs(true);
2288+
loadFromRAM(0);
2289+
2290+
QPalette *paletteRed = new QPalette();
2291+
paletteRed->setColor(QPalette::Text, Qt::GlobalColor::red);
2292+
2293+
if (index == 0)
2294+
{
2295+
ui->lineEditCustomParsingRules->setEnabled(false);
2296+
ui->labelParsingRules->setEnabled(false);
2297+
ui->comboBoxGraphDisplayMode->setPalette(QPalette()); // Empty = default (OS specific !)
2298+
}
2299+
else
2300+
{
2301+
ui->lineEditCustomParsingRules->setEnabled(true);
2302+
ui->labelParsingRules->setEnabled(true);
2303+
ui->comboBoxGraphDisplayMode->setPalette(*paletteRed);
2304+
}
2305+
}

src/mainwindow.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,6 @@ private slots:
8787
void on_clearGraphSelection();
8888
void on_comboBoxClockSource_currentIndexChanged(int index);
8989
void on_comboBoxFormat_currentIndexChanged(int index);
90-
void on_comboBoxGraphDisplayMode_currentIndexChanged(const QString &arg1);
9190
void on_comboBoxLoggingMode_currentIndexChanged(int index);
9291
void on_comboBoxSendReturnPressedSlot();
9392
void on_comboBoxSerialReadMode_currentIndexChanged(int index);
@@ -145,6 +144,8 @@ private slots:
145144
void on_actionShow_parser_data_triggered();
146145
void on_radioButtonScrollToButtom_clicked();
147146
void on_comboBoxLogFormat_currentIndexChanged(int index);
147+
void on_comboBoxGraphDisplayMode_currentIndexChanged(int index);
148+
148149
private:
149150
// QCompleter *completer;
150151
FileReader fileReader;

0 commit comments

Comments
 (0)