From aabaa5208b9e4d627af4ce7a553a930577d4f5fe Mon Sep 17 00:00:00 2001
From: SeeLook <945374+SeeLook@users.noreply.github.com>
Date: Tue, 14 Jul 2015 23:15:30 +0200
Subject: [PATCH] Exec of Touch menu returns action now, using Fusion style
 under Android and proper plugins path

---
 src/libs/core/touch/ttouchmenu.cpp |  6 +++---
 src/libs/core/touch/ttouchmenu.h   |  2 +-
 src/main.cpp                       |  4 ++++
 src/mainwindow.cpp                 | 12 ++++++------
 4 files changed, 14 insertions(+), 10 deletions(-)

diff --git a/src/libs/core/touch/ttouchmenu.cpp b/src/libs/core/touch/ttouchmenu.cpp
index dd0daba60..3b3e6e66d 100644
--- a/src/libs/core/touch/ttouchmenu.cpp
+++ b/src/libs/core/touch/ttouchmenu.cpp
@@ -73,9 +73,9 @@ void TtouchMenu::addAction(QAction* a) {
 }
 
 
-void TtouchMenu::exec(const QPoint& endPos, const QPoint& startPos) {
+QAction* TtouchMenu::exec(const QPoint& endPos, const QPoint& startPos) {
   if (startPos.x() == -1 && startPos.y() == -1)
-    QMenu::exec(endPos);
+    return QMenu::exec(endPos);
   else {
     m_endPos = endPos;
     m_startPos = startPos;
@@ -83,7 +83,7 @@ void TtouchMenu::exec(const QPoint& endPos, const QPoint& startPos) {
     m_step = 0;
     m_offset = QPoint((m_endPos.x() - m_startPos.x()) / m_count, (m_endPos.y() - m_startPos.y()) / m_count);
     m_animTimer->start(40);
-    QMenu::exec(startPos);
+    return QMenu::exec(startPos);
   }
 }
 
diff --git a/src/libs/core/touch/ttouchmenu.h b/src/libs/core/touch/ttouchmenu.h
index f62f8bba6..2c5166e1c 100644
--- a/src/libs/core/touch/ttouchmenu.h
+++ b/src/libs/core/touch/ttouchmenu.h
@@ -49,7 +49,7 @@ public:
       /** Overrides standard @p exec method of @p QMenu.
        * Menu is positioned at @p endPos point but when @p startPos is set,
        * an animation from it is performed */
-  void exec(const QPoint& endPos, const QPoint& startPos = QPoint(-1, -1));
+  QAction* exec(const QPoint& endPos, const QPoint& startPos = QPoint(-1, -1));
 
 protected:
   virtual void showEvent(QShowEvent* e); // correct initial position
diff --git a/src/main.cpp b/src/main.cpp
index 3e45092d1..dbbf71dcf 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -22,6 +22,7 @@
 #include <QFile>
 #include <QSettings>
 #include <QApplication>
+#include <QStyleFactory>
 #include <QDebug>
 #include <QTranslator>
 
@@ -61,6 +62,9 @@ int main(int argc, char *argv[])
 		}
 		resetConfig = false;
 		a = new QApplication(argc, argv);
+#if defined (Q_OS_ANDROID)
+    a->setStyle(QStyleFactory::create("Fusion"));
+#endif
 		gl = new Tglobals();
 		gl->path = Tglobals::getInstPath(qApp->applicationDirPath());
 		confFile = gl->config->fileName();
diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp
index 144bb7e9c..cf102f3aa 100755
--- a/src/mainwindow.cpp
+++ b/src/mainwindow.cpp
@@ -38,15 +38,14 @@
   #include "exam/tprogresswidget.h"
   #include "exam/texamview.h"
   #include "exam/texamexecutor.h"
-  #include <level/tlevelselector.h>
 
   #include <widgets/tpitchview.h>
   #include <tsound.h>
   #include <taboutnootka.h>
   #include <tsupportnootka.h>
-  #include <plugins/tpluginsloader.h>
 #endif
-
+#include <level/tlevelselector.h>
+#include <plugins/tpluginsloader.h>
 
 extern Tglobals *gl;
 extern bool resetConfig;
@@ -172,7 +171,7 @@ MainWindow::MainWindow(QWidget *parent) :
   connect(bar->aboutSimpleAct, &QAction::triggered, this, &MainWindow::aboutSlot);
 #else
   connect(bar->settingsAct, SIGNAL(triggered()), this, SLOT(createSettingsDialog()));
-  connect(bar->levelCreatorAct, SIGNAL(triggered()), this, SLOT(openLevelCreator()));
+//   connect(bar->levelCreatorAct, SIGNAL(triggered()), this, SLOT(openLevelCreator()));
   connect(bar->startExamAct, SIGNAL(triggered()), this, SLOT(startExamSlot()));
   connect(bar->analyseAct, SIGNAL(triggered()), this, SLOT(analyseSlot()));
   connect(bar->aboutAct, &QAction::triggered, this, &MainWindow::aboutSlot);
@@ -183,6 +182,7 @@ MainWindow::MainWindow(QWidget *parent) :
 #endif
   setSingleNoteMode(gl->S->isSingleNoteMode);
 
+  connect(bar->levelCreatorAct, SIGNAL(triggered()), this, SLOT(openLevelCreator()));
   connect(score, SIGNAL(noteChanged(int,Tnote)), this, SLOT(noteWasClicked(int,Tnote)));
   connect(score, &TmainScore::clefChanged, this, &MainWindow::adjustAmbitus);
   connect(guitar, &TfingerBoard::guitarClicked, this, &MainWindow::guitarWasClicked);
@@ -345,7 +345,6 @@ void MainWindow::createSettingsDialog() {
 
 
 void MainWindow::openLevelCreator(QString levelFile) {
-#if !defined (Q_OS_ANDROID)
   if (score->isScorePlayed())
     m_melButt->playMelodySlot(); // stop playing
   sound->wait(); // stops pitch detection
@@ -368,15 +367,16 @@ void MainWindow::openLevelCreator(QString levelFile) {
   bool ok;
   int levelNr = levelText.toInt(&ok);
   if (ok) {
+#if !defined (Q_OS_ANDROID)
     TlevelSelector ls;
     ls.selectLevel(levelNr);
     m_level = ls.getSelectedLevel();
     prepareToExam();
     executor = new TexamExecutor(this, startExercise ? "exercise" : "", &m_level); // start exam
+#endif
   }
   else
     sound->go(); // restore pitch detection
-#endif
 }
 
 
-- 
GitLab