improve edit chain

This commit is contained in:
arm64v8a
2023-01-22 17:53:51 +09:00
parent 8fa966aba4
commit f0b8c4ec02
10 changed files with 59 additions and 9 deletions

View 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

View 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

View File

@@ -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>

View 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>

View File

@@ -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>

View File

@@ -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();
}
}

View File

@@ -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:

View File

@@ -42,3 +42,7 @@ void ProxyItem::on_remove_clicked() {
delete item;
}
}
QPushButton *ProxyItem::get_change_button() {
return ui->change;
}

View File

@@ -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;

View File

@@ -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>