From f1eed902f4c5cf4bfe6f83c03fe61887071e7501 Mon Sep 17 00:00:00 2001 From: Nodir Temirkhodjaev Date: Mon, 25 Dec 2017 21:01:42 +0500 Subject: [PATCH] UI: BlockedPage: Add "Copy..." button. --- src/driver/fortstat.c | 8 +-- src/ui/fort_qml.qrc | 2 + src/ui/i18n/i18n_ru.qm | Bin 8739 -> 8936 bytes src/ui/i18n/i18n_ru.ts | 73 ++++++++++++++---------- src/ui/qml/controls/ListViewControl.qml | 42 +++++++++++++- src/ui/qml/pages/BlockedPage.qml | 41 +++++++------ src/ui/qml/pages/StatisticsPage.qml | 4 +- src/ui/qml/pages/log/AppListView.qml | 41 ++----------- src/ui/qml/pages/log/IpListView.qml | 20 +++++++ 9 files changed, 141 insertions(+), 90 deletions(-) create mode 100644 src/ui/qml/pages/log/IpListView.qml diff --git a/src/driver/fortstat.c b/src/driver/fortstat.c index 758c211a..bf60131f 100644 --- a/src/driver/fortstat.c +++ b/src/driver/fortstat.c @@ -417,8 +417,8 @@ fort_stat_flow_associate (PFORT_STAT stat, UINT64 flow_id, flow_context = (UINT64) flow_index | ((UINT64) stat->version << 32) - | ((UINT64) proc_index << 40) - | ((UINT64) group_index << 56); + | ((UINT64) group_index << 40) + | ((UINT64) proc_index << 48); status = fort_stat_flow_set_context(stat, flow_id, flow_context, is_udp); @@ -448,7 +448,7 @@ fort_stat_flow_delete (PFORT_STAT stat, UINT64 flow_context) { KLOCK_QUEUE_HANDLE lock_queue; const UINT32 flow_index = (UINT32) flow_context; - const UINT16 proc_index = (UINT16) (flow_context >> 40); + const UINT16 proc_index = (UINT16) (flow_context >> 48); const UCHAR stat_version = (UCHAR) (flow_context >> 32); if (stat->closing) @@ -468,7 +468,7 @@ fort_stat_flow_classify (PFORT_STAT stat, UINT64 flow_context, { PFORT_STAT_PROC proc; KLOCK_QUEUE_HANDLE lock_queue; - const UINT16 proc_index = (UINT16) (flow_context >> 40); + const UINT16 proc_index = (UINT16) (flow_context >> 48); const UCHAR stat_version = (UCHAR) (flow_context >> 32); if (stat->closing) diff --git a/src/ui/fort_qml.qrc b/src/ui/fort_qml.qrc index be249872..27906dd6 100644 --- a/src/ui/fort_qml.qrc +++ b/src/ui/fort_qml.qrc @@ -3,6 +3,7 @@ qml/controls/ButtonMenu.qml qml/controls/ButtonPopup.qml qml/controls/LinkButton.qml + qml/controls/ListViewControl.qml qml/controls/RoundButtonTip.qml qml/controls/ScrollBarControl.qml qml/controls/SpinCombo.qml @@ -24,6 +25,7 @@ qml/pages/apps/AppsTextColumn.qml qml/pages/apps/SpeedLimitButton.qml qml/pages/log/AppListView.qml + qml/pages/log/IpListView.qml qml/pages/log/TrafKeepButton.qml qml/pages/log/TrafRow.qml qml/pages/schedule/TaskRow.qml diff --git a/src/ui/i18n/i18n_ru.qm b/src/ui/i18n/i18n_ru.qm index d08163fe78a536587e0e34ecfca1c0bf23370149..a6c21a27f78005a4e64055d969c69fac165b544e 100644 GIT binary patch delta 1024 zcmX|9ZERCz7(H#@+k1O^Z*S+iZtL1^Ml}9df&=Psb?E3OU4t@3AdW#KZrR!xSm=^5 z!cxRV3=%S!lP?vaI!43|7%B=#m|JiO$xP?6@S*ZGKemt%g-t<%XIa9pljnWUd!F;0 z_eqxiQP%28v;tBP$ld{j^8u{^i1Y!@5#YrX;OYckCc2LTi;0=zK;>z`*G**Y`w60> ziTomn&d-3f7^HB3dMhDq6@ca1Gq zo1o!M+i&_4p7+e(IIL9t#N7KMfE>l#`^zn2*iv|J6JTFxi8{Ts(c9owZ zzgX;EFEN^RqVwKkR4W#TKVQKy_lfbDD(jS(7@#}X12K7Xm~L97*RvNho`jS*k)-aY z(np3DLFm6qUw!yDpai9UdkpYvh?2ky7dMV()E&YD+0BxJCmLwbJykjl>w~|IS zwDp^E6GyBm*9{K0#5!8g$6=%L3$Mi~KS-Qv(;(MAo5TA9a`VYK49P2ZufERkYUJT_ zv~8s1k<>E4;aAdUSg78wEV}eHVE#+#sQQ>=+*b}Ay#jb!l+#;(06bO7KQ(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diff --git a/src/ui/i18n/i18n_ru.ts b/src/ui/i18n/i18n_ru.ts index 62e485cd..ed9c4031 100644 --- a/src/ui/i18n/i18n_ru.ts +++ b/src/ui/i18n/i18n_ru.ts @@ -14,22 +14,22 @@ Некорректный IP адрес для исключения: %1 - + Size of configuration is too big Конфигурация слишком большая - + Number of Application Groups must be < %1 Количество групп приложений должно быть < %1 - + Length of Application Group's Name must be < %1 Длина наименования группы приложения должна быть < %1 - + Length of Application's Path must be < %1 Длина пути приложения должна быть < %1 @@ -148,7 +148,7 @@ TaskUpdateChecker - + New version! Новая версия! @@ -185,29 +185,44 @@ - + Clear… Очистить… - + Remove Application Удалить приложение - + Clear All Очистить всё - + + Copy… + Копировать… + + + + Application Path + Путь приложения + + + + IP Address + IP Адрес + + + Resolve Addresses Преобразовать адреса - + Log Blocked Applications Показ блокированных приложений @@ -500,101 +515,101 @@ Успешный запуск - + Adaptive Адаптивный - + Bytes Байты - + KiB KiB - + MiB MiB - + GiB GiB - + TiB TiB - + Refresh Обновить - + Units: Единицы: - + Reset Total Сбросить общую - + Collect Traffic Statistics Собирать статистику трафика - + All Все - + Hourly Stat Почасовая - + Daily Stat Ежедневная - + Monthly Stat Ежемесячная - + Total Stat Общая - + Date Дата - + Download Загрузка - + Upload Выгрузка - + Sum Сумма diff --git a/src/ui/qml/controls/ListViewControl.qml b/src/ui/qml/controls/ListViewControl.qml index 9c36e13c..72e5784f 100644 --- a/src/ui/qml/controls/ListViewControl.qml +++ b/src/ui/qml/controls/ListViewControl.qml @@ -1,5 +1,43 @@ -import QtQuick 2.0 +import QtQuick 2.9 +import QtQuick.Controls 2.2 -Item { +ListView { + id: listView + signal clicked(int index) + + readonly property string currentItemText: + (currentIndex >= 0 && currentIndex < count && currentItem) + ? currentItem.displayText : "" + + Keys.onUpPressed: decrementCurrentIndex() + Keys.onDownPressed: incrementCurrentIndex() + + ScrollBar.vertical: ScrollBarControl {} + + highlightRangeMode: ListView.ApplyRange + highlightResizeDuration: 0 + highlightMoveDuration: 200 + + highlight: Item { + Rectangle { + anchors.fill: parent + anchors.margins: 1 - listView.spacing / 2 - border.width + radius: 2 + border.width: 3 + border.color: palette.highlight + color: "transparent" + } + } + + MouseArea { + anchors.fill: parent + onClicked: { + const index = listView.indexAt(mouse.x, mouse.y); + if (index >= 0) { + listView.currentIndex = index; + listView.clicked(index); + } + } + } } diff --git a/src/ui/qml/pages/BlockedPage.qml b/src/ui/qml/pages/BlockedPage.qml index 7867d909..e6adbb33 100644 --- a/src/ui/qml/pages/BlockedPage.qml +++ b/src/ui/qml/pages/BlockedPage.qml @@ -12,9 +12,9 @@ BasePage { readonly property IpListModel ipListModel: appBlockedModel.ipListModel(currentAppPath) - readonly property string currentAppPath: - (appListView.currentIndex >= 0 && appListView.currentItem) - ? appListView.currentItem.appPath : "" + readonly property string currentAppPath: appListView.currentItemText + + readonly property string currentIpText: ipListView.currentItemText HostInfoCache { id: hostInfoCache @@ -48,6 +48,26 @@ BasePage { } } + ButtonMenu { + enabled: appListView.count + icon.source: "qrc:/images/page_copy.png" + text: translationManager.dummyBool + && qsTranslate("qml", "Copy…") + + MenuItem { + enabled: !!currentAppPath + text: translationManager.dummyBool + && qsTranslate("qml", "Application Path") + onTriggered: guiUtil.setClipboardData(currentAppPath) + } + MenuItem { + enabled: !!currentIpText + text: translationManager.dummyBool + && qsTranslate("qml", "IP Address") + onTriggered: guiUtil.setClipboardData(currentIpText) + } + } + CheckBox { text: translationManager.dummyBool && qsTranslate("qml", "Resolve Addresses") @@ -101,25 +121,12 @@ BasePage { model: appBlockedModel } - ListView { + IpListView { id: ipListView Layout.fillWidth: true Layout.fillHeight: true - spacing: 5 model: ipListModel - - delegate: Label { - width: ipListView.width - elide: Text.ElideRight - text: (firewallConf.resolveAddress - && hostInfoCache.dummyBool - && hostInfoCache.hostName(ipText)) || ipText - - readonly property string ipText: display - } - - ScrollBar.vertical: ScrollBarControl {} } } } diff --git a/src/ui/qml/pages/StatisticsPage.qml b/src/ui/qml/pages/StatisticsPage.qml index 35aebdbe..c42926ac 100644 --- a/src/ui/qml/pages/StatisticsPage.qml +++ b/src/ui/qml/pages/StatisticsPage.qml @@ -15,9 +15,7 @@ BasePage { appListView.currentIndex, currentAppPath) - readonly property string currentAppPath: - (appListView.currentIndex >= 0 && appListView.currentItem) - ? appListView.currentItem.appPath : "" + readonly property string currentAppPath: appListView.currentItemText readonly property var trafCellWidths: [ trafsContainer.width * 0.34, diff --git a/src/ui/qml/pages/log/AppListView.qml b/src/ui/qml/pages/log/AppListView.qml index 0df374b6..717cb121 100644 --- a/src/ui/qml/pages/log/AppListView.qml +++ b/src/ui/qml/pages/log/AppListView.qml @@ -3,7 +3,7 @@ import QtQuick.Controls 2.2 import "../../controls" import com.fortfirewall 1.0 -ListView { +ListViewControl { id: appListView spacing: 10 @@ -11,56 +11,27 @@ ListView { property string emptyText property string emptyIcon - Keys.onUpPressed: decrementCurrentIndex() - Keys.onDownPressed: incrementCurrentIndex() - - ScrollBar.vertical: ScrollBarControl {} - - highlightRangeMode: ListView.ApplyRange - highlightResizeDuration: 0 - highlightMoveDuration: 200 - - highlight: Item { - Rectangle { - anchors.fill: parent - anchors.margins: -7 - radius: 2 - border.width: 3 - border.color: palette.highlight - color: "transparent" - } - } + onClicked: forceActiveFocus() delegate: Row { id: appItem width: appListView.width spacing: 6 - readonly property string appPath: display + readonly property string displayText: display // TODO: Use SHGetFileInfo() to get app's display name and icon Image { anchors.verticalCenter: parent.verticalCenter anchors.verticalCenterOffset: 1 - source: (!appItem.appPath && emptyIcon) + source: (!appItem.displayText && emptyIcon) || "qrc:/images/application.png" } Label { font.pixelSize: 20 elide: Text.ElideRight - text: (!appItem.appPath && emptyText) - || fileUtil.fileName(appItem.appPath) - } - } - - MouseArea { - anchors.fill: parent - onClicked: { - const index = appListView.indexAt(mouse.x, mouse.y); - if (index >= 0) { - appListView.currentIndex = index; - appListView.forceActiveFocus(); - } + text: (!appItem.displayText && emptyText) + || fileUtil.fileName(appItem.displayText) } } } diff --git a/src/ui/qml/pages/log/IpListView.qml b/src/ui/qml/pages/log/IpListView.qml new file mode 100644 index 00000000..9c5e2379 --- /dev/null +++ b/src/ui/qml/pages/log/IpListView.qml @@ -0,0 +1,20 @@ +import QtQuick 2.9 +import QtQuick.Controls 2.2 +import "../../controls" +import com.fortfirewall 1.0 + +ListViewControl { + id: ipListView + + spacing: 6 + + delegate: Label { + width: ipListView.width + elide: Text.ElideRight + text: (firewallConf.resolveAddress + && hostInfoCache.dummyBool + && hostInfoCache.hostName(displayText)) || displayText + + readonly property string displayText: display + } +}