Added basic high privilege checks and message box

This commit is contained in:
AdenKoperczak 2024-12-19 14:31:12 -05:00
parent d81f187d88
commit 71f967d536
4 changed files with 75 additions and 2 deletions

View file

@ -13,6 +13,7 @@
#include <scwx/qt/settings/general_settings.hpp>
#include <scwx/qt/types/qt_types.hpp>
#include <scwx/qt/ui/setup/setup_wizard.hpp>
#include <scwx/qt/util/check_privilege.hpp>
#include <scwx/network/cpr.hpp>
#include <scwx/util/environment.hpp>
#include <scwx/util/logger.hpp>
@ -31,6 +32,8 @@
#include <QPalette>
#include <QStyle>
#include <QMessageBox>
#define QT6CT_LIBRARY
#include <qt6ct-common/qt6ct.h>
#undef QT6CT_LIBRARY
@ -73,6 +76,20 @@ int main(int argc, char* argv[])
QCoreApplication::installTranslator(&translator);
}
// Test to see if scwx was run with high privilege
if (scwx::qt::util::is_high_privilege())
{
QMessageBox::StandardButton pressed = QMessageBox::warning(
nullptr,
"Warning: Running with High Privileges",
"Although Supercell-Wx can be run with high privileges, "
"it is not recommended",
QMessageBox::Ok | QMessageBox::Close);
if (pressed & QMessageBox::Ok) {
return 0;
}
}
if (!scwx::util::GetEnvironment("SCWX_TEST").empty())
{
QStandardPaths::setTestModeEnabled(true);