Browse Source

Add checkbox to enable/disable auto refresh

duke
Duke 2 months ago
parent
commit
89ee26aed4
  1. 32
      src/mainwindow.cpp
  2. 5
      src/mainwindow.ui

32
src/mainwindow.cpp

@ -2045,18 +2045,28 @@ void MainWindow::setupDebugLogTab() {
ui->debugLog->setPlainText( readDebugLines() ); ui->debugLog->setPlainText( readDebugLines() );
// Set up timer QObject::connect(ui->debugAuto, &QCheckBox::stateChanged, [=](auto checked) {
QTimer* debugTimer = new QTimer(); if(checked) {
QObject::connect(debugTimer, &QTimer::timeout, [=]() { QTimer* debugTimer = new QTimer();
uint32_t debugLines = ui->debugLines->text().trimmed().toInt(); DEBUG("debugAuto checkbox checked");
if (debugLines == 0) { debugLines = 50; } // Set up timer
ui->debugLog->setPlainText( readDebugLines(debugLines) ); QObject::connect(debugTimer, &QTimer::timeout, [=]() {
DEBUG("Refreshed debug data with debugLines=" << debugLines); uint32_t debugLines = ui->debugLines->text().trimmed().toInt();
if (debugLines == 0) { debugLines = 50; }
ui->debugLog->setPlainText( readDebugLines(debugLines) );
DEBUG("Refreshed debug data with debugLines=" << debugLines);
});
//TODO: allow customizing refresh speed
uint32_t debugRefreshSpeed = 30*1000;
debugTimer->start(debugRefreshSpeed);
DEBUG("started debug refresh at speed=" << debugRefreshSpeed); //Settings::debugRefreshSpeed;
} else {
DEBUG("debugAuto checkbox unchecked");
//TODO: store debugTimer in class so we can access it here and stop it
// debugTimer->stop();
}
}); });
//TODO: allow customizing refresh speed
uint32_t debugRefreshSpeed = 30*1000;
debugTimer->start(debugRefreshSpeed);
DEBUG("started debug refresh at speed=" << debugRefreshSpeed); //Settings::debugRefreshSpeed;
} }
void MainWindow::setupPeersTab() { void MainWindow::setupPeersTab() {

5
src/mainwindow.ui

@ -1183,13 +1183,16 @@
</item> </item>
<item row="0" column="3"> <item row="0" column="3">
<widget class="QCheckbox" name="debugAuto"> <widget class="QCheckBox" name="debugAuto">
<property name="text"> <property name="text">
<string>Auto refresh</string> <string>Auto refresh</string>
</property> </property>
<property name="enabled"> <property name="enabled">
<bool>false</bool> <bool>false</bool>
</property> </property>
<property name="checkable">
<bool>true</bool>
</property>
</widget> </widget>
</item> </item>

Loading…
Cancel
Save