mirror of
https://github.com/ciphervance/supercell-wx.git
synced 2025-11-01 09:00:05 +00:00
Add specific dialog and setting for high privilege warning
This commit is contained in:
parent
71f967d536
commit
923dad4e2e
7 changed files with 274 additions and 18 deletions
47
scwx-qt/source/scwx/qt/ui/high_privilege_dialog.cpp
Normal file
47
scwx-qt/source/scwx/qt/ui/high_privilege_dialog.cpp
Normal file
|
|
@ -0,0 +1,47 @@
|
|||
#include "high_privilege_dialog.hpp"
|
||||
#include "ui_high_privilege_dialog.h"
|
||||
|
||||
#include <scwx/util/logger.hpp>
|
||||
#include <QPushButton>
|
||||
|
||||
namespace scwx
|
||||
{
|
||||
namespace qt
|
||||
{
|
||||
namespace ui
|
||||
{
|
||||
|
||||
static const std::string logPrefix_ = "scwx::qt::ui::high_privilege_dialog";
|
||||
static const auto logger_ = scwx::util::Logger::Create(logPrefix_);
|
||||
|
||||
class HighPrivilegeDialogImpl
|
||||
{
|
||||
public:
|
||||
explicit HighPrivilegeDialogImpl(HighPrivilegeDialog* self) :
|
||||
self_ {self} {};
|
||||
~HighPrivilegeDialogImpl() = default;
|
||||
|
||||
HighPrivilegeDialog* self_;
|
||||
};
|
||||
|
||||
HighPrivilegeDialog::HighPrivilegeDialog(QWidget* parent) :
|
||||
QDialog(parent),
|
||||
p {std::make_unique<HighPrivilegeDialogImpl>(this)},
|
||||
ui(new Ui::HighPrivilegeDialog)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
}
|
||||
|
||||
bool HighPrivilegeDialog::disable_high_privilege_message() {
|
||||
return ui->highPrivilegeCheckBox->isChecked();
|
||||
}
|
||||
|
||||
HighPrivilegeDialog::~HighPrivilegeDialog()
|
||||
{
|
||||
delete ui;
|
||||
}
|
||||
|
||||
} // namespace ui
|
||||
} // namespace qt
|
||||
} // namespace scwx
|
||||
|
||||
40
scwx-qt/source/scwx/qt/ui/high_privilege_dialog.hpp
Normal file
40
scwx-qt/source/scwx/qt/ui/high_privilege_dialog.hpp
Normal file
|
|
@ -0,0 +1,40 @@
|
|||
#pragma once
|
||||
|
||||
#include <QDialog>
|
||||
|
||||
namespace Ui
|
||||
{
|
||||
class HighPrivilegeDialog;
|
||||
}
|
||||
|
||||
namespace scwx
|
||||
{
|
||||
namespace qt
|
||||
{
|
||||
namespace ui
|
||||
{
|
||||
|
||||
class HighPrivilegeDialogImpl;
|
||||
|
||||
class HighPrivilegeDialog : public QDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
private:
|
||||
Q_DISABLE_COPY(HighPrivilegeDialog)
|
||||
|
||||
public:
|
||||
explicit HighPrivilegeDialog(QWidget* parent = nullptr);
|
||||
~HighPrivilegeDialog();
|
||||
|
||||
bool disable_high_privilege_message();
|
||||
|
||||
private:
|
||||
friend HighPrivilegeDialogImpl;
|
||||
std::unique_ptr<HighPrivilegeDialogImpl> p;
|
||||
Ui::HighPrivilegeDialog* ui;
|
||||
};
|
||||
|
||||
} // namespace ui
|
||||
} // namespace qt
|
||||
} // namespace scwx
|
||||
101
scwx-qt/source/scwx/qt/ui/high_privilege_dialog.ui
Normal file
101
scwx-qt/source/scwx/qt/ui/high_privilege_dialog.ui
Normal file
|
|
@ -0,0 +1,101 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>HighPrivilegeDialog</class>
|
||||
<widget class="QDialog" name="HighPrivilegeDialog">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>301</width>
|
||||
<height>269</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Minimum">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Warning: High Privilege</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Minimum">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string><html><head/><body><h1 align="center" style=" margin-top:18px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:xx-large; font-weight:700; color:#ff0000;">Warning: Run Supercell Wx with Low Privileges.</span></h1><p align="center">Please run Supercell Wx without admin or root permissions. Supercell Wx should not need such permissions to run. If you do not want to run Supercell Wx with high privilege, click &quot;Close&quot;, and relaunch with lower permissions. Otherwise, click &quot;Ignore&quot;. You may disable this warning with the checkbox below.</p></body></html></string>
|
||||
</property>
|
||||
<property name="textFormat">
|
||||
<enum>Qt::TextFormat::RichText</enum>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignmentFlag::AlignLeading|Qt::AlignmentFlag::AlignLeft|Qt::AlignmentFlag::AlignTop</set>
|
||||
</property>
|
||||
<property name="wordWrap">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="highPrivilegeCheckBox">
|
||||
<property name="text">
|
||||
<string>Disable High Privilege Warning</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QDialogButtonBox" name="buttonBox">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Orientation::Horizontal</enum>
|
||||
</property>
|
||||
<property name="standardButtons">
|
||||
<set>QDialogButtonBox::StandardButton::Close|QDialogButtonBox::StandardButton::Ignore</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources>
|
||||
<include location="../../../../scwx-qt.qrc"/>
|
||||
</resources>
|
||||
<connections>
|
||||
<connection>
|
||||
<sender>buttonBox</sender>
|
||||
<signal>accepted()</signal>
|
||||
<receiver>HighPrivilegeDialog</receiver>
|
||||
<slot>accept()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>248</x>
|
||||
<y>254</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>157</x>
|
||||
<y>274</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
<connection>
|
||||
<sender>buttonBox</sender>
|
||||
<signal>rejected()</signal>
|
||||
<receiver>HighPrivilegeDialog</receiver>
|
||||
<slot>reject()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>316</x>
|
||||
<y>260</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>286</x>
|
||||
<y>274</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
</connections>
|
||||
</ui>
|
||||
Loading…
Add table
Add a link
Reference in a new issue