search scroll bar
This commit is contained in:
parent
216b52ba76
commit
4d17f1ce87
|
@ -13,6 +13,7 @@
|
|||
#include <QHBoxLayout>
|
||||
#include <QVBoxLayout>
|
||||
#include <QCheckBox>
|
||||
#include <QScrollBar>
|
||||
#include "editor.h"
|
||||
|
||||
class Search : public QWidget
|
||||
|
@ -28,6 +29,8 @@ public:
|
|||
void setFindEditFocus();
|
||||
void setFindEditText(QString str);
|
||||
bool isFocused();
|
||||
void updateScrollBar();
|
||||
QScrollBar * horizontalScrollBar();
|
||||
protected:
|
||||
void paintEvent(QPaintEvent *event) override;
|
||||
QLineEdit * findEdit;
|
||||
|
@ -42,6 +45,7 @@ protected:
|
|||
QPushButton * closeButton;
|
||||
QHBoxLayout * hLayoutFind;
|
||||
QHBoxLayout * hLayoutReplace;
|
||||
QScrollBar * scrollBar;
|
||||
QVBoxLayout * vLayout;
|
||||
private:
|
||||
Editor * editor;
|
||||
|
@ -63,6 +67,7 @@ private slots:
|
|||
void findEnterPressed();
|
||||
void replaceEnterPressed();
|
||||
void findTextChanged(QString);
|
||||
void scrollBarValueChanged(int value);
|
||||
};
|
||||
|
||||
#endif // SEARCH_H
|
||||
|
|
|
@ -1252,6 +1252,9 @@ void Editor::resizeEvent(QResizeEvent * e)
|
|||
QTextEdit::resizeEvent(e);
|
||||
hidePopups();
|
||||
updateWidgetsGeometry();
|
||||
if (static_cast<Search *>(search)->isVisible()) {
|
||||
static_cast<Search *>(search)->updateScrollBar();
|
||||
}
|
||||
}
|
||||
|
||||
void Editor::updateWidgetsGeometry()
|
||||
|
@ -2144,6 +2147,9 @@ void Editor::blockCountChanged(int /*blockCount*/)
|
|||
void Editor::horizontalScrollbarValueChanged(int /* sliderPos */)
|
||||
{
|
||||
updateLineAnnotationView();
|
||||
if (static_cast<Search *>(search)->isVisible()) {
|
||||
static_cast<Search *>(search)->updateScrollBar();
|
||||
}
|
||||
}
|
||||
|
||||
void Editor::verticalScrollbarValueChanged(int /* sliderPos */)
|
||||
|
@ -5607,12 +5613,14 @@ void Editor::showSearch()
|
|||
{
|
||||
search->show();
|
||||
static_cast<Search *>(search)->setFindEditFocus();
|
||||
static_cast<Search *>(search)->updateScrollBar();
|
||||
updateViewportMargins();
|
||||
}
|
||||
|
||||
void Editor::closeSearch()
|
||||
{
|
||||
search->hide();
|
||||
static_cast<Search *>(search)->updateScrollBar();
|
||||
updateViewportMargins();
|
||||
setFocus();
|
||||
static_cast<LineMap *>(lineMap)->clearMarks();
|
||||
|
|
|
@ -17,6 +17,10 @@ Search::Search(Editor * codeEditor) : QWidget(codeEditor)
|
|||
editor = codeEditor;
|
||||
vLayout = new QVBoxLayout(this);
|
||||
|
||||
scrollBar = new QScrollBar(Qt::Horizontal);
|
||||
scrollBar->setVisible(false);
|
||||
vLayout->addWidget(scrollBar);
|
||||
|
||||
findEdit = new QLineEdit();
|
||||
findEdit->setMinimumWidth(INPUT_WIDTH_MIN);
|
||||
findEdit->setMaximumWidth(INPUT_WIDTH_MAX);
|
||||
|
@ -98,6 +102,7 @@ Search::Search(Editor * codeEditor) : QWidget(codeEditor)
|
|||
connect(findEdit, SIGNAL(returnPressed()), this, SLOT(findEnterPressed()));
|
||||
connect(replaceEdit, SIGNAL(returnPressed()), this, SLOT(replaceEnterPressed()));
|
||||
connect(findEdit, SIGNAL(textChanged(QString)), this, SLOT(findTextChanged(QString)));
|
||||
connect(scrollBar, SIGNAL(valueChanged(int)), this, SLOT(scrollBarValueChanged(int)));
|
||||
|
||||
CaSe = false;
|
||||
Word = false;
|
||||
|
@ -234,3 +239,33 @@ bool Search::isFocused()
|
|||
{
|
||||
return findEdit->hasFocus() || replaceEdit->hasFocus();
|
||||
}
|
||||
|
||||
void Search::updateScrollBar()
|
||||
{
|
||||
scrollBar->setMinimum(editor->horizontalScrollBar()->minimum());
|
||||
scrollBar->setMaximum(editor->horizontalScrollBar()->maximum());
|
||||
scrollBar->setSingleStep(editor->horizontalScrollBar()->singleStep());
|
||||
scrollBar->setPageStep(editor->horizontalScrollBar()->pageStep());
|
||||
scrollBar->setValue(editor->horizontalScrollBar()->value());
|
||||
if (editor->horizontalScrollBar()->maximum() > editor->horizontalScrollBar()->minimum()) {
|
||||
editor->horizontalScrollBar()->show();
|
||||
} else {
|
||||
editor->horizontalScrollBar()->hide();
|
||||
}
|
||||
if (isVisible() && scrollBar->maximum() > scrollBar->minimum()) {
|
||||
scrollBar->show();
|
||||
editor->horizontalScrollBar()->hide();
|
||||
} else {
|
||||
scrollBar->hide();
|
||||
}
|
||||
}
|
||||
|
||||
void Search::scrollBarValueChanged(int value)
|
||||
{
|
||||
editor->horizontalScrollBar()->setValue(value);
|
||||
}
|
||||
|
||||
QScrollBar * Search::horizontalScrollBar()
|
||||
{
|
||||
return scrollBar;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue