Incorporate feedback (namespace), Adds shortcut for zen mode, 1:1 ratio #3
@@ -10,24 +10,25 @@
|
||||
#include <QWidgetAction>
|
||||
#include <QFormLayout>
|
||||
#include <QSpinBox>
|
||||
#include <QShortcut>
|
||||
#include <QDebug>
|
||||
|
||||
// system includes
|
||||
#include <stdexcept>
|
||||
|
||||
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>
|
||||
void setActionsEnabled(const T &actions, bool enabled)
|
||||
{
|
||||
for(auto action : actions)
|
||||
action->setEnabled(enabled);
|
||||
}
|
||||
template<typename T>
|
||||
void setActionsEnabled(const T &actions, bool enabled)
|
||||
{
|
||||
for(auto action : actions)
|
||||
action->setEnabled(enabled);
|
||||
}
|
||||
}
|
||||
|
||||
MainWindow::MainWindow(QWidget *parent) :
|
||||
@@ -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())
|
||||
{
|
||||
|
@@ -9,8 +9,10 @@
|
||||
// system includes
|
||||
#include <cmath>
|
||||
|
||||
qint32 framesForDuration(qint64 duration){
|
||||
return qint32(44100 * duration / 1000000LL);
|
||||
namespace {
|
||||
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);
|
||||
|
||||
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
|
||||
@@ -123,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
|
||||
|
Reference in New Issue
Block a user