fix(托盘):openKylin同步主线托盘问题修改。(BUG号:I7GTAA、I7WGGL)

This commit is contained in:
chenxuechao 2023-12-11 15:36:18 +08:00 committed by cxc
parent c91e1ccbca
commit b5de686bf3
2 changed files with 29 additions and 17 deletions

View File

@ -266,6 +266,11 @@ void StatusNotiferScrollArea::itemAdded(QString serviceAndPath)
}
}
if (m_services.contains(serviceAndPath)) {
qWarning() << serviceAndPath + " has been added.";
return ;
}
int slash = serviceAndPath.indexOf('/');
QString serv = serviceAndPath.left(slash);
QString path = serviceAndPath.mid(slash);

View File

@ -51,6 +51,7 @@ StatusNotifierButton::StatusNotifierButton(QString service, QString objectPath,
m_plugin(plugin)
{
this->setAcceptDrops(true);
this->setFixedSize(m_plugin->panel()->panelSize()*0.7, m_plugin->panel()->panelSize()*0.7);
m_interface = new SniAsync(service, objectPath, QDBusConnection::sessionBus(), this);
connect(m_interface, &SniAsync::NewIcon, this, &StatusNotifierButton::newIcon);
@ -68,9 +69,13 @@ StatusNotifierButton::StatusNotifierButton(QString service, QString objectPath,
} else {
if(this->m_id.isEmpty()) {
if(m_count < 10) { //超过10次将不再获取
QTimer::singleShot(500,[this] {
QTimer *tmpTimer = new QTimer(this);
connect(tmpTimer, &QTimer::timeout, this, [=] () {
tmpTimer->stop();
hideAbleStatusNotifierButton();
tmpTimer->deleteLater();
});
tmpTimer->start(500);
qWarning()<<"Get item id for the"<<m_count<<"time";
} else {
qCritical()<<"count more than 10 times, "<<m_id<<m_toolTipTitle<<service<<"Load failed!";
@ -119,7 +124,10 @@ StatusNotifierButton::StatusNotifierButton(QString service, QString objectPath,
StatusNotifierButton::~StatusNotifierButton()
{
delete m_interface;
if (m_interface) {
delete m_interface;
m_interface = nullptr;
}
if(m_themeSettings) {
delete(m_themeSettings);
m_themeSettings = NULL;
@ -164,9 +172,12 @@ void StatusNotifierButton::refetchIcon(Status status)
if (!iconName.isEmpty()) {
if (QIcon::hasThemeIcon(iconName)) {
nextIcon = QIcon::fromTheme(iconName);
} else if (QFile(iconName).exists()) {
nextIcon.addFile(iconName);
} else {
if(m_themePath.isEmpty())
if(m_themePath.isEmpty()) {
m_themePath = "/usr/share/icons/";
}
QDir themeDir(m_themePath);
if (themeDir.exists()) {
if (themeDir.exists(iconName + ".png")) {
@ -342,9 +353,6 @@ void StatusNotifierButton::mouseMoveEvent(QMouseEvent *e)
drag->deleteLater();
refetchIcon(ACTIVE);
}
QToolButton::mouseMoveEvent(e);
//QAbstractButton::mouseMoveEvent(e);
}
void StatusNotifierButton::mouseReleaseEvent(QMouseEvent *event)
@ -524,22 +532,21 @@ void StatusNotifierButton::leaveEvent(QEvent *event)
void StatusNotifierButton::paintEvent(QPaintEvent *event)
{
if (m_plugin->panel()->isHorizontal()) {
this->setFixedSize(m_plugin->panel()->panelSize()*0.7, m_plugin->panel()->panelSize()*0.7);
} else {
this->setFixedSize(m_plugin->panel()->panelSize()*0.7, m_plugin->panel()->panelSize()*0.7);
}
this->setFixedSize(m_plugin->panel()->panelSize()*0.7, m_plugin->panel()->panelSize()*0.7);
QToolButton::paintEvent(event);
}
QString StatusNotifierButton::hideAbleStatusNotifierButton()
{
m_interface->propertyGetAsync(QLatin1String("Id"), [this] (QString title) {
m_id = "";
m_id = title;
emit paramReady();
});
return m_id;
if (m_interface) {
m_interface->propertyGetAsync(QLatin1String("Id"), [this] (QString title) {
m_id = "";
m_id = title;
emit paramReady();
});
return m_id;
}
return QString();
}
int StatusNotifierButton::getStatus()