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 ...@@ -60,7 +60,7 @@ inline bool installLocale (App &app, QTranslator &translator, const QLocale &loc
return translator.load(locale, LANGUAGES_PATH) && app.installTranslator(&translator); 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"); setApplicationVersion("4.0");
setWindowIcon(QIcon(WINDOW_ICON_PATH)); setWindowIcon(QIcon(WINDOW_ICON_PATH));
...@@ -143,7 +143,7 @@ void App::initContentApp () { ...@@ -143,7 +143,7 @@ void App::initContentApp () {
} }
} }
// Register types and create sub-windows. // Register types.
registerTypes(); registerTypes();
// Enable notifications. // Enable notifications.
...@@ -155,7 +155,9 @@ void App::initContentApp () { ...@@ -155,7 +155,9 @@ void App::initContentApp () {
core->setParent(this); core->setParent(this);
} }
// Create sub windows.
createSubWindows(); createSubWindows();
// Load main view. // Load main view.
qInfo() << "Loading main view..."; qInfo() << "Loading main view...";
m_engine.load(QUrl(QML_VIEW_MAIN_WINDOW)); m_engine.load(QUrl(QML_VIEW_MAIN_WINDOW));
...@@ -177,6 +179,13 @@ void App::initContentApp () { ...@@ -177,6 +179,13 @@ void App::initContentApp () {
if (m_parser.isSet("selftest")) if (m_parser.isSet("selftest"))
QTimer::singleShot(300, this, &App::quit); 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; ...@@ -32,23 +32,21 @@ using namespace std;
int main (int argc, char *argv[]) { int main (int argc, char *argv[]) {
Logger::init(); Logger::init();
// Force OpenGLES & shader version 2.0.
QCoreApplication::setAttribute(Qt::AA_UseOpenGLES, true); QCoreApplication::setAttribute(Qt::AA_UseOpenGLES, true);
// Force shader version 2.0.
QSurfaceFormat fmt; QSurfaceFormat fmt;
fmt.setVersion(2, 0); fmt.setVersion(2, 0);
QSurfaceFormat::setDefaultFormat(fmt); 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 app(argc, argv);
app.parseArgs(); app.parseArgs();
if (app.isSecondary()) {
app.sendMessage("show", 0);
return 0;
}
app.initContentApp(); app.initContentApp();
// Run! // 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