stc_rpncalc/qt_gui/main.cpp

43 lines
1.4 KiB
C++
Raw Permalink Normal View History

// 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 <https://www.gnu.org/licenses/>.
2019-04-03 06:07:15 +02:00
#include <QApplication>
#include <QFontDatabase>
2019-04-03 06:07:15 +02:00
#include <QQmlApplicationEngine>
#include <QQmlContext>
#include "calculator.h"
int main(int argc, char** argv)
{
QApplication app(argc, argv);
2019-04-04 08:04:20 +02:00
//QML engine
2019-04-03 06:07:15 +02:00
QQmlApplicationEngine engine;
engine.load(QUrl(QStringLiteral("qrc:/main.qml")));
2019-04-04 08:04:20 +02:00
//calculator
2019-04-03 06:07:15 +02:00
Calculator calculator;
engine.rootContext()->setContextProperty("_calculator", &calculator);
2019-04-04 08:04:20 +02:00
//fixed-width font for LCD
QFont fixedFont = QFontDatabase::systemFont(QFontDatabase::FixedFont);
fixedFont.setStyleHint(QFont::TypeWriter);
fixedFont.setPointSize(24);
engine.rootContext()->setContextProperty("_fixedFont", fixedFont);
2019-04-04 08:04:20 +02:00
//handle quit
QObject::connect(&app, &QApplication::aboutToQuit, &calculator, &Calculator::quit);
2019-04-03 06:07:15 +02:00
return app.exec();
}