From e456ef2b5c834f4b2faf60d709fd1135e945fefb Mon Sep 17 00:00:00 2001 From: arm64v8a <48624112+arm64v8a@users.noreply.github.com> Date: Tue, 9 Aug 2022 15:22:16 +0800 Subject: [PATCH] more hotkey --- qv2ray/v2/ui/LogHighlighter.cpp | 4 +++ sub/GroupUpdater.cpp | 7 ++-- translations/zh_CN.ts | 44 +++++++++++++----------- ui/mainwindow.cpp | 39 +++++++++++++++------ ui/mainwindow.h | 6 ++-- ui/mainwindow.ui | 61 ++++++++++++++++++++++++++++++--- ui/widget/GroupItem.cpp | 9 ++--- 7 files changed, 124 insertions(+), 46 deletions(-) diff --git a/qv2ray/v2/ui/LogHighlighter.cpp b/qv2ray/v2/ui/LogHighlighter.cpp index 4644878..4b2d193 100644 --- a/qv2ray/v2/ui/LogHighlighter.cpp +++ b/qv2ray/v2/ui/LogHighlighter.cpp @@ -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; diff --git a/sub/GroupUpdater.cpp b/sub/GroupUpdater.cpp index 295ba94..acac972 100644 --- a/sub/GroupUpdater.cpp +++ b/sub/GroupUpdater.cpp @@ -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 { diff --git a/translations/zh_CN.ts b/translations/zh_CN.ts index 132651e..67472ed 100644 --- a/translations/zh_CN.ts +++ b/translations/zh_CN.ts @@ -665,10 +665,6 @@ Archive 归档 - - Update %1? - 更新 %1 ? - Last update: %1 最后更新 %1 @@ -989,14 +985,6 @@ End: %2 New profile 手动输入配置 - - Start [ Enter ] - 启动 [ Enter ] - - - Delete [ Delete ] - 删除 [ Delete ] - Hotkey Settings 热键设置 @@ -1025,18 +1013,10 @@ End: %2 Load routing and apply: %1 加载路由规则并应用: %1 - - Copy links of selected [ Ctrl+C ] - 批量复制选中项目的分享链接 [ Ctrl+C ] - Copied %1 item(s) 复制了 %1 个项目 - - Add profile from clipboard [ Ctrl+V ] - 从剪切板添加 [ Ctrl+V ] - Full Test 完整测试 @@ -1081,6 +1061,30 @@ End: %2 Restart VPN to take effect. 重启 VPN 生效。 + + Start + 启动 + + + Delete + 删除 + + + Copy links of selected + 批量复制选中项目的分享链接 + + + Clone + 克隆 + + + Update subscripton + 更新订阅 + + + Clone %1 item(s) + 克隆 %1 个项目 + ProxyItem diff --git a/ui/mainwindow.cpp b/ui/mainwindow.cpp index 7f1cd96..8f34a3e 100644 --- a/ui/mainwindow.cpp +++ b/ui/mainwindow.cpp @@ -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> 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); } diff --git a/ui/mainwindow.h b/ui/mainwindow.h index 2e4c18d..efad682 100644 --- a/ui/mainwindow.h +++ b/ui/mainwindow.h @@ -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; diff --git a/ui/mainwindow.ui b/ui/mainwindow.ui index 26c23bd..f46afbb 100644 --- a/ui/mainwindow.ui +++ b/ui/mainwindow.ui @@ -522,17 +522,19 @@ Current Group + - + + @@ -572,7 +574,10 @@ - Start [ Enter ] + Start + + + Return @@ -587,12 +592,18 @@ - Add profile from clipboard [ Ctrl+V ] + Add profile from clipboard + + + Ctrl+V - Delete [ Delete ] + Delete + + + Del @@ -609,6 +620,9 @@ QR Code and link + + Ctrl+Q + @@ -619,16 +633,25 @@ Tcp Ping + + Ctrl+Shift+T + Url Test + + Ctrl+Shift+U + Clear Test Result + + Ctrl+Shift+C + @@ -639,6 +662,9 @@ Reset Traffic + + Ctrl+R + @@ -712,6 +738,9 @@ Full Test + + Ctrl+Shift+F + @@ -722,6 +751,9 @@ Select All + + Ctrl+A + @@ -746,7 +778,10 @@ - Copy links of selected [ Ctrl+C ] + Copy links of selected + + + Ctrl+C @@ -757,6 +792,22 @@ Enable VPN + + + Clone + + + Ctrl+D + + + + + Update subscripton + + + Ctrl+U + + diff --git a/ui/widget/GroupItem.cpp b/ui/widget/GroupItem.cpp index c96e058..d02191d 100644 --- a/ui/widget/GroupItem.cpp +++ b/ui/widget/GroupItem.cpp @@ -96,12 +96,9 @@ 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(); - }); - } + NekoRay::sub::groupUpdater->AsyncUpdate(ent->url, ent->id, this, [=] { + refresh_data(); + }); } void GroupItem::on_edit_clicked() {