Commit 1d53011f authored by Ronan Abhamon's avatar Ronan Abhamon

feat(src/app/App): show window if a secondary instance is created

parent 52cba384
......@@ -60,7 +60,7 @@ inline bool installLocale (App &app, QTranslator &translator, const QLocale &loc
return translator.load(locale, LANGUAGES_PATH) && app.installTranslator(&translator);
}
App::App (int &argc, char *argv[]) : SingleApplication(argc, argv) {
App::App (int &argc, char *argv[]) : SingleApplication(argc, argv, true) {
setApplicationVersion("4.0");
setWindowIcon(QIcon(WINDOW_ICON_PATH));
......@@ -143,7 +143,7 @@ void App::initContentApp () {
}
}
// Register types and create sub-windows.
// Register types.
registerTypes();
// Enable notifications.
......@@ -155,7 +155,9 @@ void App::initContentApp () {
core->setParent(this);
}
// Create sub windows.
createSubWindows();
// Load main view.
qInfo() << "Loading main view...";
m_engine.load(QUrl(QML_VIEW_MAIN_WINDOW));
......@@ -177,6 +179,13 @@ void App::initContentApp () {
if (m_parser.isSet("selftest"))
QTimer::singleShot(300, this, &App::quit);
QObject::connect(
this, &App::receivedMessage, this, [this](int, QByteArray message) {
if (message == "show")
getMainWindow()->showNormal();
}
);
}
// -----------------------------------------------------------------------------
......
......@@ -32,23 +32,21 @@ using namespace std;
int main (int argc, char *argv[]) {
Logger::init();
// Force OpenGLES & shader version 2.0.
QCoreApplication::setAttribute(Qt::AA_UseOpenGLES, true);
// Force shader version 2.0.
QSurfaceFormat fmt;
fmt.setVersion(2, 0);
QSurfaceFormat::setDefaultFormat(fmt);
/*
* TODO: Uncomment me in the future!
* Disabled for a moment.
* `QXcbConnection: XCB error` errors on Cinnamon.
* QGuiApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
*/
App app(argc, argv);
app.parseArgs();
if (app.isSecondary()) {
app.sendMessage("show", 0);
return 0;
}
app.initContentApp();
// Run!
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment