Sandboxie/SandboxiePlus/SandMan/Windows/SettingsWindow.h

182 lines
4.2 KiB
C
Raw Normal View History

2021-10-16 16:19:51 +01:00
#pragma once
#include <QtWidgets/QMainWindow>
#include "ui_SettingsWindow.h"
#include <QProxyStyle>
2022-08-15 12:18:26 +01:00
#include "../../MiscHelpers/Common/SettingsWidgets.h"
2021-10-16 16:19:51 +01:00
class CustomTabStyle : public QProxyStyle {
public:
CustomTabStyle(QStyle* style = 0) : QProxyStyle(style) {}
QSize sizeFromContents(ContentsType type, const QStyleOption* option, const QSize& size, const QWidget* widget) const;
void drawControl(ControlElement element, const QStyleOption* option, QPainter* painter, const QWidget* widget) const;
};
2022-08-10 19:14:37 +01:00
void FixTriStateBoxPallete(QWidget* pWidget);
2022-07-01 07:37:29 +01:00
class CSecretCheckBox : public QCheckBox
{
Q_OBJECT
public:
CSecretCheckBox(const QString& Text) : QCheckBox(Text)
{
setTristate(false);
m_SecretMode = false;
}
bool IsSecretSet() const { return m_SecretMode && this->checkState() == Qt::PartiallyChecked; }
protected:
void mouseDoubleClickEvent(QMouseEvent* e)
{
if (QApplication::keyboardModifiers() & Qt::ControlModifier) {
setTristate();
m_SecretMode = true;
}
}
bool m_SecretMode;
};
2021-10-16 16:19:51 +01:00
2022-09-29 17:28:48 +01:00
void AddIconToLabel(QLabel* pLabel, const QPixmap& Pixmap);
2022-08-15 12:18:26 +01:00
//////////////////////////////////////////////////////////////////////////
// CSettingsWindow
class CSettingsWindow : public CConfigDialog
2021-10-16 16:19:51 +01:00
{
Q_OBJECT
public:
CSettingsWindow(QWidget *parent = Q_NULLPTR);
~CSettingsWindow();
virtual void accept() {}
virtual void reject();
2022-05-15 14:02:58 +01:00
static bool ApplyCertificate(const QByteArray &Certificate, QWidget* widget);
2022-07-09 10:46:07 +01:00
static void LoadCertificate(QString CertPath = QString());
enum ETabs {
eOptions = 0,
eShell,
eGuiConfig,
eAdvanced,
eProgCtrl,
eConfigLock,
eSoftCompat,
eEditIni,
eSupport
};
2021-10-16 16:19:51 +01:00
signals:
2022-07-09 10:46:07 +01:00
void OptionsChanged(bool bRebuildUI = false);
2021-10-16 16:19:51 +01:00
void Closed();
public slots:
void ok();
void apply();
2022-07-10 17:28:10 +01:00
void showTab(int Tab, bool bExclusive = false);
2021-10-16 16:19:51 +01:00
private slots:
void OnChange();
void OnTab();
2022-07-09 10:46:07 +01:00
void OnChangeGUI() { m_bRebuildUI = true; }
2021-10-16 16:19:51 +01:00
void OnFeaturesChanged() { m_FeaturesChanged = true; }
void OnBrowse();
void OnSetPassword();
void OnWarnChanged() { m_WarnProgsChanged = true; }
void OnAddWarnProg();
void OnAddWarnFolder();
void OnDelWarnProg();
void OnTemplateClicked(QTreeWidgetItem* pItem, int Column);
2022-05-29 07:07:17 +01:00
void OnTemplateDoubleClicked(QTreeWidgetItem* pItem, int Column);
2021-10-16 16:19:51 +01:00
void OnAddCompat();
void OnDelCompat();
2022-01-13 22:52:58 +00:00
void SetIniEdit(bool bEnable);
void OnEditIni();
void OnSaveIni();
void OnCancelEdit();
2021-10-16 16:19:51 +01:00
void CertChanged();
2022-01-13 22:52:58 +00:00
void UpdateCert();
2021-10-16 16:19:51 +01:00
2022-08-11 23:09:35 +01:00
void GetUpdates();
void OnUpdateData(const QVariantMap& Data, const QVariantMap& Params);
void OnUpdate(const QString& Channel);
2022-08-15 12:18:26 +01:00
void OnSetTree();
2021-10-16 16:19:51 +01:00
protected:
void closeEvent(QCloseEvent *e);
2022-08-15 12:18:26 +01:00
bool eventFilter(QObject *watched, QEvent *e);
2022-09-29 17:28:48 +01:00
void OnTab(QWidget* pTab);
2022-08-15 12:18:26 +01:00
2021-10-16 16:19:51 +01:00
void AddWarnEntry(const QString& Name, int type);
void LoadSettings();
void SaveSettings();
2022-01-13 22:52:58 +00:00
void LoadIniSection();
void SaveIniSection();
2022-07-09 10:46:07 +01:00
bool m_bRebuildUI;
2021-10-16 16:19:51 +01:00
int m_CompatLoaded;
QString m_NewPassword;
bool m_WarnProgsChanged;
bool m_CompatChanged;
bool m_FeaturesChanged;
bool m_CertChanged;
2022-08-11 23:09:35 +01:00
QVariantMap m_UpdateData;
2022-07-24 14:30:54 +01:00
2021-10-16 16:19:51 +01:00
private:
2022-07-24 14:30:54 +01:00
void WriteAdvancedCheck(QCheckBox* pCheck, const QString& Name, const QString& OnValue, const QString& OffValue);
void WriteText(const QString& Name, const QString& Value);
void WriteTextList(const QString& Setting, const QStringList& List);
2021-10-16 16:19:51 +01:00
Ui::SettingsWindow ui;
};
2022-07-01 07:19:30 +01:00
void CSettingsWindow__AddContextMenu(bool bAlwaysClassic = false);
2022-05-15 12:26:22 +01:00
void CSettingsWindow__RemoveContextMenu();
void CSettingsWindow__AddBrowserIcon();
2022-02-04 21:08:25 +00:00
2021-10-16 16:19:51 +01:00
void WindowsMoveFile(const QString& from, const QString& to);
2022-01-13 22:52:58 +00:00
extern quint32 g_FeatureFlags;
2021-10-16 16:19:51 +01:00
extern QByteArray g_Certificate;
2022-01-13 22:52:58 +00:00
union SCertInfo {
quint64 State;
struct {
quint32
2022-01-30 14:53:37 +00:00
valid : 1, // certificate is active
expired : 1, // certificate is expired but may be active
outdated : 1, // certificate is expired, not anymore valid for the current build
business : 1, // certificate is siutable for business use
2022-08-09 17:19:46 +01:00
evaluation: 1, // evaluation certificate
reservd_1 : 3,
2022-01-13 22:52:58 +00:00
reservd_2 : 8,
reservd_3 : 8,
reservd_4 : 8;
2022-08-09 17:19:46 +01:00
qint32
2022-01-13 22:52:58 +00:00
expirers_in_sec : 30,
unused_1 : 1, // skim a couple high bits to use as flags flag, 0x3fffffff -> is 34 years count down isenough
about_to_expire : 1;
};
};
extern SCertInfo g_CertInfo;