From 5dc2edf795ac48d483545097ccb529f05c81ae33 Mon Sep 17 00:00:00 2001 From: Gitea Date: Mon, 23 Sep 2019 21:51:33 +0200 Subject: [PATCH 1/4] Cleanup global namespace --- mainwindow.cpp | 18 +++++++++--------- osciwidget.cpp | 6 ++++-- 2 files changed, 13 insertions(+), 11 deletions(-) diff --git a/mainwindow.cpp b/mainwindow.cpp index d8df364..4bb901e 100644 --- a/mainwindow.cpp +++ b/mainwindow.cpp @@ -16,18 +16,18 @@ #include namespace { -constexpr int samplerates[] = { 44100, 48000, 96000, 192000 }; + constexpr int samplerates[] = { 44100, 48000, 96000, 192000 }; -constexpr int refreshrates[] = { 1, 15, 30, 50, 60 }; + constexpr int refreshrates[] = { 1, 15, 30, 50, 60 }; -constexpr int zoomlevels[] = { 50, 75, 100, 200, 400, 800 }; + constexpr int zoomlevels[] = { 50, 75, 100, 200, 400, 800 }; -template -void setActionsEnabled(const T &actions, bool enabled) -{ - for(auto action : actions) - action->setEnabled(enabled); -} + template + void setActionsEnabled(const T &actions, bool enabled) + { + for(auto action : actions) + action->setEnabled(enabled); + } } MainWindow::MainWindow(QWidget *parent) : diff --git a/osciwidget.cpp b/osciwidget.cpp index e6f3f21..9aa29f6 100644 --- a/osciwidget.cpp +++ b/osciwidget.cpp @@ -9,8 +9,10 @@ // system includes #include -qint32 framesForDuration(qint64 duration){ - return qint32(44100 * duration / 1000000LL); +namespace { + qint32 framesForDuration(qint64 duration){ + return qint32(44100 * duration / 1000000LL); + } } -- 2.50.1 From 185257005931256a95307230026f187f1d3a8419 Mon Sep 17 00:00:00 2001 From: Gitea Date: Mon, 23 Sep 2019 21:52:06 +0200 Subject: [PATCH 2/4] Ensures 1:1 ratio while displaying --- osciwidget.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/osciwidget.cpp b/osciwidget.cpp index 9aa29f6..61b1f56 100644 --- a/osciwidget.cpp +++ b/osciwidget.cpp @@ -125,7 +125,10 @@ void OsciWidget::drawBuffer(SampleBuffer::iterator &bufferPos, const SampleBuffe QPainter painter(&m_pixmap); painter.setRenderHint(QPainter::Antialiasing); painter.translate(m_pixmap.width()/2, m_pixmap.height()/2); - painter.scale(m_factor * m_pixmap.width() / 2.0, m_factor * m_pixmap.height() / 2.0); + + // ensure 1:1 ratio + auto smallerSide = std::min(m_pixmap.width(), m_pixmap.height()); + painter.scale(m_factor * smallerSide/ 2.0, m_factor * smallerSide/ 2.0); QPen pen; pen.setCosmetic(true); // let pen be scale invariant -- 2.50.1 From 765ea8c9be68387144fd4894000df1423a0d331f Mon Sep 17 00:00:00 2001 From: Gitea Date: Mon, 23 Sep 2019 21:53:26 +0200 Subject: [PATCH 3/4] Set buffer reset time to 2 seconds --- osciwidget.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osciwidget.cpp b/osciwidget.cpp index 61b1f56..77ff83c 100644 --- a/osciwidget.cpp +++ b/osciwidget.cpp @@ -64,7 +64,7 @@ void OsciWidget::renderSamples(const SamplePair *begin, const SamplePair *end) auto offset = std::distance(m_buffer.begin(), m_bufferOffset); - if(m_globalTimer.elapsed()-m_lastBufferUpdate > 5000) + if(m_globalTimer.elapsed()-m_lastBufferUpdate > 2000) { //qDebug() << "deleting: " << m_bufferOffset - m_buffer.begin() << m_buffer.size(); // Delete drawn frames -- 2.50.1 From e0c5f6bd4a4d303418ab48f31fb906ea3557e4a3 Mon Sep 17 00:00:00 2001 From: Gitea Date: Mon, 23 Sep 2019 21:56:51 +0200 Subject: [PATCH 4/4] Adds preliminary "Z" shortcut for "zen" mode --- mainwindow.cpp | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/mainwindow.cpp b/mainwindow.cpp index 4bb901e..cb0dc0f 100644 --- a/mainwindow.cpp +++ b/mainwindow.cpp @@ -10,6 +10,7 @@ #include #include #include +#include #include // system includes @@ -142,6 +143,22 @@ MainWindow::MainWindow(QWidget *parent) : m_ui->menuDebug->addAction(widgetAction); } + // TODO cleanup when we have clean a strategy for implementing shortcuts and actions + auto toggleZen = new QShortcut(QKeySequence(tr("Z")), this); + connect(toggleZen, &QShortcut::activated, this, [=](){ + setWindowFlags(windowFlags() ^ Qt::FramelessWindowHint); + setWindowState(windowState() ^ Qt::WindowFullScreen); + show(); + menuBar()->setVisible(!menuBar()->isVisible()); + statusBar()->setVisible(!statusBar()->isVisible()); + QCursor *currentCursor = QGuiApplication::overrideCursor(); + if(!currentCursor || *currentCursor != Qt::BlankCursor){ + QGuiApplication::setOverrideCursor(Qt::BlankCursor); + }else{ + QGuiApplication::restoreOverrideCursor(); + } + }); + // autostart if (m_inputDevices.isEmpty()) { -- 2.50.1