diff --git a/plugins/mobilehotspot/mobilehotspotwidget.cpp b/plugins/mobilehotspot/mobilehotspotwidget.cpp index 3aaf0540..33ab4943 100644 --- a/plugins/mobilehotspot/mobilehotspotwidget.cpp +++ b/plugins/mobilehotspot/mobilehotspotwidget.cpp @@ -34,6 +34,8 @@ #define LINE_MAX_SIZE 16777215, 1 #define LINE_MIN_SIZE 0, 1 #define ICON_SIZE 24,24 +#define PASSWORD_FRAME_MIN_HIGHT 60 +#define PASSWORD_FRAME_FIX_HIGHT 80 #define PASSWORD_FRAME_MIN_SIZE 550, 60 #define PASSWORD_FRAME_MAX_SIZE 16777215, 86 #define PASSWORD_ITEM_MARGINS 16, 12, 16, 14 @@ -176,16 +178,28 @@ void MobileHotspotWidget::paintEvent(QPaintEvent *event) QWidget::paintEvent(event); } +void MobileHotspotWidget::resetFreamSize() +{ + int height = 0; + for (int i = 0; i < m_hotspotFrame->layout()->count(); i ++) { + QWidget *w = m_hotspotFrame->layout()->itemAt(i)->widget(); + if (w != nullptr) { + height += w->height(); + } + } + m_hotspotFrame->setFixedHeight(height); +} + void MobileHotspotWidget::initUI() { - QFrame *hotspotFrame = new QFrame(this); - hotspotFrame->setMinimumSize(FRAME_MIN_SIZE); - hotspotFrame->setMaximumSize(FRAME_MAX_SIZE); - hotspotFrame->setFrameShape(QFrame::Box); + m_hotspotFrame = new QFrame(this); + m_hotspotFrame->setMinimumSize(FRAME_MIN_SIZE); + m_hotspotFrame->setMaximumSize(FRAME_MAX_SIZE); + m_hotspotFrame->setFrameShape(QFrame::Box); QVBoxLayout *hotspotLyt = new QVBoxLayout(this); hotspotLyt->setContentsMargins(0, 0, 0, 0); - hotspotFrame->setLayout(hotspotLyt); + m_hotspotFrame->setLayout(hotspotLyt); m_hotspotTitleLabel = new TitleLabel(this); m_hotspotTitleLabel->setText(tr("Hotspot")); @@ -212,18 +226,11 @@ void MobileHotspotWidget::initUI() hotspotLyt->addWidget(m_interfaceFrame); hotspotLyt->setSpacing(0); - int height = 0; - for (int i = 0; i < hotspotLyt->count(); i ++) { - QWidget *w = hotspotLyt->itemAt(i)->widget(); - if (w != nullptr) { - height += w->height(); - } - } - hotspotFrame->setFixedHeight(height); + resetFreamSize(); m_Vlayout->addWidget(m_hotspotTitleLabel); m_Vlayout->addSpacing(8); - m_Vlayout->addWidget(hotspotFrame); + m_Vlayout->addWidget(m_hotspotFrame); } @@ -272,13 +279,14 @@ void MobileHotspotWidget::onApLineEditTextEdit(QString text) void MobileHotspotWidget::onPwdTextChanged() { if (m_pwdNameLine->text().length() < 8) { + m_passwordFrame->setFixedHeight(PASSWORD_FRAME_FIX_HIGHT); m_pwdHintLabel->show(); - m_pwdHintLabel->setText(tr("Contains at least 8 characters")); //至少包含8个字符 } else { - m_pwdHintLabel->clear(); + m_passwordFrame->setFixedHeight(PASSWORD_FRAME_MIN_HIGHT); m_pwdHintLabel->hide(); } - + resetFreamSize(); + this->update(); } void MobileHotspotWidget::onActiveConnectionChanged(QString deviceName, QString ssid, QString uuid, int status) @@ -466,8 +474,6 @@ void MobileHotspotWidget::setPasswordFrame() m_passwordFrame->setMinimumSize(PASSWORD_FRAME_MIN_SIZE); m_passwordFrame->setMaximumSize(PASSWORD_FRAME_MAX_SIZE); - QHBoxLayout *passwordHLayout = new QHBoxLayout(m_passwordFrame); - m_pwdLabel = new QLabel(tr("Password"), this); m_pwdLabel->setMinimumWidth(LABLE_MIN_WIDTH); m_pwdNameLine = new KPasswordEdit(this); @@ -480,8 +486,9 @@ void MobileHotspotWidget::setPasswordFrame() QPalette hintTextColor; hintTextColor.setColor(QPalette::WindowText, Qt::red); m_pwdHintLabel->setPalette(hintTextColor); + m_pwdHintLabel->setText(tr("Contains at least 8 characters")); //至少包含8个字符 - QWidget *pwdInputWidget = new QWidget(this); + QWidget *pwdInputWidget = new QWidget(m_passwordFrame); QVBoxLayout *pwdInputVLayout = new QVBoxLayout(pwdInputWidget); pwdInputVLayout->setContentsMargins(CONTENTS_MARGINS); pwdInputVLayout->setSpacing(0); @@ -493,6 +500,8 @@ void MobileHotspotWidget::setPasswordFrame() pwdLayout->setSpacing(0); pwdLayout->addRow(m_pwdLabel, pwdInputWidget); + m_passwordFrame->setLayout(pwdLayout); + m_pwdNameLine->installEventFilter(this); } diff --git a/plugins/mobilehotspot/mobilehotspotwidget.h b/plugins/mobilehotspot/mobilehotspotwidget.h index de463f9b..f2a82e81 100644 --- a/plugins/mobilehotspot/mobilehotspotwidget.h +++ b/plugins/mobilehotspot/mobilehotspotwidget.h @@ -57,6 +57,7 @@ public: ~MobileHotspotWidget(); private: + QFrame *m_hotspotFrame = nullptr; QFrame *m_switchFrame = nullptr; //开关 QFrame *m_ApNameFrame = nullptr; //wifi名称 QFrame *m_passwordFrame = nullptr; //密码 @@ -95,6 +96,7 @@ private: QString m_uuid = ""; QString m_hostName = ""; + void resetFreamSize(); void initUI(); void initDbusConnect(); void initInterfaceInfo(); diff --git a/plugins/mobilehotspot/translations/bo.ts b/plugins/mobilehotspot/translations/bo.ts index 5722fa2f..70f2c4b7 100644 --- a/plugins/mobilehotspot/translations/bo.ts +++ b/plugins/mobilehotspot/translations/bo.ts @@ -4,7 +4,7 @@ BlacklistItem - + Remove @@ -12,7 +12,7 @@ BlacklistPage - + Blacklist @@ -20,7 +20,7 @@ ConnectDevListItem - + drag into blacklist @@ -28,7 +28,7 @@ ConnectdevPage - + Connect device @@ -56,79 +56,79 @@ MobileHotspotWidget - + ukui control center - + ukui control center desktop message - + wirless switch is close or no wireless device - + start to close hotspot - + hotpots name or device is invalid - + start to open hotspot - + Contains at least 8 characters - + Hotspot - - + + hotspot already close - + Open - + Wi-Fi Name - + Password - + Frequency band - + Net card - - + + hotspot already open diff --git a/plugins/mobilehotspot/translations/bo_CN.ts b/plugins/mobilehotspot/translations/bo_CN.ts index 366a5dce..2e4fb436 100644 --- a/plugins/mobilehotspot/translations/bo_CN.ts +++ b/plugins/mobilehotspot/translations/bo_CN.ts @@ -4,7 +4,7 @@ BlacklistItem - + Remove སྤོ་སྐྱོད་བྱས་པ། @@ -12,7 +12,7 @@ BlacklistPage - + Blacklist སྒྲིག་ཆས་ཀྱི་མིང་ཐོ་ནག་པོ། @@ -20,7 +20,7 @@ ConnectDevListItem - + drag into blacklist མིང་ཐོ་ནག་པོའི་ཁ་སྣོན་རྒྱག་པ། @@ -28,7 +28,7 @@ ConnectdevPage - + Connect device འབྲེལ་མཐུད་སྒྲིག་ཆས། @@ -56,27 +56,27 @@ MobileHotspotWidget - + ukui control center ཝུའུ་ཁི་ལན་གྱི་ཚོད་འཛིན་ལྟེ་གནས། - + ukui control center desktop message ukui ཚོད་འཛིན་ལྟེ་གནས་ཀྱི་ཅོག་ངོས་ཆ་འཕྲིན། - + wirless switch is close or no wireless device སྐུད་མེད་གློག་སྒོ་རྒྱག་པའམ་ཡང་ན་སྐུད་མེད་སྒྲིག་ཆས་མེད་པ། - + start to close hotspot སྒོ་རྒྱག་འགོ་བརྩམས། - + hotpots name or device is invalid ཚ་བ་ཆེ་བའི་མིང་ངམ་སྒྲིག་ཆས་ལ་ནུས་པ་མེད། @@ -85,54 +85,54 @@ གསང་གྲངས་ཀྱི་རིང་ཚད་ནི་གླེང་མང་བའི་གནད་དོན་བརྒྱད་ལས་ཆུང་བ་བྱེད་མི་རུང་།! - + start to open hotspot ཀུན་གྱིས་དོ་སྣང་བྱེད་ཡུལ་གསར་སྐྲུན་བྱེད་འགོ་ - + Contains at least 8 characters མ་མཐར་ཡང་ཡིག་རྟགས་བརྒྱད་འདུས་ཡོད། - + Hotspot ཚ་བ་ཆེ་བ། - - + + hotspot already close ཚ་བ་ཆེ་བའི་གནད་དོན་ཐག་ཉེ་རུ་སོང་ཡོད། - + Open སྒོ་ཕྱེ་བ། - + Wi-Fi Name Wi-Fiཡི་མིང་། - + Password གསང་གྲངས། - + Frequency band ཐེངས་གྲངས་ཀྱི་རོལ་ཆའི་རུ་ཁག - + Net card དྲ་རྒྱའི་བྱང་བུ། - - + + hotspot already open ཚ་བ་ཆེ་བའི་གནད་དོན་དེ་སྒོ་ཕྱེ་ཟིན། diff --git a/plugins/mobilehotspot/translations/tr.ts b/plugins/mobilehotspot/translations/tr.ts index 5722fa2f..70f2c4b7 100644 --- a/plugins/mobilehotspot/translations/tr.ts +++ b/plugins/mobilehotspot/translations/tr.ts @@ -4,7 +4,7 @@ BlacklistItem - + Remove @@ -12,7 +12,7 @@ BlacklistPage - + Blacklist @@ -20,7 +20,7 @@ ConnectDevListItem - + drag into blacklist @@ -28,7 +28,7 @@ ConnectdevPage - + Connect device @@ -56,79 +56,79 @@ MobileHotspotWidget - + ukui control center - + ukui control center desktop message - + wirless switch is close or no wireless device - + start to close hotspot - + hotpots name or device is invalid - + start to open hotspot - + Contains at least 8 characters - + Hotspot - - + + hotspot already close - + Open - + Wi-Fi Name - + Password - + Frequency band - + Net card - - + + hotspot already open diff --git a/plugins/mobilehotspot/translations/zh_CN.ts b/plugins/mobilehotspot/translations/zh_CN.ts index b23165e8..4d44a72a 100644 --- a/plugins/mobilehotspot/translations/zh_CN.ts +++ b/plugins/mobilehotspot/translations/zh_CN.ts @@ -4,7 +4,7 @@ BlacklistItem - + Remove 移出 @@ -12,7 +12,7 @@ BlacklistPage - + Blacklist 设备黑名单 @@ -20,7 +20,7 @@ ConnectDevListItem - + drag into blacklist 添加进黑名单 @@ -28,7 +28,7 @@ ConnectdevPage - + Connect device 连接设备 @@ -56,27 +56,27 @@ MobileHotspotWidget - + ukui control center 控制面板 - + ukui control center desktop message 控制面板桌面通知 - + wirless switch is close or no wireless device 无线开关已关闭或不存在有热点功能的无线网卡 - + start to close hotspot 开始关闭热点 - + hotpots name or device is invalid 热点名称或设备错误 @@ -85,54 +85,54 @@ 不能创建密码长度小于八位的热点! - + start to open hotspot 开始创建热点 - + Contains at least 8 characters 至少包含8个字符 - + Hotspot 移动热点 - - + + hotspot already close 热点已关闭 - + Open 开启 - + Wi-Fi Name Wi-Fi名称 - + Password 网络密码 - + Frequency band 网络频带 - + Net card 共享网卡端口 - - + + hotspot already open 热点已开启