Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 1 addition & 39 deletions src/app/main.cpp
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
// SPDX-FileCopyrightText: 2017 - 2022 UnionTech Software Technology Co., Ltd.
// SPDX-FileCopyrightText: 2017 - 2026 UnionTech Software Technology Co., Ltd.
//
// SPDX-License-Identifier: GPL-3.0-only

#include <QDebug>

Check warning on line 5 in src/app/main.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: <QDebug> not found. Please note: Cppcheck does not need standard library headers to get proper results.
#include <QIcon>

Check warning on line 6 in src/app/main.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: <QIcon> not found. Please note: Cppcheck does not need standard library headers to get proper results.
#include <QProcess>

#include "bmwindow.h"

Check warning on line 8 in src/app/main.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: "bmwindow.h" not found.
#include <bminterface.h>

Check warning on line 9 in src/app/main.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: <bminterface.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
#include <util/utils.h>

#include <DLog>
Expand All @@ -19,36 +18,6 @@
DCORE_USE_NAMESPACE
DWIDGET_USE_NAMESPACE

#ifdef Q_OS_MAC
static bool switchToRoot(QApplication &app)
{
QStringList allappargs = app.arguments();
QProcess whoamip;
whoamip.start("whoami");
whoamip.waitForFinished();

if (QString(whoamip.readAll()).remove("\r").remove("\n") != "root") {
QString argsconc = "";
QString argsconcSingleQuote = "";

for (int i = 1; i < allappargs.size(); ++i) {
argsconc += QString("\"%1\" ").arg(allappargs.at(i));
argsconcSingleQuote += QString("'%1' ").arg(allappargs.at(i));
}

argsconc += "\"rootcheck=no\"";
argsconcSingleQuote += "'rootcheck=no'";

QProcess::startDetached("osascript", QStringList() << "-e" << QString("do shell script \"'%1' %2\" with administrator privileges").arg(app.applicationFilePath()).arg(argsconcSingleQuote));
return true;

}

return false;
}

#endif

int main(int argc, char **argv)
{
Utils::initResource();
Expand All @@ -73,22 +42,15 @@
// app.setApplicationVersion(DApplication::buildVersion(VERSION));
// app.setTheme("light");

#ifdef Q_OS_MAC
if (switchToRoot(app)) {
exit(0);
}
#endif
const QString m_format = "%{time}{yyyyMMdd.HH:mm:ss.zzz}[%{type:1}][%{function:-40} %{line:-4} %{threadid:-8} ] %{message}\n";
DLogManager::setLogFormat(m_format);
DLogManager::registerConsoleAppender();
DLogManager::registerFileAppender();

#ifndef Q_OS_MAC
qputenv("DTK_USE_SEMAPHORE_SINGLEINSTANCE", "1");
if (!DGuiApplicationHelper::instance()->setSingleInstance(app.applicationName(), DGuiApplicationHelper::UserScope)) {
exit(0);
}
#endif

#ifdef Q_OS_WIN
Utils::loadFonts();
Expand Down
Loading