mirror of
https://invent.kde.org/system/dolphin
synced 2024-11-05 18:47:12 +00:00
Provide a search box for the nepomuksearch:/ KIO slave. This is just an initial prototype to get some feedback, the search box and the URL navigator still need some love for this usecase...
CCMAIL: sebastian@trueg.de svn path=/trunk/KDE/kdebase/apps/; revision=913451
This commit is contained in:
parent
ed7d5e466f
commit
be1298d9aa
3 changed files with 43 additions and 1 deletions
|
@ -53,6 +53,8 @@
|
|||
#include <kfiledialog.h>
|
||||
#include <kfileplacesmodel.h>
|
||||
#include <kglobal.h>
|
||||
#include <klineedit.h>
|
||||
#include <ktoolbar.h>
|
||||
#include <kicon.h>
|
||||
#include <kiconloader.h>
|
||||
#include <kio/netaccess.h>
|
||||
|
@ -90,6 +92,7 @@ DolphinMainWindow::DolphinMainWindow(int id) :
|
|||
m_tabBar(0),
|
||||
m_activeViewContainer(0),
|
||||
m_centralWidgetLayout(0),
|
||||
m_searchBar(0),
|
||||
m_id(id),
|
||||
m_tabIndex(0),
|
||||
m_viewTab(),
|
||||
|
@ -840,6 +843,13 @@ void DolphinMainWindow::slotTestCanDecode(const QDragMoveEvent* event, bool& can
|
|||
canDecode = KUrl::List::canDecode(event->mimeData());
|
||||
}
|
||||
|
||||
void DolphinMainWindow::searchItems()
|
||||
{
|
||||
const QString nepomukString = "nepomuksearch:/" + m_searchBar->text();
|
||||
m_activeViewContainer->setUrl(KUrl(nepomukString));
|
||||
}
|
||||
|
||||
|
||||
void DolphinMainWindow::init()
|
||||
{
|
||||
DolphinSettings& settings = DolphinSettings::instance();
|
||||
|
@ -901,6 +911,10 @@ void DolphinMainWindow::init()
|
|||
|
||||
setupGUI(Keys | Save | Create | ToolBar);
|
||||
|
||||
m_searchBar->setParent(toolBar("searchToolBar"));
|
||||
m_searchBar->setFont(KGlobalSettings::generalFont());
|
||||
m_searchBar->show();
|
||||
|
||||
stateChanged("new_file");
|
||||
|
||||
QClipboard* clipboard = QApplication::clipboard();
|
||||
|
@ -1055,6 +1069,11 @@ void DolphinMainWindow::setupActions()
|
|||
KStandardAction::home(this, SLOT(goHome()), actionCollection());
|
||||
|
||||
// setup 'Tools' menu
|
||||
KToggleAction* showSearchBar = actionCollection()->add<KToggleAction>("show_search_bar");
|
||||
showSearchBar->setText(i18nc("@action:inmenu Tools", "Show Search Bar"));
|
||||
showSearchBar->setShortcut(Qt::CTRL | Qt::Key_S);
|
||||
connect(showSearchBar, SIGNAL(triggered(bool)), this, SLOT(toggleFilterBarVisibility(bool)));
|
||||
|
||||
KToggleAction* showFilterBar = actionCollection()->add<KToggleAction>("show_filter_bar");
|
||||
showFilterBar->setText(i18nc("@action:inmenu Tools", "Show Filter Bar"));
|
||||
showFilterBar->setShortcut(Qt::CTRL | Qt::Key_I);
|
||||
|
@ -1103,6 +1122,18 @@ void DolphinMainWindow::setupActions()
|
|||
openInNewWindow->setText(i18nc("@action:inmenu", "Open in New Window"));
|
||||
openInNewWindow->setIcon(KIcon("window-new"));
|
||||
connect(openInNewWindow, SIGNAL(triggered()), this, SLOT(openInNewWindow()));
|
||||
|
||||
// 'Search' toolbar
|
||||
m_searchBar = new KLineEdit(this);
|
||||
m_searchBar->setMinimumWidth(150);
|
||||
m_searchBar->setClearButtonShown(true);
|
||||
connect(m_searchBar, SIGNAL(returnPressed()), this, SLOT(searchItems()));
|
||||
|
||||
KAction* search = new KAction(this);
|
||||
actionCollection()->addAction("search_bar", search);
|
||||
search->setText(i18nc("@action:inmenu", "Search Bar"));
|
||||
search->setDefaultWidget(m_searchBar);
|
||||
search->setShortcutConfigurable(false);
|
||||
}
|
||||
|
||||
void DolphinMainWindow::setupDockWidgets()
|
||||
|
|
|
@ -41,6 +41,7 @@ class DolphinViewActionHandler;
|
|||
class DolphinApplication;
|
||||
class DolphinSettingsDialog;
|
||||
class DolphinViewContainer;
|
||||
class KLineEdit;
|
||||
class KNewMenu;
|
||||
class KTabBar;
|
||||
class KUrl;
|
||||
|
@ -360,6 +361,11 @@ private slots:
|
|||
*/
|
||||
void slotTestCanDecode(const QDragMoveEvent* event, bool& accept);
|
||||
|
||||
/**
|
||||
* Searchs items that match to the text entered in the search bar.
|
||||
*/
|
||||
void searchItems();
|
||||
|
||||
private:
|
||||
DolphinMainWindow(int id);
|
||||
void init();
|
||||
|
@ -420,6 +426,7 @@ private:
|
|||
KTabBar* m_tabBar;
|
||||
DolphinViewContainer* m_activeViewContainer;
|
||||
QVBoxLayout* m_centralWidgetLayout;
|
||||
KLineEdit* m_searchBar;
|
||||
int m_id;
|
||||
|
||||
struct ViewTab
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
<!DOCTYPE kpartgui SYSTEM "kpartgui.dtd">
|
||||
<kpartgui name="dolphin" version="7">
|
||||
<kpartgui name="dolphin" version="8">
|
||||
<MenuBar>
|
||||
<Menu name="file">
|
||||
<Action name="create_new" />
|
||||
|
@ -125,4 +125,8 @@
|
|||
<Action name="show_preview" />
|
||||
<Action name="split_view" />
|
||||
</ToolBar>
|
||||
<ToolBar iconText="icononly" name="searchToolBar" newline="false">
|
||||
<text context="@title:menu">Search Toolbar</text>
|
||||
<Action name="search_bar" />
|
||||
</ToolBar>
|
||||
</kpartgui>
|
||||
|
|
Loading…
Reference in a new issue