Merge branch 'dbus-interface' of http://gitlab2.kylin.com/kylin-desktop/kylin-nm into dbus-interface-local

This commit is contained in:
chenxuechao 2022-07-19 10:45:55 +08:00
commit c832a96c30
19 changed files with 154 additions and 31 deletions

3
debian/control vendored
View File

@ -24,7 +24,7 @@ Build-Depends: debhelper (>=9),
libukcc-dev (>= 3.1.1+1217),
libukui-log4qt-dev,
libkysdk-qtwidgets-dev(>= 1.2.0),
libukui-common-dev,
libkysdk-sysinfo-dev,
libkysdk-waylandhelper-dev(>= 1.2.0kylin2),
libkysec-dev,
Standards-Version: 4.5.0
@ -39,6 +39,7 @@ Depends: network-manager (>=1.2.6),
ukui-control-center (>= 3.1.1+1217),
libkysdk-qtwidgets(>= 1.2.0),
libkysdk-waylandhelper(>= 1.2.0kylin2),
libkysdk-sysinfo,
${shlibs:Depends},
${misc:Depends}
Description: Gui Applet tool for display and edit network simply

View File

@ -34,6 +34,11 @@ AddNetBtn::AddNetBtn(bool isWlan, QWidget *parent) : QPushButton(parent)
this->setMaximumSize(QSize(16777215, 60));
this->setProperty("useButtonPalette", true);
this->setFlat(true);
QPalette pal = this->palette();
QColor color = pal.color(QPalette::Button);
color.setAlphaF(0.5);
pal.setColor(QPalette::Button, color);
this->setPalette(pal);
QHBoxLayout *addLyt = new QHBoxLayout;
QLabel *iconLabel = new QLabel();

View File

@ -0,0 +1,33 @@
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* Copyright (C) 2022 Tianjin KYLIN Information Technology Co., Ltd.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
*
*/
#include "grayinfobutton.h"
#include <QVariant>
#define BUTTON_SIZE 36,36
#define ICON_SIZE 16,16
GrayInfoButton::GrayInfoButton(QWidget *parent): QPushButton(parent)
{
this->setFixedSize(BUTTON_SIZE);
this->setIcon(QIcon::fromTheme("preferences-system-details-symbolic"));
this->setProperty("useButtonPalette", true);
this->setFlat(true);
}

View File

@ -0,0 +1,34 @@
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* Copyright (C) 2022 Tianjin KYLIN Information Technology Co., Ltd.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
*
*/
#ifndef GRAYINFOBUTTON_H
#define GRAYINFOBUTTON_H
#include <QPushButton>
#include <QIcon>
class GrayInfoButton : public QPushButton
{
Q_OBJECT
public:
explicit GrayInfoButton(QWidget * parent = nullptr);
~GrayInfoButton() = default;
};
#endif // GRAYINFOBUTTON_H

View File

@ -2,8 +2,10 @@
SOURCES += \
$$PWD/AddBtn/addnetbtn.cpp \
$$PWD/AddBtn/grayinfobutton.cpp
HEADERS += \
$$PWD/AddBtn/addnetbtn.h \
$$PWD/AddBtn/grayinfobutton.h

View File

@ -31,6 +31,11 @@ LanItem::LanItem(bool isAcitve, QWidget *parent)
this->setMinimumSize(550, 58);
this->setProperty("useButtonPalette", true);
this->setFlat(true);
QPalette pal = this->palette();
QColor color = pal.color(QPalette::Button);
color.setAlphaF(0.5);
pal.setColor(QPalette::Button, color);
this->setPalette(pal);
// setStyleSheet("QPushButton:!checked{background-color: palette(base)}");
QHBoxLayout *mLanLyt = new QHBoxLayout(this);
mLanLyt->setContentsMargins(16,0,16,0);
@ -41,7 +46,7 @@ LanItem::LanItem(bool isAcitve, QWidget *parent)
statusLabel = new QLabel(this);
statusLabel->setAlignment(Qt::AlignRight | Qt::AlignVCenter);
// statusLabel->setMinimumSize(36,36);
infoLabel = new InfoButton(this);
infoLabel = new GrayInfoButton(this);
mLanLyt->addWidget(iconLabel);
mLanLyt->addWidget(titileLabel,Qt::AlignLeft);
mLanLyt->addStretch();

View File

@ -30,7 +30,8 @@
#include <QImage>
#include <QPainter>
#include "fixlabel.h"
#include "infobutton.h"
//#include "infobutton.h"
#include "../component/AddBtn/grayinfobutton.h"
class LanItem : public QPushButton
{
@ -39,7 +40,7 @@ public:
~LanItem();
public:
QLabel * iconLabel = nullptr;
InfoButton * infoLabel = nullptr;
GrayInfoButton * infoLabel = nullptr;
FixLabel * titileLabel = nullptr;
QLabel * statusLabel = nullptr;

View File

@ -438,7 +438,7 @@ void NetConnect::addLanItem(ItemFrame *frame, QString devName, QStringList infoL
lanItem->uuid = infoList.at(1);
lanItem->dbusPath = infoList.at(2);
connect(lanItem->infoLabel, &InfoButton::clicked, this, [=]{
connect(lanItem->infoLabel, &GrayInfoButton::clicked, this, [=]{
// open landetail page
if (!m_interface->isValid()) {
return;
@ -707,7 +707,7 @@ void NetConnect::addOneLanFrame(ItemFrame *frame, QString deviceName, QStringLis
lanItem->uuid = connUuid;
lanItem->dbusPath = connDbusPath;
connect(lanItem->infoLabel, &InfoButton::clicked, this, [=]{
connect(lanItem->infoLabel, &GrayInfoButton::clicked, this, [=]{
// open landetail page
if (!m_interface->isValid()) {
return;

View File

@ -1026,7 +1026,7 @@ void WlanConnect::addOneWlanFrame(ItemFrame *frame, QString deviceName, QString
wlanItem->statusLabel->setText("");
}
connect(wlanItem->infoLabel, &InfoButton::clicked, this, [=]{
connect(wlanItem->infoLabel, &GrayInfoButton::clicked, this, [=]{
// open detail page
if (!m_interface->isValid()) {
return;

View File

@ -33,6 +33,11 @@ WlanItem::WlanItem(bool bAcitve, bool isLock, QWidget *parent)
this->setMinimumSize(550, 58);
this->setProperty("useButtonPalette", true);
this->setFlat(true);
QPalette pal = this->palette();
QColor color = pal.color(QPalette::Button);
color.setAlphaF(0.5);
pal.setColor(QPalette::Button, color);
this->setPalette(pal);
QHBoxLayout *mLanLyt = new QHBoxLayout(this);
mLanLyt->setContentsMargins(16,0,16,0);
mLanLyt->setSpacing(16);
@ -41,7 +46,7 @@ WlanItem::WlanItem(bool bAcitve, bool isLock, QWidget *parent)
statusLabel = new QLabel(this);
statusLabel->setAlignment(Qt::AlignRight | Qt::AlignVCenter);
// statusLabel->setMinimumSize(36,36);
infoLabel = new InfoButton(this);
infoLabel = new GrayInfoButton(this);
mLanLyt->addWidget(iconLabel);
mLanLyt->addWidget(titileLabel,Qt::AlignLeft);
mLanLyt->addStretch();

View File

@ -29,7 +29,8 @@
#include <QGSettings>
#include <QImage>
#include "fixlabel.h"
#include "infobutton.h"
//#include "infobutton.h"
#include "../component/AddBtn/grayinfobutton.h"
class WlanItem : public QPushButton
{
@ -38,7 +39,7 @@ public:
~WlanItem();
public:
QLabel * iconLabel = nullptr;
InfoButton * infoLabel = nullptr;
GrayInfoButton * infoLabel = nullptr;
FixLabel * titileLabel = nullptr;
QLabel * statusLabel = nullptr;
QString uuid = "";

View File

@ -31,7 +31,7 @@
#include "ukuistylehelper/ukuistylehelper.h"
#include "windowmanager/windowmanager.h"
#include "kysdk/kysdk-system/libkysysinfo.h"
#define MAINWINDOW_WIDTH 420
#define MAINWINDOW_HEIGHT 476
@ -165,16 +165,19 @@ void MainWindow::secondaryStart()
*/
void MainWindow::initPlatform()
{
if(v10Sp1.compare(KDKGetPrjCodeName().c_str(),Qt::CaseInsensitive) == 0) {
QString feature = KDKGetOSRelease(KEY_PRODUCT_FEATURES).c_str();
if (feature.toInt() == 3) {
char* projectName = kdk_system_get_projectName();
QString strProjectName(projectName);
free(projectName);
projectName = NULL;
if(v10Sp1.compare(strProjectName,Qt::CaseInsensitive) == 0) {
unsigned int feature = kdk_system_get_productFeatures();
if (feature == 3) {
m_isShowInCenter = true;
}
} else if (intel.compare(KDKGetPrjCodeName().c_str(),Qt::CaseInsensitive) == 0) {
} else if (intel.compare(strProjectName,Qt::CaseInsensitive) == 0) {
m_isShowInCenter = true;
}
qDebug() << KDKGetPrjCodeName().c_str() << KDKGetOSRelease(KEY_PRODUCT_FEATURES).c_str() << "m_isShowInCenter" << m_isShowInCenter;
qDebug() << "projectName" << projectName << m_isShowInCenter;
}
/**

View File

@ -33,7 +33,6 @@
#include "lanpage.h"
#include "wlanpage.h"
#include "netdetails/netdetail.h"
#include <ukuisdk/kylin-com4cxx.h>
#ifdef WITHKYSEC
#include <kysec/libkysec.h>

View File

@ -841,7 +841,7 @@ void LanPage::updateActivatedConnectionArea(KyConnectItem *p_newItem)
deleteConnectionMapItem(m_activeConnectionMap, m_activatedLanListWidget, EMPTY_CONNECT_UUID);
QListWidgetItem *p_listWidgetItem = addNewItem(p_newItem, m_activatedLanListWidget);
m_activeConnectionMap.insert(p_newItem->m_connectUuid, p_listWidgetItem);
this->showDesktopNotify(tr("LAN Connected Successfully"), "networkconnected");
// this->showDesktopNotify(tr("LAN Connected Successfully"), "networkconnected");
}
if (m_inactivatedLanListWidget->count() < MAX_ITEMS) {
m_inactivatedLanListWidget->setFixedWidth(MIN_WIDTH);
@ -865,7 +865,7 @@ void LanPage::updateConnectionArea(KyConnectItem *p_newItem)
qDebug()<<"[LanPage] update connection item"<<p_newItem->m_connectName;
QListWidgetItem *p_listWidgetItem = insertNewItem(p_newItem, m_inactivatedLanListWidget);
m_inactiveConnectionMap.insert(p_newItem->m_connectUuid, p_listWidgetItem);
this->showDesktopNotify(tr("LAN Disconnected Successfully"), "networkdisconnected");
// this->showDesktopNotify(tr("LAN Disconnected Successfully"), "networkdisconnected");
}
if (m_inactivatedLanListWidget->count() < MAX_ITEMS) {
m_inactivatedLanListWidget->setFixedWidth(MIN_WIDTH);

View File

@ -560,7 +560,7 @@ void WlanPage::onWlanRemoved(QString interface, QString ssid)
} else {
deleteWirelessItemFormMap(m_activateConnectionItemMap,
m_activatedNetListWidget, ssid);
showDesktopNotify(tr("WLAN Disconnected Successfully"), "networkdisconnected");
// showDesktopNotify(tr("WLAN Disconnected Successfully"), "networkdisconnected");
QListWidgetItem *p_listWidgetItem = addEmptyItem(m_activatedNetListWidget);
m_activateConnectionItemMap.insert(EMPTY_SSID, p_listWidgetItem);
@ -812,6 +812,7 @@ void WlanPage::sendApStateChangeSignal(QString uuid,
return;
}
#if 0
void WlanPage::wlanShowNotify(QString ssid, NetworkManager::ActiveConnection::State state,
NetworkManager::ActiveConnection::Reason reason)
{
@ -825,6 +826,7 @@ void WlanPage::wlanShowNotify(QString ssid, NetworkManager::ActiveConnection::St
return;
}
#endif
void WlanPage::updateActivatedArea(QString uuid, QString ssid, QString devName)
{
@ -922,7 +924,7 @@ void WlanPage::onConnectionStateChanged(QString uuid,
!m_activateConnectionItemMap.contains(ssid)) {
qDebug() << "wlan remove before deactivated";
} else {
wlanShowNotify(ssid, state, reason);
// wlanShowNotify(ssid, state, reason);
}
}

View File

@ -170,8 +170,8 @@ private:
void sendApStateChangeSignal(QString uuid, QString ssid, QString deviceName,
NetworkManager::ActiveConnection::State state);
void wlanShowNotify(QString ssid, NetworkManager::ActiveConnection::State state,
NetworkManager::ActiveConnection::Reason reason);
// void wlanShowNotify(QString ssid, NetworkManager::ActiveConnection::State state,
// NetworkManager::ActiveConnection::Reason reason);
private:
QMap<QString, QListWidgetItem*> m_wirelessNetItemMap;

View File

@ -26,8 +26,10 @@
#define ICON_SIZE 16,16
#define BACKGROUND_COLOR QColor(0,0,0,0)
#define FOREGROUND_COLOR_NORMAL qApp->palette().text().color()
#define FOREGROUND_COLOR_HOVER QColor(55,144,250,255)
#define FOREGROUND_COLOR_PRESS QColor(36,109,212,255)
//#define FOREGROUND_COLOR_HOVER QColor(55,144,250,255)
//#define FOREGROUND_COLOR_PRESS QColor(36,109,212,255)
#define FOREGROUND_COLOR_BRIGHTTEXT qApp->palette().brightText().color()
#define FOREGROUND_COLOR_HIGHLIGHT qApp->palette().highlight().color()
#define OUTER_PATH 8,8,16,16
#define INNER_PATH 9,9,14,14
#define TEXT_POS 14,5,16,16,0
@ -54,6 +56,26 @@ void InfoButton::onPaletteChanged()
this->repaint();
}
QColor InfoButton::mixColor(const QColor &c1, const QColor &c2, qreal bias)
{
if (bias <= 0.0) {
return c1;
}
if (bias >= 1.0) {
return c2;
}
if (qIsNaN(bias)) {
return c1;
}
qreal r = mixQreal(c1.redF(), c2.redF(), bias);
qreal g = mixQreal(c1.greenF(), c2.greenF(), bias);
qreal b = mixQreal(c1.blueF(), c2.blueF(), bias);
qreal a = mixQreal(c1.alphaF(), c2.alphaF(), bias);
return QColor::fromRgbF(r, g, b, a);
}
void InfoButton::paintEvent(QPaintEvent *event)
{
QPalette pal = this->palette();
@ -87,7 +109,8 @@ void InfoButton::paintEvent(QPaintEvent *event)
void InfoButton::enterEvent(QEvent *event)
{
m_foregroundColor = FOREGROUND_COLOR_HOVER;
// m_foregroundColor = FOREGROUND_COLOR_HOVER;
m_foregroundColor = FOREGROUND_COLOR_HIGHLIGHT;
this->update();
}
@ -99,14 +122,16 @@ void InfoButton::leaveEvent(QEvent *event)
void InfoButton::mousePressEvent(QMouseEvent *event)
{
m_foregroundColor = FOREGROUND_COLOR_PRESS;
// m_foregroundColor = FOREGROUND_COLOR_PRESS;
m_foregroundColor = mixColor(FOREGROUND_COLOR_HIGHLIGHT, FOREGROUND_COLOR_BRIGHTTEXT, 0.2);
this->update();
return QPushButton::mousePressEvent(event);
}
void InfoButton::mouseReleaseEvent(QMouseEvent *event)
{
m_foregroundColor = FOREGROUND_COLOR_HOVER;
// m_foregroundColor = FOREGROUND_COLOR_HOVER;
m_foregroundColor = mixColor(FOREGROUND_COLOR_HIGHLIGHT, FOREGROUND_COLOR_BRIGHTTEXT, 0.2);
this->update();
return QPushButton::mouseReleaseEvent(event);
}

View File

@ -39,6 +39,12 @@ protected:
private:
void initUI();
static inline qreal mixQreal(qreal a, qreal b, qreal bias)
{
return a + (b - a) * bias;
}
QColor mixColor(const QColor &c1, const QColor &c2, qreal bias);
private:
QColor m_backgroundColor;
QColor m_foregroundColor;

View File

@ -15,11 +15,12 @@ CONFIG += c++14 qt warn_on link_pkgconfig
#CONFIG += release
PKGCONFIG +=gio-2.0 glib-2.0 gio-unix-2.0 libnm libnma libsecret-1 gtk+-3.0 gsettings-qt libcap kysdk-qtwidgets kysdk-waylandhelper
PKGCONFIG +=kysdk-system
INCLUDEPATH += /usr/include/KF5/NetworkManagerQt
LIBS += -L/usr/lib/ -lgsettings-qt -lX11 -lKF5NetworkManagerQt -lukui-log4qt -lukui-com4c -lukui-com4cxx -lkysec
#LIBS += -lkysec
LIBS += -L/usr/lib/ -lgsettings-qt -lX11 -lKF5NetworkManagerQt -lukui-log4qt -lkysec
target.path = /usr/bin
target.source += $$TARGET
desktop.path = /etc/xdg/autostart/