format code
This commit is contained in:
parent
b582584c69
commit
6c9b76ed90
33
src/main.cpp
33
src/main.cpp
|
@ -7,33 +7,30 @@
|
||||||
|
|
||||||
#include <QApplication>
|
#include <QApplication>
|
||||||
#include <QCommandLineParser>
|
#include <QCommandLineParser>
|
||||||
|
#include <QLocalServer>
|
||||||
|
#include <QLocalSocket>
|
||||||
#include <QLoggingCategory>
|
#include <QLoggingCategory>
|
||||||
#include <QMessageBox>
|
#include <QMessageBox>
|
||||||
#include <QLocalSocket>
|
|
||||||
#include <QLocalServer>
|
|
||||||
|
|
||||||
void showErrorMessage(const char* text) {
|
void showErrorMessage(const char *text) {
|
||||||
QMessageBox msgBox;
|
QMessageBox msgBox;
|
||||||
|
|
||||||
msgBox.setIcon(QMessageBox::Critical);
|
msgBox.setIcon(QMessageBox::Critical);
|
||||||
msgBox.setText(text);
|
msgBox.setText(text);
|
||||||
msgBox.setStandardButtons(QMessageBox::Ok);
|
msgBox.setStandardButtons(QMessageBox::Ok);
|
||||||
msgBox.setDefaultButton(QMessageBox::Ok);
|
msgBox.setDefaultButton(QMessageBox::Ok);
|
||||||
msgBox.setWindowIcon(
|
msgBox.setWindowIcon(QIcon(":assets/de.shorsh.discord-screenaudio.png"));
|
||||||
QIcon(":assets/de.shorsh.discord-screenaudio.png"));
|
|
||||||
|
|
||||||
msgBox.exec();
|
msgBox.exec();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool isProgramRunning(const QString &program_name) {
|
||||||
bool isProgramRunning(const QString& program_name)
|
QLocalSocket socket;
|
||||||
{
|
socket.connectToServer(program_name);
|
||||||
QLocalSocket socket;
|
if (socket.waitForConnected()) {
|
||||||
socket.connectToServer(program_name);
|
return true; // program is already running
|
||||||
if (socket.waitForConnected()) {
|
}
|
||||||
return true; // program is already running
|
return false;
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int main(int argc, char *argv[]) {
|
int main(int argc, char *argv[]) {
|
||||||
|
@ -42,15 +39,15 @@ int main(int argc, char *argv[]) {
|
||||||
// Check if discord is already running
|
// Check if discord is already running
|
||||||
QString program_name = "discord-screenaudio";
|
QString program_name = "discord-screenaudio";
|
||||||
if (isProgramRunning(program_name)) {
|
if (isProgramRunning(program_name)) {
|
||||||
// if running show error message
|
// if running show error message
|
||||||
showErrorMessage("Discord is already running");
|
showErrorMessage("Discord is already running");
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
// open server so we can check if discord is running
|
// open server so we can check if discord is running
|
||||||
QLocalServer server;
|
QLocalServer server;
|
||||||
server.listen(program_name);
|
server.listen(program_name);
|
||||||
QObject::connect(&server, &QLocalServer::newConnection, [](){});
|
QObject::connect(&server, &QLocalServer::newConnection, []() {});
|
||||||
|
|
||||||
QApplication::setApplicationName("discord-screenaudio");
|
QApplication::setApplicationName("discord-screenaudio");
|
||||||
QApplication::setWindowIcon(
|
QApplication::setWindowIcon(
|
||||||
|
|
Loading…
Reference in New Issue