mirror of
https://github.com/tnodir/fort
synced 2024-11-15 01:55:44 +00:00
Add AppsColumn.
This commit is contained in:
parent
15ae2c10b0
commit
a89354f0ea
@ -7,6 +7,10 @@
|
||||
class AppGroup : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_PROPERTY(bool enabled READ enabled WRITE setEnabled NOTIFY enabledChanged)
|
||||
Q_PROPERTY(QString name READ name WRITE setName NOTIFY nameChanged)
|
||||
Q_PROPERTY(QString blockText READ blockText WRITE setBlockText NOTIFY blockTextChanged)
|
||||
Q_PROPERTY(QString allowText READ allowText WRITE setAllowText NOTIFY allowTextChanged)
|
||||
|
||||
public:
|
||||
explicit AppGroup(QObject *parent = nullptr);
|
||||
|
@ -85,6 +85,13 @@ void FirewallConf::addAppGroup(AppGroup *appGroup, int to)
|
||||
emit appGroupsChanged();
|
||||
}
|
||||
|
||||
void FirewallConf::addAppGroupByName(const QString &name)
|
||||
{
|
||||
AppGroup *appGroup = new AppGroup();
|
||||
appGroup->setName(name);
|
||||
addAppGroup(appGroup);
|
||||
}
|
||||
|
||||
void FirewallConf::moveAppGroup(int from, int to)
|
||||
{
|
||||
m_appGroups.move(from, to);
|
||||
@ -94,7 +101,9 @@ void FirewallConf::moveAppGroup(int from, int to)
|
||||
void FirewallConf::removeAppGroup(int from, int to)
|
||||
{
|
||||
for (int i = to; i >= from; --i) {
|
||||
delete m_appGroups.at(i);
|
||||
AppGroup *appGroup = m_appGroups.at(i);
|
||||
appGroup->deleteLater();
|
||||
|
||||
m_appGroups.removeAt(i);
|
||||
}
|
||||
emit appGroupsChanged();
|
||||
|
@ -44,10 +44,6 @@ public:
|
||||
const QList<AppGroup *> &appGroupsList() const { return m_appGroups; }
|
||||
QQmlListProperty<AppGroup> appGroups();
|
||||
|
||||
void addAppGroup(AppGroup *appGroup, int to = -1);
|
||||
void moveAppGroup(int from, int to);
|
||||
void removeAppGroup(int from, int to);
|
||||
|
||||
QVariant toVariant() const;
|
||||
void fromVariant(const QVariant &v);
|
||||
|
||||
@ -59,6 +55,10 @@ signals:
|
||||
void appGroupsChanged();
|
||||
|
||||
public slots:
|
||||
void addAppGroup(AppGroup *appGroup, int to = -1);
|
||||
void addAppGroupByName(const QString &name);
|
||||
void moveAppGroup(int from, int to);
|
||||
void removeAppGroup(int from, int to);
|
||||
|
||||
private:
|
||||
uint m_filterEnabled : 1;
|
||||
|
@ -1,5 +1,6 @@
|
||||
<RCC>
|
||||
<qresource prefix="/">
|
||||
<file>qml/controls/TextAreaFrame.qml</file>
|
||||
<file>qml/main.qml</file>
|
||||
<file>qml/pages/ActivityPage.qml</file>
|
||||
<file>qml/pages/AddressesPage.qml</file>
|
||||
@ -7,5 +8,7 @@
|
||||
<file>qml/pages/BasePage.qml</file>
|
||||
<file>qml/pages/OptionsPage.qml</file>
|
||||
<file>qml/pages/addresses/AddressesColumn.qml</file>
|
||||
<file>qml/pages/apps/AppsColumn.qml</file>
|
||||
<file>qml/pages/apps/AppsTextColumn.qml</file>
|
||||
</qresource>
|
||||
</RCC>
|
||||
|
@ -79,10 +79,10 @@ bool FortManager::saveConf()
|
||||
void FortManager::handleClosedWindow()
|
||||
{
|
||||
m_engine->deleteLater();
|
||||
m_engine = 0;
|
||||
m_engine = nullptr;
|
||||
|
||||
if (m_firewallConfToEdit && m_firewallConfToEdit != m_firewallConf) {
|
||||
m_firewallConfToEdit->deleteLater();
|
||||
m_firewallConfToEdit = 0;
|
||||
m_firewallConfToEdit = nullptr;
|
||||
}
|
||||
}
|
||||
|
21
src/ui/qml/controls/TextAreaFrame.qml
Normal file
21
src/ui/qml/controls/TextAreaFrame.qml
Normal file
@ -0,0 +1,21 @@
|
||||
import QtQuick 2.9
|
||||
import QtQuick.Controls 2.2
|
||||
|
||||
Frame {
|
||||
id: frame
|
||||
|
||||
signal editingFinished() // Workaround for QTBUG-59908
|
||||
|
||||
readonly property alias textArea: textArea
|
||||
|
||||
padding: 0
|
||||
|
||||
ScrollView {
|
||||
anchors.fill: parent
|
||||
|
||||
TextArea {
|
||||
id: textArea
|
||||
onEditingFinished: frame.editingFinished()
|
||||
}
|
||||
}
|
||||
}
|
@ -13,8 +13,8 @@ ApplicationWindow {
|
||||
|
||||
width: 800
|
||||
height: 600
|
||||
minimumWidth: 400
|
||||
minimumHeight: 300
|
||||
minimumWidth: 540
|
||||
minimumHeight: 500
|
||||
|
||||
font.pixelSize: 16
|
||||
|
||||
|
@ -1,19 +1,45 @@
|
||||
import QtQuick 2.9
|
||||
import QtQuick.Layouts 1.3
|
||||
import QtQuick.Controls 2.2
|
||||
import "apps"
|
||||
import com.fortfirewall 1.0
|
||||
|
||||
BasePage {
|
||||
|
||||
readonly property var appGroups: firewallConf.appGroups
|
||||
|
||||
function resetGroupName() {
|
||||
editGroupName.text = "";
|
||||
editGroupName.forceActiveFocus();
|
||||
}
|
||||
|
||||
ColumnLayout {
|
||||
anchors.fill: parent
|
||||
|
||||
RowLayout {
|
||||
Button {
|
||||
text: QT_TRANSLATE_NOOP("qml", "Add Group")
|
||||
TextField {
|
||||
enabled: rptAppGroups.count < 16
|
||||
id: editGroupName
|
||||
placeholderText: QT_TRANSLATE_NOOP("qml", "Group Name")
|
||||
}
|
||||
Button {
|
||||
text: QT_TRANSLATE_NOOP("qml", "Remove Group")
|
||||
enabled: editGroupName.text
|
||||
text: QT_TRANSLATE_NOOP("qml", "Add Group")
|
||||
onClicked: {
|
||||
const lastIndex = appGroups.length;
|
||||
firewallConf.addAppGroupByName(editGroupName.text);
|
||||
barGroups.currentIndex = lastIndex;
|
||||
resetGroupName();
|
||||
}
|
||||
}
|
||||
Button {
|
||||
enabled: appsColumn.enabled
|
||||
text: QT_TRANSLATE_NOOP("qml", "Rename Group")
|
||||
onClicked: {
|
||||
const appGroup = appsColumn.appGroup;
|
||||
appGroup.name = editGroupName.text;
|
||||
resetGroupName();
|
||||
}
|
||||
}
|
||||
|
||||
Item {
|
||||
@ -22,24 +48,53 @@ BasePage {
|
||||
|
||||
CheckBox {
|
||||
text: QT_TRANSLATE_NOOP("qml", "Block All")
|
||||
checked: firewallConf.appBlockAll
|
||||
onToggled: {
|
||||
firewallConf.appBlockAll = checked;
|
||||
}
|
||||
}
|
||||
CheckBox {
|
||||
text: QT_TRANSLATE_NOOP("qml", "Allow All")
|
||||
checked: firewallConf.appAllowAll
|
||||
onToggled: {
|
||||
firewallConf.appAllowAll = checked;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
TabBar {
|
||||
id: barGroups
|
||||
Layout.fillWidth: true
|
||||
clip: true
|
||||
|
||||
TabButton {
|
||||
text: QT_TRANSLATE_NOOP("qml", "Options")
|
||||
Repeater {
|
||||
id: rptAppGroups
|
||||
model: appGroups
|
||||
|
||||
TabButton {
|
||||
width: Math.max(70, implicitWidth)
|
||||
text: appGroup.name
|
||||
|
||||
readonly property AppGroup appGroup: modelData
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Item {
|
||||
AppsColumn {
|
||||
id: appsColumn
|
||||
Layout.fillWidth: true
|
||||
Layout.fillHeight: true
|
||||
|
||||
enabled: index >= 0
|
||||
opacity: enabled ? 1.0 : 0
|
||||
|
||||
Behavior on opacity { NumberAnimation { duration: 150 } }
|
||||
|
||||
index: barGroups.currentIndex
|
||||
appGroup: enabled ? barGroups.currentItem.appGroup
|
||||
: nullAppGroup
|
||||
|
||||
readonly property AppGroup nullAppGroup: AppGroup {}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -2,5 +2,4 @@ import QtQuick 2.9
|
||||
import QtQuick.Controls 2.2
|
||||
|
||||
Frame {
|
||||
|
||||
}
|
||||
|
@ -1,6 +1,7 @@
|
||||
import QtQuick 2.9
|
||||
import QtQuick.Layouts 1.3
|
||||
import QtQuick.Controls 2.2
|
||||
import "../../controls"
|
||||
import com.fortfirewall 1.0
|
||||
|
||||
ColumnLayout {
|
||||
@ -8,8 +9,8 @@ ColumnLayout {
|
||||
Layout.fillWidth: true
|
||||
Layout.fillHeight: true
|
||||
|
||||
property alias title: title
|
||||
property alias checkBoxAll: checkBoxAll
|
||||
readonly property alias title: title
|
||||
readonly property alias checkBoxAll: checkBoxAll
|
||||
|
||||
property AddressGroup addressGroup
|
||||
|
||||
@ -27,28 +28,23 @@ ColumnLayout {
|
||||
}
|
||||
}
|
||||
|
||||
Frame {
|
||||
TextAreaFrame {
|
||||
Layout.fillWidth: true
|
||||
Layout.fillHeight: true
|
||||
|
||||
padding: 0
|
||||
|
||||
ScrollView {
|
||||
anchors.fill: parent
|
||||
|
||||
TextArea {
|
||||
placeholderText: "
|
||||
textArea {
|
||||
placeholderText: "
|
||||
10.0.0.0/24
|
||||
127.0.0.0/24
|
||||
169.254.0.0/16
|
||||
172.16.0.0/16
|
||||
192.168.0.0/16
|
||||
"
|
||||
text: addressGroup.text
|
||||
onEditingFinished: {
|
||||
addressGroup.text = text;
|
||||
}
|
||||
}
|
||||
text: addressGroup.text
|
||||
}
|
||||
|
||||
onEditingFinished: {
|
||||
addressGroup.text = textArea.text;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
72
src/ui/qml/pages/apps/AppsColumn.qml
Normal file
72
src/ui/qml/pages/apps/AppsColumn.qml
Normal file
@ -0,0 +1,72 @@
|
||||
import QtQuick 2.9
|
||||
import QtQuick.Layouts 1.3
|
||||
import QtQuick.Controls 2.2
|
||||
import com.fortfirewall 1.0
|
||||
|
||||
ColumnLayout {
|
||||
|
||||
property int index
|
||||
property AppGroup appGroup
|
||||
|
||||
RowLayout {
|
||||
Button {
|
||||
text: QT_TRANSLATE_NOOP("qml", "Remove Group")
|
||||
onClicked: {
|
||||
firewallConf.removeAppGroup(index, index);
|
||||
}
|
||||
}
|
||||
|
||||
Item {
|
||||
Layout.fillWidth: true
|
||||
}
|
||||
|
||||
CheckBox {
|
||||
text: QT_TRANSLATE_NOOP("qml", "Enabled")
|
||||
checked: appGroup.enabled
|
||||
onToggled: {
|
||||
appGroup.enabled = checked;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
RowLayout {
|
||||
Layout.fillWidth: true
|
||||
Layout.fillHeight: true
|
||||
spacing: 10
|
||||
|
||||
AppsTextColumn {
|
||||
title {
|
||||
text: QT_TRANSLATE_NOOP("qml", "Block")
|
||||
}
|
||||
|
||||
textArea {
|
||||
placeholderText: "
|
||||
System
|
||||
C:\\Program Files\\Internet Explorer\\iexplore.exe
|
||||
"
|
||||
text: appGroup.blockText
|
||||
}
|
||||
|
||||
onEditingFinished: {
|
||||
appGroup.blockText = textArea.text;
|
||||
}
|
||||
}
|
||||
|
||||
AppsTextColumn {
|
||||
title {
|
||||
text: QT_TRANSLATE_NOOP("qml", "Allow")
|
||||
}
|
||||
|
||||
textArea {
|
||||
placeholderText: "
|
||||
C:\\Program Files\\Skype\\Phone\\Skype.exe
|
||||
"
|
||||
text: appGroup.allowText
|
||||
}
|
||||
|
||||
onEditingFinished: {
|
||||
appGroup.allowText = textArea.text;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
29
src/ui/qml/pages/apps/AppsTextColumn.qml
Normal file
29
src/ui/qml/pages/apps/AppsTextColumn.qml
Normal file
@ -0,0 +1,29 @@
|
||||
import QtQuick 2.9
|
||||
import QtQuick.Layouts 1.3
|
||||
import QtQuick.Controls 2.2
|
||||
import "../../controls"
|
||||
import com.fortfirewall 1.0
|
||||
|
||||
ColumnLayout {
|
||||
id: container
|
||||
Layout.preferredWidth: 100
|
||||
Layout.fillWidth: true
|
||||
Layout.fillHeight: true
|
||||
|
||||
signal editingFinished() // Workaround for QTBUG-59908
|
||||
|
||||
readonly property alias title: title
|
||||
readonly property alias textArea: textAreaFrame.textArea
|
||||
|
||||
Label {
|
||||
id: title
|
||||
}
|
||||
|
||||
TextAreaFrame {
|
||||
id: textAreaFrame
|
||||
Layout.fillWidth: true
|
||||
Layout.fillHeight: true
|
||||
|
||||
onEditingFinished: container.editingFinished()
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user