mirror of
https://github.com/tnodir/fort
synced 2024-11-15 11:25:08 +00:00
UI: Options: Prepare Rules tab
This commit is contained in:
parent
c1a6ae1ffc
commit
f531ee54c3
@ -12,6 +12,7 @@ QT_FORWARD_DECLARE_CLASS(QLabel)
|
|||||||
QT_FORWARD_DECLARE_CLASS(QLineEdit)
|
QT_FORWARD_DECLARE_CLASS(QLineEdit)
|
||||||
QT_FORWARD_DECLARE_CLASS(QMenu)
|
QT_FORWARD_DECLARE_CLASS(QMenu)
|
||||||
QT_FORWARD_DECLARE_CLASS(QPushButton)
|
QT_FORWARD_DECLARE_CLASS(QPushButton)
|
||||||
|
QT_FORWARD_DECLARE_CLASS(QSplitter)
|
||||||
QT_FORWARD_DECLARE_CLASS(QTabBar)
|
QT_FORWARD_DECLARE_CLASS(QTabBar)
|
||||||
|
|
||||||
class ConfManager;
|
class ConfManager;
|
||||||
|
@ -1,14 +1,203 @@
|
|||||||
#include "rulespage.h"
|
#include "rulespage.h"
|
||||||
|
|
||||||
RulesPage::RulesPage(OptionsController *ctrl, QWidget *parent) : OptBasePage(ctrl, parent)
|
#include <QGroupBox>
|
||||||
|
#include <QHBoxLayout>
|
||||||
|
#include <QHeaderView>
|
||||||
|
#include <QSplitter>
|
||||||
|
#include <QVBoxLayout>
|
||||||
|
|
||||||
|
#include <form/controls/tableview.h>
|
||||||
|
#include <model/policylistmodel.h>
|
||||||
|
#include <user/iniuser.h>
|
||||||
|
|
||||||
|
RulesPage::RulesPage(OptionsController *ctrl, QWidget *parent) :
|
||||||
|
OptBasePage(ctrl, parent),
|
||||||
|
m_presetLibListModel(new PolicyListModel(PolicyListModel::PolicyListPresetLibrary, this)),
|
||||||
|
m_presetAppListModel(new PolicyListModel(PolicyListModel::PolicyListPresetApp, this)),
|
||||||
|
m_globalPreListModel(new PolicyListModel(PolicyListModel::PolicyListGlobalBeforeApp, this)),
|
||||||
|
m_globalPostListModel(new PolicyListModel(PolicyListModel::PolicyListGlobalAfterApp, this))
|
||||||
{
|
{
|
||||||
setupUi();
|
setupUi();
|
||||||
|
|
||||||
|
presetAppListModel()->initialize();
|
||||||
|
presetLibListModel()->initialize();
|
||||||
|
globalPreListModel()->initialize();
|
||||||
|
globalPostListModel()->initialize();
|
||||||
}
|
}
|
||||||
|
|
||||||
void RulesPage::onSaveWindowState(IniUser * /*ini*/) { }
|
void RulesPage::onSaveWindowState(IniUser *ini)
|
||||||
|
{
|
||||||
|
ini->setOptWindowRulesSplit(m_splitter->saveState());
|
||||||
|
ini->setOptWindowRulesPresetSplit(m_presetSplitter->saveState());
|
||||||
|
ini->setOptWindowRulesGlobalSplit(m_globalSplitter->saveState());
|
||||||
|
}
|
||||||
|
|
||||||
void RulesPage::onRestoreWindowState(IniUser * /*ini*/) { }
|
void RulesPage::onRestoreWindowState(IniUser *ini)
|
||||||
|
{
|
||||||
|
m_splitter->restoreState(ini->optWindowRulesSplit());
|
||||||
|
m_presetSplitter->restoreState(ini->optWindowRulesPresetSplit());
|
||||||
|
m_globalSplitter->restoreState(ini->optWindowRulesGlobalSplit());
|
||||||
|
}
|
||||||
|
|
||||||
void RulesPage::onRetranslateUi() { }
|
void RulesPage::onRetranslateUi()
|
||||||
|
{
|
||||||
|
m_gbPresetLib->setTitle(tr("Library of preset rules:"));
|
||||||
|
m_gbPresetApp->setTitle(tr("Preset rules for applications:"));
|
||||||
|
m_gbGlobalPre->setTitle(tr("Global rules, applied before application rules:"));
|
||||||
|
m_gbGlobalPost->setTitle(tr("Global rules, applied after application rules:"));
|
||||||
|
}
|
||||||
|
|
||||||
void RulesPage::setupUi() { }
|
void RulesPage::setupUi()
|
||||||
|
{
|
||||||
|
// Column #1
|
||||||
|
setupPresetSplitter();
|
||||||
|
|
||||||
|
// Column #2
|
||||||
|
setupGlobalSplitter();
|
||||||
|
|
||||||
|
// Splitter
|
||||||
|
m_splitter = new QSplitter();
|
||||||
|
m_splitter->setHandleWidth(20);
|
||||||
|
m_splitter->addWidget(m_presetSplitter);
|
||||||
|
m_splitter->addWidget(m_globalSplitter);
|
||||||
|
|
||||||
|
// Main layout
|
||||||
|
auto layout = new QHBoxLayout();
|
||||||
|
layout->addWidget(m_splitter);
|
||||||
|
|
||||||
|
this->setLayout(layout);
|
||||||
|
}
|
||||||
|
|
||||||
|
void RulesPage::setupPresetSplitter()
|
||||||
|
{
|
||||||
|
// Preset Lib Group Box
|
||||||
|
setupPresetLibBox();
|
||||||
|
|
||||||
|
// Preset App Group Box
|
||||||
|
setupPresetAppBox();
|
||||||
|
|
||||||
|
// Splitter
|
||||||
|
m_presetSplitter = new QSplitter();
|
||||||
|
m_presetSplitter->setHandleWidth(10);
|
||||||
|
m_presetSplitter->setOrientation(Qt::Vertical);
|
||||||
|
m_presetSplitter->addWidget(m_gbPresetLib);
|
||||||
|
m_presetSplitter->addWidget(m_gbPresetApp);
|
||||||
|
}
|
||||||
|
|
||||||
|
void RulesPage::setupPresetLibBox()
|
||||||
|
{
|
||||||
|
setupPresetLibView();
|
||||||
|
|
||||||
|
auto layout = new QVBoxLayout();
|
||||||
|
layout->setContentsMargins(0, 0, 0, 0);
|
||||||
|
layout->addWidget(m_presetLibListView);
|
||||||
|
|
||||||
|
m_gbPresetLib = new QGroupBox(this);
|
||||||
|
m_gbPresetLib->setFlat(true);
|
||||||
|
m_gbPresetLib->setLayout(layout);
|
||||||
|
}
|
||||||
|
|
||||||
|
void RulesPage::setupPresetLibView()
|
||||||
|
{
|
||||||
|
m_presetLibListView = new TableView();
|
||||||
|
m_presetLibListView->setAlternatingRowColors(true);
|
||||||
|
m_presetLibListView->setSelectionMode(QAbstractItemView::SingleSelection);
|
||||||
|
m_presetLibListView->setSelectionBehavior(QAbstractItemView::SelectItems);
|
||||||
|
|
||||||
|
m_presetLibListView->horizontalHeader()->setVisible(false);
|
||||||
|
|
||||||
|
m_presetLibListView->setModel(presetLibListModel());
|
||||||
|
|
||||||
|
// m_presetLibListView->setMenu(m_btEdit->menu());
|
||||||
|
}
|
||||||
|
|
||||||
|
void RulesPage::setupPresetAppBox()
|
||||||
|
{
|
||||||
|
setupPresetAppView();
|
||||||
|
|
||||||
|
auto layout = new QVBoxLayout();
|
||||||
|
layout->setContentsMargins(0, 0, 0, 0);
|
||||||
|
layout->addWidget(m_presetAppListView);
|
||||||
|
|
||||||
|
m_gbPresetApp = new QGroupBox(this);
|
||||||
|
m_gbPresetApp->setFlat(true);
|
||||||
|
m_gbPresetApp->setLayout(layout);
|
||||||
|
}
|
||||||
|
|
||||||
|
void RulesPage::setupPresetAppView()
|
||||||
|
{
|
||||||
|
m_presetAppListView = new TableView();
|
||||||
|
m_presetAppListView->setAlternatingRowColors(true);
|
||||||
|
m_presetAppListView->setSelectionMode(QAbstractItemView::SingleSelection);
|
||||||
|
m_presetAppListView->setSelectionBehavior(QAbstractItemView::SelectItems);
|
||||||
|
|
||||||
|
m_presetAppListView->horizontalHeader()->setVisible(false);
|
||||||
|
|
||||||
|
m_presetAppListView->setModel(presetAppListModel());
|
||||||
|
}
|
||||||
|
|
||||||
|
void RulesPage::setupGlobalSplitter()
|
||||||
|
{
|
||||||
|
// Global Pre Group Box
|
||||||
|
setupGlobalPreBox();
|
||||||
|
|
||||||
|
// Global Post Group Box
|
||||||
|
setupGlobalPostBox();
|
||||||
|
|
||||||
|
// Splitter
|
||||||
|
m_globalSplitter = new QSplitter();
|
||||||
|
m_globalSplitter->setHandleWidth(10);
|
||||||
|
m_globalSplitter->setOrientation(Qt::Vertical);
|
||||||
|
m_globalSplitter->addWidget(m_gbGlobalPre);
|
||||||
|
m_globalSplitter->addWidget(m_gbGlobalPost);
|
||||||
|
}
|
||||||
|
|
||||||
|
void RulesPage::setupGlobalPreBox()
|
||||||
|
{
|
||||||
|
setupGlobalPreView();
|
||||||
|
|
||||||
|
auto layout = new QVBoxLayout();
|
||||||
|
layout->setContentsMargins(0, 0, 0, 0);
|
||||||
|
layout->addWidget(m_globalPreListView);
|
||||||
|
|
||||||
|
m_gbGlobalPre = new QGroupBox(this);
|
||||||
|
m_gbGlobalPre->setFlat(true);
|
||||||
|
m_gbGlobalPre->setLayout(layout);
|
||||||
|
}
|
||||||
|
|
||||||
|
void RulesPage::setupGlobalPreView()
|
||||||
|
{
|
||||||
|
m_globalPreListView = new TableView();
|
||||||
|
m_globalPreListView->setAlternatingRowColors(true);
|
||||||
|
m_globalPreListView->setSelectionMode(QAbstractItemView::SingleSelection);
|
||||||
|
m_globalPreListView->setSelectionBehavior(QAbstractItemView::SelectItems);
|
||||||
|
|
||||||
|
m_globalPreListView->horizontalHeader()->setVisible(false);
|
||||||
|
|
||||||
|
m_globalPreListView->setModel(globalPreListModel());
|
||||||
|
}
|
||||||
|
|
||||||
|
void RulesPage::setupGlobalPostBox()
|
||||||
|
{
|
||||||
|
setupGlobalPostView();
|
||||||
|
|
||||||
|
auto layout = new QVBoxLayout();
|
||||||
|
layout->setContentsMargins(0, 0, 0, 0);
|
||||||
|
layout->addWidget(m_globalPostListView);
|
||||||
|
|
||||||
|
m_gbGlobalPost = new QGroupBox(this);
|
||||||
|
m_gbGlobalPost->setFlat(true);
|
||||||
|
m_gbGlobalPost->setLayout(layout);
|
||||||
|
}
|
||||||
|
|
||||||
|
void RulesPage::setupGlobalPostView()
|
||||||
|
{
|
||||||
|
m_globalPostListView = new TableView();
|
||||||
|
m_globalPostListView->setAlternatingRowColors(true);
|
||||||
|
m_globalPostListView->setSelectionMode(QAbstractItemView::SingleSelection);
|
||||||
|
m_globalPostListView->setSelectionBehavior(QAbstractItemView::SelectItems);
|
||||||
|
|
||||||
|
m_globalPostListView->horizontalHeader()->setVisible(false);
|
||||||
|
|
||||||
|
m_globalPostListView->setModel(globalPostListModel());
|
||||||
|
}
|
||||||
|
@ -3,6 +3,9 @@
|
|||||||
|
|
||||||
#include "optbasepage.h"
|
#include "optbasepage.h"
|
||||||
|
|
||||||
|
class PolicyListModel;
|
||||||
|
class TableView;
|
||||||
|
|
||||||
class RulesPage : public OptBasePage
|
class RulesPage : public OptBasePage
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
@ -10,6 +13,11 @@ class RulesPage : public OptBasePage
|
|||||||
public:
|
public:
|
||||||
explicit RulesPage(OptionsController *ctrl = nullptr, QWidget *parent = nullptr);
|
explicit RulesPage(OptionsController *ctrl = nullptr, QWidget *parent = nullptr);
|
||||||
|
|
||||||
|
PolicyListModel *presetLibListModel() const { return m_presetLibListModel; }
|
||||||
|
PolicyListModel *presetAppListModel() const { return m_presetAppListModel; }
|
||||||
|
PolicyListModel *globalPreListModel() const { return m_globalPreListModel; }
|
||||||
|
PolicyListModel *globalPostListModel() const { return m_globalPostListModel; }
|
||||||
|
|
||||||
protected slots:
|
protected slots:
|
||||||
void onSaveWindowState(IniUser *ini) override;
|
void onSaveWindowState(IniUser *ini) override;
|
||||||
void onRestoreWindowState(IniUser *ini) override;
|
void onRestoreWindowState(IniUser *ini) override;
|
||||||
@ -18,6 +26,34 @@ protected slots:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
void setupUi();
|
void setupUi();
|
||||||
|
void setupPresetSplitter();
|
||||||
|
void setupPresetLibBox();
|
||||||
|
void setupPresetLibView();
|
||||||
|
void setupPresetAppBox();
|
||||||
|
void setupPresetAppView();
|
||||||
|
void setupGlobalSplitter();
|
||||||
|
void setupGlobalPreBox();
|
||||||
|
void setupGlobalPreView();
|
||||||
|
void setupGlobalPostBox();
|
||||||
|
void setupGlobalPostView();
|
||||||
|
|
||||||
|
private:
|
||||||
|
PolicyListModel *m_presetLibListModel = nullptr;
|
||||||
|
PolicyListModel *m_presetAppListModel = nullptr;
|
||||||
|
PolicyListModel *m_globalPreListModel = nullptr;
|
||||||
|
PolicyListModel *m_globalPostListModel = nullptr;
|
||||||
|
|
||||||
|
QGroupBox *m_gbPresetLib = nullptr;
|
||||||
|
QGroupBox *m_gbPresetApp = nullptr;
|
||||||
|
QGroupBox *m_gbGlobalPre = nullptr;
|
||||||
|
QGroupBox *m_gbGlobalPost = nullptr;
|
||||||
|
QSplitter *m_splitter = nullptr;
|
||||||
|
QSplitter *m_presetSplitter = nullptr;
|
||||||
|
QSplitter *m_globalSplitter = nullptr;
|
||||||
|
TableView *m_presetLibListView = nullptr;
|
||||||
|
TableView *m_presetAppListView = nullptr;
|
||||||
|
TableView *m_globalPreListView = nullptr;
|
||||||
|
TableView *m_globalPostListView = nullptr;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // RULESPAGE_H
|
#endif // RULESPAGE_H
|
||||||
|
@ -71,6 +71,27 @@ public:
|
|||||||
QByteArray optWindowAppsSplit() const { return valueByteArray("optWindow/appsSplit"); }
|
QByteArray optWindowAppsSplit() const { return valueByteArray("optWindow/appsSplit"); }
|
||||||
void setOptWindowAppsSplit(const QByteArray &v) { setValue("optWindow/appsSplit", v); }
|
void setOptWindowAppsSplit(const QByteArray &v) { setValue("optWindow/appsSplit", v); }
|
||||||
|
|
||||||
|
QByteArray optWindowRulesPresetSplit() const
|
||||||
|
{
|
||||||
|
return valueByteArray("optWindow/rulesPresetSplit");
|
||||||
|
}
|
||||||
|
void setOptWindowRulesPresetSplit(const QByteArray &v)
|
||||||
|
{
|
||||||
|
setValue("optWindow/rulesPresetSplit", v);
|
||||||
|
}
|
||||||
|
|
||||||
|
QByteArray optWindowRulesGlobalSplit() const
|
||||||
|
{
|
||||||
|
return valueByteArray("optWindow/rulesGlobalSplit");
|
||||||
|
}
|
||||||
|
void setOptWindowRulesGlobalSplit(const QByteArray &v)
|
||||||
|
{
|
||||||
|
setValue("optWindow/rulesGlobalSplit", v);
|
||||||
|
}
|
||||||
|
|
||||||
|
QByteArray optWindowRulesSplit() const { return valueByteArray("optWindow/rulesSplit"); }
|
||||||
|
void setOptWindowRulesSplit(const QByteArray &v) { setValue("optWindow/rulesSplit", v); }
|
||||||
|
|
||||||
QRect serviceWindowGeometry() const { return value("serviceWindow/geometry").toRect(); }
|
QRect serviceWindowGeometry() const { return value("serviceWindow/geometry").toRect(); }
|
||||||
void setServiceWindowGeometry(const QRect &v) { setValue("serviceWindow/geometry", v); }
|
void setServiceWindowGeometry(const QRect &v) { setValue("serviceWindow/geometry", v); }
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user