2018-07-09 18:05:31 +00:00
|
|
|
#include <cstdint>
|
|
|
|
#include <QApplication>
|
|
|
|
#include <QStyleFactory>
|
2018-07-25 06:01:01 +00:00
|
|
|
#include <QTranslator>
|
2018-07-09 18:05:31 +00:00
|
|
|
#include "MainWindow.hpp"
|
2018-08-19 00:28:52 +00:00
|
|
|
#include "SongGroupEditor.hpp"
|
2018-07-14 06:06:33 +00:00
|
|
|
#include "boo/IApplication.hpp"
|
2018-07-25 06:01:01 +00:00
|
|
|
#include <QResource>
|
2018-07-29 03:37:06 +00:00
|
|
|
#include <QCommandLineParser>
|
2018-08-07 07:09:23 +00:00
|
|
|
#include <logvisor/logvisor.hpp>
|
2018-07-14 06:06:33 +00:00
|
|
|
|
|
|
|
using namespace std::literals;
|
2018-07-09 18:05:31 +00:00
|
|
|
|
|
|
|
#ifdef __APPLE__
|
|
|
|
void MacOSSetDarkAppearance();
|
|
|
|
#endif
|
|
|
|
|
|
|
|
extern "C" const uint8_t MAINICON_QT[];
|
|
|
|
|
2018-12-08 05:20:09 +00:00
|
|
|
static QIcon MakeAppIcon() {
|
|
|
|
QIcon ret;
|
|
|
|
|
|
|
|
const uint8_t* ptr = MAINICON_QT;
|
|
|
|
for (int i = 0; i < 6; ++i) {
|
|
|
|
uint32_t size = *reinterpret_cast<const uint32_t*>(ptr);
|
|
|
|
ptr += 4;
|
|
|
|
|
|
|
|
QPixmap pm;
|
|
|
|
pm.loadFromData(ptr, size);
|
|
|
|
ret.addPixmap(pm);
|
|
|
|
ptr += size;
|
|
|
|
}
|
|
|
|
|
|
|
|
return ret;
|
2018-07-09 18:05:31 +00:00
|
|
|
}
|
2018-03-15 00:25:29 +00:00
|
|
|
|
2018-07-14 06:06:33 +00:00
|
|
|
/* This is for adapting the get*Name methods */
|
2018-12-08 05:20:09 +00:00
|
|
|
class BooInterface : public boo::IApplication {
|
|
|
|
std::vector<boo::SystemString> m_args;
|
2019-08-25 04:37:47 +00:00
|
|
|
void _deletedWindow(boo::IWindow* window) override {}
|
2018-12-08 05:20:09 +00:00
|
|
|
|
2018-07-14 06:06:33 +00:00
|
|
|
public:
|
2019-08-25 04:37:47 +00:00
|
|
|
EPlatformType getPlatformType() const override { return EPlatformType::Qt; }
|
2018-07-14 06:06:33 +00:00
|
|
|
|
2019-08-25 04:37:47 +00:00
|
|
|
int run() override { return 0; }
|
|
|
|
boo::SystemStringView getUniqueName() const override { return _SYS_STR("amuse-gui"sv); }
|
|
|
|
boo::SystemStringView getFriendlyName() const override { return _SYS_STR("Amuse"sv); }
|
|
|
|
boo::SystemStringView getProcessName() const override { return _SYS_STR("amuse-gui"sv); }
|
|
|
|
const std::vector<boo::SystemString>& getArgs() const override { return m_args; }
|
2018-07-14 06:06:33 +00:00
|
|
|
|
2018-12-08 05:20:09 +00:00
|
|
|
/* Constructors/initializers for sub-objects */
|
2019-08-25 04:37:47 +00:00
|
|
|
std::shared_ptr<boo::IWindow> newWindow(boo::SystemStringView title) override { return {}; }
|
2018-07-14 06:06:33 +00:00
|
|
|
};
|
|
|
|
|
2018-07-26 03:41:48 +00:00
|
|
|
MainWindow* g_MainWindow = nullptr;
|
|
|
|
|
2018-12-08 05:20:09 +00:00
|
|
|
int main(int argc, char* argv[]) {
|
|
|
|
QApplication::setAttribute(Qt::AA_Use96Dpi);
|
2018-07-09 18:05:31 +00:00
|
|
|
#if (QT_VERSION >= QT_VERSION_CHECK(5, 6, 0))
|
2018-12-08 05:20:09 +00:00
|
|
|
QApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
|
|
|
|
QApplication::setAttribute(Qt::AA_UseHighDpiPixmaps);
|
2018-07-09 18:05:31 +00:00
|
|
|
#endif
|
2018-12-08 05:20:09 +00:00
|
|
|
QApplication::setStyle(new ColoredTabBarStyle(QStyleFactory::create("Fusion")));
|
|
|
|
QApplication a(argc, argv);
|
|
|
|
QApplication::setWindowIcon(MakeAppIcon());
|
|
|
|
|
|
|
|
a.setOrganizationName("AxioDL");
|
|
|
|
a.setApplicationName("Amuse");
|
|
|
|
|
|
|
|
QPalette darkPalette;
|
|
|
|
darkPalette.setColor(QPalette::Window, QColor(53, 53, 53));
|
|
|
|
darkPalette.setColor(QPalette::WindowText, Qt::white);
|
|
|
|
darkPalette.setColor(QPalette::Base, QColor(42, 42, 42));
|
|
|
|
darkPalette.setColor(QPalette::Disabled, QPalette::Base, QColor(25, 25, 25, 53));
|
|
|
|
darkPalette.setColor(QPalette::AlternateBase, QColor(53, 53, 53));
|
|
|
|
darkPalette.setColor(QPalette::ToolTipBase, QColor(42, 42, 42));
|
|
|
|
darkPalette.setColor(QPalette::ToolTipText, Qt::white);
|
|
|
|
darkPalette.setColor(QPalette::Text, Qt::white);
|
|
|
|
darkPalette.setColor(QPalette::Disabled, QPalette::Text, QColor(255, 255, 255, 120));
|
|
|
|
darkPalette.setColor(QPalette::Disabled, QPalette::Light, QColor(0, 0, 0, 0));
|
|
|
|
darkPalette.setColor(QPalette::Button, QColor(53, 53, 53));
|
|
|
|
darkPalette.setColor(QPalette::Disabled, QPalette::Button, QColor(53, 53, 53, 53));
|
|
|
|
darkPalette.setColor(QPalette::ButtonText, Qt::white);
|
|
|
|
darkPalette.setColor(QPalette::Disabled, QPalette::ButtonText, QColor(255, 255, 255, 120));
|
|
|
|
darkPalette.setColor(QPalette::BrightText, Qt::red);
|
|
|
|
darkPalette.setColor(QPalette::Link, QColor(42, 130, 218));
|
|
|
|
darkPalette.setColor(QPalette::Highlight, QColor(42, 130, 218));
|
|
|
|
darkPalette.setColor(QPalette::Disabled, QPalette::Highlight, QColor(42, 130, 218, 53));
|
|
|
|
darkPalette.setColor(QPalette::HighlightedText, Qt::white);
|
|
|
|
darkPalette.setColor(QPalette::Disabled, QPalette::HighlightedText, QColor(255, 255, 255, 120));
|
|
|
|
a.setPalette(darkPalette);
|
2018-07-09 18:05:31 +00:00
|
|
|
|
|
|
|
#ifdef __APPLE__
|
2018-12-08 05:20:09 +00:00
|
|
|
MacOSSetDarkAppearance();
|
2018-07-09 18:05:31 +00:00
|
|
|
#endif
|
|
|
|
|
2018-12-08 05:20:09 +00:00
|
|
|
logvisor::RegisterConsoleLogger();
|
|
|
|
logvisor::RegisterStandardExceptions();
|
2018-08-07 07:09:23 +00:00
|
|
|
|
2018-12-08 05:20:09 +00:00
|
|
|
BooInterface booApp;
|
|
|
|
boo::APP = &booApp;
|
2018-07-14 06:06:33 +00:00
|
|
|
|
2018-12-08 05:20:09 +00:00
|
|
|
Q_INIT_RESOURCE(translation_res);
|
|
|
|
QTranslator translator;
|
|
|
|
if (translator.load(QLocale(), QLatin1String("lang"), QLatin1String("_"), QLatin1String(":/translations")))
|
|
|
|
a.installTranslator(&translator);
|
2018-07-25 06:01:01 +00:00
|
|
|
|
2018-12-08 05:20:09 +00:00
|
|
|
MainWindow w;
|
|
|
|
g_MainWindow = &w;
|
|
|
|
w.show();
|
2018-07-29 03:37:06 +00:00
|
|
|
|
2018-12-08 05:20:09 +00:00
|
|
|
QCommandLineParser parser;
|
|
|
|
parser.process(a);
|
|
|
|
QStringList args = parser.positionalArguments();
|
|
|
|
if (!args.empty())
|
|
|
|
w.openProject(args.back());
|
2018-07-29 03:37:06 +00:00
|
|
|
|
2018-12-08 05:20:09 +00:00
|
|
|
return a.exec();
|
2018-03-15 00:25:29 +00:00
|
|
|
}
|