mirror of
https://github.com/MatsuriDayo/nekoray.git
synced 2025-12-18 13:04:37 +03:00
improve edit chain
This commit is contained in:
1
res/icon/material/delete.svg
Normal file
1
res/icon/material/delete.svg
Normal file
@@ -0,0 +1 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M19,4H15.5L14.5,3H9.5L8.5,4H5V6H19M6,19A2,2 0 0,0 8,21H16A2,2 0 0,0 18,19V7H6V19Z" /></svg>
|
||||
|
After Width: | Height: | Size: 160 B |
1
res/icon/material/swap-horizontal.svg
Normal file
1
res/icon/material/swap-horizontal.svg
Normal file
@@ -0,0 +1 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M21,9L17,5V8H10V10H17V13M7,11L3,15L7,19V16H14V14H7V11Z" /></svg>
|
||||
|
After Width: | Height: | Size: 133 B |
@@ -11,6 +11,8 @@
|
||||
<file>icon/material/cancel.svg</file>
|
||||
<file>icon/material/history.svg</file>
|
||||
<file>icon/material/swap-vertical.svg</file>
|
||||
<file>icon/material/delete.svg</file>
|
||||
<file>icon/material/swap-horizontal.svg</file>
|
||||
</qresource>
|
||||
<qresource prefix="/neko">
|
||||
<file alias="nekobox.png">public/nekobox.png</file>
|
||||
|
||||
@@ -1237,7 +1237,7 @@ End: %2</source>
|
||||
<name>ProxyItem</name>
|
||||
<message>
|
||||
<source>Remove</source>
|
||||
<translation>حذف کردن</translation>
|
||||
<translation type="vanished">حذف کردن</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Confirmation</source>
|
||||
|
||||
@@ -1240,7 +1240,7 @@ Split by line.</source>
|
||||
<name>ProxyItem</name>
|
||||
<message>
|
||||
<source>Remove</source>
|
||||
<translation>删除</translation>
|
||||
<translation type="vanished">删除</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Confirmation</source>
|
||||
|
||||
@@ -44,13 +44,30 @@ void EditChain::on_select_profile_clicked() {
|
||||
});
|
||||
}
|
||||
|
||||
void EditChain::AddProfileToListIfExist(int id) {
|
||||
auto _ent = NekoRay::profileManager->GetProfile(id);
|
||||
void EditChain::AddProfileToListIfExist(int profileId) {
|
||||
auto _ent = NekoRay::profileManager->GetProfile(profileId);
|
||||
if (_ent != nullptr && _ent->type != "chain") {
|
||||
auto wI = new QListWidgetItem();
|
||||
wI->setData(114514, profileId);
|
||||
auto w = new ProxyItem(this, _ent, wI);
|
||||
wI->setData(114514, id);
|
||||
ui->listWidget->addItem(wI);
|
||||
ui->listWidget->setItemWidget(wI, w);
|
||||
// change button
|
||||
connect(w->get_change_button(), &QPushButton::clicked, w, [=] {
|
||||
get_edit_dialog()->hide();
|
||||
GetMainWindow()->start_select_mode(w, [=](int newId) {
|
||||
get_edit_dialog()->show();
|
||||
ReplaceProfile(w, newId);
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
void EditChain::ReplaceProfile(ProxyItem *w, int profileId) {
|
||||
auto _ent = NekoRay::profileManager->GetProfile(profileId);
|
||||
if (_ent != nullptr && _ent->type != "chain") {
|
||||
w->item->setData(114514, profileId);
|
||||
w->ent = _ent;
|
||||
w->refresh_data();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,6 +9,8 @@ namespace Ui {
|
||||
}
|
||||
QT_END_NAMESPACE
|
||||
|
||||
class ProxyItem;
|
||||
|
||||
class EditChain : public QWidget, public ProfileEditor {
|
||||
Q_OBJECT
|
||||
|
||||
@@ -25,7 +27,9 @@ private:
|
||||
Ui::EditChain *ui;
|
||||
QSharedPointer<NekoRay::ProxyEntity> ent;
|
||||
|
||||
void AddProfileToListIfExist(int id);
|
||||
void AddProfileToListIfExist(int profileId);
|
||||
|
||||
static void ReplaceProfile(ProxyItem *w, int profileId);
|
||||
|
||||
private slots:
|
||||
|
||||
|
||||
@@ -42,3 +42,7 @@ void ProxyItem::on_remove_clicked() {
|
||||
delete item;
|
||||
}
|
||||
}
|
||||
|
||||
QPushButton *ProxyItem::get_change_button() {
|
||||
return ui->change;
|
||||
}
|
||||
|
||||
@@ -11,6 +11,8 @@ namespace Ui {
|
||||
}
|
||||
QT_END_NAMESPACE
|
||||
|
||||
class QPushButton;
|
||||
|
||||
class ProxyItem : public QWidget {
|
||||
Q_OBJECT
|
||||
|
||||
@@ -21,6 +23,8 @@ public:
|
||||
|
||||
void refresh_data();
|
||||
|
||||
QPushButton *get_change_button();
|
||||
|
||||
QSharedPointer<NekoRay::ProxyEntity> ent;
|
||||
QListWidgetItem *item;
|
||||
bool remove_confirm = false;
|
||||
|
||||
@@ -35,6 +35,20 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="change">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Maximum" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset resource="../../res/neko.qrc">
|
||||
<normaloff>:/icon/material/swap-horizontal.svg</normaloff>:/icon/material/swap-horizontal.svg</iconset>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="remove">
|
||||
<property name="sizePolicy">
|
||||
@@ -43,8 +57,9 @@
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Remove</string>
|
||||
<property name="icon">
|
||||
<iconset resource="../../res/neko.qrc">
|
||||
<normaloff>:/icon/material/delete.svg</normaloff>:/icon/material/delete.svg</iconset>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
@@ -124,6 +139,8 @@
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources/>
|
||||
<resources>
|
||||
<include location="../../res/neko.qrc"/>
|
||||
</resources>
|
||||
<connections/>
|
||||
</ui>
|
||||
|
||||
Reference in New Issue
Block a user