Skip to content
Snippets Groups Projects
Commit 366949ea authored by SeeLook's avatar SeeLook
Browse files

Tuning translations are initialized in proper place (after translations...

Tuning translations are initialized in proper place (after translations loading), disabling screen lock on Android
parent 2096fe62
No related branches found
No related tags found
No related merge requests found
/***************************************************************************
* Copyright (C) 2015 by Tomasz Bojczuk *
* tomaszbojczuk@gmail.com *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 3 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
***************************************************************************/
#include "tandroid.h"
#include <QtAndroidExtras/qandroidfunctions.h>
void Tandroid::setScreenLockDisabled() {
QAndroidJniObject activity = QtAndroid::androidActivity();
if (activity.isValid()) {
QAndroidJniObject window = activity.callObjectMethod("getWindow", "()Landroid/view/Window;");
if (window.isValid()) {
const int FLAG_KEEP_SCREEN_ON = 128;
const int FLAG_FULLSCREEN = 1024;
// const int FLAG_FORCE_NOT_FULLSCREEN = 2048;
window.callObjectMethod("addFlags", "(I)V", FLAG_KEEP_SCREEN_ON | FLAG_FULLSCREEN);
}
}
}
QString Tandroid::accountName() {
return "fake";
// return QAndroidJniObject::callStaticObjectMethod<jstring>
// ("net/sf/nootka/account",
// "getName").toString();
}
/***************************************************************************
* Copyright (C) 2015 by Tomasz Bojczuk *
* tomaszbojczuk@gmail.com *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 3 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
***************************************************************************/
#ifndef TANDROID_H
#define TANDROID_H
#include <QtCore/qstring.h>
/**
* Android functions requiring invoking native methods through JNI
*/
namespace Tandroid {
/** Sets phone/tablet screen saving disabled. */
void setScreenLockDisabled();
QString accountName();
}
#endif // TANDROID_H
......@@ -227,8 +227,14 @@ void Tglobals::loadSettings(QSettings* cfg) {
E->repeatIncorrect = cfg->value("repeatIncorrect", true).toBool();
E->expertsAnswerEnable = cfg->value("expertsAnswerEnable", false).toBool();
E->studentName = cfg->value("studentName", "").toString();
#if defined (Q_OS_ANDROID)
E->examsDir = cfg->value("examsDir", qgetenv("EXTERNAL_STORAGE")).toString();
E->levelsDir = cfg->value("levelsDir", qgetenv("EXTERNAL_STORAGE")).toString();
qDebug() << "Android user name:" << qgetenv("USER") << qgetenv("EXTERNAL_STORAGE");
#else
E->examsDir = cfg->value("examsDir", QDir::homePath()).toString();
E->levelsDir = cfg->value("levelsDir", QDir::homePath()).toString();
#endif
E->closeWithoutConfirm = cfg->value("closeWithoutConfirm", false).toBool();
E->showCorrected = cfg->value("showCorrected", true).toBool();
E->mistakePreview = cfg->value("mistakePreview", 3000).toInt();
......@@ -266,22 +272,19 @@ void Tglobals::loadSettings(QSettings* cfg) {
A->skipStillerVal = cfg->value("skipStillerThan", 80.0).toReal();
cfg->endGroup();
cfg->beginGroup("layout");
L->soundViewEnabled = cfg->value("soundViewEnabled", true).toBool();
L->guitarEnabled = cfg->value("guitarEnabled", true).toBool();
#if defined (Q_OS_ANDROID)
// override some options not supported under mobile systems
enableTouch = true;
L->toolBarAutoHide = true;
L->iconTextOnToolBar = Qt::ToolButtonTextBesideIcon;
L->hintsBarEnabled = false;
L->soundViewEnabled = false;
L->guitarEnabled = true;
S->keySignatureEnabled = true;
S->doubleAccidentalsEnabled = true;
#else
cfg->beginGroup("layout");
L->toolBarAutoHide = cfg->value("toolBarAutoHide", false).toBool();
L->iconTextOnToolBar = Qt::ToolButtonStyle(cfg->value("iconTextOnToolBar", 3).toInt());
L->hintsBarEnabled = cfg->value("hintsBarEnabled", true).toBool();
L->soundViewEnabled = cfg->value("soundViewEnabled", true).toBool();
L->guitarEnabled = cfg->value("guitarEnabled", true).toBool();
cfg->endGroup();
#endif
......
......@@ -22,13 +22,16 @@
#include "widgets/tpushbutton.h"
#include "tcolor.h"
#include "tscoreparams.h"
#include <QApplication>
#include <QMessageBox>
#include <QTranslator>
#include <QLibraryInfo>
#include <QFontDatabase>
#include <QDebug>
#include <QDir>
#include <QtWidgets/qapplication.h>
#include <QtWidgets/qmessagebox.h>
#include <QtCore/qtranslator.h>
#include <QtCore/qlibraryinfo.h>
#include <QtGui/qfontdatabase.h>
#include <QtCore/qdebug.h>
#include <QtCore/qdir.h>
#if defined (Q_OS_ANDROID)
#include "Android/tandroid.h"
#endif
Tglobals* Tcore::m_gl = 0;
......@@ -39,7 +42,6 @@ bool initCoreLibrary() {
qDebug() << "Tglobals was not created. Construct it first!";
return false;
}
Ttune::prepareDefinedTunes();
Tcolor::setShadow(qApp->palette());
#if defined(Q_OS_MAC)
TpushButton::setCheckColor(Tcore::gl()->S->pointerColor, qApp->palette().base().color());
......@@ -54,6 +56,7 @@ bool initCoreLibrary() {
#endif
#if defined (Q_OS_ANDROID)
qApp->addLibraryPath(qApp->applicationDirPath());
Tandroid::setScreenLockDisabled(); // TODO: interact with some settings option
#endif
return true;
}
......@@ -91,6 +94,7 @@ void prepareTranslations(QApplication* a, QTranslator& qt, QTranslator& noo) {
TkeySignature::setNameStyle(Tcore::gl()->S->nameStyleInKeySign, Tcore::gl()->S->majKeyNameSufix,
Tcore::gl()->S->minKeyNameSufix);
Ttune::prepareDefinedTunes();
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment