mirror of
https://github.com/Mahdi-zarei/nekoray.git
synced 2025-12-19 13:50:12 +08:00
make stats widget movable and persistant &&
make cells copiable on click
This commit is contained in:
parent
f1c12e05b3
commit
33df4bba91
@ -93,6 +93,7 @@ namespace NekoGui {
|
||||
int max_log_line = 200;
|
||||
QString splitter_state = "";
|
||||
bool enable_stats = true;
|
||||
QString stats_tab = ""; // either connection or log
|
||||
|
||||
// Subscription
|
||||
QString user_agent = ""; // set at main.cpp
|
||||
|
||||
@ -180,6 +180,8 @@ private:
|
||||
int exit_reason = 0;
|
||||
//
|
||||
QMutex mu_download_assets;
|
||||
//
|
||||
int toolTipID;
|
||||
|
||||
QList<std::shared_ptr<NekoGui::ProxyEntity>> get_now_selected_list();
|
||||
|
||||
|
||||
@ -308,11 +308,49 @@
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="movable">
|
||||
<bool>false</bool>
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="tabBarAutoHide">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<widget class="QWidget" name="Logs">
|
||||
<property name="enabled">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<attribute name="title">
|
||||
<string>Logs</string>
|
||||
</attribute>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_3" stretch="0">
|
||||
<property name="spacing">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="sizeConstraint">
|
||||
<enum>QLayout::SizeConstraint::SetDefaultConstraint</enum>
|
||||
</property>
|
||||
<property name="leftMargin">
|
||||
<number>1</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>1</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QTextBrowser" name="masterLogBrowser">
|
||||
<property name="contextMenuPolicy">
|
||||
<enum>Qt::ContextMenuPolicy::CustomContextMenu</enum>
|
||||
</property>
|
||||
<property name="openLinks">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<widget class="QWidget" name="connections_tab">
|
||||
<attribute name="title">
|
||||
<string>Connections</string>
|
||||
@ -387,44 +425,6 @@
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<widget class="QWidget" name="Logs">
|
||||
<property name="enabled">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<attribute name="title">
|
||||
<string>Logs</string>
|
||||
</attribute>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_3" stretch="0">
|
||||
<property name="spacing">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="sizeConstraint">
|
||||
<enum>QLayout::SizeConstraint::SetDefaultConstraint</enum>
|
||||
</property>
|
||||
<property name="leftMargin">
|
||||
<number>1</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>1</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QTextBrowser" name="masterLogBrowser">
|
||||
<property name="contextMenuPolicy">
|
||||
<enum>Qt::ContextMenuPolicy::CustomContextMenu</enum>
|
||||
</property>
|
||||
<property name="openLinks">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
|
||||
@ -310,6 +310,7 @@ namespace NekoGui {
|
||||
_add(new configItem("system_dns_servers", &system_dns_servers, itemType::stringList));
|
||||
_add(new configItem("windows_set_admin", &windows_set_admin, itemType::boolean));
|
||||
_add(new configItem("enable_stats", &enable_stats, itemType::boolean));
|
||||
_add(new configItem("stats_tab", &stats_tab, itemType::string));
|
||||
}
|
||||
|
||||
void DataStore::UpdateStartedId(int id) {
|
||||
|
||||
@ -42,6 +42,8 @@
|
||||
#include <QDir>
|
||||
#include <QFileInfo>
|
||||
#include <QStyleHints>
|
||||
#include <QToolTip>
|
||||
#include <random>
|
||||
#include <3rdparty/QHotkey/qhotkey.h>
|
||||
#include <include/global/HTTPRequestHelper.hpp>
|
||||
|
||||
@ -156,6 +158,19 @@ MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWi
|
||||
|
||||
// setup connection UI
|
||||
setupConnectionList();
|
||||
for (int i=0;i<ui->stats_widget->tabBar()->count();i++)
|
||||
{
|
||||
if (ui->stats_widget->tabBar()->tabText(i) == NekoGui::dataStore->stats_tab)
|
||||
{
|
||||
ui->stats_widget->tabBar()->setCurrentIndex(i);
|
||||
break;
|
||||
}
|
||||
}
|
||||
connect(ui->stats_widget->tabBar(), &QTabBar::currentChanged, this, [=](int index)
|
||||
{
|
||||
auto tabText = ui->stats_widget->tabBar()->tabText(index);
|
||||
NekoGui::dataStore->stats_tab = tabText;
|
||||
});
|
||||
connect(ui->connections->horizontalHeader(), &QHeaderView::sectionClicked, this, [=](int index)
|
||||
{
|
||||
// TODO this is a very bad idea to hardcode it like this, need to refactor it later
|
||||
@ -842,7 +857,6 @@ void MainWindow::neko_set_spmode_vpn(bool enable, bool save) {
|
||||
void MainWindow::setupConnectionList()
|
||||
{
|
||||
ui->connections->horizontalHeader()->setHighlightSections(false);
|
||||
ui->connections->setSelectionMode(QAbstractItemView::NoSelection);
|
||||
ui->connections->setEditTriggers(QAbstractItemView::NoEditTriggers);
|
||||
ui->connections->horizontalHeader()->setSectionResizeMode(0, QHeaderView::Stretch);
|
||||
ui->connections->horizontalHeader()->setSectionResizeMode(1, QHeaderView::Stretch);
|
||||
@ -851,6 +865,22 @@ void MainWindow::setupConnectionList()
|
||||
ui->connections->horizontalHeader()->setSectionResizeMode(4, QHeaderView::ResizeToContents);
|
||||
ui->connections->horizontalHeader()->setSectionResizeMode(5, QHeaderView::ResizeToContents);
|
||||
ui->connections->verticalHeader()->hide();
|
||||
connect(ui->connections, &QTableWidget::cellClicked, this, [=](int row, int column)
|
||||
{
|
||||
if (column > 3) return;
|
||||
auto selected = ui->connections->item(row, column);
|
||||
QApplication::clipboard()->setText(selected->text());
|
||||
QPoint pos = ui->connections->mapToGlobal(ui->connections->visualItemRect(selected).center());
|
||||
QToolTip::showText(pos, "Copied!", this);
|
||||
auto r = ++toolTipID;
|
||||
QTimer::singleShot(1500, [=] {
|
||||
if (r != toolTipID)
|
||||
{
|
||||
return;
|
||||
}
|
||||
QToolTip::hideText();
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
void MainWindow::UpdateConnectionList(const QMap<QString, NekoGui_traffic::ConnectionMetadata>& toUpdate, const QMap<QString, NekoGui_traffic::ConnectionMetadata>& toAdd)
|
||||
|
||||
Loading…
Reference in New Issue
Block a user