mirror of
https://invent.kde.org/system/dolphin
synced 2024-11-05 18:47:12 +00:00
* Show the search options as soon as the search bar gains focus.
* Allow the user to manually close the options. * Added tooltip descriptions. svn path=/trunk/KDE/kdebase/apps/; revision=1047281
This commit is contained in:
parent
a97291c90d
commit
d9e3139e50
6 changed files with 57 additions and 15 deletions
|
@ -1012,9 +1012,9 @@ void DolphinMainWindow::slotTabMoved(int from, int to)
|
||||||
m_tabIndex = m_tabBar->currentIndex();
|
m_tabIndex = m_tabBar->currentIndex();
|
||||||
}
|
}
|
||||||
|
|
||||||
void DolphinMainWindow::slotSearchBoxTextChanged(const QString& text)
|
void DolphinMainWindow::showSearchOptions()
|
||||||
{
|
{
|
||||||
m_searchOptionsConfigurator->setVisible(!text.isEmpty());
|
m_searchOptionsConfigurator->show();
|
||||||
}
|
}
|
||||||
|
|
||||||
void DolphinMainWindow::init()
|
void DolphinMainWindow::init()
|
||||||
|
@ -1098,8 +1098,8 @@ void DolphinMainWindow::init()
|
||||||
|
|
||||||
m_searchBox->setParent(toolBar("searchToolBar"));
|
m_searchBox->setParent(toolBar("searchToolBar"));
|
||||||
m_searchBox->show();
|
m_searchBox->show();
|
||||||
connect(m_searchBox, SIGNAL(textChanged(const QString&)),
|
connect(m_searchBox, SIGNAL(requestSearchOptions()),
|
||||||
this, SLOT(slotSearchBoxTextChanged(const QString&)));
|
this, SLOT(showSearchOptions()));
|
||||||
|
|
||||||
stateChanged("new_file");
|
stateChanged("new_file");
|
||||||
|
|
||||||
|
|
|
@ -401,11 +401,10 @@ private slots:
|
||||||
void slotTabMoved(int from, int to);
|
void slotTabMoved(int from, int to);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Is connected to the searchbox signal 'textChanged' and
|
* Is connected to the searchbox signal 'requestSearchOptions' and
|
||||||
* takes care to make the search options configurator visible
|
* takes care to show the search options.
|
||||||
* if a search text has been entered.
|
|
||||||
*/
|
*/
|
||||||
void slotSearchBoxTextChanged(const QString& text);
|
void showSearchOptions();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
DolphinMainWindow(int id);
|
DolphinMainWindow(int id);
|
||||||
|
|
|
@ -284,9 +284,10 @@ bool DolphinSearchBox::eventFilter(QObject* watched, QEvent* event)
|
||||||
// Postpone the creation of the search completer until
|
// Postpone the creation of the search completer until
|
||||||
// the search box is used. This decreases the startup time
|
// the search box is used. This decreases the startup time
|
||||||
// of Dolphin.
|
// of Dolphin.
|
||||||
Q_ASSERT(m_completer == 0);
|
if (m_completer == 0) {
|
||||||
m_completer = new DolphinSearchCompleter(m_searchInput);
|
m_completer = new DolphinSearchCompleter(m_searchInput);
|
||||||
m_searchInput->removeEventFilter(this);
|
}
|
||||||
|
emit requestSearchOptions();
|
||||||
}
|
}
|
||||||
|
|
||||||
return QWidget::eventFilter(watched, event);
|
return QWidget::eventFilter(watched, event);
|
||||||
|
|
|
@ -82,10 +82,7 @@ signals:
|
||||||
*/
|
*/
|
||||||
void search(const KUrl& url);
|
void search(const KUrl& url);
|
||||||
|
|
||||||
/**
|
void requestSearchOptions();
|
||||||
* Is emitted if the text of the searchbox has been changed.
|
|
||||||
*/
|
|
||||||
void textChanged(const QString& text);
|
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void emitSearchSignal();
|
void emitSearchSignal();
|
||||||
|
|
|
@ -22,7 +22,9 @@
|
||||||
#include "searchcriterionselector.h"
|
#include "searchcriterionselector.h"
|
||||||
|
|
||||||
#include <kcombobox.h>
|
#include <kcombobox.h>
|
||||||
|
#include <kdialog.h>
|
||||||
#include <kicon.h>
|
#include <kicon.h>
|
||||||
|
#include <klineedit.h>
|
||||||
#include <klocale.h>
|
#include <klocale.h>
|
||||||
#include <kseparator.h>
|
#include <kseparator.h>
|
||||||
|
|
||||||
|
@ -61,11 +63,22 @@ DolphinSearchOptionsConfigurator::DolphinSearchOptionsConfigurator(QWidget* pare
|
||||||
|
|
||||||
// add button "Save"
|
// add button "Save"
|
||||||
QPushButton* saveButton = new QPushButton(this);
|
QPushButton* saveButton = new QPushButton(this);
|
||||||
|
saveButton->setIcon(KIcon("document-save"));
|
||||||
saveButton->setText(i18nc("@action:button", "Save"));
|
saveButton->setText(i18nc("@action:button", "Save"));
|
||||||
|
saveButton->setToolTip(i18nc("@info", "Save search options"));
|
||||||
|
connect(saveButton, SIGNAL(clicked()), this, SLOT(saveQuery()));
|
||||||
|
|
||||||
|
// add button "Close"
|
||||||
|
QPushButton* closeButton = new QPushButton(this);
|
||||||
|
closeButton->setIcon(KIcon("dialog-close"));
|
||||||
|
closeButton->setText(i18nc("@action:button", "Close"));
|
||||||
|
closeButton->setToolTip(i18nc("@info", "Close search options"));
|
||||||
|
connect(closeButton, SIGNAL(clicked()), this, SLOT(hide()));
|
||||||
|
|
||||||
// add "Add selector" button
|
// add "Add selector" button
|
||||||
m_addSelectorButton = new QPushButton(this);
|
m_addSelectorButton = new QPushButton(this);
|
||||||
m_addSelectorButton->setIcon(KIcon("list-add"));
|
m_addSelectorButton->setIcon(KIcon("list-add"));
|
||||||
|
m_addSelectorButton->setToolTip(i18nc("@info", "Add search option"));
|
||||||
m_addSelectorButton->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
|
m_addSelectorButton->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
|
||||||
connect(m_addSelectorButton, SIGNAL(clicked()), this, SLOT(addSelector()));
|
connect(m_addSelectorButton, SIGNAL(clicked()), this, SLOT(addSelector()));
|
||||||
|
|
||||||
|
@ -76,6 +89,7 @@ DolphinSearchOptionsConfigurator::DolphinSearchOptionsConfigurator(QWidget* pare
|
||||||
hBoxLayout->addWidget(m_searchWhatBox);
|
hBoxLayout->addWidget(m_searchWhatBox);
|
||||||
hBoxLayout->addWidget(filler, 1);
|
hBoxLayout->addWidget(filler, 1);
|
||||||
hBoxLayout->addWidget(saveButton);
|
hBoxLayout->addWidget(saveButton);
|
||||||
|
hBoxLayout->addWidget(closeButton);
|
||||||
hBoxLayout->addWidget(m_addSelectorButton);
|
hBoxLayout->addWidget(m_addSelectorButton);
|
||||||
|
|
||||||
m_vBoxLayout->addWidget(new KSeparator(this));
|
m_vBoxLayout->addWidget(new KSeparator(this));
|
||||||
|
@ -114,4 +128,30 @@ void DolphinSearchOptionsConfigurator::updateSelectorButton()
|
||||||
m_addSelectorButton->setEnabled(selectors < 10);
|
m_addSelectorButton->setEnabled(selectors < 10);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void DolphinSearchOptionsConfigurator::saveQuery()
|
||||||
|
{
|
||||||
|
KDialog dialog(0, Qt::Dialog);
|
||||||
|
|
||||||
|
QWidget* container = new QWidget(&dialog);
|
||||||
|
|
||||||
|
QLabel* label = new QLabel(i18nc("@label", "Name:"), container);
|
||||||
|
KLineEdit* lineEdit = new KLineEdit(container);
|
||||||
|
lineEdit->setMinimumWidth(250);
|
||||||
|
|
||||||
|
QHBoxLayout* layout = new QHBoxLayout(container);
|
||||||
|
layout->addWidget(label, Qt::AlignRight);
|
||||||
|
layout->addWidget(lineEdit);
|
||||||
|
|
||||||
|
dialog.setMainWidget(container);
|
||||||
|
dialog.setCaption(i18nc("@title:window", "Save Search Options"));
|
||||||
|
dialog.setButtons(KDialog::Ok | KDialog::Cancel);
|
||||||
|
dialog.setDefaultButton(KDialog::Ok);
|
||||||
|
dialog.setButtonText(KDialog::Ok, i18nc("@action:button", "Save"));
|
||||||
|
|
||||||
|
KConfigGroup dialogConfig(KSharedConfig::openConfig("dolphinrc"),
|
||||||
|
"SaveSearchOptionsDialog");
|
||||||
|
dialog.restoreDialogSize(dialogConfig);
|
||||||
|
dialog.exec(); // TODO...
|
||||||
|
}
|
||||||
|
|
||||||
#include "dolphinsearchoptionsconfigurator.moc"
|
#include "dolphinsearchoptionsconfigurator.moc"
|
||||||
|
|
|
@ -52,6 +52,11 @@ private slots:
|
||||||
*/
|
*/
|
||||||
void updateSelectorButton();
|
void updateSelectorButton();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Saves the current query by adding it as Places entry.
|
||||||
|
*/
|
||||||
|
void saveQuery();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
KComboBox* m_searchFromBox;
|
KComboBox* m_searchFromBox;
|
||||||
KComboBox* m_searchWhatBox;
|
KComboBox* m_searchWhatBox;
|
||||||
|
|
Loading…
Reference in a new issue