🦄 refactor(UI模块): 重新设置搜索设备按钮

This commit is contained in:
huheng@kylinos.cn 2022-11-29 18:19:23 +08:00
parent 7721b9f482
commit f73261ad5e
4 changed files with 24 additions and 29 deletions

View File

@ -132,9 +132,4 @@ void ConnectInterface::setSearchBtnState(bool state)
} else {
m_searchWin->setSearchBtnState(false);
}
}
void ConnectInterface::moveSearchBtn()
{
m_searchWin->moveSearchBtn();
}

View File

@ -26,7 +26,6 @@ public:
void setItemInfo(const QMap<QString, KMobileCommon::DiscoveryDeviceInfo> &map);
void showLoad();
void setSearchBtnState(bool state);
void moveSearchBtn();
Q_SIGNALS:
void sigBackBtnClicked();

View File

@ -8,7 +8,6 @@
SearchDeviceWin::SearchDeviceWin(QWidget *parent) : QWidget(parent)
{
initUI();
initSearchButton();
}
SearchDeviceWin::~SearchDeviceWin()
@ -79,7 +78,7 @@ void SearchDeviceWin::initUI()
void SearchDeviceWin::showLoad()
{
isSearchInitFinish = false;
m_searchBtn->hide();
showSearchBtn(false);
m_stackedWidget->setCurrentIndex(1);
}
@ -87,9 +86,9 @@ void SearchDeviceWin::setSearchBtnState(bool isShow)
{
isShowSearchBtn = isShow;
if (isShowSearchBtn && isSearchInitFinish) {
m_searchBtn->show();
showSearchBtn(true);
} else {
m_searchBtn->hide();
showSearchBtn(false);
}
}
@ -128,26 +127,30 @@ void SearchDeviceWin::setItemInfo(const QMap<QString, KMobileCommon::DiscoveryDe
m_stackedWidget->setCurrentIndex(0);
isSearchInitFinish = true;
if (isShowSearchBtn && isSearchInitFinish) {
m_searchBtn->show();
showSearchBtn(true);
}
}
void SearchDeviceWin::initSearchButton()
void SearchDeviceWin::showSearchBtn(bool isShow)
{
m_searchBtn = new LevitationButton(this);
m_searchBtn->setIcon(":/connectinterface/searchrefresh.svg");
m_searchBtn->setText(tr("Search"));
m_searchBtn->hide();
connect(m_searchBtn, &LevitationButton::clicked, this, [=]() {
qInfo() << "continue search clicked";
Q_EMIT sigContinueSearch();
});
}
void SearchDeviceWin::moveSearchBtn()
{
m_searchBtn->move(
QPoint(this->width() / 2 - m_searchBtn->width() / 2, this->height() - 16 - m_searchBtn->height()));
if (isShow) {
if (m_searchBtn == nullptr) {
m_searchBtn = new LevitationButton(this);
m_searchBtn->setIcon(":/connectinterface/searchrefresh.svg");
m_searchBtn->setText(tr("Search"));
connect(m_searchBtn, &LevitationButton::clicked, this, [=]() {
qInfo() << "continue search clicked";
Q_EMIT sigContinueSearch();
});
m_searchBtn->move(
QPoint(this->width() / 2 - m_searchBtn->width() / 2, this->height() - 16 - m_searchBtn->height()));
}
m_searchBtn->show();
} else {
if (m_searchBtn != nullptr) {
m_searchBtn->hide();
}
}
}
void SearchDeviceWin::setTheme(PublicAttributes::Theme theme)

View File

@ -31,8 +31,6 @@ public:
void setSearchBtnState(bool isShow);
void moveSearchBtn();
Q_SIGNALS:
void sigItemInfo(QString);
void sigContinueSearch();
@ -41,7 +39,7 @@ Q_SIGNALS:
private:
void initUI();
void initSearchButton();
void showSearchBtn(bool isShow);
private:
QListWidget *m_listWidget = nullptr;