Fix the problem that the right side of each result is blocked in tablet mode.
This commit is contained in:
parent
c749aa7b83
commit
1e51726207
|
@ -301,6 +301,14 @@ void ResultArea::pressUp()
|
|||
}
|
||||
}
|
||||
|
||||
int ResultArea::getVScrollBarWidth()
|
||||
{
|
||||
if (verticalScrollBar()->isVisible()) {
|
||||
return this->verticalScrollBar()->width();
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
bool ResultArea::getSelectedState()
|
||||
{
|
||||
return m_is_selected;
|
||||
|
@ -414,6 +422,8 @@ bool ResultArea::viewportEvent(QEvent *event)
|
|||
|
||||
void ResultArea::initUi()
|
||||
{
|
||||
m_scrollBar = new ResultScrollBar(this);
|
||||
this->setVerticalScrollBar(m_scrollBar);
|
||||
// this->verticalScrollBar()->setProperty("drawScrollBarGroove", false);
|
||||
QPalette pal = palette();
|
||||
QPalette scroll_bar_pal = this->verticalScrollBar()->palette();
|
||||
|
@ -518,6 +528,8 @@ void ResultArea::initConnections()
|
|||
connect(this, &ResultArea::resizeWidth, this, [=] (int size) {
|
||||
m_titleLabel->setFixedWidth(size);
|
||||
});
|
||||
connect(m_scrollBar, &ResultScrollBar::scrollBarAppeared, this, &ResultArea::scrollBarAppeared);
|
||||
connect(m_scrollBar, &ResultScrollBar::scrollBarIsHideen, this, &ResultArea::scrollBarIsHideen);
|
||||
}
|
||||
|
||||
void ResultArea::setupConnectionsForWidget(ResultWidget *widget)
|
||||
|
@ -821,3 +833,20 @@ void DetailWidget::clearLayout(QLayout *layout)
|
|||
// }
|
||||
// }
|
||||
//}
|
||||
|
||||
ResultScrollBar::ResultScrollBar(QWidget *parent) : QScrollBar(parent)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void ResultScrollBar::showEvent(QShowEvent *event)
|
||||
{
|
||||
Q_EMIT this->scrollBarAppeared();
|
||||
return QScrollBar::showEvent(event);
|
||||
}
|
||||
|
||||
void ResultScrollBar::hideEvent(QHideEvent *event)
|
||||
{
|
||||
Q_EMIT this->scrollBarIsHideen();
|
||||
return QScrollBar::hideEvent(event);
|
||||
}
|
||||
|
|
|
@ -21,6 +21,7 @@
|
|||
#ifndef SEARCHPAGESECTION_H
|
||||
#define SEARCHPAGESECTION_H
|
||||
#include <QScrollArea>
|
||||
#include <QScrollBar>
|
||||
#include <QPaintEvent>
|
||||
#include <QPainter>
|
||||
#include <QStyleOption>
|
||||
|
@ -30,6 +31,22 @@
|
|||
#include "web-search-view.h"
|
||||
|
||||
namespace UkuiSearch {
|
||||
class ResultScrollBar : public QScrollBar
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
ResultScrollBar(QWidget *parent = nullptr);
|
||||
~ResultScrollBar() = default;
|
||||
|
||||
protected:
|
||||
void showEvent(QShowEvent *event);
|
||||
void hideEvent(QHideEvent *event);
|
||||
|
||||
Q_SIGNALS:
|
||||
void scrollBarAppeared();
|
||||
void scrollBarIsHideen();
|
||||
};
|
||||
|
||||
class ResultArea : public QScrollArea
|
||||
{
|
||||
Q_OBJECT
|
||||
|
@ -44,6 +61,7 @@ public:
|
|||
void pressEnter();
|
||||
void pressDown();
|
||||
void pressUp();
|
||||
int getVScrollBarWidth();
|
||||
|
||||
void setResultSelection();
|
||||
bool getSelectedState();
|
||||
|
@ -71,6 +89,7 @@ private:
|
|||
BestListWidget * m_bestListWidget = nullptr;
|
||||
QList<ResultWidget *> m_widget_list;
|
||||
TitleLabel * m_titleLabel = nullptr;
|
||||
ResultScrollBar *m_scrollBar = nullptr;
|
||||
|
||||
bool m_detail_open_state = false;
|
||||
bool m_is_selected = false;
|
||||
|
@ -86,6 +105,8 @@ Q_SIGNALS:
|
|||
void resizeHeight(int height);
|
||||
void resizeWidth(const int &);
|
||||
void rowClicked();
|
||||
void scrollBarAppeared();
|
||||
void scrollBarIsHideen();
|
||||
};
|
||||
|
||||
class DetailWidget : public QWidget
|
||||
|
@ -153,7 +174,6 @@ Q_SIGNALS:
|
|||
//protected:
|
||||
// bool eventFilter(QObject *, QEvent *);
|
||||
//};
|
||||
|
||||
}
|
||||
|
||||
#endif // SEARCHPAGESECTION_H
|
||||
|
|
|
@ -118,6 +118,15 @@ void SearchResultPage::sendResizeWidthSignal(int size)
|
|||
Q_EMIT this->resizeWidth(size);
|
||||
}
|
||||
|
||||
void SearchResultPage::setWidth(int width)
|
||||
{
|
||||
int margin = m_resultArea->getVScrollBarWidth();
|
||||
if (!margin) {
|
||||
margin = 8;//Default margin is 8
|
||||
}
|
||||
this->sendResizeWidthSignal(width - margin);
|
||||
}
|
||||
|
||||
void SearchResultPage::paintEvent(QPaintEvent *event)
|
||||
{
|
||||
QPainter p(this);
|
||||
|
@ -197,11 +206,19 @@ void SearchResultPage::initConnections()
|
|||
connect(this, &SearchResultPage::startSearch, m_detailArea, &DetailArea::hide);
|
||||
connect(this, &SearchResultPage::stopSearch, m_detailArea, &DetailArea::hide);
|
||||
connect(this, &SearchResultPage::startSearch, this, [=] () {
|
||||
sendResizeWidthSignal(656);
|
||||
// sendResizeWidthSignal(656);
|
||||
setWidth(672);
|
||||
});
|
||||
connect(m_resultArea, &ResultArea::scrollBarAppeared, this, [ & ]{
|
||||
setWidth(672);
|
||||
});
|
||||
connect(m_resultArea, &ResultArea::scrollBarIsHideen, this, [ & ]{
|
||||
setWidth(672);
|
||||
});
|
||||
connect(m_resultArea, &ResultArea::keyPressChanged, m_detailArea, &DetailArea::setWidgetInfo);
|
||||
connect(m_resultArea, &ResultArea::keyPressChanged, this, [=] () {
|
||||
sendResizeWidthSignal(280);
|
||||
// sendResizeWidthSignal(280);
|
||||
setWidth(296);
|
||||
});
|
||||
connect(m_resultArea, &ResultArea::currentRowChanged, m_detailArea, &DetailArea::setWidgetInfo);
|
||||
connect(m_resultArea, &ResultArea::currentRowChanged, this, &SearchResultPage::currentRowChanged);
|
||||
|
@ -209,7 +226,8 @@ void SearchResultPage::initConnections()
|
|||
connect(m_resultArea, &ResultArea::resizeHeight, this, &SearchResultPage::resizeHeight);
|
||||
connect(this, &SearchResultPage::resizeWidth, m_resultArea, &ResultArea::resizeWidth);
|
||||
connect(m_resultArea, &ResultArea::rowClicked, this, [=] () {
|
||||
sendResizeWidthSignal(280);
|
||||
// sendResizeWidthSignal(280);
|
||||
setWidth(296);
|
||||
});
|
||||
connect(this, &SearchResultPage::setSelectionInfo, m_resultArea, &ResultArea::setSelectionInfo);
|
||||
//跟随主题透明度变化
|
||||
|
@ -231,7 +249,8 @@ void SearchResultPage::setupConnectionsForWidget(ResultWidget *widget)
|
|||
});
|
||||
connect(this, &SearchResultPage::currentRowChanged, widget, &ResultWidget::clearSelectedRow);
|
||||
connect(widget, &ResultWidget::rowClicked, this, [=] () {
|
||||
sendResizeWidthSignal(280);
|
||||
// sendResizeWidthSignal(280);
|
||||
setWidth(296);
|
||||
});
|
||||
connect(this, &SearchResultPage::resizeWidth, widget, &ResultWidget::resizeWidth);
|
||||
}
|
||||
|
|
|
@ -40,6 +40,7 @@ public:
|
|||
void pressDown();
|
||||
bool getSelectedState();
|
||||
void sendResizeWidthSignal(int size);
|
||||
void setWidth(int width);
|
||||
|
||||
protected:
|
||||
void paintEvent(QPaintEvent *event);
|
||||
|
|
Loading…
Reference in New Issue