1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41
|
/*
This file is part of KDSingleApplication.
SPDX-FileCopyrightText: 2019 Klarälvdalens Datakonsult AB, a KDAB Group company <info@kdab.com>
SPDX-License-Identifier: MIT
Contact KDAB at <info@kdab.com> for commercial licensing options.
*/
#include <QtWidgets/QApplication>
#include <kdsingleapplication.h>
#include "primaryinstancewidget.h"
#include "secondaryinstancewidget.h"
int main(int argc, char **argv)
{
QApplication app(argc, argv);
KDSingleApplication kdsa;
QWidget *widget;
if (kdsa.isPrimaryInstance()) {
PrimaryInstanceWidget *piw = new PrimaryInstanceWidget;
QObject::connect(&kdsa, &KDSingleApplication::messageReceived,
piw, &PrimaryInstanceWidget::addMessage);
widget = piw;
} else {
SecondaryInstanceWidget *siw = new SecondaryInstanceWidget(&kdsa);
widget = siw;
}
widget->setAttribute(Qt::WA_DeleteOnClose);
widget->show();
return app.exec();
}
|