diff --git a/plugins/mobilehotspot/mobilehotspotwidget.cpp b/plugins/mobilehotspot/mobilehotspotwidget.cpp index 8c1046ba..2e3161ab 100644 --- a/plugins/mobilehotspot/mobilehotspotwidget.cpp +++ b/plugins/mobilehotspot/mobilehotspotwidget.cpp @@ -2,14 +2,15 @@ #include #define LABEL_RECT 17, 0, 105, 23 -#define CONTENTS_MARGINS 0, 0, 40, 0 -#define FRAME_MIN_SIZE 550, 0 +#define CONTENTS_MARGINS 0, 0, 0, 0 +#define FRAME_MIN_SIZE 550, 60 #define FRAME_MAX_SIZE 16777215, 16777215 #define CONTECT_FRAME_MAX_SIZE 16777215, 60 #define LABLE_MIN_WIDTH 140 -#define COMBOBOX_MIN_WIDTH 600 +#define COMBOBOX_MIN_WIDTH 200 #define LINE_MAX_SIZE 16777215, 1 #define LINE_MIN_SIZE 0, 1 +#define LAYOUT_LEFT_MARGINS 8 #define WIRELESS 1 @@ -59,11 +60,11 @@ MobileHotspotWidget::MobileHotspotWidget(QWidget *parent) : QWidget(parent) m_hostName = getHostName(); + initDbusConnect(); + initInterfaceInfo(); getApInfo(); - initDbusConnect(); - connect(m_switchBtn, &SwitchButton::checkedChanged, this, &MobileHotspotWidget::setUiEnabled); connect(m_interfaceComboBox, QOverload::of(&QComboBox::currentIndexChanged), this, [=]() { m_interfaceName = m_interfaceComboBox->currentText(); @@ -301,9 +302,18 @@ void MobileHotspotWidget::initInterfaceInfo() void MobileHotspotWidget::getApInfo() { - if(!m_interface->isValid()) { + if (!m_interface->isValid()) { return; } + + if (m_interfaceComboBox->count() <= 0) { + m_switchBtn->setChecked(false); + setWidgetHidden(true); + qWarning() << "getApInfo but interface is empty"; + return; + } + + QDBusReply reply = m_interface->call("getStoredApInfo"); if (!reply.isValid()) { qDebug()<<"execute dbus method 'getStoredApInfo' is invalid in func getObjectPath()"; @@ -350,6 +360,7 @@ void MobileHotspotWidget::setSwitchFrame() m_switchLabel = new QLabel(tr("Open"), this); m_switchLabel->setMinimumWidth(LABLE_MIN_WIDTH); m_switchBtn = new SwitchButton(this, false); + switchLayout->addSpacing(LAYOUT_LEFT_MARGINS); switchLayout->addWidget(m_switchLabel); switchLayout->addStretch(); switchLayout->addWidget(m_switchBtn); @@ -372,6 +383,7 @@ void MobileHotspotWidget::setApNameFrame() m_apNameLine = new QLineEdit(this); m_apNameLine->setMinimumWidth(COMBOBOX_MIN_WIDTH); m_apNameLine->setMaxLength(AP_NAME_MAX_LENGTH); + apNameHLayout->addSpacing(LAYOUT_LEFT_MARGINS); apNameHLayout->addWidget(m_apNameLabel); apNameHLayout->addWidget(m_apNameLine); m_ApNameFrame->setLayout(apNameHLayout); @@ -393,6 +405,7 @@ void MobileHotspotWidget::setPasswordFrame() m_pwdNameLine = new QLineEdit(this); m_pwdNameLine->setMinimumWidth(COMBOBOX_MIN_WIDTH); m_pwdNameLine->setEchoMode(QLineEdit::Password); + passwordHLayout->addSpacing(LAYOUT_LEFT_MARGINS); passwordHLayout->addWidget(m_pwdLabel); passwordHLayout->addWidget(m_pwdNameLine); @@ -434,6 +447,7 @@ void MobileHotspotWidget::setFreqBandFrame() m_freqBandComboBox->setSizePolicy(QSizePolicy::Expanding,QSizePolicy::Fixed); m_freqBandComboBox->addItem("2.4Ghz"); m_freqBandComboBox->addItem("5Ghz"); + freqBandHLayout->addSpacing(LAYOUT_LEFT_MARGINS); freqBandHLayout->addWidget(m_freqBandLabel); freqBandHLayout->addWidget(m_freqBandComboBox); @@ -456,6 +470,7 @@ void MobileHotspotWidget::setInterFaceFrame() m_interfaceComboBox->setInsertPolicy(QComboBox::NoInsert); m_interfaceComboBox->setMinimumWidth(COMBOBOX_MIN_WIDTH); m_interfaceComboBox->setSizePolicy(QSizePolicy::Expanding,QSizePolicy::Fixed); + interfaceHLayout->addSpacing(LAYOUT_LEFT_MARGINS); interfaceHLayout->addWidget(m_interfaceLabel); interfaceHLayout->addWidget(m_interfaceComboBox); diff --git a/plugins/netconnect/netconnect.cpp b/plugins/netconnect/netconnect.cpp index 39d2c675..93dbd65c 100644 --- a/plugins/netconnect/netconnect.cpp +++ b/plugins/netconnect/netconnect.cpp @@ -44,6 +44,7 @@ const QByteArray GSETTINGS_SCHEMA = "org.ukui.kylin-nm.switch"; #define DEACTIVATING 3 #define DEACTIVATED 4 +#define NO_MARGINS 0,0,0,0 #define MAIN_LAYOUT_MARGINS 0,0,0,8 bool sortByVal(const QPair &l, const QPair &r) { @@ -166,6 +167,7 @@ void NetConnect::initComponent() { wiredSwitch = new SwitchButton(pluginWidget, false); ui->openWIifLayout->addWidget(wiredSwitch); ui->detailLayOut->setContentsMargins(MAIN_LAYOUT_MARGINS); + ui->verticalLayout_3->setContentsMargins(NO_MARGINS); connect(wiredSwitch, &SwitchButton::disabledClick, this, [=]() { showDesktopNotify(tr("No ethernet device avaliable")); diff --git a/plugins/netconnect/netconnect.ui b/plugins/netconnect/netconnect.ui index ba375768..74f98621 100644 --- a/plugins/netconnect/netconnect.ui +++ b/plugins/netconnect/netconnect.ui @@ -33,7 +33,10 @@ 0 - 32 + 0 + + + 0 diff --git a/plugins/wlanconnect/wlanconnect.cpp b/plugins/wlanconnect/wlanconnect.cpp index 5f693e3c..ab9900a9 100644 --- a/plugins/wlanconnect/wlanconnect.cpp +++ b/plugins/wlanconnect/wlanconnect.cpp @@ -55,6 +55,7 @@ const QString NoNetSymbolic = ":/img/plugins/netconnect/nonet.svg"; #define DEACTIVATING 3 #define DEACTIVATED 4 +#define NO_MARGINS 0,0,0,0 #define MAIN_LAYOUT_MARGINS 0,0,0,8 bool intThan(int sign1, int sign2) @@ -177,6 +178,7 @@ void WlanConnect::initComponent() { m_wifiSwitch = new SwitchButton(pluginWidget, false); ui->openWIifLayout->addWidget(m_wifiSwitch); ui->detailLayOut_3->setContentsMargins(MAIN_LAYOUT_MARGINS); + ui->verticalLayout_3->setContentsMargins(NO_MARGINS); connect(m_wifiSwitch, &SwitchButton::disabledClick, this, [=]() { showDesktopNotify(tr("No wireless network card detected")); diff --git a/plugins/wlanconnect/wlanconnect.ui b/plugins/wlanconnect/wlanconnect.ui index 01b8e2a9..fa8cfe41 100644 --- a/plugins/wlanconnect/wlanconnect.ui +++ b/plugins/wlanconnect/wlanconnect.ui @@ -21,7 +21,7 @@ 0 - 32 + 0 diff --git a/src/frontend/list-items/wlanlistitem.cpp b/src/frontend/list-items/wlanlistitem.cpp index b7a21d6a..bb64b9a7 100644 --- a/src/frontend/list-items/wlanlistitem.cpp +++ b/src/frontend/list-items/wlanlistitem.cpp @@ -217,7 +217,7 @@ void WlanListItem::initWlanUI() #define PWD_AREA_HEIGHT 36 #define CONNECT_BUTTON_WIDTH 96 -#define FRAME_CONTENT_MARGINS 56,4,16,4 +#define FRAME_CONTENT_MARGINS 56,0,16,4 #define FRAME_SPACING 8 #define PWD_CONTENT_MARGINS 8,0,34,0 #define SHOW_PWD_BUTTON_SIZE 24,24 diff --git a/src/frontend/mainwindow.cpp b/src/frontend/mainwindow.cpp index 0fc8e72e..61f1caf3 100644 --- a/src/frontend/mainwindow.cpp +++ b/src/frontend/mainwindow.cpp @@ -96,6 +96,8 @@ void MainWindow::firstlyStart() }); m_secondaryStartTimer->start(5 * 1000); + m_createPagePtrMap.clear(); + //加载key ring agent_init(); } @@ -624,7 +626,21 @@ void MainWindow::showPropertyWidget(QString devName, QString ssid) void MainWindow::showCreateWiredConnectWidget(const QString devName) { qDebug() << "showCreateWiredConnectWidget! devName = " << devName; + if (m_createPagePtrMap.contains(devName)) { + if (m_createPagePtrMap[devName] != nullptr) { + qDebug() << "showCreateWiredConnectWidget" << devName << "already create,just raise"; + + KWindowSystem::raiseWindow(m_createPagePtrMap[devName]->winId()); + return; + } + } NetDetail *netDetail = new NetDetail(devName, "", "", false, false, true, this); + connect(netDetail, &NetDetail::createPageClose, [&](QString interfaceName){ + if (m_createPagePtrMap.contains(interfaceName)) { + m_createPagePtrMap[interfaceName] = nullptr; + } + }); + m_createPagePtrMap.insert(devName, netDetail); netDetail->show(); } diff --git a/src/frontend/mainwindow.h b/src/frontend/mainwindow.h index ec0b6443..30d548fb 100644 --- a/src/frontend/mainwindow.h +++ b/src/frontend/mainwindow.h @@ -9,6 +9,7 @@ #include #include #include +#include #include "lanpage.h" #include "wlanpage.h" #include "netdetails/netdetail.h" @@ -141,6 +142,8 @@ private: IconActiveType iconStatus = IconActiveType::NOT_CONNECTED; + QMap m_createPagePtrMap; + private slots: void onTrayIconActivated(); void onShowMainwindowActionTriggled(); diff --git a/src/frontend/netdetails/ipv4page.cpp b/src/frontend/netdetails/ipv4page.cpp index abb220a8..45f8fe0f 100644 --- a/src/frontend/netdetails/ipv4page.cpp +++ b/src/frontend/netdetails/ipv4page.cpp @@ -68,6 +68,7 @@ void Ipv4Page::initComponent() { connect(ipv4ConfigCombox, SIGNAL(currentIndexChanged(int)), this, SLOT(configChanged(int))); connect(ipv4ConfigCombox, SIGNAL(currentIndexChanged(int)), this, SLOT(setEnableOfSaveBtn())); + connect(ipv4addressEdit, SIGNAL(textChanged(QString)), this, SLOT(setEnableOfSaveBtn())); connect(netMaskEdit, SIGNAL(textChanged(QString)), this, SLOT(setEnableOfSaveBtn())); connect(gateWayEdit, SIGNAL(textChanged(QString)), this, SLOT(setEnableOfSaveBtn())); connect(firstDnsEdit, SIGNAL(textChanged(QString)), this, SLOT(setEnableOfSaveBtn())); diff --git a/src/frontend/netdetails/ipv6page.cpp b/src/frontend/netdetails/ipv6page.cpp index f281125d..9691b827 100644 --- a/src/frontend/netdetails/ipv6page.cpp +++ b/src/frontend/netdetails/ipv6page.cpp @@ -143,6 +143,7 @@ void Ipv6Page::initComponent() { connect(ipv6ConfigCombox, SIGNAL(currentIndexChanged(int)), this, SLOT(configChanged(int))); connect(ipv6ConfigCombox, SIGNAL(currentIndexChanged(int)), this, SLOT(setEnableOfSaveBtn())); + connect(ipv6AddressEdit, SIGNAL(textChanged(QString)), this, SLOT(setEnableOfSaveBtn())); connect(lengthEdit, SIGNAL(textChanged(QString)), this, SLOT(setEnableOfSaveBtn())); connect(gateWayEdit, SIGNAL(textChanged(QString)), this, SLOT(setEnableOfSaveBtn())); connect(firstDnsEdit, SIGNAL(textChanged(QString)), this, SLOT(setEnableOfSaveBtn())); diff --git a/src/frontend/netdetails/netdetail.cpp b/src/frontend/netdetails/netdetail.cpp index 7e5588cd..b5645f2d 100644 --- a/src/frontend/netdetails/netdetail.cpp +++ b/src/frontend/netdetails/netdetail.cpp @@ -1,7 +1,9 @@ #include "netdetail.h" #include "backend/kylinipv4arping.h" #include "backend/kylinipv6arping.h" -#include "xatom/xatom-helper.h" +//#include "xatom/xatom-helper.h" + +#include #define WINDOW_WIDTH 520 #define WINDOW_HEIGHT 590 @@ -48,15 +50,15 @@ NetDetail::NetDetail(QString interface, QString name, QString uuid, bool isActiv QDialog(parent) { //设置窗口无边框,阴影 -#if (QT_VERSION >= QT_VERSION_CHECK(5, 12, 0)) - MotifWmHints window_hints; - window_hints.flags = MWM_HINTS_FUNCTIONS | MWM_HINTS_DECORATIONS; - window_hints.functions = MWM_FUNC_ALL; - window_hints.decorations = MWM_DECOR_BORDER; - XAtomHelper::getInstance()->setWindowMotifHint(this->winId(), window_hints); -#else +//#if (QT_VERSION >= QT_VERSION_CHECK(5, 12, 0)) +// MotifWmHints window_hints; +// window_hints.flags = MWM_HINTS_FUNCTIONS | MWM_HINTS_DECORATIONS; +// window_hints.functions = MWM_FUNC_ALL; +// window_hints.decorations = MWM_DECOR_BORDER; +// XAtomHelper::getInstance()->setWindowMotifHint(this->winId(), window_hints); +//#else this->setWindowFlags(Qt::Dialog | Qt::FramelessWindowHint); -#endif +//#endif // this->setProperty("useStyleWindowManager", false); //禁用拖动 // setWindowFlags(Qt::Dialog | Qt::FramelessWindowHint ); // setAttribute(Qt::WA_TranslucentBackground); @@ -120,6 +122,7 @@ void NetDetail::paintEvent(QPaintEvent *event) void NetDetail::closeEvent(QCloseEvent *event) { emit this->detailPageClose(false); + emit this->createPageClose(m_deviceName); return QDialog::closeEvent(event); } @@ -145,6 +148,12 @@ void NetDetail::initUI() securityPage = new SecurityPage(this); createNetPage = new CreatNetPage(this); + detailPage->installEventFilter(this); + ipv4Page->installEventFilter(this); + ipv6Page->installEventFilter(this); + securityPage->installEventFilter(this); + createNetPage->installEventFilter(this); + titleWidget = new QWidget(this); centerWidget = new QWidget(this); bottomWidget = new QWidget(this); @@ -917,3 +926,19 @@ bool NetDetail::checkWirelessSecurity(KySecuType secuType) } return true; } + +bool NetDetail::eventFilter(QObject *w, QEvent *event) +{ + // 回车键触发确定按钮点击事件 + if (event->type() == QEvent::KeyPress) { + QKeyEvent *mEvent = static_cast(event); + if (mEvent->key() == Qt::Key_Enter || mEvent->key() == Qt::Key_Return) { + if (confimBtn->isEnabled()) { + emit confimBtn->clicked(); + } + return true; + } + + } + return QDialog::eventFilter(w, event); +} diff --git a/src/frontend/netdetails/netdetail.h b/src/frontend/netdetails/netdetail.h index 7e0b59e7..5d229281 100644 --- a/src/frontend/netdetails/netdetail.h +++ b/src/frontend/netdetails/netdetail.h @@ -39,6 +39,7 @@ public: protected: void paintEvent(QPaintEvent *event); void closeEvent(QCloseEvent *event); + bool eventFilter(QObject *w, QEvent *event); private: void initUI(); @@ -135,5 +136,6 @@ private slots: signals: void detailPageClose(bool on); + void createPageClose(QString); }; #endif // NETDETAIL_H diff --git a/src/frontend/tab-pages/lanpage.cpp b/src/frontend/tab-pages/lanpage.cpp index 0a64c5d0..91bed84c 100644 --- a/src/frontend/tab-pages/lanpage.cpp +++ b/src/frontend/tab-pages/lanpage.cpp @@ -34,6 +34,9 @@ LanPage::LanPage(QWidget *parent) : TabPage(parent) initLanArea(); connect(m_activeResourse, &KyActiveConnectResourse::stateChangeReason, this, &LanPage::onConnectionStateChange); + connect(m_activeResourse, &KyActiveConnectResourse::activeConnectRemove, this, [=] (QString activeConnectUuid) { + sendLanStateChangeSignal(activeConnectUuid,Deactivated); + } ); connect(m_connectResourse, &KyConnectResourse::connectionAdd, this, &LanPage::onAddConnection); connect(m_connectResourse, &KyConnectResourse::connectionRemove, this, &LanPage::onRemoveConnection); diff --git a/src/frontend/tools/divider.cpp b/src/frontend/tools/divider.cpp index ffe42053..738f9af5 100644 --- a/src/frontend/tools/divider.cpp +++ b/src/frontend/tools/divider.cpp @@ -11,8 +11,10 @@ Divider::Divider(QWidget * parent) : QFrame(parent) void Divider::paintEvent(QPaintEvent * e) { QPainter p(this); + QColor color; + color.setRgb(77,77,77); p.save(); - p.setBrush(this->palette().color(QPalette::Text)); + p.setBrush(color); p.setPen(Qt::transparent); p.setOpacity(0.3); p.drawRoundedRect(this->rect(), 6, 6);