diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 4c98e16aa76cfea7b3bcb3571de2134becb28ce7..9e3d0c20927ed974520539a2137d126c3aa019df 100755 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -112,7 +112,7 @@ set(NOOTKA_SRC main/tnootkacertificate.cpp main/tpiechartitem.cpp main/tnotetoplay.cpp - main/tgotititem.cpp + main/tgotit.cpp dialogs/tdialogloaderobject.cpp dialogs/tlevelcreatoritem.cpp diff --git a/src/main.cpp b/src/main.cpp index 18ffc8d6db0df8716b1299606508116cc8c0f143..14817f8025e71d588e597a5c04ae7ef7ba4aae5b 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -27,7 +27,7 @@ #include "main/tmainscoreobject.h" #include "dialogs/tdialogloaderobject.h" #include "help/tmainhelp.h" -#include "main/tgotititem.h" +#include "main/tgotit.h" #if defined (Q_OS_ANDROID) #include <Android/tandroid.h> @@ -208,7 +208,7 @@ int main(int argc, char *argv[]) // but if there will be another window - delete line above } nooObj->setQmlEngine(e); - qmlRegisterType<TgotItItem>("Nootka", 1, 0, "TgotItItem"); + qmlRegisterType<TgotIt>("Nootka.Main", 1, 0, "TgotIt"); qmlRegisterType<TnameItem>("Nootka.Main", 1, 0, "TnameItem"); qmlRegisterType<TmainScoreObject>("Nootka.Main", 1, 0, "TmainScoreObject"); qmlRegisterType<TdialogLoaderObject>("Nootka.Dialogs", 1, 0, "TdialogObject"); diff --git a/src/main/tgotititem.cpp b/src/main/tgotit.cpp similarity index 69% rename from src/main/tgotititem.cpp rename to src/main/tgotit.cpp index 55fa2343ca65e2bc886f715dfc0bb2c339f0b264..c3dce382e0532ac4f96663af1a6ede69b888eedc 100644 --- a/src/main/tgotititem.cpp +++ b/src/main/tgotit.cpp @@ -16,17 +16,39 @@ * along with this program. If not, see <http://www.gnu.org/licenses/>. * ***************************************************************************/ -#include "tgotititem.h" +#include "tgotit.h" +#include <tsound.h> -// #include <QtGui/qpainter.h> -// #include <QtGui/qpalette.h> -// #include <QtGui/qguiapplication.h> +// #include <QtCore/qdebug.h> -TgotItItem::TgotItItem(QQuickItem *parent) : - QQuickItem(parent) +TgotIt::TgotIt(QObject *parent) : + QObject(parent) { - } +TgotIt::~TgotIt() { + if (m_gotItType == GotSoundInfo) { + SOUND->stopListen(); + SOUND->setTunerMode(false); + SOUND->startListen(); + } +} + + +void TgotIt::setGotItType(TgotIt::EgotItType gt) { + if (gt != m_gotItType) { + switch (gt) { + case GotSoundInfo: + SOUND->stopListen(); + SOUND->setTunerMode(true); + SOUND->startListen(); + break; + default: + break; + } + m_gotItType = gt; + emit gotItTypeChanged(); + } +} diff --git a/src/main/tgotititem.h b/src/main/tgotit.h similarity index 70% rename from src/main/tgotititem.h rename to src/main/tgotit.h index ed3d8dba33f1f07ef980aaf8ff1f315cef5d7484..964a8a14eb5aaaedbbc21b9626611f2c4a431292 100644 --- a/src/main/tgotititem.h +++ b/src/main/tgotit.h @@ -17,26 +17,40 @@ ***************************************************************************/ -#ifndef TGOTITITEM_H -#define TGOTITITEM_H +#ifndef TGOTIT_H +#define TGOTIT_H -#include <QtQuick/qquickitem.h> +#include <QtCore/qobject.h> -class TgotItItem : public QQuickItem +class TgotIt : public QObject { Q_OBJECT + Q_PROPERTY(EgotItType gotItType READ gotItType WRITE setGotItType NOTIFY gotItTypeChanged) + public: - explicit TgotItItem(QQuickItem* parent = nullptr); + explicit TgotIt(QObject* parent = nullptr); + ~TgotIt() override; + + enum EgotItType { + GotAnything = 0, + GotSoundInfo, + GotExamOrExer + }; + Q_ENUM(EgotItType) + EgotItType gotItType() const { return m_gotItType; } + void setGotItType(EgotItType gt); +signals: + void gotItTypeChanged(); private: + EgotItType m_gotItType = GotAnything; }; - -#endif // TGOTITITEM_H +#endif // TGOTIT_H diff --git a/src/qml/gotit/GotIt.qml b/src/qml/gotit/GotIt.qml index 464174df884ac1b3690a57099b7d39da36316a37..7d624f7e162fac0363afa6e8b2e41cccaac35859 100644 --- a/src/qml/gotit/GotIt.qml +++ b/src/qml/gotit/GotIt.qml @@ -6,7 +6,7 @@ import QtQuick 2.9 import QtQuick.Controls 2.2 import QtGraphicalEffects 1.0 -import Nootka 1.0 +import Nootka.Main 1.0 import "../" @@ -16,6 +16,7 @@ Popup { signal clicked() + property alias gotItType: gotIt.gotItType property alias againChecked: showAgainChB.checked property alias againVisible: showAgainChB.visible @@ -27,57 +28,52 @@ Popup { background: Rectangle { color: Noo.alpha(activPal.base, 235) } - TgotItItem { - id: gotIt - clip: true + TgotIt { id: gotIt } - z: 10000 - width: parent.width; height: parent.height + RectangularGlow { + z: 10 + anchors.fill: bg + glowRadius: Noo.factor() / 2 + color: activPal.text + cornerRadius: bg.radius + glowRadius + } - RectangularGlow { - z: 10 - anchors.fill: bg - glowRadius: Noo.factor() / 2 - color: activPal.text - cornerRadius: bg.radius + glowRadius + Rectangle { + id: bg + z: 10 + width: gotColl.width + 2 * radius + height: gotColl.height + 1.5 * radius + radius: (gotColl.height + 4 * Noo.factor()) / 4 + x: parent.width - width + radius; y: parent.height - height + radius + Noo.factor() + color: ma.containsMouse ? activPal.highlight : Qt.tint(activPal.base, Noo.alpha(activPal.highlight, 150)) + transformOrigin: Item.TopRight + MouseArea { + id: ma + anchors.fill: parent + hoverEnabled: !Noo.isAndroid() + onClicked: pop.clicked() } + } - Rectangle { - id: bg - z: 10 - width: gotColl.width + 2 * radius - height: gotColl.height + 1.5 * radius - radius: (gotColl.height + 4 * Noo.factor()) / 4 - x: parent.width - width + radius; y: parent.height - height + radius + Noo.factor() - color: ma.containsMouse ? activPal.highlight : Qt.tint(activPal.base, Noo.alpha(activPal.highlight, 150)) - transformOrigin: Item.TopRight - MouseArea { - id: ma - anchors.fill: parent - hoverEnabled: !Noo.isAndroid() - onClicked: pop.clicked() - } + Column { + id: gotColl + z: 10 + x: parent.width - width; y: parent.height - height + Item { width: Noo.factor(); height: Noo.factor() / (showAgainChB.visible ? 2 : 1) } + Text { + id: gotText + anchors { right: parent.right; rightMargin: Noo.factor() } + color: activPal.text + font { pixelSize: Noo.factor() * 3; bold: true } + style: ma.containsMouse ? Text.Sunken : Text.Normal + styleColor: activPal.base + text: qsTr("GOT IT!") } - Column { - id: gotColl - z: 10 - x: parent.width - width; y: parent.height - height - Item { width: Noo.factor(); height: Noo.factor() / (showAgainChB.visible ? 2 : 1) } - Text { - id: gotText - anchors { right: parent.right; rightMargin: Noo.factor() } - color: activPal.text - font { pixelSize: Noo.factor() * 3; bold: true } - style: ma.containsMouse ? Text.Sunken : Text.Normal - styleColor: activPal.base - text: qsTr("GOT IT!") - } - TcheckBox { - id: showAgainChB - text: qsTranslate("ThelpDialogBase", "always show this help window") - } - Item { width: Noo.factor(); height: Noo.factor() / 2 } + TcheckBox { + id: showAgainChB + text: qsTranslate("ThelpDialogBase", "always show this help window") } + Item { width: Noo.factor(); height: Noo.factor() / 2 } } } diff --git a/src/src.pro b/src/src.pro index cd51c9d68a6e1bfcc0a78078d776ba15e0efd2d1..223dad6d746509f11ed14c2b5aae8154cb6dcfea 100644 --- a/src/src.pro +++ b/src/src.pro @@ -33,7 +33,7 @@ SOURCES += main.cpp \ main/tnootkacertificate.cpp \ main/tpiechartitem.cpp \ main/tnotetoplay.cpp \ - main/tgotititem.cpp \ + main/tgotit.cpp \ \ dialogs/tdialogloaderobject.cpp \ dialogs/tlevelcreatoritem.cpp \ @@ -75,7 +75,7 @@ HEADERS += mobile/tmobilemenu.h \ main/tnootkacertificate.h \ main/tpiechartitem.h \ main/tnotetoplay.h \ - main/tgotititem.h \ + main/tgotit.h \ \ dialogs/tdialogloaderobject.h \ dialogs/tlevelcreatoritem.h \