修复悬浮标题显示英文问题;

This commit is contained in:
iaom 2022-04-15 15:52:15 +08:00
parent 324da7cb11
commit 9e2e6afa7a
4 changed files with 33 additions and 25 deletions

View File

@ -392,8 +392,8 @@ void ResultArea::initUi()
this->widget()->setContentsMargins(0,0,0,0); this->widget()->setContentsMargins(0,0,0,0);
m_mainLyt->setSpacing(0); m_mainLyt->setSpacing(0);
m_titleLable = new TitleLabel(this); m_titleLabel = new TitleLabel(this);
m_titleLable->hide(); m_titleLabel->hide();
} }
void ResultArea::initConnections() void ResultArea::initConnections()
@ -439,35 +439,35 @@ void ResultArea::initConnections()
} }
if (value < (widget->pos().ry() + TITLE_HEIGHT) if (value < (widget->pos().ry() + TITLE_HEIGHT)
or value > (widget->pos().ry() + widget->height() - FRAME_HEIGHT + 2*TITLE_HEIGHT)) {//暂定下一项标题显示完全后悬浮标题隐藏 or value > (widget->pos().ry() + widget->height() - FRAME_HEIGHT + 2*TITLE_HEIGHT)) {//暂定下一项标题显示完全后悬浮标题隐藏
if (!m_titleLable->isHidden()) { if (!m_titleLabel->isHidden()) {
m_titleLable->hide(); m_titleLabel->hide();
this->setViewportMargins(0,0,0,0); this->setViewportMargins(0,0,0,0);
} }
} else { } else {
if (m_titleLable->isHidden()) { if (m_titleLabel->isHidden()) {
m_titleLable->setText(widget->pluginId()); m_titleLabel->setText(widget->pluginName());
m_titleLable->setShowMoreLableVisible();//防止多项展开后无法收回其他项 m_titleLabel->setShowMoreLableVisible();//防止多项展开后无法收回其他项
m_titleLable->show(); m_titleLabel->show();
this->setViewportMargins(0,TITLE_HEIGHT,0,0); this->setViewportMargins(0,TITLE_HEIGHT,0,0);
} }
break; break;
} }
} }
}); });
connect(this->m_titleLable, &TitleLabel::retractClicked, this, [=] () { connect(this->m_titleLabel, &TitleLabel::retractClicked, this, [=] () {
Q_FOREACH(auto widget, m_widget_list) { Q_FOREACH(auto widget, m_widget_list) {
if (widget->pluginId() == m_titleLable->text()) { if (widget->pluginName() == m_titleLabel->text()) {
widget->reduceListSlot(); widget->reduceListSlot();
widget->resetTitleLabel(); widget->resetTitleLabel();
if (!m_titleLable->isHidden()) { if (!m_titleLabel->isHidden()) {
m_titleLable->hide(); m_titleLabel->hide();
this->setViewportMargins(0,0,0,0); this->setViewportMargins(0,0,0,0);
} }
} }
} }
}); });
connect(this, &ResultArea::resizeWidth, this, [=] (int size) { connect(this, &ResultArea::resizeWidth, this, [=] (int size) {
m_titleLable->setFixedWidth(size); m_titleLabel->setFixedWidth(size);
}); });
} }
@ -475,8 +475,8 @@ void ResultArea::setupConnectionsForWidget(ResultWidget *widget)
{ {
connect(this, &ResultArea::startSearch, widget, &ResultWidget::startSearch); connect(this, &ResultArea::startSearch, widget, &ResultWidget::startSearch);
connect(this, &ResultArea::startSearch, this, [=] () { connect(this, &ResultArea::startSearch, this, [=] () {
if (!m_titleLable->isHidden()) { if (!m_titleLabel->isHidden()) {
m_titleLable->hide(); m_titleLabel->hide();
this->setViewportMargins(0,0,0,0); this->setViewportMargins(0,0,0,0);
} }
}); });
@ -495,12 +495,12 @@ void ResultArea::setupConnectionsForWidget(ResultWidget *widget)
connect(widget, &ResultWidget::showMoreClicked, this, [=] () {//点击展开搜索结果后 显示悬浮窗 connect(widget, &ResultWidget::showMoreClicked, this, [=] () {//点击展开搜索结果后 显示悬浮窗
if (widget->height() > FRAME_HEIGHT) {//当前widget高度大于搜索结果界面高度则显示悬浮窗 if (widget->height() > FRAME_HEIGHT) {//当前widget高度大于搜索结果界面高度则显示悬浮窗
this->verticalScrollBar()->setValue(widget->pos().ry() + TITLE_HEIGHT); //置顶当前类型搜索结果,不显示标题栏 this->verticalScrollBar()->setValue(widget->pos().ry() + TITLE_HEIGHT); //置顶当前类型搜索结果,不显示标题栏
viewport()->stackUnder(m_titleLable); viewport()->stackUnder(m_titleLabel);
m_titleLable->setText(widget->pluginId()); m_titleLabel->setText(widget->pluginName());
m_titleLable->setFixedSize(widget->width(), TITLE_HEIGHT); m_titleLabel->setFixedSize(widget->width(), TITLE_HEIGHT);
m_titleLable->setShowMoreLableVisible(); m_titleLabel->setShowMoreLableVisible();
if (m_titleLable->isHidden()) { if (m_titleLabel->isHidden()) {
m_titleLable->show(); m_titleLabel->show();
this->setViewportMargins(0,TITLE_HEIGHT,0,0); this->setViewportMargins(0,TITLE_HEIGHT,0,0);
} }
} else { } else {
@ -508,8 +508,8 @@ void ResultArea::setupConnectionsForWidget(ResultWidget *widget)
} }
}); });
connect(widget, &ResultWidget::retractClicked, this, [=] () {//点击收起搜索结果后 connect(widget, &ResultWidget::retractClicked, this, [=] () {//点击收起搜索结果后
if (!m_titleLable->isHidden()) { if (!m_titleLabel->isHidden()) {
m_titleLable->hide(); m_titleLabel->hide();
this->setViewportMargins(0,0,0,0); this->setViewportMargins(0,0,0,0);
} }
}); });

View File

@ -67,7 +67,7 @@ private:
QVBoxLayout * m_mainLyt = nullptr; QVBoxLayout * m_mainLyt = nullptr;
BestListWidget * m_bestListWidget = nullptr; BestListWidget * m_bestListWidget = nullptr;
QList<ResultWidget *> m_widget_list; QList<ResultWidget *> m_widget_list;
TitleLabel * m_titleLable = nullptr; TitleLabel * m_titleLabel = nullptr;
bool m_detail_open_state = false; bool m_detail_open_state = false;
bool m_is_selected = false; bool m_is_selected = false;

View File

@ -18,6 +18,11 @@ QString ResultWidget::pluginId()
return m_plugin_id; return m_plugin_id;
} }
QString ResultWidget::pluginName()
{
return m_titleLabel->text();
}
void ResultWidget::setEnabled(const bool &enabled) void ResultWidget::setEnabled(const bool &enabled)
{ {
m_enabled = enabled; m_enabled = enabled;
@ -120,7 +125,8 @@ void ResultWidget::initUi()
m_mainLyt->setSpacing(MAIN_SPACING); m_mainLyt->setSpacing(MAIN_SPACING);
m_titleLabel = new TitleLabel(this); m_titleLabel = new TitleLabel(this);
m_titleLabel->setText(SearchPluginManager::getInstance()->getPlugin(m_plugin_id)->getPluginName()); m_plugin_name = SearchPluginManager::getInstance()->getPlugin(m_plugin_id)->getPluginName();
m_titleLabel->setText(m_plugin_name);
m_titleLabel->setFixedHeight(TITLE_HEIGHT); m_titleLabel->setFixedHeight(TITLE_HEIGHT);
m_resultView = new ResultView(m_plugin_id, this); m_resultView = new ResultView(m_plugin_id, this);

View File

@ -65,6 +65,7 @@ public:
ResultWidget(const QString &plugin_id, QWidget *parent = nullptr); ResultWidget(const QString &plugin_id, QWidget *parent = nullptr);
~ResultWidget() = default; ~ResultWidget() = default;
QString pluginId(); QString pluginId();
QString pluginName();
void setEnabled(const bool&); void setEnabled(const bool&);
void clearResult(); void clearResult();
int getResultNum(); int getResultNum();
@ -88,6 +89,7 @@ private:
void initConnections(); void initConnections();
QString m_plugin_id; QString m_plugin_id;
QString m_plugin_name;
bool m_enabled = true; bool m_enabled = true;
QVBoxLayout * m_mainLyt = nullptr; QVBoxLayout * m_mainLyt = nullptr;
TitleLabel * m_titleLabel = nullptr; TitleLabel * m_titleLabel = nullptr;