mirror of
https://github.com/Swordfish90/cool-retro-term.git
synced 2026-02-08 00:32:27 +00:00
Change the single application library with a better one.
This commit is contained in:
6
.gitmodules
vendored
6
.gitmodules
vendored
@@ -2,6 +2,6 @@
|
|||||||
path = qmltermwidget
|
path = qmltermwidget
|
||||||
url = https://github.com/Swordfish90/qmltermwidget
|
url = https://github.com/Swordfish90/qmltermwidget
|
||||||
branch = unstable
|
branch = unstable
|
||||||
[submodule "singleapplication"]
|
[submodule "KDSingleApplication"]
|
||||||
path = singleapplication
|
path = KDSingleApplication
|
||||||
url = https://github.com/itay-grudev/SingleApplication.git
|
url = https://github.com/KDAB/KDSingleApplication.git
|
||||||
|
|||||||
1
KDSingleApplication
Submodule
1
KDSingleApplication
Submodule
Submodule KDSingleApplication added at 1848dd64e8
@@ -1,8 +1,7 @@
|
|||||||
QT += qml quick widgets sql quickcontrols2
|
QT += qml quick widgets sql quickcontrols2
|
||||||
DEFINES += QAPPLICATION_CLASS=QApplication
|
|
||||||
TARGET = cool-retro-term
|
TARGET = cool-retro-term
|
||||||
|
|
||||||
include(../singleapplication/singleapplication.pri)
|
include(../KDSingleApplication/kdsingleapplication.pri)
|
||||||
|
|
||||||
DESTDIR = $$OUT_PWD/../
|
DESTDIR = $$OUT_PWD/../
|
||||||
|
|
||||||
|
|||||||
24
app/main.cpp
24
app/main.cpp
@@ -8,7 +8,7 @@
|
|||||||
#include <QIcon>
|
#include <QIcon>
|
||||||
#include <QQuickStyle>
|
#include <QQuickStyle>
|
||||||
|
|
||||||
#include <singleapplication.h>
|
#include <kdsingleapplication.h>
|
||||||
|
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
@@ -80,12 +80,18 @@ int main(int argc, char *argv[])
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
SingleApplication app(argc, argv, true);
|
QApplication app(argc, argv);
|
||||||
app.setAttribute(Qt::AA_MacDontSwapCtrlAndMeta, true);
|
app.setAttribute(Qt::AA_MacDontSwapCtrlAndMeta, true);
|
||||||
|
app.setApplicationName(QStringLiteral("cool-retro-term"));
|
||||||
|
app.setOrganizationName(QStringLiteral("cool-retro-term"));
|
||||||
|
app.setOrganizationDomain(QStringLiteral("cool-retro-term"));
|
||||||
|
|
||||||
if (app.isSecondary()) {
|
KDSingleApplication singleApp(QStringLiteral("cool-retro-term"));
|
||||||
app.sendMessage("new-window");
|
|
||||||
return 0;
|
if (!singleApp.isPrimaryInstance()) {
|
||||||
|
if (singleApp.sendMessage("new-window"))
|
||||||
|
return 0;
|
||||||
|
qWarning() << "KDSingleApplication: primary not reachable, continuing as independent instance.";
|
||||||
}
|
}
|
||||||
|
|
||||||
QQmlApplicationEngine engine;
|
QQmlApplicationEngine engine;
|
||||||
@@ -101,9 +107,6 @@ int main(int argc, char *argv[])
|
|||||||
app.setWindowIcon(QIcon(":../icons/32x32/cool-retro-term.png"));
|
app.setWindowIcon(QIcon(":../icons/32x32/cool-retro-term.png"));
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
app.setOrganizationName("cool-retro-term");
|
|
||||||
app.setOrganizationDomain("cool-retro-term");
|
|
||||||
|
|
||||||
// Manage command line arguments from the cpp side
|
// Manage command line arguments from the cpp side
|
||||||
QStringList args = app.arguments();
|
QStringList args = app.arguments();
|
||||||
|
|
||||||
@@ -150,9 +153,8 @@ int main(int argc, char *argv[])
|
|||||||
QMetaObject::invokeMethod(rootObject, "createWindow", Qt::QueuedConnection);
|
QMetaObject::invokeMethod(rootObject, "createWindow", Qt::QueuedConnection);
|
||||||
};
|
};
|
||||||
|
|
||||||
QObject::connect(&app, &SingleApplication::receivedMessage, &app,
|
QObject::connect(&singleApp, &KDSingleApplication::messageReceived, &app,
|
||||||
[&requestNewWindow](quint32 instanceId, QByteArray message) {
|
[&requestNewWindow](const QByteArray &message) {
|
||||||
Q_UNUSED(instanceId);
|
|
||||||
if (message.isEmpty() || message == QByteArray("new-window"))
|
if (message.isEmpty() || message == QByteArray("new-window"))
|
||||||
requestNewWindow();
|
requestNewWindow();
|
||||||
});
|
});
|
||||||
|
|||||||
Submodule singleapplication deleted from a8da87d782
Reference in New Issue
Block a user