Commit bf86ce05 authored by Christoph Cullmann's avatar Christoph Cullmann

Enlarge the find and replace add-on combo boxes

Summary:
When the find and replace toolview is in the left or right sidebars, move the combo boxes on their own rows so they have more space.
This patch changes the position of the combo boxes when the toolview width is smaller than its height.
The goal is to be able to see a large string in the find and/or replace combo boxes within a moderately narrow toolview.

Test Plan:
Original suggestion, widgets are not grouped:
{F6930229}
{F6930232}

2nd suggestion, buttons are small:
{F6931264}
{F6931265}

3rd suggestion:
{F6933433}

toolview height Vs combobox width:

before, 22 result lines, the combobox needs to be expanded
{F7021390}

after, 20 result lines, the combobox is large
{F7021407}

Reviewers: #kate, sars, #vdg, ngraham

Reviewed By: #kate, sars, #vdg, ngraham

Subscribers: cullmann, ngraham, kwrite-devel

Tags: #kate, #vdg

Differential Revision: https://phabricator.kde.org/D22059
parent e762f14c
......@@ -222,6 +222,7 @@ m_switchToProjectModeWhenAvailable(false),
m_searchDiskFilesDone(true),
m_searchOpenFilesDone(true),
m_isSearchAsYouType(false),
m_isLeftRight(false),
m_projectPluginView(nullptr),
m_mainWindow (mainWin)
{
......@@ -1991,6 +1992,57 @@ void KatePluginSearchView::resultTabChanged(int index)
searchPlaceChanged();
}
void KatePluginSearchView::onResize(const QSize& size)
{
bool vertical = size.width() < size.height();
if(!m_isLeftRight && vertical) {
m_isLeftRight = true;
m_ui.gridLayout->addWidget(m_ui.searchCombo, 0, 1, 1, 8);
m_ui.gridLayout->addWidget(m_ui.findLabel, 0, 0);
m_ui.gridLayout->addWidget(m_ui.searchButton, 1, 0, 1, 2);
m_ui.gridLayout->addWidget(m_ui.nextButton, 1, 2);
m_ui.gridLayout->addWidget(m_ui.searchPlaceCombo, 1, 3, 1, 3);
m_ui.gridLayout->addWidget(m_ui.displayOptions, 1, 6);
m_ui.gridLayout->addWidget(m_ui.matchCase, 1, 7);
m_ui.gridLayout->addWidget(m_ui.useRegExp, 1, 8);
m_ui.gridLayout->addWidget(m_ui.replaceCombo, 2, 1, 1, 8);
m_ui.gridLayout->addWidget(m_ui.replaceLabel, 2, 0);
m_ui.gridLayout->addWidget(m_ui.replaceButton, 3, 0, 1, 2);
m_ui.gridLayout->addWidget(m_ui.replaceCheckedBtn, 3, 2);
m_ui.gridLayout->addWidget(m_ui.expandResults, 3, 7);
m_ui.gridLayout->addWidget(m_ui.newTabButton, 3, 8);
m_ui.gridLayout->setColumnStretch(4, 2);
m_ui.gridLayout->setColumnStretch(2, 0);
}
else if(m_isLeftRight && !vertical) {
m_isLeftRight = false;
m_ui.gridLayout->addWidget(m_ui.searchCombo, 0, 2);
m_ui.gridLayout->addWidget(m_ui.findLabel, 0, 1);
m_ui.gridLayout->addWidget(m_ui.searchButton, 0, 3);
m_ui.gridLayout->addWidget(m_ui.nextButton, 0, 4);
m_ui.gridLayout->addWidget(m_ui.searchPlaceCombo, 0, 5, 1, 4);
m_ui.gridLayout->addWidget(m_ui.matchCase, 1, 5);
m_ui.gridLayout->addWidget(m_ui.useRegExp, 1, 6);
m_ui.gridLayout->addWidget(m_ui.replaceCombo, 1, 2);
m_ui.gridLayout->addWidget(m_ui.replaceLabel, 1, 1);
m_ui.gridLayout->addWidget(m_ui.replaceButton, 1, 3);
m_ui.gridLayout->addWidget(m_ui.replaceCheckedBtn, 1, 4);
m_ui.gridLayout->addWidget(m_ui.expandResults, 1, 8);
m_ui.gridLayout->addWidget(m_ui.newTabButton, 0, 0);
m_ui.gridLayout->addWidget(m_ui.displayOptions, 1, 0);
m_ui.gridLayout->setColumnStretch(4, 0);
m_ui.gridLayout->setColumnStretch(2, 2);
m_ui.findLabel->setAlignment(Qt::AlignRight);
m_ui.replaceLabel->setAlignment(Qt::AlignRight);
}
}
bool KatePluginSearchView::eventFilter(QObject *obj, QEvent *event)
{
......@@ -2015,6 +2067,13 @@ bool KatePluginSearchView::eventFilter(QObject *obj, QEvent *event)
}
// NOTE: Qt::Key_Escape is handled by handleEsc
}
if (event->type() == QEvent::Resize) {
QResizeEvent *re = static_cast<QResizeEvent*>(event);
if(obj == m_toolView)
{
onResize(re->size());
}
}
return QObject::eventFilter(obj, event);
}
......
......@@ -183,6 +183,8 @@ protected:
private:
QTreeWidgetItem *rootFileItem(const QString &url, const QString &fName);
QStringList filterFiles(const QStringList& files) const;
void onResize(const QSize& size);
Ui::SearchDialog m_ui;
QWidget *m_toolView;
......@@ -199,6 +201,7 @@ private:
bool m_searchDiskFilesDone;
bool m_searchOpenFilesDone;
bool m_isSearchAsYouType;
bool m_isLeftRight;
QString m_resultBaseDir;
QList<KTextEditor::MovingRange*> m_matchRanges;
QTimer m_changeTimer;
......@@ -209,7 +212,7 @@ private:
* current project plugin view, if any
*/
QObject *m_projectPluginView;
/**
* our main window
*/
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment