mirror of
https://github.com/MatsuriDayo/nekoray.git
synced 2025-12-18 21:14: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/cancel.svg</file>
|
||||||
<file>icon/material/history.svg</file>
|
<file>icon/material/history.svg</file>
|
||||||
<file>icon/material/swap-vertical.svg</file>
|
<file>icon/material/swap-vertical.svg</file>
|
||||||
|
<file>icon/material/delete.svg</file>
|
||||||
|
<file>icon/material/swap-horizontal.svg</file>
|
||||||
</qresource>
|
</qresource>
|
||||||
<qresource prefix="/neko">
|
<qresource prefix="/neko">
|
||||||
<file alias="nekobox.png">public/nekobox.png</file>
|
<file alias="nekobox.png">public/nekobox.png</file>
|
||||||
|
|||||||
@@ -1237,7 +1237,7 @@ End: %2</source>
|
|||||||
<name>ProxyItem</name>
|
<name>ProxyItem</name>
|
||||||
<message>
|
<message>
|
||||||
<source>Remove</source>
|
<source>Remove</source>
|
||||||
<translation>حذف کردن</translation>
|
<translation type="vanished">حذف کردن</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<source>Confirmation</source>
|
<source>Confirmation</source>
|
||||||
|
|||||||
@@ -1240,7 +1240,7 @@ Split by line.</source>
|
|||||||
<name>ProxyItem</name>
|
<name>ProxyItem</name>
|
||||||
<message>
|
<message>
|
||||||
<source>Remove</source>
|
<source>Remove</source>
|
||||||
<translation>删除</translation>
|
<translation type="vanished">删除</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<source>Confirmation</source>
|
<source>Confirmation</source>
|
||||||
|
|||||||
@@ -44,13 +44,30 @@ void EditChain::on_select_profile_clicked() {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
void EditChain::AddProfileToListIfExist(int id) {
|
void EditChain::AddProfileToListIfExist(int profileId) {
|
||||||
auto _ent = NekoRay::profileManager->GetProfile(id);
|
auto _ent = NekoRay::profileManager->GetProfile(profileId);
|
||||||
if (_ent != nullptr && _ent->type != "chain") {
|
if (_ent != nullptr && _ent->type != "chain") {
|
||||||
auto wI = new QListWidgetItem();
|
auto wI = new QListWidgetItem();
|
||||||
|
wI->setData(114514, profileId);
|
||||||
auto w = new ProxyItem(this, _ent, wI);
|
auto w = new ProxyItem(this, _ent, wI);
|
||||||
wI->setData(114514, id);
|
|
||||||
ui->listWidget->addItem(wI);
|
ui->listWidget->addItem(wI);
|
||||||
ui->listWidget->setItemWidget(wI, w);
|
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
|
QT_END_NAMESPACE
|
||||||
|
|
||||||
|
class ProxyItem;
|
||||||
|
|
||||||
class EditChain : public QWidget, public ProfileEditor {
|
class EditChain : public QWidget, public ProfileEditor {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
@@ -25,7 +27,9 @@ private:
|
|||||||
Ui::EditChain *ui;
|
Ui::EditChain *ui;
|
||||||
QSharedPointer<NekoRay::ProxyEntity> ent;
|
QSharedPointer<NekoRay::ProxyEntity> ent;
|
||||||
|
|
||||||
void AddProfileToListIfExist(int id);
|
void AddProfileToListIfExist(int profileId);
|
||||||
|
|
||||||
|
static void ReplaceProfile(ProxyItem *w, int profileId);
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
|
|
||||||
|
|||||||
@@ -42,3 +42,7 @@ void ProxyItem::on_remove_clicked() {
|
|||||||
delete item;
|
delete item;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QPushButton *ProxyItem::get_change_button() {
|
||||||
|
return ui->change;
|
||||||
|
}
|
||||||
|
|||||||
@@ -11,6 +11,8 @@ namespace Ui {
|
|||||||
}
|
}
|
||||||
QT_END_NAMESPACE
|
QT_END_NAMESPACE
|
||||||
|
|
||||||
|
class QPushButton;
|
||||||
|
|
||||||
class ProxyItem : public QWidget {
|
class ProxyItem : public QWidget {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
@@ -21,6 +23,8 @@ public:
|
|||||||
|
|
||||||
void refresh_data();
|
void refresh_data();
|
||||||
|
|
||||||
|
QPushButton *get_change_button();
|
||||||
|
|
||||||
QSharedPointer<NekoRay::ProxyEntity> ent;
|
QSharedPointer<NekoRay::ProxyEntity> ent;
|
||||||
QListWidgetItem *item;
|
QListWidgetItem *item;
|
||||||
bool remove_confirm = false;
|
bool remove_confirm = false;
|
||||||
|
|||||||
@@ -35,6 +35,20 @@
|
|||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</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>
|
<item>
|
||||||
<widget class="QPushButton" name="remove">
|
<widget class="QPushButton" name="remove">
|
||||||
<property name="sizePolicy">
|
<property name="sizePolicy">
|
||||||
@@ -43,8 +57,9 @@
|
|||||||
<verstretch>0</verstretch>
|
<verstretch>0</verstretch>
|
||||||
</sizepolicy>
|
</sizepolicy>
|
||||||
</property>
|
</property>
|
||||||
<property name="text">
|
<property name="icon">
|
||||||
<string>Remove</string>
|
<iconset resource="../../res/neko.qrc">
|
||||||
|
<normaloff>:/icon/material/delete.svg</normaloff>:/icon/material/delete.svg</iconset>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
@@ -124,6 +139,8 @@
|
|||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
<resources/>
|
<resources>
|
||||||
|
<include location="../../res/neko.qrc"/>
|
||||||
|
</resources>
|
||||||
<connections/>
|
<connections/>
|
||||||
</ui>
|
</ui>
|
||||||
|
|||||||
Reference in New Issue
Block a user