sdk-tooltips-UI

This commit is contained in:
zhangyuanyuan1 2022-04-08 15:10:21 +08:00
parent ae64cbf5d7
commit 5b19e942bb
7 changed files with 127 additions and 118 deletions

View File

@ -217,10 +217,6 @@ void DetailPage::initUI() {
if (mIsWlan) {
layout->addLayout(mAutoLayout);
}
// //复制按钮位置
// QPoint m_copyBtnPosition = m_netCopyButton->mapToGlobal(m_netCopyButton->pos());
// m_netCopyButton->m_copyTip->move(m_copyBtnPosition.x() - 100, m_copyBtnPosition.y() + 12);
}
void DetailPage::setEnableOfSaveBtn() {

View File

@ -2,6 +2,7 @@
#include <QFontMetrics>
#include <QDebug>
#include <QApplication>
#include <QToolTip>
#include "coninfo.h"
#define THEME_SCHAME "org.ukui.style"
@ -125,39 +126,22 @@ CopyButton::CopyButton()
btnPal.setColor(QPalette::Button, color);
this->setPalette(btnPal);
//获取当前主题的颜色
QPalette pal = qApp->palette();
QGSettings * styleGsettings = nullptr;
const QByteArray style_id(THEME_SCHAME);
if (QGSettings::isSchemaInstalled(style_id)) {
styleGsettings = new QGSettings(style_id);
QString currentTheme = styleGsettings->get(COLOR_THEME).toString();
if(currentTheme == "ukui-default"){
pal = lightPalette(this);
}
}
//设置“复制全部”消息提示
m_copyTip = new KBallonTip();
m_copyTip->setTipType(Nothing);
m_copyTip->setFixedSize(90, 38);
m_copyTip->setWindowFlags(Qt::FramelessWindowHint);
m_copyTip->setAttribute(Qt::WA_TranslucentBackground, true);
m_copyTip->setContentsMargins(15, 7, 0, 7);
m_copyTip->setText(tr("Copy all"));
// m_copyTip->setTipTime(5500);
m_copyTip->setPalette(pal);
// m_copyTip->setFocusPolicy(Qt::NoFocus);
// //设置“复制全部”消息提示
// m_copyTip = new KBallonTip();
// m_copyTip->setTipType(Nothing);
// m_copyTip->setFixedSize(90, 38);
// m_copyTip->setWindowFlags(Qt::FramelessWindowHint);
// m_copyTip->setAttribute(Qt::WA_TranslucentBackground, true);
// m_copyTip->setContentsMargins(15, 7, 0, 7);
// m_copyTip->setText(tr("Copy all"));
//设置“复制成功”消息弹窗格式
m_copiedTip = new KBallonTip();
m_copiedTip->setTipType(Normal);
m_copiedTip->setFixedSize(145, 55);
m_copiedTip->setFixedSize(158, 58);
m_copiedTip->setWindowFlags(Qt::FramelessWindowHint);
m_copiedTip->setAttribute(Qt::WA_TranslucentBackground, true);
m_copiedTip->setText(tr("Copied successfully"));
// m_copiedTip->setTipTime(1500);
m_copiedTip->setPalette(pal);
m_copiedTip->setText(tr("Copied successfully!"));
}
CopyButton::~CopyButton()
@ -174,6 +158,22 @@ CopyButton::~CopyButton()
}
}
QPalette CopyButton::GetTheme()
{
//获取当前主题的颜色
QPalette pal = qApp->palette();
QGSettings * styleGsettings = nullptr;
const QByteArray style_id(THEME_SCHAME);
if (QGSettings::isSchemaInstalled(style_id)) {
styleGsettings = new QGSettings(style_id);
QString currentTheme = styleGsettings->get(COLOR_THEME).toString();
if(currentTheme == "ukui-default"){
pal = lightPalette(this);
}
}
return pal;
}
void CopyButton::mousePressEvent(QMouseEvent *event)
{
return QPushButton:: mousePressEvent(event);
@ -182,22 +182,29 @@ void CopyButton::mousePressEvent(QMouseEvent *event)
void CopyButton::mouseReleaseEvent(QMouseEvent *event)
{
//设置弹窗位置并显示
m_mousePosition = event->globalPos();
m_copiedTip->move(m_mousePosition.x() - 195, m_mousePosition.y() + 130);
// QPoint m_mousePosition = event->globalPos();
QPoint m_copyBtnPosition = this->mapToGlobal(this->pos());
m_copiedTip->move(m_copyBtnPosition.x() - 500, m_copyBtnPosition.y() + 130);
QPalette pal = GetTheme();
m_copiedTip->setPalette(pal);
// m_copiedTip->setTipTime(1500);
m_copiedTip->showInfo();
return QPushButton::mouseReleaseEvent(event);
}
void CopyButton::enterEvent(QEvent *event)
{
// this->setToolTip(tr("Copy all"));
QPoint m_enterPosition = cursor().pos();
m_copyTip->move(m_enterPosition.x() - 120, m_enterPosition.y() + 12);
m_copyTip->showInfo();
//信号
QPalette palette = QToolTip::palette();
palette = GetTheme();
QToolTip::setPalette(palette);
this->setToolTip(tr("Copy all"));
//设置弹窗位置并显示
// m_copyBtnPosition = this->mapToGlobal(this->pos());
// m_copyTip->move(m_copyBtnPosition.x() - 395, m_copyBtnPosition.y() + 35);
// QPalette pal = GetTheme();
// m_copyTip->setPalette(pal);
// m_copyTip->setTipTime(2000);
// m_copyTip->showInfo();
return QPushButton::enterEvent(event);
}

View File

@ -76,13 +76,12 @@ public:
explicit CopyButton();
~CopyButton();
public:
KBallonTip * m_copyTip = nullptr;
private:
QPalette GetTheme();
private:
KBallonTip * m_copyTip = nullptr;
KBallonTip * m_copiedTip = nullptr;
QPoint m_mousePosition;
QPoint m_enterPosition;
// QPoint m_copyBtnPosition;
protected:
void mousePressEvent(QMouseEvent *event);

View File

@ -4,12 +4,12 @@
<context>
<name>CopyButton</name>
<message>
<location filename="../src/frontend/netdetails/detailwidget.cpp" line="133"/>
<source>Copied successfully</source>
<location filename="../src/frontend/netdetails/detailwidget.cpp" line="143"/>
<source>Copied successfully!</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../src/frontend/netdetails/detailwidget.cpp" line="140"/>
<location filename="../src/frontend/netdetails/detailwidget.cpp" line="196"/>
<source>Copy all</source>
<translation type="unfinished"></translation>
</message>
@ -65,71 +65,72 @@
<context>
<name>DetailPage</name>
<message>
<location filename="../src/frontend/netdetails/detailpage.cpp" line="182"/>
<location filename="../src/frontend/netdetails/detailpage.cpp" line="185"/>
<source>Auto Connection</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../src/frontend/netdetails/detailpage.cpp" line="138"/>
<location filename="../src/frontend/netdetails/detailpage.h" line="86"/>
<location filename="../src/frontend/netdetails/detailpage.cpp" line="141"/>
<location filename="../src/frontend/netdetails/detailpage.h" line="88"/>
<source>SSID:</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../src/frontend/netdetails/detailpage.cpp" line="129"/>
<location filename="../src/frontend/netdetails/detailpage.cpp" line="133"/>
<source>Please input SSID:</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../src/frontend/netdetails/detailpage.cpp" line="142"/>
<location filename="../src/frontend/netdetails/detailpage.h" line="87"/>
<location filename="../src/frontend/netdetails/detailpage.cpp" line="145"/>
<location filename="../src/frontend/netdetails/detailpage.h" line="89"/>
<source>Protocol:</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../src/frontend/netdetails/detailpage.cpp" line="146"/>
<location filename="../src/frontend/netdetails/detailpage.cpp" line="149"/>
<location filename="../src/frontend/netdetails/detailpage.h" line="90"/>
<source>Security Type:</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../src/frontend/netdetails/detailpage.cpp" line="150"/>
<location filename="../src/frontend/netdetails/detailpage.h" line="89"/>
<location filename="../src/frontend/netdetails/detailpage.cpp" line="153"/>
<location filename="../src/frontend/netdetails/detailpage.h" line="91"/>
<source>Hz:</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../src/frontend/netdetails/detailpage.cpp" line="154"/>
<location filename="../src/frontend/netdetails/detailpage.h" line="90"/>
<location filename="../src/frontend/netdetails/detailpage.cpp" line="157"/>
<location filename="../src/frontend/netdetails/detailpage.h" line="92"/>
<source>Chan:</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../src/frontend/netdetails/detailpage.cpp" line="158"/>
<location filename="../src/frontend/netdetails/detailpage.h" line="91"/>
<location filename="../src/frontend/netdetails/detailpage.cpp" line="161"/>
<location filename="../src/frontend/netdetails/detailpage.h" line="93"/>
<source>BandWidth:</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../src/frontend/netdetails/detailpage.cpp" line="172"/>
<location filename="../src/frontend/netdetails/detailpage.h" line="94"/>
<location filename="../src/frontend/netdetails/detailpage.cpp" line="175"/>
<location filename="../src/frontend/netdetails/detailpage.h" line="96"/>
<source>IPV6:</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../src/frontend/netdetails/detailpage.cpp" line="162"/>
<location filename="../src/frontend/netdetails/detailpage.h" line="92"/>
<location filename="../src/frontend/netdetails/detailpage.cpp" line="165"/>
<location filename="../src/frontend/netdetails/detailpage.h" line="94"/>
<source>IPV4:</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../src/frontend/netdetails/detailpage.cpp" line="166"/>
<location filename="../src/frontend/netdetails/detailpage.h" line="93"/>
<location filename="../src/frontend/netdetails/detailpage.cpp" line="169"/>
<location filename="../src/frontend/netdetails/detailpage.h" line="95"/>
<source>IPV4 Dns:</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../src/frontend/netdetails/detailpage.cpp" line="176"/>
<location filename="../src/frontend/netdetails/detailpage.h" line="95"/>
<location filename="../src/frontend/netdetails/detailpage.cpp" line="179"/>
<location filename="../src/frontend/netdetails/detailpage.h" line="97"/>
<source>Mac:</source>
<translation type="unfinished"></translation>
</message>

View File

@ -102,12 +102,12 @@
<context>
<name>CopyButton</name>
<message>
<location filename="../src/frontend/netdetails/detailwidget.cpp" line="133"/>
<source>Copied successfully</source>
<location filename="../src/frontend/netdetails/detailwidget.cpp" line="143"/>
<source>Copied successfully!</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../src/frontend/netdetails/detailwidget.cpp" line="140"/>
<location filename="../src/frontend/netdetails/detailwidget.cpp" line="196"/>
<source>Copy all</source>
<translation type="unfinished"></translation>
</message>
@ -163,71 +163,72 @@
<context>
<name>DetailPage</name>
<message>
<location filename="../src/frontend/netdetails/detailpage.cpp" line="182"/>
<location filename="../src/frontend/netdetails/detailpage.cpp" line="185"/>
<source>Auto Connection</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../src/frontend/netdetails/detailpage.cpp" line="138"/>
<location filename="../src/frontend/netdetails/detailpage.h" line="86"/>
<location filename="../src/frontend/netdetails/detailpage.cpp" line="141"/>
<location filename="../src/frontend/netdetails/detailpage.h" line="88"/>
<source>SSID:</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../src/frontend/netdetails/detailpage.cpp" line="129"/>
<location filename="../src/frontend/netdetails/detailpage.cpp" line="133"/>
<source>Please input SSID:</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../src/frontend/netdetails/detailpage.cpp" line="142"/>
<location filename="../src/frontend/netdetails/detailpage.h" line="87"/>
<location filename="../src/frontend/netdetails/detailpage.cpp" line="145"/>
<location filename="../src/frontend/netdetails/detailpage.h" line="89"/>
<source>Protocol:</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../src/frontend/netdetails/detailpage.cpp" line="146"/>
<location filename="../src/frontend/netdetails/detailpage.cpp" line="149"/>
<location filename="../src/frontend/netdetails/detailpage.h" line="90"/>
<source>Security Type:</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../src/frontend/netdetails/detailpage.cpp" line="150"/>
<location filename="../src/frontend/netdetails/detailpage.h" line="89"/>
<location filename="../src/frontend/netdetails/detailpage.cpp" line="153"/>
<location filename="../src/frontend/netdetails/detailpage.h" line="91"/>
<source>Hz:</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../src/frontend/netdetails/detailpage.cpp" line="154"/>
<location filename="../src/frontend/netdetails/detailpage.h" line="90"/>
<location filename="../src/frontend/netdetails/detailpage.cpp" line="157"/>
<location filename="../src/frontend/netdetails/detailpage.h" line="92"/>
<source>Chan:</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../src/frontend/netdetails/detailpage.cpp" line="158"/>
<location filename="../src/frontend/netdetails/detailpage.h" line="91"/>
<location filename="../src/frontend/netdetails/detailpage.cpp" line="161"/>
<location filename="../src/frontend/netdetails/detailpage.h" line="93"/>
<source>BandWidth:</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../src/frontend/netdetails/detailpage.cpp" line="172"/>
<location filename="../src/frontend/netdetails/detailpage.h" line="94"/>
<location filename="../src/frontend/netdetails/detailpage.cpp" line="175"/>
<location filename="../src/frontend/netdetails/detailpage.h" line="96"/>
<source>IPV6:</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../src/frontend/netdetails/detailpage.cpp" line="162"/>
<location filename="../src/frontend/netdetails/detailpage.h" line="92"/>
<location filename="../src/frontend/netdetails/detailpage.cpp" line="165"/>
<location filename="../src/frontend/netdetails/detailpage.h" line="94"/>
<source>IPV4:</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../src/frontend/netdetails/detailpage.cpp" line="166"/>
<location filename="../src/frontend/netdetails/detailpage.h" line="93"/>
<location filename="../src/frontend/netdetails/detailpage.cpp" line="169"/>
<location filename="../src/frontend/netdetails/detailpage.h" line="95"/>
<source>IPV4 Dns:</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../src/frontend/netdetails/detailpage.cpp" line="176"/>
<location filename="../src/frontend/netdetails/detailpage.h" line="95"/>
<location filename="../src/frontend/netdetails/detailpage.cpp" line="179"/>
<location filename="../src/frontend/netdetails/detailpage.h" line="97"/>
<source>Mac:</source>
<translation type="unfinished"></translation>
</message>

Binary file not shown.

View File

@ -35,12 +35,16 @@
<context>
<name>CopyButton</name>
<message>
<location filename="../src/frontend/netdetails/detailwidget.cpp" line="133"/>
<source>Copied successfully</source>
<translation></translation>
<translation type="vanished"></translation>
</message>
<message>
<location filename="../src/frontend/netdetails/detailwidget.cpp" line="140"/>
<location filename="../src/frontend/netdetails/detailwidget.cpp" line="143"/>
<source>Copied successfully!</source>
<translation></translation>
</message>
<message>
<location filename="../src/frontend/netdetails/detailwidget.cpp" line="196"/>
<source>Copy all</source>
<translation></translation>
</message>
@ -96,71 +100,72 @@
<context>
<name>DetailPage</name>
<message>
<location filename="../src/frontend/netdetails/detailpage.cpp" line="182"/>
<location filename="../src/frontend/netdetails/detailpage.cpp" line="185"/>
<source>Auto Connection</source>
<translation></translation>
</message>
<message>
<location filename="../src/frontend/netdetails/detailpage.cpp" line="138"/>
<location filename="../src/frontend/netdetails/detailpage.h" line="86"/>
<location filename="../src/frontend/netdetails/detailpage.cpp" line="141"/>
<location filename="../src/frontend/netdetails/detailpage.h" line="88"/>
<source>SSID:</source>
<translation>SSID</translation>
</message>
<message>
<location filename="../src/frontend/netdetails/detailpage.cpp" line="129"/>
<location filename="../src/frontend/netdetails/detailpage.cpp" line="133"/>
<source>Please input SSID:</source>
<translation>SSID:</translation>
</message>
<message>
<location filename="../src/frontend/netdetails/detailpage.cpp" line="142"/>
<location filename="../src/frontend/netdetails/detailpage.h" line="87"/>
<location filename="../src/frontend/netdetails/detailpage.cpp" line="145"/>
<location filename="../src/frontend/netdetails/detailpage.h" line="89"/>
<source>Protocol:</source>
<translation></translation>
</message>
<message>
<location filename="../src/frontend/netdetails/detailpage.cpp" line="146"/>
<location filename="../src/frontend/netdetails/detailpage.cpp" line="149"/>
<location filename="../src/frontend/netdetails/detailpage.h" line="90"/>
<source>Security Type:</source>
<translation></translation>
</message>
<message>
<location filename="../src/frontend/netdetails/detailpage.cpp" line="150"/>
<location filename="../src/frontend/netdetails/detailpage.h" line="89"/>
<location filename="../src/frontend/netdetails/detailpage.cpp" line="153"/>
<location filename="../src/frontend/netdetails/detailpage.h" line="91"/>
<source>Hz:</source>
<translation></translation>
</message>
<message>
<location filename="../src/frontend/netdetails/detailpage.cpp" line="154"/>
<location filename="../src/frontend/netdetails/detailpage.h" line="90"/>
<location filename="../src/frontend/netdetails/detailpage.cpp" line="157"/>
<location filename="../src/frontend/netdetails/detailpage.h" line="92"/>
<source>Chan:</source>
<translation></translation>
</message>
<message>
<location filename="../src/frontend/netdetails/detailpage.cpp" line="158"/>
<location filename="../src/frontend/netdetails/detailpage.h" line="91"/>
<location filename="../src/frontend/netdetails/detailpage.cpp" line="161"/>
<location filename="../src/frontend/netdetails/detailpage.h" line="93"/>
<source>BandWidth:</source>
<translation></translation>
</message>
<message>
<location filename="../src/frontend/netdetails/detailpage.cpp" line="172"/>
<location filename="../src/frontend/netdetails/detailpage.h" line="94"/>
<location filename="../src/frontend/netdetails/detailpage.cpp" line="175"/>
<location filename="../src/frontend/netdetails/detailpage.h" line="96"/>
<source>IPV6:</source>
<translation>IPV6地址</translation>
</message>
<message>
<location filename="../src/frontend/netdetails/detailpage.cpp" line="162"/>
<location filename="../src/frontend/netdetails/detailpage.h" line="92"/>
<location filename="../src/frontend/netdetails/detailpage.cpp" line="165"/>
<location filename="../src/frontend/netdetails/detailpage.h" line="94"/>
<source>IPV4:</source>
<translation>IPV4地址</translation>
</message>
<message>
<location filename="../src/frontend/netdetails/detailpage.cpp" line="166"/>
<location filename="../src/frontend/netdetails/detailpage.h" line="93"/>
<location filename="../src/frontend/netdetails/detailpage.cpp" line="169"/>
<location filename="../src/frontend/netdetails/detailpage.h" line="95"/>
<source>IPV4 Dns:</source>
<translation>IPV4 DNS服务器</translation>
</message>
<message>
<location filename="../src/frontend/netdetails/detailpage.cpp" line="176"/>
<location filename="../src/frontend/netdetails/detailpage.h" line="95"/>
<location filename="../src/frontend/netdetails/detailpage.cpp" line="179"/>
<location filename="../src/frontend/netdetails/detailpage.h" line="97"/>
<source>Mac:</source>
<translation></translation>
</message>