diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 4f7b4c97b546a1ef81d5a2c3aa8451eef4d6e1ab..086cf75cc1df9cba18b19bc81c41cf870f91cd64 100755 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -57,8 +57,8 @@ if (APPLE) # Mac RPath endif (APPLE) -add_subdirectory( libs/scorek ) -# add_subdirectory( libs/core ) # libNootkaCore +# add_subdirectory( libs/scorek ) +add_subdirectory( libs/core ) # libNootkaCore # add_subdirectory( libs/score ) # libNootkaScore # add_subdirectory( libs/widgets ) # libNootkaWidgets # add_subdirectory( libs/sound ) # libNootkaSound @@ -69,8 +69,7 @@ include_directories( libs/core libs/score libs/widgets libs/sound libs/misc libs # nootka executable set(NOOTKA_SRC - main.cpp - mainwindow.cpp + main.cpp ) @@ -83,27 +82,34 @@ if(MINGW) endif(MINGW) -# add_executable(nootka WIN32 ${NOOTKA_SRC} ${NOOTKA_EXE_ICON}) -# target_link_libraries(nootka -# NootkaMain -# Qt5::Widgets -# ) -# -# -# if(UNIX AND NOT APPLE) # Linux path for Nootka binary -# install(TARGETS nootka DESTINATION bin) -# else(UNIX AND NOT APPLE) -# if(WIN32) # Windows -# install(TARGETS nootka DESTINATION .) -# else(WIN32) # MacOs -# install(TARGETS nootka DESTINATION "${CMAKE_INSTALL_PREFIX}/nootka.app/Contents/MacOs") -# install( CODE " -# execute_process(COMMAND echo copying info.plist ) -# execute_process(COMMAND sh ${CMAKE_SOURCE_DIR}/packaging/mac/grabInfo.sh ${Nootka_VERSION_FULL} ${CMAKE_SOURCE_DIR} ${CMAKE_INSTALL_PREFIX} )" -# ) -# endif(WIN32) -# endif(UNIX AND NOT APPLE) -# +qt5_add_resources(NOOTKA_SRC nootka.qrc) + + +add_executable(nootka WIN32 ${NOOTKA_SRC} ${NOOTKA_EXE_ICON}) +target_link_libraries(nootka + NootkaCore + Qt5::Core + Qt5::Widgets + Qt5::Qml + Qt5::Quick + Qt5::QuickControls2 +) + + +if(UNIX AND NOT APPLE) # Linux path for Nootka binary + install(TARGETS nootka DESTINATION bin) +else(UNIX AND NOT APPLE) + if(WIN32) # Windows + install(TARGETS nootka DESTINATION .) + else(WIN32) # MacOs + install(TARGETS nootka DESTINATION "${CMAKE_INSTALL_PREFIX}/nootka.app/Contents/MacOs") + install( CODE " + execute_process(COMMAND echo copying info.plist ) + execute_process(COMMAND sh ${CMAKE_SOURCE_DIR}/packaging/mac/grabInfo.sh ${Nootka_VERSION_FULL} ${CMAKE_SOURCE_DIR} ${CMAKE_INSTALL_PREFIX} )" + ) + endif(WIN32) +endif(UNIX AND NOT APPLE) + # add_subdirectory( plugins ) diff --git a/src/libs/core/CMakeLists.txt b/src/libs/core/CMakeLists.txt index 099e5c5666e287f98f392cce1b6d83fb2c383fdc..e2b303bc11461ac0f0d81c28d9f0d027b0ecf686 100644 --- a/src/libs/core/CMakeLists.txt +++ b/src/libs/core/CMakeLists.txt @@ -4,6 +4,7 @@ add_definitions(-DNOOTKACORE_LIBRARY) + set(LIB_NOOTKACORE_SRC tinitcorelib.cpp texamparams.h @@ -16,15 +17,15 @@ set(LIB_NOOTKACORE_SRC tpath.cpp tmtr.cpp - animations/tabstractanim.cpp - animations/tblinkingitem.cpp - animations/tcoloredanim.cpp - animations/tcombinedanim.cpp - animations/tfadeanim.cpp - animations/tmorphedanim.cpp - animations/tmovedanim.cpp - animations/tscaledanim.cpp - animations/tcrossfadetextanim.cpp +# animations/tabstractanim.cpp +# animations/tblinkingitem.cpp +# animations/tcoloredanim.cpp +# animations/tcombinedanim.cpp +# animations/tfadeanim.cpp +# animations/tmorphedanim.cpp +# animations/tmovedanim.cpp +# animations/tscaledanim.cpp +# animations/tcrossfadetextanim.cpp music/tnote.cpp music/tnamestylefilter.cpp @@ -36,8 +37,8 @@ set(LIB_NOOTKACORE_SRC music/tmeasure.cpp music/tmelody.cpp - graphics/tdropshadoweffect.cpp - graphics/tgraphicstexttip.cpp +# graphics/tdropshadoweffect.cpp +# graphics/tgraphicstexttip.cpp exam/tqatype.cpp exam/tqaunit.cpp @@ -48,19 +49,24 @@ set(LIB_NOOTKACORE_SRC exam/textrans.h exam/tresulttext.cpp - widgets/tpushbutton.cpp +# widgets/tpushbutton.cpp touch/ttouchproxy.cpp - touch/ttoucharea.cpp +# touch/ttoucharea.cpp touch/ttouchparams.cpp plugins/tplugininterface.h plugins/tpluginsloader.cpp ) + +qt5_add_resources(LIB_NOOTKACORE_SRC core.qrc) + + add_library(NootkaCore SHARED ${LIB_NOOTKACORE_SRC} ) target_link_libraries(NootkaCore Qt5::Widgets) + if(UNIX AND NOT APPLE) # Linux path for Nootka library install(TARGETS NootkaCore DESTINATION lib/nootka) else(UNIX AND NOT APPLE) diff --git a/src/libs/core/tinitcorelib.cpp b/src/libs/core/tinitcorelib.cpp index 4c448a87b432f9c502466a998f17ccb23569bddc..72347bf78c3e7dc035ee548ca4957b6863e56b45 100644 --- a/src/libs/core/tinitcorelib.cpp +++ b/src/libs/core/tinitcorelib.cpp @@ -1,5 +1,5 @@ /*************************************************************************** - * Copyright (C) 2014-2016 by Tomasz Bojczuk * + * Copyright (C) 2014-2017 by Tomasz Bojczuk * * seelook@gmail.com * * * * This program is free software; you can redistribute it and/or modify * @@ -55,12 +55,10 @@ bool initCoreLibrary() { Tcolor::setShadow(qApp->palette()); #if defined(Q_OS_MAC) - TpushButton::setCheckColor(Tcore::gl()->S->pointerColor, qApp->palette().base().color()); QDir dir(qApp->applicationDirPath()); dir.cdUp(); qApp->addLibraryPath(dir.path() + QLatin1String("/Frameworks")); #else - TpushButton::setCheckColor(qApp->palette().highlight().color(), qApp->palette().highlightedText().color() ); qApp->addLibraryPath(qApp->applicationDirPath()); #endif @@ -96,18 +94,9 @@ void prepareTranslations(QApplication* a, QTranslator& qt, QTranslator& noo) { translationsPath = Tpath::lang(); #endif - /** Until Qt 5.2 version translations where inside qt_xx.ts files - * and all shipped with Qt for all supported languages. - * But since Qt 5.3 they are split into several files and Nootka requires just qtbase_xx.qm. - * qtbase_es.qm is missing so far but it was obtained and shipped with Nootka. */ - QString qtlang = QStringLiteral("qtbase_"); -#if (QT_VERSION < QT_VERSION_CHECK(5, 3, 0)) - qtlang = QStringLiteral("qt_"); -#else if (loc.language() == QLocale::Spanish) // So far, there are missing translationsPath = Tpath::lang(); // TODO Check when those qtbase translations will be shipped with Qt -#endif - if (qt.load(loc, qtlang, QString(), translationsPath)) + if (qt.load(loc, QStringLiteral("qtbase_"), QString(), translationsPath)) a->installTranslator(&qt); #if defined (Q_OS_ANDROID) diff --git a/src/main.cpp b/src/main.cpp index 9718be6aa72de2677e8eb1e7cde17ff5fe3b311f..ec592b91965ffea848d81d0c9d8c3615c2704c8c 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1,5 +1,5 @@ /*************************************************************************** - * Copyright (C) 2011-2015 by Tomasz Bojczuk * + * Copyright (C) 2011-2017 by Tomasz Bojczuk * * seelook@gmail.com * * * * This program is free software; you can redistribute it and/or modify * @@ -16,21 +16,24 @@ * along with this program. If not, see <http://www.gnu.org/licenses/>. * ***************************************************************************/ -#include "mainwindow.h" + #if defined (Q_OS_ANDROID) #include "ttouchstyle.h" #include <Android/tandroid.h> - // #include <QtWidgets/qstylefactory.h> #endif #include <tinitcorelib.h> +#include <tpath.h> #include <tmtr.h> -#include <QtCore/qpointer.h> -#include <QtCore/qfile.h> -#include <QtCore/qsettings.h> #include <QtWidgets/qapplication.h> +#include <QtGui/qicon.h> +#include <QtQml/qqmlapplicationengine.h> #include <QtCore/qdebug.h> #include <QtCore/qtranslator.h> #include <QtCore/qdatetime.h> +#include <QtCore/qpointer.h> +#include <QtCore/qfile.h> +#include <QtCore/qsettings.h> + static QString logFile; @@ -68,60 +71,57 @@ int main(int argc, char *argv[]) qDebug() << "==== NOOTKA LOG =======\n" << QDateTime::currentDateTime().toString(); #endif - QTranslator qtTranslator; - QTranslator nooTranslator; - QPointer<QApplication> a = 0; - MainWindow *w = 0; - int exitCode; - bool firstTime = true; - QString confFile; - resetConfig = false; - do { + QTranslator qtTranslator; + QTranslator nooTranslator; + QPointer<QApplication> a = 0; + QQmlApplicationEngine *e = nullptr; + + int exitCode; + bool firstTime = true; + QString confFile; + resetConfig = false; + do { #if !defined (Q_OS_ANDROID) - if (a) delete a; - if (resetConfig) { // delete config file - new Nootka instance will start with first run wizard - QFile f(confFile); - f.remove(); - } - resetConfig = false; + if (a) delete a; + if (resetConfig) { // delete config file - new Nootka instance will start with first run wizard + QFile f(confFile); + f.remove(); + } + resetConfig = false; #endif - a = new QApplication(argc, argv); + a = new QApplication(argc, argv); Tmtr::init(a); -#if defined (Q_OS_ANDROID) - a->setStyle(new TtouchStyle); -// a->setStyle(QStyleFactory::create("Fusion")); -#endif - gl = new Tglobals(); - gl->path = Tglobals::getInstPath(qApp->applicationDirPath()); - confFile = gl->config->fileName(); - if (!initCoreLibrary()) - return 110; - prepareTranslations(a, qtTranslator, nooTranslator); - if (!loadNootkaFont(a)) - return 111; + gl = new Tglobals(); + gl->path = Tglobals::getInstPath(qApp->applicationDirPath()); + confFile = gl->config->fileName(); + if (!initCoreLibrary()) + return 110; + prepareTranslations(a, qtTranslator, nooTranslator); + if (!loadNootkaFont(a)) + return 111; + + a->setWindowIcon(QIcon(Tpath::img("nootka"))); // creating main window - w = new MainWindow(); + e = new QQmlApplicationEngine(QUrl(QStringLiteral("qrc:/MainWindow.qml"))); -#if defined (Q_OS_ANDROID) - w->showFullScreen(); -#else - w->show(); -#endif +// #if defined (Q_OS_ANDROID) +// w->showFullScreen(); // TODO +// #endif if (firstTime) { #if defined (Q_OS_ANDROID) QString androidArg = Tandroid::getRunArgument(); if (!androidArg.isEmpty()) w->openFile(androidArg); -#else - if (argc > 1) - w->openFile(QString::fromLocal8Bit(argv[argc - 1])); +#else // TODO +// if (argc > 1) +// w->openFile(QString::fromLocal8Bit(argv[argc - 1])); #endif } - firstTime = false; - exitCode = a->exec(); - delete w; + firstTime = false; + exitCode = a->exec(); + delete e; delete gl; #if defined (Q_OS_ANDROID) if (resetConfig) { // delete config file - new Nootka instance will start with first run wizard @@ -132,11 +132,8 @@ int main(int argc, char *argv[]) resetConfig = false; // do - while loop doesn't work with Android qApp->quit(); // HACK: calling QApplication::quick() solves hang on x86 when Qt uses native (usually obsolete) SSL libraries #endif - } while (resetConfig); + } while (resetConfig); -#if defined (Q_OS_ANDROID) - Tcore::androidStyle->deleteLater(); -#endif delete a; - return exitCode; + return exitCode; } diff --git a/src/qml/HeadButton.qml b/src/qml/HeadButton.qml new file mode 100644 index 0000000000000000000000000000000000000000..ad457b6e2a77973e5f9855d6629577e9ba18eef7 --- /dev/null +++ b/src/qml/HeadButton.qml @@ -0,0 +1,54 @@ +/*************************************************************************** + * Copyright (C) 2017 by Tomasz Bojczuk * + * seelook@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/>. * + ***************************************************************************/ + +import QtQuick 2.7 +import QtQuick.Controls 2.0 +import QtQuick.Window 2.0 + + +ToolButton { + antialiasing: true + hoverEnabled: true + + implicitWidth: Math.max(icon.width, butText.width) + Screen.pixelDensity * 2 + implicitHeight: Screen.pixelDensity * 13 // 1.3 cm + + property alias icon: icon.source + property alias name: butText.text + property alias tip: toolTip.text + + Image { + id: icon + y: Screen.pixelDensity + sourceSize.height: Screen.pixelDensity * 8 + anchors.horizontalCenter: butText.horizontalCenter + } + Text { + id: butText + font.pixelSize: Screen.pixelDensity * 2.5 + anchors.horizontalCenter: parent.horizontalCenter + anchors.top: icon.bottom + } + + ToolTip { + id: toolTip + delay: 1000 + timeout: 5000 + visible: hovered && text != "" + } +} diff --git a/src/qml/MainWindow.qml b/src/qml/MainWindow.qml new file mode 100644 index 0000000000000000000000000000000000000000..dceab9dd4f8603b0e2c4b3462b89cca789fd68ed --- /dev/null +++ b/src/qml/MainWindow.qml @@ -0,0 +1,35 @@ +/*************************************************************************** + * Copyright (C) 2017 by Tomasz Bojczuk * + * seelook@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/>. * + ***************************************************************************/ + +import QtQuick 2.7 +import QtQuick.Controls 2.0 +import QtQuick.Layouts 1.3 +import QtQuick.Window 2.0 + + +ApplicationWindow { + id: qrabWindow + visible: true + title: "Nootka" + + width: Screen.desktopAvailableWidth / 2 + height: Screen.desktopAvailableHeight / 2 + + header: TtoolBar {} + +} diff --git a/src/qml/TtoolBar.qml b/src/qml/TtoolBar.qml new file mode 100644 index 0000000000000000000000000000000000000000..2185948a1507b7180d4c8d9668812e0b1912772a --- /dev/null +++ b/src/qml/TtoolBar.qml @@ -0,0 +1,62 @@ +/*************************************************************************** + * Copyright (C) 2017 by Tomasz Bojczuk * + * seelook@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/>. * + ***************************************************************************/ + + +import QtQuick 2.7 +import QtQuick.Controls 2.0 +import QtQuick.Layouts 1.3 +import QtQuick.Window 2.0 + + +ToolBar { + height: settAct.height + + RowLayout { +// anchors.topMargin: Screen.pixelDensity + anchors.fill: parent + + HeadButton { + id: settAct + name: qsTr("Settings") + icon: "picts/systemsettings.png" + tip: qsTr("Application preferences") + onClicked: { + } + } + HeadButton { + id: levelAct + name: qsTr("Level") + icon: "picts/levelCreator.png" + tip: qsTr("Levels creator") + } +// HeadButton { +// id: chartAct +// name: qsTr("Analyze", "could be Chart as well") +// icon: "picts/charts.png" +// tip: qsTr("Analysis of exam results") +// } + HeadButton { + id: examAct + name: qsTr("Lessons") + icon: "picts/startExam.png" + tip: qsTr("Start exercises or an exam") + } + + Item { Layout.fillWidth: true } + } +}