Fixbug 134326

This commit is contained in:
zhangyuanyuan1 2022-08-15 20:16:00 +08:00
parent 3e6e8ef25e
commit 921fc4eb88
4 changed files with 26 additions and 24 deletions

View File

@ -429,7 +429,7 @@ void LanPage::constructConnectionArea()
}
}
if (m_inactivatedLanListWidget->count() < MAX_ITEMS) {
if (m_inactivatedLanListWidget->count() <= MAX_ITEMS) {
m_inactivatedLanListWidget->setFixedWidth(MIN_WIDTH);
} else {
m_inactivatedLanListWidget->setFixedWidth(MAX_WIDTH);
@ -475,7 +475,7 @@ bool LanPage::removeConnectionItem(QMap<QString, QListWidgetItem *> &connectMap,
p_listWidgetItem = nullptr;
iter = connectMap.erase(iter);
if (m_inactivatedLanListWidget->count() < MAX_ITEMS) {
if (m_inactivatedLanListWidget->count() <= MAX_ITEMS) {
m_inactivatedLanListWidget->setFixedWidth(MIN_WIDTH);
}
return true;
@ -528,7 +528,7 @@ void LanPage::onAddConnection(QString uuid) //新增一个有线
delete p_newItem;
p_newItem = nullptr;
if (m_inactivatedLanListWidget->count() >= MAX_ITEMS) {
if (m_inactivatedLanListWidget->count() > MAX_ITEMS) {
m_inactivatedLanListWidget->setFixedWidth(MAX_WIDTH);
}
return;
@ -857,7 +857,7 @@ void LanPage::updateActivatedConnectionArea(KyConnectItem *p_newItem)
m_activeConnectionMap.insert(p_newItem->m_connectUuid, p_listWidgetItem);
// this->showDesktopNotify(tr("LAN Connected Successfully"), "networkconnected");
}
if (m_inactivatedLanListWidget->count() < MAX_ITEMS) {
if (m_inactivatedLanListWidget->count() <= MAX_ITEMS) {
m_inactivatedLanListWidget->setFixedWidth(MIN_WIDTH);
}
@ -881,7 +881,7 @@ void LanPage::updateConnectionArea(KyConnectItem *p_newItem)
m_inactiveConnectionMap.insert(p_newItem->m_connectUuid, p_listWidgetItem);
// this->showDesktopNotify(tr("LAN Disconnected Successfully"), "networkdisconnected");
}
if (m_inactivatedLanListWidget->count() < MAX_ITEMS) {
if (m_inactivatedLanListWidget->count() <= MAX_ITEMS) {
m_inactivatedLanListWidget->setFixedWidth(MIN_WIDTH);
} else {
m_inactivatedLanListWidget->setFixedWidth(MAX_WIDTH);

View File

@ -94,16 +94,17 @@ void TabPage::initUI()
m_inactivatedNetLabel = new QLabel(m_inactivatedNetFrame);
m_inactivatedNetLabel->setContentsMargins(TEXT_MARGINS);
m_inactivatedNetListArea = new QScrollArea(m_inactivatedNetFrame);
m_inactivatedNetListArea->setFrameShape(QFrame::Shape::NoFrame);
m_inactivatedNetListArea->setWidgetResizable(true);
m_inactivatedNetListArea->setBackgroundRole(QPalette::Base);
m_inactivatedNetListArea->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
m_inactivatedNetListArea->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
// m_inactivatedNetListArea = new QScrollArea(m_inactivatedNetFrame);
// m_inactivatedNetListArea->setFrameShape(QFrame::Shape::NoFrame);
// m_inactivatedNetListArea->setWidgetResizable(true);
// m_inactivatedNetListArea->setBackgroundRole(QPalette::Base);
// m_inactivatedNetListArea->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
// m_inactivatedNetListArea->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
m_inactivatedNetListArea = new QWidget(m_inactivatedNetFrame);
m_inactivatedAreaLayout = new QVBoxLayout(m_inactivatedNetListArea);
m_inactivatedAreaLayout->setSpacing(MAIN_LAYOUT_SPACING);
m_inactivatedAreaLayout->setContentsMargins(MAIN_LAYOUT_MARGINS);
m_inactivatedNetListArea->setLayout(m_inactivatedAreaLayout);
// m_inactivatedNetListArea->setLayout(m_inactivatedAreaLayout);
m_inactivatedNetLayout->addWidget(m_inactivatedNetLabel);
m_inactivatedNetLayout->addWidget(m_inactivatedNetListArea);
@ -133,9 +134,9 @@ void TabPage::initUI()
m_mainLayout->addWidget(m_inactivatedNetDivider);
m_mainLayout->addWidget(m_settingsFrame);
QPalette pal = m_inactivatedNetListArea->palette();
pal.setBrush(QPalette::Base, QColor(0,0,0,0)); //背景透明
m_inactivatedNetListArea->setPalette(pal);
// QPalette pal = m_inactivatedNetListArea->palette();
// pal.setBrush(QPalette::Base, QColor(0,0,0,0)); //背景透明
// m_inactivatedNetListArea->setPalette(pal);
onPaletteChanged();
}

View File

@ -52,7 +52,7 @@ enum network_mode {
#define DEVICE_LAYOUT_MARGINS 24,0,24,8
#define DEVICE_COMBOBOX_WIDTH 180
#define ACTIVE_NET_LAYOUT_MARGINS 8,8,8,8
#define NET_LAYOUT_MARGINS 8,8,0,3
#define NET_LAYOUT_MARGINS 8,8,0,1
#define NET_LAYOUT_SPACING 8
#define NET_LIST_SPACING 0
#define TEXT_MARGINS 16,0,0,0
@ -63,8 +63,8 @@ enum network_mode {
#define ACTIVE_AREA_MAX_HEIGHT 92
#define MAX_ITEMS 4
#define MAX_WIDTH 400
#define MIN_WIDTH 383
#define MAX_WIDTH 408
#define MIN_WIDTH 396
#define SCROLL_STEP 4
@ -133,7 +133,8 @@ protected:
QFrame * m_inactivatedNetFrame = nullptr;
QVBoxLayout * m_inactivatedNetLayout = nullptr;
QLabel * m_inactivatedNetLabel = nullptr;
QScrollArea * m_inactivatedNetListArea = nullptr;
// QScrollArea * m_inactivatedNetListArea = nullptr;
QWidget * m_inactivatedNetListArea = nullptr;
QVBoxLayout * m_inactivatedAreaLayout = nullptr;
Divider * m_inactivatedNetDivider = nullptr;

View File

@ -393,7 +393,7 @@ void WlanPage::deleteWirelessItemFormMap(QMap<QString, QListWidgetItem*> &wirele
delete p_listWidgetItem;
p_listWidgetItem = nullptr;
if (m_inactivatedNetListWidget->count() < MAX_ITEMS) {
if (m_inactivatedNetListWidget->count() <= MAX_ITEMS) {
m_inactivatedNetListWidget->setFixedWidth(MIN_WIDTH);
}
return;
@ -484,7 +484,7 @@ void WlanPage::constructWirelessNetArea()
qDebug() << "[WlanPage] Stopped loading wireless net list! time="
<< QDateTime::currentDateTime().toString("hh:mm:ss.zzzz");
if (m_inactivatedNetListWidget->count() < MAX_ITEMS) {
if (m_inactivatedNetListWidget->count() <= MAX_ITEMS) {
m_inactivatedNetListWidget->setFixedWidth(MIN_WIDTH);
} else {
m_inactivatedNetListWidget->setFixedWidth(MAX_WIDTH);
@ -539,7 +539,7 @@ void WlanPage::onWlanAdded(QString interface, KyWirelessNetItem &item)
updateWlanItemState(m_inactivatedNetListWidget, p_listWidgetItem, Deactivated);
addWlanMoreItem();
if (m_inactivatedNetListWidget->count() >= MAX_ITEMS) {
if (m_inactivatedNetListWidget->count() > MAX_ITEMS) {
m_inactivatedNetListWidget->setFixedWidth(MAX_WIDTH);
}
return;
@ -866,7 +866,7 @@ void WlanPage::updateActivatedArea(QString uuid, QString ssid, QString devName)
m_activateConnectionItemMap.insert(wirelessNetItem.m_NetSsid, p_listWidgetItem);
m_activatedNetListWidget->setFixedHeight(p_listWidgetItem->sizeHint().height());
if (m_inactivatedNetListWidget->count() < MAX_ITEMS) {
if (m_inactivatedNetListWidget->count() <= MAX_ITEMS) {
m_inactivatedNetListWidget->setFixedWidth(MIN_WIDTH);
}
return;
@ -899,7 +899,7 @@ void WlanPage::updateWirelessNetArea(QString uuid, QString ssid, QString devName
// 更新更多条目以保证其处于listwidget的最底部
addWlanMoreItem();
if (m_inactivatedNetListWidget->count() < MAX_ITEMS) {
if (m_inactivatedNetListWidget->count() <= MAX_ITEMS) {
m_inactivatedNetListWidget->setFixedWidth(MIN_WIDTH);
} else {
m_inactivatedNetListWidget->setFixedWidth(MAX_WIDTH);