/ desktop / main.cpp
main.cpp
 1  #include <QGuiApplication>
 2  #include <QQmlApplicationEngine>
 3  #include <QQuickStyle>
 4  #include <iostream>
 5  #include <thread>
 6  
 7  #include "config/config.hpp"
 8  #include "datalake/database.hpp"
 9  #include "datalake/indexer.hpp"
10  
11  int main(int argc, char* argv[]) {
12    QQuickStyle::setStyle(QStringLiteral("org.kde.breeze"));
13    QGuiApplication app(argc, argv);
14    app.setApplicationDisplayName("Koto");
15    app.setDesktopFileName("com.github.joshstrobl.koto.desktop");
16  
17    QQmlApplicationEngine engine;
18  
19    engine.loadFromModule("com.github.joshstrobl.koto", "Main");
20  
21    if (engine.rootObjects().isEmpty()) { return -1; }
22  
23    std::thread([]() {
24      Cartographer::create();
25      KotoConfig::create();
26      KotoDatabase::create();
27  
28      KotoDatabase::instance().connect();
29  
30      // If we needed to bootstrap, index all libraries, otherwise load the database
31      if (KotoDatabase::instance().requiredBootstrap()) {
32        indexAllLibraries();
33      } else {
34        KotoDatabase::instance().load();
35        std::cout << "===== Summary =====" << std::endl;
36        for (auto artist : Cartographer::instance().getArtists()) {
37          std::cout << "Artist: " << artist->getName().toStdString() << std::endl;
38          for (auto album : artist->getAlbums()) {
39            std::cout << "  Album: " << album->getTitle().toStdString() << std::endl;
40            for (auto track : album->getTracks()) { std::cout << "    Track: " << track->getTitle().toStdString() << std::endl; }
41          }
42        }
43        std::cout << "===== Tracks without albums and/or artists =====" << std::endl;
44        for (auto track : Cartographer::instance().getTracks()) {
45          if (track->album_uuid.has_value()) continue;
46          std::cout << "Track: " << track->getTitle().toStdString() << std::endl;
47        }
48      }
49    }).detach();
50  
51    return app.exec();
52  }