Merge branch '3.1-mavis' into 'dbus-interface'

3.1 mavis

See merge request kylin-desktop/kylin-nm!573
This commit is contained in:
赵 世旭 2022-04-18 06:59:38 +00:00
commit 0eef6207e6
11 changed files with 100 additions and 24 deletions

1
debian/control vendored
View File

@ -23,6 +23,7 @@ Build-Depends: debhelper (>=9),
libgtk-3-dev,
libukcc-dev (>= 3.1.1+1217),
libukui-log4qt-dev,
libukui-common-dev,
Standards-Version: 4.5.0
Rules-Requires-Root: no
Homepage: https://github.com/ukui/kylin-nm

View File

@ -197,10 +197,10 @@ private:
public:
static KyNetworkResourceManager* m_pInstance;
NetworkManager::ActiveConnection::List m_activeConns;
NetworkManager::Connection::List m_connections;
NetworkManager::Device::List m_devices;
NetworkManager::WirelessNetwork::List m_wifiNets;
NetworkManager::ActiveConnection::List m_activeConns; //已连接资源类
NetworkManager::Connection::List m_connections; //配置文件资源类
NetworkManager::Device::List m_devices; //设备类
NetworkManager::WirelessNetwork::List m_wifiNets; //无线热点类
};

View File

@ -228,6 +228,10 @@ QStringList DbusAdaptor::getApInfoBySsid(QString devName, QString ssid)
return list;
}
void DbusAdaptor::showKylinNM(int type)
{
parent()->onShowMainWindow(type);
}
//扫描
void DbusAdaptor::reScan()

View File

@ -86,6 +86,8 @@ public Q_SLOTS: // METHODS
//keyring
void keyRingInit();
void keyRingClear();
//just show
void showKylinNM(int type);
Q_SIGNALS: // SIGNALS
// void wirelessActivating(QString devName, QString ssid);
// void wiredActivating(QString devName, QString ssid);

View File

@ -234,7 +234,7 @@ void WlanListItem::initWlanUI()
m_pwdLineEdit = new QLineEdit(m_pwdFrame);
m_pwdLineEdit->setFixedWidth(LINEEDIT_WIDTH);
m_pwdLineEdit->setAttribute(Qt::WA_InputMethodEnabled, false);
// m_pwdLineEdit->setAttribute(Qt::WA_InputMethodEnabled, false);
m_pwdLineEdit->setContextMenuPolicy(Qt::NoContextMenu);
QRegExp rx("^[A-Za-z0-9`~!@#$%^&*()_-+=<>,.\\\/]+$");

View File

@ -17,8 +17,10 @@
#define THEME_SCHAME "org.ukui.style"
#define COLOR_THEME "styleName"
#define LAN_PAGE_INDEX 0
#define WLAN_PAGE_INDEX 1
const QString v10Sp1 = "V10SP1";
const QString intel = "V10SP1-edu";
#define KEY_PRODUCT_FEATURES "PRODUCT_FEATURES"
#include <kwindowsystem.h>
#include <kwindowsystem_export.h>
@ -89,6 +91,7 @@ void MainWindow::firstlyStart()
initDbusConnnect();
initWindowTheme();
initTrayIcon();
initPlatform();
installEventFilter(this);
m_secondaryStartTimer = new QTimer(this);
connect(m_secondaryStartTimer, &QTimer::timeout, this, [ = ]() {
@ -113,6 +116,23 @@ void MainWindow::secondaryStart()
m_loadFinished = true;
}
/**
* @brief MainWindow::initWindowProperties
*/
void MainWindow::initPlatform()
{
if(v10Sp1.compare(KDKGetPrjCodeName().c_str(),Qt::CaseInsensitive) == 0) {
QString feature = KDKGetOSRelease(KEY_PRODUCT_FEATURES).c_str();
if (feature.toInt() == 3) {
m_isShowInCenter = true;
}
} else if (intel.compare(KDKGetPrjCodeName().c_str(),Qt::CaseInsensitive) == 0) {
m_isShowInCenter = true;
}
qDebug() << KDKGetPrjCodeName().c_str() << KDKGetOSRelease(KEY_PRODUCT_FEATURES).c_str() << "m_isShowInCenter" << m_isShowInCenter;
}
/**
* @brief MainWindow::initWindowProperties
*/
@ -277,8 +297,14 @@ void MainWindow::initDbusConnnect()
connect(m_wlanWidget, &WlanPage::secuTypeChange, this, &MainWindow::secuTypeChange);
connect(m_wlanWidget, &WlanPage::signalStrengthChange, this, &MainWindow::signalStrengthChange);
connect(m_wlanWidget, &WlanPage::timeToUpdate , this, &MainWindow::timeToUpdate);
connect(m_wlanWidget, &WlanPage::showMainWindow, this, &MainWindow::onShowByWlanPage);
connect(m_wlanWidget, &WlanPage::showMainWindow, this, &MainWindow::onShowMainWindow);
connect(m_wlanWidget, &WlanPage::connectivityChanged, this, &MainWindow::onConnectivityChanged);
//模式切换
QDBusConnection::sessionBus().connect(QString("com.kylin.statusmanager.interfacer"),
QString("/"),
QString("com.kylin.statusmanager.interface"),
QString("mode_change_signal"), this, SLOT(onTabletModeChanged(bool)));
}
/**
@ -286,6 +312,13 @@ void MainWindow::initDbusConnnect()
*/
void MainWindow::resetWindowPosition()
{
if (m_isShowInCenter) {
QRect availableGeometry = qApp->primaryScreen()->availableGeometry();
this->move((availableGeometry.width() - this->width())/2, (availableGeometry.height() - this->height())/2);
return;
}
#define MARGIN 4
#define PANEL_TOP 1
#define PANEL_LEFT 2
@ -518,16 +551,20 @@ void MainWindow::onWlanConnectStatusToChangeTrayIcon(int state)
}
}
void MainWindow::onShowByWlanPage()
void MainWindow::onTabletModeChanged(bool mode)
{
m_centralWidget->setCurrentIndex(WLAN_PAGE_INDEX);
qDebug() << "TabletMode change" << mode;
Q_UNUSED(mode)
//模式切换时,隐藏主界面
hideMainwindow();
}
void MainWindow::onShowMainWindow(int type)
{
m_centralWidget->setCurrentIndex(type);
if(QApplication::activeWindow() != this) {
this->resetWindowPosition();
this->showNormal();
this->raise();
this->activateWindow();
emit this->mainWindowVisibleChanged(true);
this->showMainwindow();
}
}

View File

@ -10,9 +10,11 @@
#include <QAction>
#include <QDBusInterface>
#include <QMap>
#include <QScreen>
#include "lanpage.h"
#include "wlanpage.h"
#include "netdetails/netdetail.h"
#include <ukuisdk/kylin-com4cxx.h>
enum IconActiveType {
NOT_CONNECTED = 0,
@ -108,6 +110,7 @@ private:
void secondaryStart(); //二级启动
bool m_loadFinished = false; //是否二级启动已执行完
QTimer * m_secondaryStartTimer = nullptr; //执行二级启动的倒计时
void initPlatform();
void initWindowProperties();
void initTransparency();
void paintWithTrans();
@ -149,10 +152,15 @@ private:
bool m_lanIsLoading = false;
bool m_wlanIsLoading = false;
bool m_isShowInCenter = false;
IconActiveType iconStatus = IconActiveType::NOT_CONNECTED;
QMap<QString, NetDetail*> m_createPagePtrMap;
public slots:
void onShowMainWindow(int type);
private slots:
void onTransChanged();
void onTrayIconActivated(QSystemTrayIcon::ActivationReason reason);
@ -163,8 +171,8 @@ private slots:
void onSetTrayIconLoading();
void onLanConnectStatusToChangeTrayIcon(int state);
void onWlanConnectStatusToChangeTrayIcon(int state);
void onShowByWlanPage();
void onConnectivityChanged(NetworkManager::Connectivity connectivity);
void onTabletModeChanged(bool mode);
};
#endif // MAINWINDOW_H

View File

@ -1292,7 +1292,7 @@ void WlanPage::activateWirelessConnection(const QString& devName, const QString&
QMouseEvent *event = new QMouseEvent(QEvent::MouseButtonPress, QPoint(0,0), Qt::LeftButton, Qt::LeftButton, Qt::NoModifier);
QApplication::postEvent(p_wlanItem, event);
emit showMainWindow();
emit showMainWindow(WLAN_PAGE_INDEX);
} else {
qDebug() << "[WlanPage]activateWirelessConnection no such " << ssid << "in" << devName;
}

View File

@ -19,6 +19,9 @@
#define MORE_TEXT_MARGINS 16,0,0,0
#define SCROLLAREA_HEIGHT 200
#define LAN_PAGE_INDEX 0
#define WLAN_PAGE_INDEX 1
class WlanListItem;
class WlanPage : public TabPage
@ -64,7 +67,7 @@ signals:
void wlanConnectChanged(int state);
void timeToUpdate();
void showMainWindow();
void showMainWindow(int type);
void connectivityChanged(NetworkManager::Connectivity connectivity);

View File

@ -88,14 +88,35 @@ int main(int argc, char *argv[])
// QApplication a(argc, argv);
QString id = QString("kylin-nm"+ QLatin1String(getenv("DISPLAY")));
QtSingleApplication a(id, argc, argv);
// qInstallMessageHandler(messageOutput);
if (a.isRunning()) {
a.sendMessage("raise_window_noop");
return EXIT_SUCCESS;
}
QApplication::setQuitOnLastWindowClosed(false);
QCommandLineParser parser;
parser.setApplicationDescription(QCoreApplication::translate("main", "kylinnm"));
parser.addHelpOption();
parser.addVersionOption();
QCommandLineOption swOption(QStringLiteral("sw"),QCoreApplication::translate("main", "show kylin-nm wifi page"));
QCommandLineOption snOption(QStringLiteral("sn"),QCoreApplication::translate("main", "show kylin-nm lan page"));
parser.addOptions({swOption,snOption});
parser.process(a);
QDBusInterface interface("com.kylin.network",
"/com/kylin/network",
"com.kylin.network",
QDBusConnection::sessionBus());
if(interface.isValid()) {
if (parser.isSet(swOption))
{
interface.call(QStringLiteral("showKylinNM"),1);
} else {
interface.call(QStringLiteral("showKylinNM"),0);
}
return 0;
}
QThread thread;
KyNetworkResourceManager *p_networkResource = KyNetworkResourceManager::getInstance();
p_networkResource->moveToThread(&thread);

View File

@ -18,7 +18,7 @@ PKGCONFIG +=gio-2.0 glib-2.0 gio-unix-2.0 libnm libnma libsecret-1 gtk+-3.0 gset
INCLUDEPATH += /usr/include/KF5/NetworkManagerQt
LIBS += -L/usr/lib/ -lgsettings-qt -lX11 -lKF5NetworkManagerQt -lukui-log4qt
LIBS += -L/usr/lib/ -lgsettings-qt -lX11 -lKF5NetworkManagerQt -lukui-log4qt -lukui-com4c -lukui-com4cxx
#LIBS += -lkysec
target.path = /usr/bin
target.source += $$TARGET