diff --git a/changes b/changes index 5f0d7d2276da892160e1ef5920f9dc282848249f..81ee612e5dc4ed624530fb7423c609e86414e8a4 100644 --- a/changes +++ b/changes @@ -1,8 +1,10 @@ 1.??? + - added notifications about too hi/low input volume - improved look of sound views, better fit to high DPI screens ANDROID - reduced paint operations, application works even 2-4 times faster - volume settings and pitch preview can be invoked with volume keys + - stop pitch detection when app is going background, restore when backs BUGS FIXES - other small fixes diff --git a/src/libs/sound/tsound.cpp b/src/libs/sound/tsound.cpp index 49feabc6af1ee52b88535388f29edbd85c3e702a..48b165ab7f6b0a758710a55bf4c77a403cfd8eb9 100755 --- a/src/libs/sound/tsound.cpp +++ b/src/libs/sound/tsound.cpp @@ -275,6 +275,11 @@ bool Tsound::isSnifferPaused() { } +bool Tsound::isSniferStopped() { + return sniffer ? sniffer->isStoped() : true; +} + + void Tsound::restoreAfterAnswer() { m_pitchView->setBgColor(Qt::transparent); m_pitchView->setDisabled(true); diff --git a/src/libs/sound/tsound.h b/src/libs/sound/tsound.h index a86f1595ccbf6990624f558ddc4c67a993145286..cb6927116caf508df076cb7d4cf9333349f42160 100644 --- a/src/libs/sound/tsound.h +++ b/src/libs/sound/tsound.h @@ -84,6 +84,7 @@ public: void pauseSinffing(); void unPauseSniffing(); bool isSnifferPaused(); + bool isSniferStopped(); /** Prepares sound to exam. * Given notes in params are level range notes and are put to sniffer ambitus. */ diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 4e39d50fe9ed1f0f7a91dfd4feace4e8bfd29029..cd8c4013a1ca6b82021d0414e683b75bb8266e6e 100755 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -82,10 +82,13 @@ void noteToKey(Tnote& n, TkeySignature k) { QNetworkAccessManager nam; } - TtouchMessage *m_touchMessage; + static TtouchMessage *m_touchMessage; + static bool m_isAppActive = true; /**< Whether Nootka is active (displayed) or suspended (and/or screen is off) */ + static bool m_wasPitchEnabled = false; /**< Stores state of pitch detection when Nootka becomes inactive screen is locked (off) */ #endif + MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), m_examResults(0), @@ -196,6 +199,24 @@ MainWindow::MainWindow(QWidget *parent) : connect(m_pitchView, &TpitchView::lowPCMvolume, this, &MainWindow::pcmStatusMessage); connect(m_pitchView, &TpitchView::hiPCMvolume, this, &MainWindow::pcmStatusMessage); +#if defined (Q_OS_ANDROID) + connect(qApp, &QGuiApplication::applicationStateChanged, [=](Qt::ApplicationState state){ + if (state == Qt::ApplicationActive) { // Nootka backs to live + if (!m_isAppActive) { // restore pitch detection state + if (m_wasPitchEnabled) + m_sound->go(); + m_isAppActive = true; + } + } else { // Nootka goes to background + if (m_isAppActive) { // when it was active, store pitch detection state + m_wasPitchEnabled = !(m_sound->isSniferStopped() || m_sound->isSnifferPaused()); + m_isAppActive = false; + m_sound->wait(); + } + } + }); +#endif + qApp->installEventFilter(this); }