-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
20 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
/* | ||
* Copyright (C) 2023 Chupligin Sergey <[email protected]> | ||
* Copyright (C) 2023-2024 Chupligin Sergey <[email protected]> | ||
* | ||
* This library is free software; you can redistribute it and/or | ||
* modify it under the terms of the GNU Library General Public | ||
|
@@ -17,6 +17,7 @@ | |
* Boston, MA 02110-1301, USA. | ||
*/ | ||
|
||
#include "glacierapp.h" | ||
#include "dbusadaptor.h" | ||
#include "qcoreapplication.h" | ||
|
||
|
@@ -26,25 +27,24 @@ DBusAdaptor::DBusAdaptor(QQuickWindow* window) | |
: QDBusAbstractAdaptor(window) | ||
, m_window(window) | ||
{ | ||
QDBusConnection sessionbus = QDBusConnection::sessionBus(); | ||
QString serviceName = QString("org.glacier.%1").arg(qApp->applicationName().replace("-", "_")); | ||
|
||
QDBusConnection::sessionBus().registerService(serviceName); | ||
if (!QDBusConnection::sessionBus().registerObject("/", m_window)) { | ||
qWarning() << Q_FUNC_INFO << "Cannot register DBus object!"; | ||
qCWarning(lcGlacierAppCoreLog) << Q_FUNC_INFO << "Cannot register DBus object!"; | ||
}; | ||
} | ||
|
||
void DBusAdaptor::show(QStringList args) | ||
{ | ||
Q_UNUSED(args); | ||
qDebug() << "show window from dbus call"; | ||
qCDebug(lcGlacierAppCoreLog) << "show window from dbus call"; | ||
m_window->show(); | ||
} | ||
|
||
void DBusAdaptor::quit(QStringList args) | ||
{ | ||
Q_UNUSED(args); | ||
qDebug() << "quit over dbus"; | ||
qCDebug(lcGlacierAppCoreLog) << "quit over dbus"; | ||
qApp->quit(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
/* | ||
* Copyright (C) 2017-2023 Chupligin Sergey <[email protected]> | ||
* Copyright (C) 2017-2024 Chupligin Sergey <[email protected]> | ||
* | ||
* This library is free software; you can redistribute it and/or | ||
* modify it under the terms of the GNU Library General Public | ||
|
@@ -23,7 +23,6 @@ | |
|
||
#include <QDBusConnection> | ||
#include <QDBusConnectionInterface> | ||
#include <QDebug> | ||
#include <QFileInfo> | ||
#include <QGuiApplication> | ||
#include <QQmlApplicationEngine> | ||
|
@@ -43,6 +42,8 @@ | |
#include <QSettings> | ||
#endif | ||
|
||
Q_LOGGING_CATEGORY(lcGlacierAppCoreLog, "org.glacier.app", QtWarningMsg) | ||
|
||
QGuiApplication* GlacierApp::app(int& argc, char** argv) | ||
{ | ||
setenv("QT_QUICK_CONTROLS_STYLE", "Nemo", 1); | ||
|
@@ -67,14 +68,14 @@ QGuiApplication* GlacierApp::app(int& argc, char** argv) | |
|
||
QTranslator* myappTranslator = new QTranslator(app); | ||
if (myappTranslator->load(locale, app->applicationName(), QLatin1String("_"), QLatin1String("/usr/share/%1/translations/").arg(app->applicationName()))) { | ||
qDebug() << "translation.load() success" << locale; | ||
qCDebug(lcGlacierAppCoreLog) << "translation.load() success" << locale; | ||
if (app->installTranslator(myappTranslator)) { | ||
qDebug() << "installTranslator() success" << locale; | ||
qCDebug(lcGlacierAppCoreLog) << "installTranslator() success" << locale; | ||
} else { | ||
qDebug() << "installTranslator() failed" << locale; | ||
qCDebug(lcGlacierAppCoreLog) << "installTranslator() failed" << locale; | ||
} | ||
} else { | ||
qDebug() << "translation.load() failed" << locale; | ||
qCDebug(lcGlacierAppCoreLog) << "translation.load() failed" << locale; | ||
} | ||
connect(app, &QGuiApplication::aboutToQuit, saveWindowSize); | ||
|
||
|
@@ -85,7 +86,7 @@ QGuiApplication* GlacierApp::app(int& argc, char** argv) | |
QString serviceName = QString("org.glacier.%1").arg(qApp->applicationName().replace("-", "_")); | ||
QDBusConnection sessionBus = QDBusConnection::sessionBus(); | ||
if (sessionBus.interface()->isServiceRegistered(serviceName)) { | ||
qWarning() << "Current application run shadow mode. Call and exit."; | ||
qCWarning(lcGlacierAppCoreLog) << "Current application run shadow mode. Call and exit."; | ||
QDBusMessage message = QDBusMessage::createMethodCall(serviceName, | ||
"/", | ||
"glacier.app", | ||
|
@@ -147,7 +148,7 @@ QQuickWindow* GlacierApp::showWindow() | |
#endif | ||
|
||
if (QCoreApplication::arguments().contains("--prestart") || QCoreApplication::arguments().contains("-p")) { | ||
qDebug() << "Application run in shadow mode"; | ||
qCDebug(lcGlacierAppCoreLog) << "Application run in shadow mode"; | ||
new DBusAdaptor(window); | ||
} else { | ||
window->show(); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
/* | ||
* Copyright (C) 2017-2023 Chupligin Sergey <[email protected]> | ||
* Copyright (C) 2017-2024 Chupligin Sergey <[email protected]> | ||
* | ||
* This library is free software; you can redistribute it and/or | ||
* modify it under the terms of the GNU Library General Public | ||
|
@@ -22,6 +22,9 @@ | |
|
||
#include <QLocale> | ||
#include <QObject> | ||
#include <QLoggingCategory> | ||
|
||
Q_DECLARE_LOGGING_CATEGORY(lcGlacierAppCoreLog) | ||
|
||
class QGuiApplication; | ||
class QQmlApplicationEngine; | ||
|