Commit 6b759fbc authored by Kåre Särs's avatar Kåre Särs
Browse files

S&R: Move the current-folder button to the main options

Replace the find/replace labels with placeholders
Move the current-folder button next to searchPlacesCombo
Move the new-tab and more search-options to the right of the second row
Vertical layout difference is search&replace combos on separate rows
Fix tab navigation

BUG: 429091
parent cf11bcbf
......@@ -263,18 +263,33 @@ void KatePluginSearchView::nextFocus(QWidget *currentWidget, bool *found, bool n
return;
}
// we use the object names here because there can be multiple replaceButtons (on multiple result tabs)
// we use the object names here because there can be multiple trees (on multiple result tabs)
if (next) {
if (currentWidget->objectName() == QLatin1String("tree") || currentWidget == m_ui.binaryCheckBox) {
m_ui.newTabButton->setFocus();
m_ui.searchCombo->setFocus();
*found = true;
return;
}
if (currentWidget == m_ui.excludeCombo && m_ui.searchPlaceCombo->currentIndex() > Folder) {
m_ui.searchCombo->setFocus();
*found = true;
return;
}
if (currentWidget == m_ui.displayOptions) {
if (m_ui.displayOptions->isChecked()) {
m_ui.folderRequester->setFocus();
*found = true;
return;
if (m_ui.searchPlaceCombo->currentIndex() < Folder) {
m_ui.searchCombo->setFocus();
*found = true;
return;
} else if (m_ui.searchPlaceCombo->currentIndex() == Folder) {
m_ui.folderRequester->setFocus();
*found = true;
return;
} else {
m_ui.filterCombo->setFocus();
*found = true;
return;
}
} else {
Results *res = qobject_cast<Results *>(m_ui.resultTabWidget->currentWidget());
if (!res) {
......@@ -286,9 +301,21 @@ void KatePluginSearchView::nextFocus(QWidget *currentWidget, bool *found, bool n
}
}
} else {
if (currentWidget == m_ui.newTabButton) {
if (currentWidget == m_ui.searchCombo) {
if (m_ui.displayOptions->isChecked()) {
m_ui.binaryCheckBox->setFocus();
if (m_ui.searchPlaceCombo->currentIndex() < Folder) {
m_ui.displayOptions->setFocus();
*found = true;
return;
} else if (m_ui.searchPlaceCombo->currentIndex() == Folder) {
m_ui.binaryCheckBox->setFocus();
*found = true;
return;
} else {
m_ui.excludeCombo->setFocus();
*found = true;
return;
}
} else {
Results *res = qobject_cast<Results *>(m_ui.resultTabWidget->currentWidget());
if (!res) {
......@@ -444,6 +471,7 @@ KatePluginSearchView::KatePluginSearchView(KTextEditor::Plugin *plugin, KTextEdi
connect(&m_replacer, &ReplaceMatches::replaceStatus, this, &KatePluginSearchView::replaceStatus);
m_ui.searchCombo->lineEdit()->setPlaceholderText(i18n("Find"));
// Hook into line edit context menus
m_ui.searchCombo->setContextMenuPolicy(Qt::CustomContextMenu);
connect(m_ui.searchCombo, &QComboBox::customContextMenuRequested, this, &KatePluginSearchView::searchContextMenu);
......@@ -461,6 +489,8 @@ KatePluginSearchView::KatePluginSearchView(KTextEditor::Plugin *plugin, KTextEdi
regexHelperActOnAction(action, actionList, m_ui.searchCombo->lineEdit());
});
m_ui.replaceCombo->lineEdit()->setPlaceholderText(i18n("Replace"));
// Hook into line edit context menus
m_ui.replaceCombo->setContextMenuPolicy(Qt::CustomContextMenu);
connect(m_ui.replaceCombo, &QComboBox::customContextMenuRequested, this, &KatePluginSearchView::replaceContextMenu);
m_ui.replaceCombo->completer()->setCompletionMode(QCompleter::PopupCompletion);
......@@ -1323,7 +1353,7 @@ void KatePluginSearchView::searchDone()
m_ui.useRegExp->setDisabled(false);
m_ui.matchCase->setDisabled(false);
m_ui.expandResults->setDisabled(false);
m_ui.currentFolderButton->setDisabled(false);
m_ui.currentFolderButton->setDisabled(m_ui.searchPlaceCombo->currentIndex() != Folder);
if (!m_curResults) {
return;
......@@ -2106,50 +2136,49 @@ 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.stopAndNext, 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);
if (!m_isVerticalLayout && vertical) {
// Change the layout to vertical (left/right)
m_isVerticalLayout = true;
// Search row 1
m_ui.gridLayout->addWidget(m_ui.searchCombo, 0, 0, 1, 5);
// Search row 2
m_ui.gridLayout->addWidget(m_ui.searchButton, 1, 0);
m_ui.gridLayout->addWidget(m_ui.stopAndNext, 1, 1);
m_ui.gridLayout->addWidget(m_ui.searchPlaceLayoutW, 1, 2, 1, 3);
// Replace row 1
m_ui.gridLayout->addWidget(m_ui.replaceCombo, 2, 0, 1, 5);
// Replace row 2
m_ui.gridLayout->addWidget(m_ui.replaceButton, 3, 0);
m_ui.gridLayout->addWidget(m_ui.replaceCheckedBtn, 3, 1);
m_ui.gridLayout->addWidget(m_ui.searchOptionsLayoutW, 3, 2);
m_ui.gridLayout->addWidget(m_ui.newTabButton, 3, 3);
m_ui.gridLayout->addWidget(m_ui.displayOptions, 3, 4);
m_ui.gridLayout->setColumnStretch(0, 0);
m_ui.gridLayout->setColumnStretch(2, 4);
} else if (m_isVerticalLayout && !vertical) {
// Change layout to horizontal (top/bottom)
m_isVerticalLayout = false;
// Top row
m_ui.gridLayout->addWidget(m_ui.searchCombo, 0, 0);
m_ui.gridLayout->addWidget(m_ui.searchButton, 0, 1);
m_ui.gridLayout->addWidget(m_ui.stopAndNext, 0, 2);
m_ui.gridLayout->addWidget(m_ui.searchPlaceLayoutW, 0, 3, 1, 3);
// Second row
m_ui.gridLayout->addWidget(m_ui.replaceCombo, 1, 0);
m_ui.gridLayout->addWidget(m_ui.replaceButton, 1, 1);
m_ui.gridLayout->addWidget(m_ui.replaceCheckedBtn, 1, 2);
m_ui.gridLayout->addWidget(m_ui.searchOptionsLayoutW, 1, 3);
m_ui.gridLayout->addWidget(m_ui.newTabButton, 1, 4);
m_ui.gridLayout->addWidget(m_ui.displayOptions, 1, 5);
m_ui.gridLayout->setColumnStretch(0, 4);
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.stopAndNext, 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);
}
}
......
......@@ -199,7 +199,7 @@ private:
bool m_searchDiskFilesDone = true;
bool m_searchOpenFilesDone = true;
bool m_isSearchAsYouType = false;
bool m_isLeftRight = false;
bool m_isVerticalLayout = false;
bool m_blockDiskMatchFound = false;
QString m_resultBaseDir;
QList<KTextEditor::MovingRange *> m_matchRanges;
......
......@@ -6,135 +6,162 @@
<rect>
<x>0</x>
<y>0</y>
<width>634</width>
<height>204</height>
<width>606</width>
<height>251</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<layout class="QGridLayout" name="gridLayout" columnstretch="0,0,1,0,0,0,0,0,0,0">
<item row="0" column="0">
<widget class="QToolButton" name="newTabButton">
<property name="toolTip">
<string>Add new search tab</string>
<layout class="QGridLayout" name="gridLayout" columnstretch="1,0,0,0,0,0">
<item row="0" column="1">
<widget class="QPushButton" name="searchButton">
<property name="enabled">
<bool>false</bool>
</property>
<property name="text">
<string>...</string>
<property name="toolTip">
<string>Search</string>
</property>
</widget>
</item>
<item row="0" column="1" alignment="Qt::AlignRight">
<widget class="QLabel" name="findLabel">
<property name="text">
<string>Find:</string>
</property>
<property name="buddy">
<cstring>searchCombo</cstring>
</property>
</widget>
</item>
<item row="0" column="2">
<widget class="QComboBox" name="searchCombo">
<property name="editable">
<bool>true</bool>
<string>Search</string>
</property>
</widget>
</item>
<item row="0" column="3">
<widget class="QPushButton" name="searchButton">
<item row="1" column="2">
<widget class="QPushButton" name="replaceCheckedBtn">
<property name="enabled">
<bool>false</bool>
</property>
<property name="toolTip">
<string>Search</string>
</property>
<property name="text">
<string>Search</string>
<string>Replace Checked</string>
</property>
</widget>
</item>
<item row="0" column="4">
<item row="0" column="2">
<widget class="QStackedWidget" name="stopAndNext">
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="currentIndex">
<number>0</number>
</property>
<widget class="QPushButton" name="nextButton">
<property name="enabled">
<bool>false</bool>
</property>
<property name="currentIndex">
<number>0</number>
<property name="toolTip">
<string>Next</string>
</property>
<widget class="QPushButton" name="nextButton">
<property name="enabled">
<bool>false</bool>
</property>
<property name="toolTip">
<string>Next</string>
</property>
<property name="text">
<string>Next</string>
</property>
</widget>
<widget class="QPushButton" name="stopButton">
<property name="toolTip">
<string>Stop</string>
</property>
<property name="text">
<string>Stop</string>
</property>
</widget>
</widget>
</item>
<item row="0" column="5" colspan="5">
<widget class="QComboBox" name="searchPlaceCombo">
<item>
<property name="text">
<string>In Current File</string>
<string>Next</string>
</property>
</item>
<item>
<property name="text">
<string>In Open Files</string>
</widget>
<widget class="QPushButton" name="stopButton">
<property name="toolTip">
<string>Stop</string>
</property>
</item>
<item>
<property name="text">
<string>In Folder</string>
<string>Stop</string>
</property>
</item>
</widget>
</widget>
</item>
<item row="1" column="0">
<widget class="QToolButton" name="displayOptions">
<property name="toolTip">
<string>Show search options</string>
</property>
<property name="text">
<string>...</string>
</property>
<property name="checkable">
<widget class="QComboBox" name="replaceCombo">
<property name="editable">
<bool>true</bool>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QLabel" name="replaceLabel">
<property name="text">
<string>Replace:</string>
</property>
<property name="buddy">
<cstring>replaceCombo</cstring>
</property>
</widget>
</item>
<item row="1" column="2">
<widget class="QComboBox" name="replaceCombo">
<item row="0" column="0">
<widget class="QComboBox" name="searchCombo">
<property name="editable">
<bool>true</bool>
</property>
</widget>
</item>
<item row="1" column="3">
<widget class="QWidget" name="searchOptionsLayoutW" native="true">
<layout class="QHBoxLayout" name="horizontalLayout">
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<widget class="QToolButton" name="matchCase">
<property name="toolTip">
<string>Match case</string>
</property>
<property name="text">
<string/>
</property>
<property name="checkable">
<bool>true</bool>
</property>
<property name="autoRaise">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QToolButton" name="useRegExp">
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Enable regular expressions. Find help for regex syntax by using the buttons in the search and replace text fields.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="text">
<string/>
</property>
<property name="checkable">
<bool>true</bool>
</property>
<property name="autoRaise">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_3">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>5</width>
<height>5</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QToolButton" name="expandResults">
<property name="toolTip">
<string>Expand results</string>
</property>
<property name="text">
<string extracomment="When this is checked the result treeview will be expanded after a search"/>
</property>
<property name="checkable">
<bool>true</bool>
</property>
<property name="autoRaise">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item row="1" column="1">
<widget class="QPushButton" name="replaceButton">
<property name="enabled">
<bool>false</bool>
......@@ -144,74 +171,70 @@
</property>
</widget>
</item>
<item row="1" column="4">
<widget class="QPushButton" name="replaceCheckedBtn">
<property name="enabled">
<bool>false</bool>
</property>
<property name="text">
<string>Replace Checked</string>
</property>
<item row="0" column="3" colspan="3">
<widget class="QWidget" name="searchPlaceLayoutW" native="true">
<layout class="QHBoxLayout" name="searchPlaceLayout">
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<widget class="QComboBox" name="searchPlaceCombo">
<item>
<property name="text">
<string>In Current File</string>
</property>
</item>
<item>
<property name="text">
<string>In Open Files</string>
</property>
</item>
<item>
<property name="text">
<string>In Folder</string>
</property>
</item>
</widget>
</item>
<item>
<widget class="QToolButton" name="currentFolderButton">
<property name="toolTip">
<string>Use the current document's path.</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item row="1" column="5">
<widget class="QToolButton" name="matchCase">
<property name="toolTip">
<string>Match case</string>
</property>
<property name="text">
<string/>
</property>
<property name="checkable">
<bool>true</bool>
</property>
<property name="autoRaise">
<bool>true</bool>
</property>
</widget>
</item>
<item row="1" column="6">
<widget class="QToolButton" name="useRegExp">
<widget class="QToolButton" name="displayOptions">
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Enable regular expressions. Find help for regex syntax by using the buttons in the search and replace text fields.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
<string>Show more search options</string>
</property>
<property name="text">
<string/>
<string>...</string>
</property>
<property name="checkable">
<bool>true</bool>
</property>
<property name="autoRaise">
<bool>true</bool>
</property>
</widget>
</item>
<item row="1" column="7">
<spacer name="horizontalSpacer_3">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>13</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item row="1" column="8">
<widget class="QToolButton" name="expandResults">
<item row="1" column="4">
<widget class="QToolButton" name="newTabButton">
<property name="toolTip">
<string>Expand results</string>
<string>Add new search tab</string>
</property>
<property name="text">
<string extracomment="When this is checked the result treeview will be expanded after a search"/>
</property>
<property name="checkable">
<bool>true</bool>
</property>
<property name="autoRaise">
<bool>true</bool>
<string>...</string>
</property>
</widget>
</item>
......@@ -325,7 +348,7 @@
<item row="1" column="1">
<layout class="QHBoxLayout" name="horizontalLayout_3">
<item>
<widget class="KUrlComboRequester" name="folderRequester" native="true"/>
<widget class="KUrlComboRequester" name="folderRequester"/>
</item>
<item>
<widget class="QToolButton" name="folderUpButton">
......@@ -334,13 +357,6 @@
</property>
</widget>
</item>
<item>
<widget class="QToolButton" name="currentFolderButton">
<property name="toolTip">
<string>Use the current document's path.</string>
</property>
</widget>
</item>
</layout>
</item>
<item row="2" column="0">
......@@ -451,9 +467,9 @@
</widget>
<customwidgets>
<customwidget>
<class>KUrlRequester</class>
<extends>QWidget</extends>
<header>kurlrequester.h</header>
<class>KComboBox</class>
<extends>QComboBox</extends>
<header>kcombobox.h</header>
</customwidget>
<customwidget>
<class>KUrlComboRequester</class>
......@@ -461,13 +477,12 @@
<header>kurlrequester.h</header>
</customwidget>
<customwidget>
<class>KComboBox</class>
<extends>QComboBox</extends>
<header>kcombobox.h</header>
<class>KUrlRequester</class>
<extends>QWidget</extends>
<header>kurlrequester.h</header>
</customwidget>
</customwidgets>
<tabstops>
<tabstop>newTabButton</tabstop>