Skip to content

Commit ff32588

Browse files
committedMar 18, 2025
GUI - save and restore log/cue zoom levels
1 parent 36941e3 commit ff32588

File tree

3 files changed

+53
-5
lines changed

3 files changed

+53
-5
lines changed
 

‎app/gui/mainwindow.cpp

+5-1
Original file line numberDiff line numberDiff line change
@@ -714,6 +714,9 @@ void MainWindow::setupWindowStructure()
714714
mainWidget->setObjectName("mainWidget");
715715

716716
setCentralWidget(mainWidget);
717+
718+
incomingPane->setZoomLevel(gui_settings->value("prefs/cue-zoom", 0).toInt());
719+
outputPane->setZoomLevel(gui_settings->value("prefs/log-zoom", 0).toInt());
717720
}
718721

719722
void MainWindow::docLinkClicked(const QUrl& url)
@@ -4344,7 +4347,8 @@ void MainWindow::writeSettings()
43444347
gui_settings->setValue("prefs/show-log", piSettings->show_log);
43454348
gui_settings->setValue("prefs/show-context", piSettings->show_context);
43464349
gui_settings->setValue("prefs/shortcut-mode", piSettings->shortcut_mode);
4347-
4350+
gui_settings->setValue("prefs/log-zoom", outputPane->currentZoomLevel());
4351+
gui_settings->setValue("prefs/cue-zoom", incomingPane->currentZoomLevel());
43484352
for (auto name : piSettings->scope_names)
43494353
{
43504354
gui_settings->setValue("prefs/scope/show-" + name.toLower(), piSettings->isScopeActive(name));

‎app/gui/widgets/sonicpilog.cpp

+42-4
Original file line numberDiff line numberDiff line change
@@ -19,16 +19,54 @@
1919
#include "model/sonicpitheme.h"
2020
#include <QScrollBar>
2121

22-
SonicPiLog::SonicPiLog(QWidget *parent) : QPlainTextEdit(parent)
22+
SonicPiLog::SonicPiLog(QWidget* parent)
23+
: QPlainTextEdit(parent)
2324
{
24-
forceScroll = true;
25+
forceScroll = true;
26+
zoomLevel = 0;
2527
}
2628

27-
void SonicPiLog::forceScrollDown(bool force)
29+
void SonicPiLog::zoomIn()
2830
{
29-
forceScroll = force;
31+
setZoomLevel(zoomLevel + 1);
3032
}
3133

34+
void SonicPiLog::zoomOut()
35+
{
36+
setZoomLevel(zoomLevel - 1);
37+
}
38+
39+
void SonicPiLog::setZoomLevel(int zoom)
40+
{
41+
const int MIN_ZOOM = -10;
42+
const int MAX_ZOOM = 10;
43+
44+
// Clamp the desired zoom to your range
45+
int targetZoom = std::clamp(zoom, MIN_ZOOM, MAX_ZOOM);
46+
47+
int delta = targetZoom - zoomLevel;
48+
49+
if (delta > 0)
50+
{
51+
QPlainTextEdit::zoomIn(delta);
52+
}
53+
else if (delta < 0)
54+
{
55+
56+
QPlainTextEdit::zoomOut(-delta);
57+
}
58+
zoomLevel = targetZoom;
59+
}
60+
61+
int SonicPiLog::currentZoomLevel() const
62+
{
63+
return zoomLevel;
64+
}
65+
66+
void SonicPiLog::forceScrollDown(bool force)
67+
{
68+
forceScroll = force;
69+
}
3270

3371
void SonicPiLog::setTextColor(QColor c)
3472
{

‎app/gui/widgets/sonicpilog.h

+6
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ class SonicPiLog : public QPlainTextEdit
2424
public:
2525
explicit SonicPiLog(QWidget *parent = 0);
2626
bool forceScroll;
27+
int zoomLevel;
2728

2829
struct Message
2930
{
@@ -51,6 +52,11 @@ public slots:
5152
void handleMultiMessage(SonicPiLog::MultiMessage mm);
5253
void forceScrollDown(bool force);
5354
void appendPlainText(QString text);
55+
void zoomIn();
56+
void zoomOut();
57+
void setZoomLevel(int zoom);
58+
int currentZoomLevel() const;
59+
5460

5561
protected:
5662
};

0 commit comments

Comments
 (0)