mirror of
https://github.com/MatsuriDayo/nekoray.git
synced 2025-12-17 12:34:37 +03:00
chore: use get_now_selected_list
This commit is contained in:
@@ -382,7 +382,7 @@ MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWi
|
|||||||
//
|
//
|
||||||
connect(ui->menu_share_item, &QMenu::aboutToShow, this, [=] {
|
connect(ui->menu_share_item, &QMenu::aboutToShow, this, [=] {
|
||||||
QString name;
|
QString name;
|
||||||
auto selected = get_now_selected();
|
auto selected = get_now_selected_list();
|
||||||
if (!selected.isEmpty()) {
|
if (!selected.isEmpty()) {
|
||||||
auto ent = selected.first();
|
auto ent = selected.first();
|
||||||
name = ent->bean->DisplayCoreType();
|
name = ent->bean->DisplayCoreType();
|
||||||
@@ -1129,7 +1129,7 @@ void MainWindow::on_menu_add_from_clipboard_triggered() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::on_menu_clone_triggered() {
|
void MainWindow::on_menu_clone_triggered() {
|
||||||
auto ents = get_now_selected();
|
auto ents = get_now_selected_list();
|
||||||
if (ents.isEmpty()) return;
|
if (ents.isEmpty()) return;
|
||||||
|
|
||||||
auto btn = QMessageBox::question(this, tr("Clone"), tr("Clone %1 item(s)").arg(ents.count()));
|
auto btn = QMessageBox::question(this, tr("Clone"), tr("Clone %1 item(s)").arg(ents.count()));
|
||||||
@@ -1144,7 +1144,7 @@ void MainWindow::on_menu_clone_triggered() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::on_menu_move_triggered() {
|
void MainWindow::on_menu_move_triggered() {
|
||||||
auto ents = get_now_selected();
|
auto ents = get_now_selected_list();
|
||||||
if (ents.isEmpty()) return;
|
if (ents.isEmpty()) return;
|
||||||
|
|
||||||
auto items = QStringList{};
|
auto items = QStringList{};
|
||||||
@@ -1168,7 +1168,7 @@ void MainWindow::on_menu_move_triggered() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::on_menu_delete_triggered() {
|
void MainWindow::on_menu_delete_triggered() {
|
||||||
auto ents = get_now_selected();
|
auto ents = get_now_selected_list();
|
||||||
if (ents.count() == 0) return;
|
if (ents.count() == 0) return;
|
||||||
if (QMessageBox::question(this, tr("Confirmation"), QString(tr("Remove %1 item(s) ?")).arg(ents.count())) ==
|
if (QMessageBox::question(this, tr("Confirmation"), QString(tr("Remove %1 item(s) ?")).arg(ents.count())) ==
|
||||||
QMessageBox::StandardButton::Yes) {
|
QMessageBox::StandardButton::Yes) {
|
||||||
@@ -1180,7 +1180,7 @@ void MainWindow::on_menu_delete_triggered() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::on_menu_reset_traffic_triggered() {
|
void MainWindow::on_menu_reset_traffic_triggered() {
|
||||||
auto ents = get_now_selected();
|
auto ents = get_now_selected_list();
|
||||||
if (ents.count() == 0) return;
|
if (ents.count() == 0) return;
|
||||||
for (const auto &ent: ents) {
|
for (const auto &ent: ents) {
|
||||||
ent->traffic_data->Reset();
|
ent->traffic_data->Reset();
|
||||||
@@ -1190,7 +1190,7 @@ void MainWindow::on_menu_reset_traffic_triggered() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::on_menu_profile_debug_info_triggered() {
|
void MainWindow::on_menu_profile_debug_info_triggered() {
|
||||||
auto ents = get_now_selected();
|
auto ents = get_now_selected_list();
|
||||||
if (ents.count() != 1) return;
|
if (ents.count() != 1) return;
|
||||||
auto btn = QMessageBox::information(this, software_name, ents.first()->ToJsonBytes(), "OK", "Edit", "Reload", 0, 0);
|
auto btn = QMessageBox::information(this, software_name, ents.first()->ToJsonBytes(), "OK", "Edit", "Reload", 0, 0);
|
||||||
if (btn == 1) {
|
if (btn == 1) {
|
||||||
@@ -1207,7 +1207,7 @@ void MainWindow::on_menu_copy_links_triggered() {
|
|||||||
ui->masterLogBrowser->copy();
|
ui->masterLogBrowser->copy();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
auto ents = get_now_selected();
|
auto ents = get_now_selected_list();
|
||||||
QStringList links;
|
QStringList links;
|
||||||
for (const auto &ent: ents) {
|
for (const auto &ent: ents) {
|
||||||
links += ent->bean->ToShareLink();
|
links += ent->bean->ToShareLink();
|
||||||
@@ -1218,7 +1218,7 @@ void MainWindow::on_menu_copy_links_triggered() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::on_menu_copy_links_nkr_triggered() {
|
void MainWindow::on_menu_copy_links_nkr_triggered() {
|
||||||
auto ents = get_now_selected();
|
auto ents = get_now_selected_list();
|
||||||
QStringList links;
|
QStringList links;
|
||||||
for (const auto &ent: ents) {
|
for (const auto &ent: ents) {
|
||||||
links += ent->bean->ToNekorayShareLink(ent->type);
|
links += ent->bean->ToNekorayShareLink(ent->type);
|
||||||
@@ -1229,7 +1229,7 @@ void MainWindow::on_menu_copy_links_nkr_triggered() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::on_menu_export_config_triggered() {
|
void MainWindow::on_menu_export_config_triggered() {
|
||||||
auto ents = get_now_selected();
|
auto ents = get_now_selected_list();
|
||||||
if (ents.count() != 1) return;
|
if (ents.count() != 1) return;
|
||||||
auto ent = ents.first();
|
auto ent = ents.first();
|
||||||
if (ent->bean->DisplayCoreType() != software_core_name) return;
|
if (ent->bean->DisplayCoreType() != software_core_name) return;
|
||||||
@@ -1257,7 +1257,7 @@ void MainWindow::on_menu_export_config_triggered() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::display_qr_link(bool nkrFormat) {
|
void MainWindow::display_qr_link(bool nkrFormat) {
|
||||||
auto ents = get_now_selected();
|
auto ents = get_now_selected_list();
|
||||||
if (ents.count() != 1) return;
|
if (ents.count() != 1) return;
|
||||||
|
|
||||||
class W : public QDialog {
|
class W : public QDialog {
|
||||||
@@ -1476,17 +1476,6 @@ void MainWindow::on_proxyListTable_customContextMenuRequested(const QPoint &pos)
|
|||||||
ui->menu_server->popup(ui->proxyListTable->viewport()->mapToGlobal(pos)); // 弹出菜单
|
ui->menu_server->popup(ui->proxyListTable->viewport()->mapToGlobal(pos)); // 弹出菜单
|
||||||
}
|
}
|
||||||
|
|
||||||
QMap<int, std::shared_ptr<NekoGui::ProxyEntity>> MainWindow::get_now_selected() {
|
|
||||||
auto items = ui->proxyListTable->selectedItems();
|
|
||||||
QMap<int, std::shared_ptr<NekoGui::ProxyEntity>> map;
|
|
||||||
for (auto item: items) {
|
|
||||||
auto id = item->data(114514).toInt();
|
|
||||||
auto ent = NekoGui::profileManager->GetProfile(id);
|
|
||||||
if (ent != nullptr) map[id] = ent;
|
|
||||||
}
|
|
||||||
return map;
|
|
||||||
}
|
|
||||||
|
|
||||||
QList<std::shared_ptr<NekoGui::ProxyEntity>> MainWindow::get_now_selected_list() {
|
QList<std::shared_ptr<NekoGui::ProxyEntity>> MainWindow::get_now_selected_list() {
|
||||||
auto items = ui->proxyListTable->selectedItems();
|
auto items = ui->proxyListTable->selectedItems();
|
||||||
QList<std::shared_ptr<NekoGui::ProxyEntity>> list;
|
QList<std::shared_ptr<NekoGui::ProxyEntity>> list;
|
||||||
|
|||||||
@@ -161,8 +161,6 @@ private:
|
|||||||
QSemaphore sem_stopped;
|
QSemaphore sem_stopped;
|
||||||
int exit_reason = 0;
|
int exit_reason = 0;
|
||||||
|
|
||||||
QMap<int, std::shared_ptr<NekoGui::ProxyEntity>> get_now_selected();
|
|
||||||
|
|
||||||
QList<std::shared_ptr<NekoGui::ProxyEntity>> get_now_selected_list();
|
QList<std::shared_ptr<NekoGui::ProxyEntity>> get_now_selected_list();
|
||||||
|
|
||||||
QList<std::shared_ptr<NekoGui::ProxyEntity>> get_selected_or_group();
|
QList<std::shared_ptr<NekoGui::ProxyEntity>> get_selected_or_group();
|
||||||
|
|||||||
@@ -283,7 +283,7 @@ void MainWindow::stop_core_daemon() {
|
|||||||
void MainWindow::neko_start(int _id) {
|
void MainWindow::neko_start(int _id) {
|
||||||
if (NekoGui::dataStore->prepare_exit) return;
|
if (NekoGui::dataStore->prepare_exit) return;
|
||||||
|
|
||||||
auto ents = get_now_selected();
|
auto ents = get_now_selected_list();
|
||||||
auto ent = (_id < 0 && !ents.isEmpty()) ? ents.first() : NekoGui::profileManager->GetProfile(_id);
|
auto ent = (_id < 0 && !ents.isEmpty()) ? ents.first() : NekoGui::profileManager->GetProfile(_id);
|
||||||
if (ent == nullptr) return;
|
if (ent == nullptr) return;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user