Move server function to the bottom and change "utils" file name to "localserver"
This commit is contained in:
parent
6f0303206e
commit
c15250498b
|
@ -45,7 +45,7 @@ set(discord-screenaudio_SRC
|
|||
src/log.cpp
|
||||
src/userscript.cpp
|
||||
src/centralwidget.cpp
|
||||
src/utils.cpp
|
||||
src/localserver.cpp
|
||||
resources.qrc
|
||||
)
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
#include "utils.h"
|
||||
#include "localserver.h"
|
||||
|
||||
bool isProgramRunning(const QString &program_name) {
|
||||
QLocalSocket socket;
|
|
@ -5,6 +5,5 @@
|
|||
#include <QLocalSocket>
|
||||
#include <QMessageBox>
|
||||
|
||||
|
||||
bool isProgramRunning(const QString &program_name);
|
||||
void showErrorMessage(const char *text);
|
27
src/main.cpp
27
src/main.cpp
|
@ -1,6 +1,6 @@
|
|||
#include "mainwindow.h"
|
||||
#include "virtmic.h"
|
||||
#include "utils.h"
|
||||
#include "localserver.h"
|
||||
|
||||
#ifdef KXMLGUI
|
||||
#include <KAboutData>
|
||||
|
@ -16,18 +16,7 @@
|
|||
int main(int argc, char *argv[]) {
|
||||
QApplication app(argc, argv);
|
||||
|
||||
// Check if discord is already running
|
||||
QString program_name = "discord-screenaudio";
|
||||
if (isProgramRunning(program_name)) {
|
||||
// if running show error message
|
||||
showErrorMessage("discord-screenaudio is already running");
|
||||
return 1;
|
||||
}
|
||||
|
||||
// open server so we can check if discord is running
|
||||
QLocalServer server;
|
||||
server.listen(program_name);
|
||||
QObject::connect(&server, &QLocalServer::newConnection, []() {});
|
||||
|
||||
QApplication::setApplicationName("discord-screenaudio");
|
||||
QApplication::setWindowIcon(
|
||||
|
@ -68,6 +57,20 @@ int main(int argc, char *argv[]) {
|
|||
qgetenv("QTWEBENGINE_CHROMIUM_FLAGS"));
|
||||
|
||||
MainWindow w(parser.isSet(notifySendOption));
|
||||
|
||||
// Check if discord is already running
|
||||
QString program_name = "discord-screenaudio";
|
||||
if (isProgramRunning(program_name)) {
|
||||
// if running show error message
|
||||
showErrorMessage("discord-screenaudio is already running");
|
||||
return 1;
|
||||
}
|
||||
|
||||
// open server so we can check if discord is running
|
||||
QLocalServer server;
|
||||
server.listen(program_name);
|
||||
QObject::connect(&server, &QLocalServer::newConnection, []() {});
|
||||
|
||||
w.show();
|
||||
|
||||
return app.exec();
|
||||
|
|
Loading…
Reference in New Issue