mirror of
https://codeberg.org/vyn/mirai.git
synced 2025-07-04 10:43:19 +00:00
Switch from Qt6 to Slint
This commit is contained in:
parent
f8be14bcf8
commit
63bf267a22
107 changed files with 27532 additions and 2896 deletions
57
src/main.cpp
57
src/main.cpp
|
@ -4,48 +4,29 @@
|
|||
* The license can be found in the LICENSE file or at https://www.gnu.org/licenses/gpl-3.0.txt
|
||||
*/
|
||||
|
||||
#include <QtCore/QRect>
|
||||
#include <QtGui/QFont>
|
||||
#include <QtGui/QGuiApplication>
|
||||
#include <QtGui/QScreen>
|
||||
#include <QtQml/QQmlApplicationEngine>
|
||||
#include <exception>
|
||||
#include <iostream>
|
||||
#include <ostream>
|
||||
#include "UiState.h"
|
||||
#include "mirai-core/Config.h"
|
||||
#include "mirai-core/Mirai.h"
|
||||
#include "mirai-core/StdFileResource.h"
|
||||
#include "nlohmann/json.hpp"
|
||||
#include <cstdlib>
|
||||
#include <string>
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
try {
|
||||
std::cout << "Mirai started" << std::endl;
|
||||
QGuiApplication app(argc, argv);
|
||||
mirai::Config config(std::string(getenv("HOME")) + "/.config/mirai/config.json");
|
||||
|
||||
qreal refDpi = 54.;
|
||||
qreal refHeight = 1440.;
|
||||
qreal refWidth = 2560.;
|
||||
QRect rect = QGuiApplication::primaryScreen()->geometry();
|
||||
qreal height = qMax(rect.width(), rect.height());
|
||||
qreal width = qMin(rect.width(), rect.height());
|
||||
qreal dpi = QGuiApplication::primaryScreen()->logicalDotsPerInch();
|
||||
// auto m_ratio = qMin(height/refHeight, width/refWidth);
|
||||
auto m_ratioFont =
|
||||
qMin(height * refDpi / (dpi * refHeight), width * refDpi / (dpi * refWidth));
|
||||
mirai::Mirai mirai;
|
||||
|
||||
QFont font("Helvetica");
|
||||
app.setFont(font);
|
||||
|
||||
QQmlApplicationEngine engine;
|
||||
const QUrl url(u"qrc:/qt/qml/Mirai/src/qml/Main.qml"_qs);
|
||||
QObject::connect(
|
||||
&engine, &QQmlApplicationEngine::objectCreationFailed, &app,
|
||||
[]() {
|
||||
QCoreApplication::exit(-1);
|
||||
},
|
||||
Qt::QueuedConnection
|
||||
for (const auto &sourceFilePath : config.sources()) {
|
||||
auto file = std::make_unique<mirai::StdFileResource>(
|
||||
mirai::BaseFileResourceConstructor{.name = sourceFilePath, .path = sourceFilePath}
|
||||
);
|
||||
engine.load(url);
|
||||
|
||||
return app.exec();
|
||||
} catch (const std::exception &e) {
|
||||
std::cout << e.what() << std::endl;
|
||||
mirai.loadResource(std::move(file));
|
||||
}
|
||||
|
||||
UiState uiState{&mirai};
|
||||
uiState.run();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue