more hotkey

This commit is contained in:
arm64v8a
2022-08-09 15:22:16 +08:00
parent 9d3bb41ea4
commit e456ef2b5c
7 changed files with 124 additions and 46 deletions

View File

@@ -104,6 +104,10 @@ namespace Qv2ray::ui {
rule.pattern = QRegularExpression(">>>>+");
rule.format = warningFormat;
highlightingRules.append(rule);
//
rule.pattern = QRegularExpression("<<<<+");
rule.format = warningFormat;
highlightingRules.append(rule);
{
// IP IPv6 Host;

View File

@@ -279,15 +279,16 @@ namespace NekoRay::sub {
bool asURL = _sub_gid >= 0 || _not_sub_as_url; // 把 _str 当作 url 处理(下载内容)
auto content = _str.trimmed();
auto group = profileManager->GetGroup(_sub_gid);
if (group != nullptr && group->archive) return;
// 网络请求
if (asURL) {
auto groupName = group == nullptr ? content : group->name;
showLog(">>>>>>> " + QObject::tr("Requesting subscription: %1").arg(groupName));
showLog(">>>>>>>> " + QObject::tr("Requesting subscription: %1").arg(groupName));
auto resp = NetworkRequestHelper::HttpGet(content);
if (!resp.error.isEmpty()) {
showLog(">>>>>>> " + QObject::tr("Requesting subscription %1 error: %2")
showLog("<<<<<<<< " + QObject::tr("Requesting subscription %1 error: %2")
.arg(groupName, resp.error + "\n" + resp.data));
return;
}
@@ -342,7 +343,7 @@ namespace NekoRay::sub {
.arg(only_out.length()).arg(notice_added)
.arg(only_in.length()).arg(notice_deleted);
if (only_out.length() + only_in.length() == 0) change = QObject::tr("Nothing");
showLog(">>>>>>> " + QObject::tr("Change of %1:").arg(group->name) + " " + change);
showLog("<<<<<<<< " + QObject::tr("Change of %1:").arg(group->name) + " " + change);
dialog_message("SubUpdater", "finish-dingyue");
});
} else {

View File

@@ -665,10 +665,6 @@
<source>Archive</source>
<translation></translation>
</message>
<message>
<source>Update %1?</source>
<translation> %1 ?</translation>
</message>
<message>
<source>Last update: %1</source>
<translation> %1</translation>
@@ -989,14 +985,6 @@ End: %2</source>
<source>New profile</source>
<translation></translation>
</message>
<message>
<source>Start [ Enter ]</source>
<translation> [ Enter ]</translation>
</message>
<message>
<source>Delete [ Delete ]</source>
<translation> [ Delete ]</translation>
</message>
<message>
<source>Hotkey Settings</source>
<translation></translation>
@@ -1025,18 +1013,10 @@ End: %2</source>
<source>Load routing and apply: %1</source>
<translation>: %1</translation>
</message>
<message>
<source>Copy links of selected [ Ctrl+C ]</source>
<translation> [ Ctrl+C ]</translation>
</message>
<message>
<source>Copied %1 item(s)</source>
<translation> %1 </translation>
</message>
<message>
<source>Add profile from clipboard [ Ctrl+V ]</source>
<translation> [ Ctrl+V ]</translation>
</message>
<message>
<source>Full Test</source>
<translation></translation>
@@ -1081,6 +1061,30 @@ End: %2</source>
<source>Restart VPN to take effect.</source>
<translation> VPN </translation>
</message>
<message>
<source>Start</source>
<translation></translation>
</message>
<message>
<source>Delete</source>
<translation></translation>
</message>
<message>
<source>Copy links of selected</source>
<translation></translation>
</message>
<message>
<source>Clone</source>
<translation></translation>
</message>
<message>
<source>Update subscripton</source>
<translation></translation>
</message>
<message>
<source>Clone %1 item(s)</source>
<translation> %1 </translation>
</message>
</context>
<context>
<name>ProxyItem</name>

View File

@@ -254,8 +254,6 @@ MainWindow::MainWindow(QWidget *parent)
//
ui->menu_program_preference->addActions(ui->menu_preferences->actions());
connect(ui->menu_add_from_clipboard2, &QAction::triggered, ui->menu_add_from_clipboard, &QAction::trigger);
connect(shortcut_ctrl_c, &QShortcut::activated, ui->menu_copy_links, &QAction::trigger);
connect(shortcut_ctrl_v, &QShortcut::activated, ui->menu_add_from_clipboard, &QAction::trigger);
//
connect(ui->menu_program, &QMenu::aboutToShow, this, [=]() {
ui->actionRemember_last_proxy->setChecked(NekoRay::dataStore->remember_enable);
@@ -870,6 +868,23 @@ void MainWindow::on_menu_add_from_clipboard_triggered() {
NekoRay::sub::groupUpdater->AsyncUpdate(clipboard);
}
void MainWindow::on_menu_clone_triggered() {
auto ents = get_now_selected();
if (ents.isEmpty()) return;
auto btn = QMessageBox::question(nullptr,
tr("Clone"),
tr("Clone %1 item(s)").arg(ents.count()));
if (btn != QMessageBox::Yes) return;
QStringList sls;
for (const auto &ent: ents) {
sls << ent->bean->ToNekorayShareLink(ent->type);
}
NekoRay::sub::groupUpdater->AsyncUpdate(sls.join("\n"));
}
void MainWindow::on_menu_move_triggered() {
auto ents = get_now_selected();
if (ents.isEmpty()) return;
@@ -1083,6 +1098,18 @@ void MainWindow::on_menu_delete_repeat_triggered() {
}
}
bool mw_sub_updating = false;
void MainWindow::on_menu_update_subscripton_triggered() {
auto group = NekoRay::profileManager->CurrentGroup();
if (group->url.isEmpty()) return;
if (mw_sub_updating) return;
mw_sub_updating = true;
NekoRay::sub::groupUpdater->AsyncUpdate(group->url, group->id, this, [=] {
mw_sub_updating = false;
});
}
void MainWindow::on_menu_remove_unavailable_triggered() {
QList<QSharedPointer<NekoRay::ProxyEntity>> out_del;
@@ -1128,14 +1155,6 @@ void MainWindow::keyPressEvent(QKeyEvent *event) {
case Qt::Key_Escape:
// take over by shortcut_esc
break;
case Qt::Key_Return: {
neko_start();
break;
}
case Qt::Key_Delete: {
on_menu_delete_triggered();
break;
}
default:
QMainWindow::keyPressEvent(event);
}

View File

@@ -74,6 +74,8 @@ private slots:
void on_menu_add_from_clipboard_triggered();
void on_menu_clone_triggered();
void on_menu_move_triggered();
void on_menu_delete_triggered();
@@ -100,6 +102,8 @@ private slots:
void on_menu_remove_unavailable_triggered();
void on_menu_update_subscripton_triggered();
void on_proxyListTable_itemDoubleClicked(QTableWidgetItem *item);
void on_proxyListTable_customContextMenuRequested(const QPoint &pos);
@@ -110,8 +114,6 @@ private:
Ui::MainWindow *ui;
QSystemTrayIcon *tray;
QShortcut *shortcut_ctrl_f = new QShortcut(QKeySequence("Ctrl+F"), this);
QShortcut *shortcut_ctrl_c = new QShortcut(QKeySequence("Ctrl+C"), this);
QShortcut *shortcut_ctrl_v = new QShortcut(QKeySequence("Ctrl+V"), this);
QShortcut *shortcut_esc = new QShortcut(QKeySequence("Esc"), this);
//
bool core_process_killed = false;

View File

@@ -522,17 +522,19 @@
<string>Current Group</string>
</property>
<addaction name="menu_delete_repeat"/>
<addaction name="menu_remove_unavailable"/>
<addaction name="menu_tcp_ping"/>
<addaction name="menu_url_test"/>
<addaction name="menu_full_test"/>
<addaction name="menu_clear_test_result"/>
<addaction name="menu_remove_unavailable"/>
<addaction name="menu_update_subscripton"/>
</widget>
<addaction name="menu_add_from_input"/>
<addaction name="menu_add_from_clipboard"/>
<addaction name="separator"/>
<addaction name="menu_start"/>
<addaction name="menu_stop"/>
<addaction name="menu_clone"/>
<addaction name="separator"/>
<addaction name="menu_select_all"/>
<addaction name="menu_move"/>
@@ -572,7 +574,10 @@
</action>
<action name="menu_start">
<property name="text">
<string>Start [ Enter ]</string>
<string>Start</string>
</property>
<property name="shortcut">
<string notr="true">Return</string>
</property>
</action>
<action name="menu_stop">
@@ -587,12 +592,18 @@
</action>
<action name="menu_add_from_clipboard">
<property name="text">
<string>Add profile from clipboard [ Ctrl+V ]</string>
<string>Add profile from clipboard</string>
</property>
<property name="shortcut">
<string notr="true">Ctrl+V</string>
</property>
</action>
<action name="menu_delete">
<property name="text">
<string>Delete [ Delete ]</string>
<string>Delete</string>
</property>
<property name="shortcut">
<string notr="true">Del</string>
</property>
</action>
<action name="menu_add_from_clipboard2">
@@ -609,6 +620,9 @@
<property name="text">
<string>QR Code and link</string>
</property>
<property name="shortcut">
<string notr="true">Ctrl+Q</string>
</property>
</action>
<action name="menu_copy_link">
<property name="text">
@@ -619,16 +633,25 @@
<property name="text">
<string notr="true">Tcp Ping</string>
</property>
<property name="shortcut">
<string notr="true">Ctrl+Shift+T</string>
</property>
</action>
<action name="menu_url_test">
<property name="text">
<string notr="true">Url Test</string>
</property>
<property name="shortcut">
<string notr="true">Ctrl+Shift+U</string>
</property>
</action>
<action name="menu_clear_test_result">
<property name="text">
<string>Clear Test Result</string>
</property>
<property name="shortcut">
<string notr="true">Ctrl+Shift+C</string>
</property>
</action>
<action name="menu_export_config">
<property name="text">
@@ -639,6 +662,9 @@
<property name="text">
<string>Reset Traffic</string>
</property>
<property name="shortcut">
<string notr="true">Ctrl+R</string>
</property>
</action>
<action name="menu_scan_qr">
<property name="text">
@@ -712,6 +738,9 @@
<property name="text">
<string>Full Test</string>
</property>
<property name="shortcut">
<string notr="true">Ctrl+Shift+F</string>
</property>
</action>
<action name="menu_hotkey_settings">
<property name="text">
@@ -722,6 +751,9 @@
<property name="text">
<string>Select All</string>
</property>
<property name="shortcut">
<string notr="true">Ctrl+A</string>
</property>
</action>
<action name="menu_qr_nkr">
<property name="text">
@@ -746,7 +778,10 @@
</action>
<action name="menu_copy_links">
<property name="text">
<string>Copy links of selected [ Ctrl+C ]</string>
<string>Copy links of selected</string>
</property>
<property name="shortcut">
<string notr="true">Ctrl+C</string>
</property>
</action>
<action name="menu_spmode_vpn">
@@ -757,6 +792,22 @@
<string>Enable VPN</string>
</property>
</action>
<action name="menu_clone">
<property name="text">
<string>Clone</string>
</property>
<property name="shortcut">
<string notr="true">Ctrl+D</string>
</property>
</action>
<action name="menu_update_subscripton">
<property name="text">
<string>Update subscripton</string>
</property>
<property name="shortcut">
<string notr="true">Ctrl+U</string>
</property>
</action>
</widget>
<customwidgets>
<customwidget>

View File

@@ -96,13 +96,10 @@ void GroupItem::refresh_data() {
}
void GroupItem::on_update_sub_clicked() {
if (QMessageBox::question(this, tr("Confirmation"), tr("Update %1?").arg(ent->name))
== QMessageBox::StandardButton::Yes) {
NekoRay::sub::groupUpdater->AsyncUpdate(ent->url, ent->id, this, [=] {
refresh_data();
});
}
}
void GroupItem::on_edit_clicked() {
auto dialog = new DialogEditGroup(ent, this);