Incorporate feedback (namespace), Adds shortcut for zen mode, 1:1 ratio #3
@@ -10,24 +10,25 @@
|
|||||||
#include <QWidgetAction>
|
#include <QWidgetAction>
|
||||||
#include <QFormLayout>
|
#include <QFormLayout>
|
||||||
#include <QSpinBox>
|
#include <QSpinBox>
|
||||||
|
#include <QShortcut>
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
|
|
||||||
// system includes
|
// system includes
|
||||||
#include <stdexcept>
|
#include <stdexcept>
|
||||||
|
|
||||||
namespace {
|
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<typename T>
|
template<typename T>
|
||||||
void setActionsEnabled(const T &actions, bool enabled)
|
void setActionsEnabled(const T &actions, bool enabled)
|
||||||
{
|
{
|
||||||
for(auto action : actions)
|
for(auto action : actions)
|
||||||
action->setEnabled(enabled);
|
action->setEnabled(enabled);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
MainWindow::MainWindow(QWidget *parent) :
|
MainWindow::MainWindow(QWidget *parent) :
|
||||||
@@ -142,6 +143,22 @@ MainWindow::MainWindow(QWidget *parent) :
|
|||||||
m_ui->menuDebug->addAction(widgetAction);
|
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
|
// autostart
|
||||||
if (m_inputDevices.isEmpty())
|
if (m_inputDevices.isEmpty())
|
||||||
{
|
{
|
||||||
|
@@ -9,8 +9,10 @@
|
|||||||
// system includes
|
// system includes
|
||||||
#include <cmath>
|
#include <cmath>
|
||||||
|
|
||||||
qint32 framesForDuration(qint64 duration){
|
namespace {
|
||||||
return qint32(44100 * duration / 1000000LL);
|
qint32 framesForDuration(qint64 duration){
|
||||||
|
return qint32(44100 * duration / 1000000LL);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -62,7 +64,7 @@ void OsciWidget::renderSamples(const SamplePair *begin, const SamplePair *end)
|
|||||||
|
|
||||||
auto offset = std::distance(m_buffer.begin(), m_bufferOffset);
|
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();
|
//qDebug() << "deleting: " << m_bufferOffset - m_buffer.begin() << m_buffer.size();
|
||||||
// Delete drawn frames
|
// Delete drawn frames
|
||||||
@@ -123,7 +125,10 @@ void OsciWidget::drawBuffer(SampleBuffer::iterator &bufferPos, const SampleBuffe
|
|||||||
QPainter painter(&m_pixmap);
|
QPainter painter(&m_pixmap);
|
||||||
painter.setRenderHint(QPainter::Antialiasing);
|
painter.setRenderHint(QPainter::Antialiasing);
|
||||||
painter.translate(m_pixmap.width()/2, m_pixmap.height()/2);
|
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;
|
QPen pen;
|
||||||
pen.setCosmetic(true); // let pen be scale invariant
|
pen.setCosmetic(true); // let pen be scale invariant
|
||||||
|
Reference in New Issue
Block a user