fix: some ui fixes

This commit is contained in:
Qv2ray-dev 2020-03-19 16:13:48 +08:00
parent da1cbb951c
commit 0c0b49b90e
3 changed files with 26 additions and 20 deletions

View File

@ -27,12 +27,12 @@ void ConnectionInfoWidget::UpdateColorScheme()
editJsonBtn->setIcon(QICON_R("json.png"));
shareLinkTxt->setStyleSheet("border-bottom: 1px solid gray; border-radius: 0px; padding: 2px; background-color: " +
this->palette().color(this->backgroundRole()).name(QColor::HexRgb));
groupSubsLinkTxt->setStyleSheet("border-bottom: 1px solid gray; border-radius: 0px; padding: 2px; background-color: " +
this->palette().color(this->backgroundRole()).name(QColor::HexRgb));
//
auto isDarkTheme = GlobalConfig.uiConfig.useDarkTheme;
qrPixmapBlured = BlurImage(ColorizeImage(qrPixmap, isDarkTheme ? QColor(Qt::black) : QColor(Qt::white), 0.7), 35);
//
qrLabel->setPixmap(IsComplexConfig(connectionId) ? QPixmap(":/assets/icons/qv2ray.ico") : (isRealPixmapShown ? qrPixmap : qrPixmapBlured));
//
connectBtn->setIcon(ConnectionManager->IsConnected(connectionId) ? QICON_R("stop.png") : QICON_R("connect.png"));
}
@ -46,12 +46,15 @@ ConnectionInfoWidget::ConnectionInfoWidget(QWidget *parent) : QWidget(parent)
shareLinkTxt->setAutoFillBackground(true);
shareLinkTxt->setCursor(QCursor(Qt::CursorShape::IBeamCursor));
shareLinkTxt->installEventFilter(this);
groupSubsLinkTxt->installEventFilter(this);
qrLabel->installEventFilter(this);
//
connect(ConnectionManager, &QvConfigHandler::OnConnected, this, &ConnectionInfoWidget::OnConnected);
connect(ConnectionManager, &QvConfigHandler::OnDisconnected, this, &ConnectionInfoWidget::OnDisConnected);
connect(ConnectionManager, &QvConfigHandler::OnConnectionModified, this, &ConnectionInfoWidget::OnConnectionModified);
connect(ConnectionManager, &QvConfigHandler::OnConnectionGroupChanged, this, &ConnectionInfoWidget::OnConnectionModified);
connect(ConnectionManager, &QvConfigHandler::OnGroupRenamed, this, &ConnectionInfoWidget::OnGroupRenamed);
connect(ConnectionManager, &QvConfigHandler::OnConnectionGroupChanged, this, &ConnectionInfoWidget::OnConnectionModified);
}
void ConnectionInfoWidget::ShowDetails(const tuple<GroupId, ConnectionId> &_identifier)
@ -113,8 +116,8 @@ void ConnectionInfoWidget::ShowDetails(const tuple<GroupId, ConnectionId> &_iden
}
//
groupShareTxt->setPlainText(shareLinks.join(NEWLINE));
groupSubsLinkLabel->setText(ConnectionManager->IsSubscription(groupId) ? get<0>(ConnectionManager->GetSubscriptionData(groupId)) :
tr("Not a subscription"));
groupSubsLinkTxt->setText(ConnectionManager->IsSubscription(groupId) ? get<0>(ConnectionManager->GetSubscriptionData(groupId)) :
tr("Not a subscription"));
}
}
@ -128,6 +131,16 @@ void ConnectionInfoWidget::OnConnectionModified(const ConnectionId &id)
ShowDetails({ GetConnectionGroupId(id), id });
}
void ConnectionInfoWidget::OnGroupRenamed(const GroupId &id, const QString &oldName, const QString &newName)
{
Q_UNUSED(oldName)
if (this->groupId == id)
{
groupNameLabel->setText(newName);
groupLabel->setText(newName);
}
}
void ConnectionInfoWidget::on_connectBtn_clicked()
{
if (ConnectionManager->IsConnected(connectionId))
@ -172,6 +185,11 @@ bool ConnectionInfoWidget::eventFilter(QObject *object, QEvent *event)
if (!shareLinkTxt->hasSelectedText())
shareLinkTxt->selectAll();
}
else if (groupSubsLinkTxt->underMouse() && event->type() == QEvent::MouseButtonRelease)
{
if (!groupSubsLinkTxt->hasSelectedText())
groupSubsLinkTxt->selectAll();
}
else if (qrLabel->underMouse() && event->type() == QEvent::MouseButtonRelease)
{
qrLabel->setPixmap(IsComplexConfig(connectionId) ? QPixmap(":/assets/icons/qv2ray.ico") :

View File

@ -31,6 +31,7 @@ class ConnectionInfoWidget
void on_deleteBtn_clicked();
void OnConnectionModified(const ConnectionId &id);
void OnGroupRenamed(const GroupId &id, const QString &oldName, const QString &newName);
void OnConnected(const ConnectionId &id);
void OnDisConnected(const ConnectionId &id);
void on_latencyBtn_clicked();

View File

@ -368,22 +368,6 @@
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QLabel" name="groupSubsLinkLabel">
<property name="cursor">
<cursorShape>IBeamCursor</cursorShape>
</property>
<property name="text">
<string/>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
<property name="textInteractionFlags">
<set>Qt::LinksAccessibleByMouse|Qt::TextSelectableByMouse</set>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="label_7">
<property name="text">
@ -419,6 +403,9 @@
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QLineEdit" name="groupSubsLinkTxt"/>
</item>
</layout>
</widget>
</widget>