Moving to QT6: Read more
QT6 Apparently means a lot of changes, these are the changes I've found to make at least CPP build. The problem is we just got rid of a lot of CPP and I don't know if the application will work. On the other hand, the QML isn't finished yet either, but this is the start of updating the application for QT6 and using MpvQt which is being built and maintained by KDE. This will be better as they'll keep the library updated for future QT updates so long as I still track with Kirigami.
This commit is contained in:
parent
398bc58525
commit
61aef5c48f
13 changed files with 1115 additions and 2302 deletions
165
src/main.cpp
165
src/main.cpp
|
@ -1,5 +1,6 @@
|
|||
#include <QApplication>
|
||||
#include <QQmlApplicationEngine>
|
||||
#include <QtCore/qstringliteral.h>
|
||||
#include <QtQml>
|
||||
#include <QUrl>
|
||||
#include <QSql>
|
||||
|
@ -10,10 +11,10 @@
|
|||
// #include <KWindowSystem>
|
||||
#include <iostream>
|
||||
#include <QQmlEngine>
|
||||
#include <QtSql>
|
||||
#include <QSqlDatabase>
|
||||
#include <QSqlTableModel>
|
||||
#include <QtWebEngine>
|
||||
// #include <QtSql>
|
||||
// #include <QSqlDatabase>
|
||||
// #include <QSqlTableModel>
|
||||
#include <QtWebEngineQuick>
|
||||
|
||||
#include <QObject>
|
||||
#include <QtGlobal>
|
||||
|
@ -37,15 +38,16 @@
|
|||
#include <qsqlquery.h>
|
||||
#include <qstringliteral.h>
|
||||
|
||||
#include "cpp/mpv/mpvobject.h"
|
||||
#include "cpp/serviceitemmodel.h"
|
||||
#include "cpp/slidemodel.h"
|
||||
#include "cpp/songsqlmodel.h"
|
||||
#include "cpp/videosqlmodel.h"
|
||||
#include "cpp/imagesqlmodel.h"
|
||||
#include "cpp/presentationsqlmodel.h"
|
||||
#include "cpp/filemanager.h"
|
||||
#include "cpp/slidehelper.h"
|
||||
#include "cpp/mpv/mpvitem.h"
|
||||
#include "cpp/mpv/mpvproperties.h"
|
||||
// #include "cpp/serviceitemmodel.h"
|
||||
// #include "cpp/slidemodel.h"
|
||||
// #include "cpp/songsqlmodel.h"
|
||||
// #include "cpp/videosqlmodel.h"
|
||||
// #include "cpp/imagesqlmodel.h"
|
||||
// #include "cpp/presentationsqlmodel.h"
|
||||
// #include "cpp/filemanager.h"
|
||||
// #include "cpp/slidehelper.h"
|
||||
|
||||
// RUST
|
||||
// #include "cxx-qt-gen/service_thing.cxxqt.h"
|
||||
|
@ -71,83 +73,87 @@ static QWindow *windowFromEngine(QQmlApplicationEngine *engine)
|
|||
return window;
|
||||
}
|
||||
|
||||
static void connectToDatabase() {
|
||||
// let's setup our sql database
|
||||
QSqlDatabase db = QSqlDatabase::database();
|
||||
if (!db.isValid()){
|
||||
db = QSqlDatabase::addDatabase("QSQLITE");
|
||||
if (!db.isValid())
|
||||
qFatal("Cannot add database: %s", qPrintable(db.lastError().text()));
|
||||
}
|
||||
// static void connectToDatabase() {
|
||||
// // let's setup our sql database
|
||||
// QSqlDatabase db = QSqlDatabase::database();
|
||||
// if (!db.isValid()){
|
||||
// db = QSqlDatabase::addDatabase("QSQLITE");
|
||||
// if (!db.isValid())
|
||||
// qFatal("Cannot add database: %s", qPrintable(db.lastError().text()));
|
||||
// }
|
||||
|
||||
const QDir writeDir = QStandardPaths::writableLocation(QStandardPaths::AppDataLocation);
|
||||
qDebug() << "dir location " << writeDir.absolutePath();
|
||||
// const QDir writeDir = QStandardPaths::writableLocation(QStandardPaths::AppDataLocation);
|
||||
// qDebug() << "dir location " << writeDir.absolutePath();
|
||||
|
||||
if (!writeDir.mkpath(".")) {
|
||||
qFatal("Failed to create writable location at %s", qPrintable(writeDir.absolutePath()));
|
||||
}
|
||||
// if (!writeDir.mkpath(".")) {
|
||||
// qFatal("Failed to create writable location at %s", qPrintable(writeDir.absolutePath()));
|
||||
// }
|
||||
|
||||
const QString dbName = writeDir.absolutePath() + "/library-db.sqlite3";
|
||||
// const QString dbName = writeDir.absolutePath() + "/library-db.sqlite3";
|
||||
|
||||
db.setHostName("localhost");
|
||||
db.setDatabaseName(dbName);
|
||||
db.setUserName("presenter");
|
||||
// TODO change password system before launch
|
||||
db.setPassword("i393jkf782djyr98302j");
|
||||
if (!db.open()) {
|
||||
qFatal("Cannot open database: %s", qPrintable(db.lastError().text()));
|
||||
QFile::remove(dbName);
|
||||
}
|
||||
qDebug() << "Finished connecting to db";
|
||||
// db.setHostName("localhost");
|
||||
// db.setDatabaseName(dbName);
|
||||
// db.setUserName("presenter");
|
||||
// // TODO change password system before launch
|
||||
// db.setPassword("i393jkf782djyr98302j");
|
||||
// if (!db.open()) {
|
||||
// qFatal("Cannot open database: %s", qPrintable(db.lastError().text()));
|
||||
// QFile::remove(dbName);
|
||||
// }
|
||||
// qDebug() << "Finished connecting to db";
|
||||
|
||||
}
|
||||
// }
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
// qDebug() << QSurfaceFormat::defaultFormat();
|
||||
QGuiApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
|
||||
QGuiApplication::setWindowIcon(QIcon::fromTheme(QStringLiteral("video-display")));
|
||||
QtWebEngine::initialize();
|
||||
QtWebEngineQuick::initialize();
|
||||
QGuiApplication app(argc, argv);
|
||||
KLocalizedString::setApplicationDomain("lumina");
|
||||
KAboutData aboutData("lumina", i18n("lumina"), "0.1",
|
||||
i18n("A church presentation app built with KDE tech."),
|
||||
KAboutLicense::GPL_V3,
|
||||
i18n("Copyright 2017 Bar Foundation"), QString(),
|
||||
"https://www.foo-the-app.net");
|
||||
KAboutData about;
|
||||
about.setComponentName(QStringLiteral("lumina"));
|
||||
about.setDisplayName(i18n("lumina"));
|
||||
about.setVersion(QByteArray("0.1"));
|
||||
about.setShortDescription(i18n("A churchpresentation app build with KDE tech."));
|
||||
about.setLicense(KAboutLicense::GPL_V3);
|
||||
|
||||
// overwrite default-generated values of organizationDomain & desktopFileName
|
||||
aboutData.setOrganizationDomain("tfcconnection.org");
|
||||
aboutData.setDesktopFileName("org.tfcconnection.lumina");
|
||||
|
||||
about.setOrganizationDomain("tfcconnection.org");
|
||||
about.setDesktopFileName(QStringLiteral("org.tfcconneciton.lumina"));
|
||||
|
||||
QQuickWindow::setGraphicsApi(QSGRendererInterface::OpenGL);
|
||||
|
||||
// set the application metadata
|
||||
KAboutData::setApplicationData(aboutData);
|
||||
KAboutData::setApplicationData(about);
|
||||
QCoreApplication::setOrganizationName(QStringLiteral("lumina"));
|
||||
QCoreApplication::setOrganizationDomain(QStringLiteral("tfcconnection.org"));
|
||||
QCoreApplication::setApplicationName(QStringLiteral("lumina"));
|
||||
qSetMessagePattern("%{category}: %{time h:m:s ap} %{type} %{function}: %{message}\n %{file}");
|
||||
qSetMessagePattern(QString::fromUtf8("%{category}: %{time h:m:s ap} %{type} %{function}: %{message}\n %{file}"));
|
||||
|
||||
#ifdef Q_OS_WINDOWS
|
||||
QIcon::setFallbackThemeName("breeze");
|
||||
QIcon::setFallbackThemeName(QStringLiteral("breeze"));
|
||||
QQuickStyle::setStyle(QStringLiteral("org.kde.breeze"));
|
||||
// QApplication::setStyle(QStringLiteral("breeze"));
|
||||
#else
|
||||
QIcon::setFallbackThemeName("breeze");
|
||||
QIcon::setFallbackThemeName(QStringLiteral("breeze"));
|
||||
QQuickStyle::setStyle(QStringLiteral("org.kde.desktop"));
|
||||
QQuickStyle::setFallbackStyle(QStringLiteral("Default"));
|
||||
#endif
|
||||
|
||||
qDebug() << QQuickStyle::availableStyles();
|
||||
// qDebug() << QQuickStyle::availableStyles();
|
||||
qDebug() << QIcon::themeName();
|
||||
qDebug() << QApplication::platformName();
|
||||
|
||||
//Need to instantiate our slide
|
||||
// QScopedPointer<Utils> utils(new Utils);
|
||||
QScopedPointer<SlideModel> slideModel(new SlideModel);
|
||||
QScopedPointer<SlideModelCpp> slideMod(new SlideModelCpp);
|
||||
QScopedPointer<File> filemanager(new File);
|
||||
// QScopedPointer<SlideModelCpp> slideMod(new SlideModelCpp);
|
||||
// QScopedPointer<File> filemanager(new File);
|
||||
// QScopedPointer<QQuickView> preswin(new QQuickView);
|
||||
QScopedPointer<ServiceItemModel> serviceItemModel(new ServiceItemModel);
|
||||
QScopedPointer<ServiceItemModelCpp> serviceItemC(new ServiceItemModelCpp);
|
||||
// QScopedPointer<ServiceItemModelCpp> serviceItemC(new ServiceItemModelCpp);
|
||||
QScopedPointer<SlideObject> slideobject(new SlideObject);
|
||||
QScopedPointer<ObsModel> obsModel(new ObsModel);
|
||||
obsModel.get()->getObs();
|
||||
|
@ -162,14 +168,14 @@ int main(int argc, char *argv[])
|
|||
// PresWindow->setSource(QUrl(QStringLiteral("qrc://qml/presenter/PresentationWindow.qml")));
|
||||
qDebug() << PresWindow->isVisible();
|
||||
|
||||
QObject::connect(serviceItemC.get(),
|
||||
SIGNAL(itemInserted(const int&, const ServiceItem&)),
|
||||
slideMod.get(),
|
||||
SLOT(insertItemFromService(const int&, const ServiceItem&)));
|
||||
QObject::connect(serviceItemC.get(),
|
||||
SIGNAL(itemAdded(const int&, const ServiceItem&)),
|
||||
slideMod.get(),
|
||||
SLOT(addItemFromService(const int&, const ServiceItem&)));
|
||||
// QObject::connect(serviceItemC.get(),
|
||||
// SIGNAL(itemInserted(const int&, const ServiceItem&)),
|
||||
// slideMod.get(),
|
||||
// SLOT(insertItemFromService(const int&, const ServiceItem&)));
|
||||
// QObject::connect(serviceItemC.get(),
|
||||
// SIGNAL(itemAdded(const int&, const ServiceItem&)),
|
||||
// slideMod.get(),
|
||||
// SLOT(addItemFromService(const int&, const ServiceItem&)));
|
||||
|
||||
QObject::connect(serviceItemModel.get(),
|
||||
&ServiceItemModel::itemAdded,
|
||||
|
@ -206,22 +212,23 @@ int main(int argc, char *argv[])
|
|||
|
||||
if (!serviceItemModel.get()->load(settings->getLastSaveFile())) {
|
||||
qDebug() << "Last saved file is missing or there isn't a last saved file.";
|
||||
serviceItemModel.get()->addItem("Black", "image",
|
||||
"qrc:/assets/black.jpg",
|
||||
"image", QStringList(""),
|
||||
"", "", 0, 1, false, 0, 0, 0);
|
||||
serviceItemModel.get()->addItem(QString::fromUtf8("Black"), QString::fromUtf8("image"),
|
||||
QString::fromUtf8("qrc:/assets/black.jpg"),
|
||||
QString::fromUtf8("image"), QStringList() << QStringLiteral(""),
|
||||
QString::fromUtf8(""), QString::fromUtf8(""), 0, 1, false, 0, 0, 0);
|
||||
}
|
||||
|
||||
// apparently mpv needs this class set
|
||||
// let's register mpv as well
|
||||
std::setlocale(LC_NUMERIC, "C");
|
||||
qmlRegisterType<MpvObject>("mpv", 1, 0, "MpvObject");
|
||||
qmlRegisterType<MpvItem>("mpv", 1, 0, "MpvItem");
|
||||
qmlRegisterSingletonInstance("org.presenter", 1, 0, "MpvProperties", MpvProperties::self());
|
||||
|
||||
//register our models
|
||||
qmlRegisterType<SongProxyModel>("org.presenter", 1, 0, "SongProxyModel");
|
||||
qmlRegisterType<VideoProxyModel>("org.presenter", 1, 0, "VideoProxyModel");
|
||||
qmlRegisterType<ImageProxyModel>("org.presenter", 1, 0, "ImageProxyModel");
|
||||
qmlRegisterType<PresentationProxyModel>("org.presenter", 1, 0, "PresentationProxyModel");
|
||||
// qmlRegisterType<SongProxyModel>("org.presenter", 1, 0, "SongProxyModel");
|
||||
// qmlRegisterType<VideoProxyModel>("org.presenter", 1, 0, "VideoProxyModel");
|
||||
// qmlRegisterType<ImageProxyModel>("org.presenter", 1, 0, "ImageProxyModel");
|
||||
// qmlRegisterType<PresentationProxyModel>("org.presenter", 1, 0, "PresentationProxyModel");
|
||||
qmlRegisterType<SongModel>("org.presenter", 1, 0, "SongModel");
|
||||
qmlRegisterType<SongEditor>("org.presenter", 1, 0, "SongEditor");
|
||||
qmlRegisterType<VideoModel>("org.presenter", 1, 0, "VideoModel");
|
||||
|
@ -237,13 +244,13 @@ int main(int argc, char *argv[])
|
|||
qmlRegisterType<SlideHelper>("org.presenter", 1, 0, "SlideHelper");
|
||||
qmlRegisterSingletonInstance("org.presenter", 1, 0,
|
||||
"ServiceItemModel", serviceItemModel.get());
|
||||
qmlRegisterSingletonInstance("org.presenter", 1, 0,
|
||||
"ServiceItemC", serviceItemC.get());
|
||||
// qmlRegisterSingletonInstance("org.presenter", 1, 0,
|
||||
// "ServiceItemC", serviceItemC.get());
|
||||
qmlRegisterSingletonInstance("org.presenter", 1, 0, "SlideModel", slideModel.get());
|
||||
qmlRegisterSingletonInstance("org.presenter", 1, 0, "SlideMod", slideMod.get());
|
||||
// qmlRegisterSingletonInstance("org.presenter", 1, 0, "SlideMod", slideMod.get());
|
||||
qmlRegisterSingletonInstance("org.presenter", 1, 0, "Utils", utils);
|
||||
qmlRegisterSingletonInstance("org.presenter", 1, 0, "SlideObject", slideobject.get());
|
||||
qmlRegisterSingletonInstance("org.presenter", 1, 0, "FileManager", filemanager.get());
|
||||
// qmlRegisterSingletonInstance("org.presenter", 1, 0, "FileManager", filemanager.get());
|
||||
qmlRegisterSingletonInstance("org.presenter", 1, 0, "PresWindow", PresWindow);
|
||||
qmlRegisterSingletonInstance("org.presenter", 1, 0, "RSettings", settings);
|
||||
qmlRegisterSingletonInstance("org.presenter", 1, 0, "ObsModel", obsModel.get());
|
||||
|
@ -253,10 +260,10 @@ int main(int argc, char *argv[])
|
|||
// we need to set it as a separate context so that it can change it's slides too.
|
||||
// This is because SlideObject singleton is started before the window is shown
|
||||
// thus it doesn't exist in this window's context. So we set it here.
|
||||
PresWindow->rootContext()->setContextProperty("SlideObj", slideobject.get());
|
||||
PresWindow->setTitle("presentation-window");
|
||||
PresWindow->rootContext()->setContextProperty(QStringLiteral("SlideObj"), slideobject.get());
|
||||
PresWindow->setTitle(QStringLiteral("presentation-window"));
|
||||
|
||||
connectToDatabase();
|
||||
// connectToDatabase();
|
||||
|
||||
qDebug() << "Starting engine";
|
||||
QQmlApplicationEngine engine;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue