X-Git-Url: https://cloud.milkyroute.net/gitweb/dolphin.git/blobdiff_plain/007907be20cc63e4c12320b0406cc255286e7792..dde672ac944af64d09cbd90dffc3d513ffe0c2b7:/src/dolphinmainwindow.cpp diff --git a/src/dolphinmainwindow.cpp b/src/dolphinmainwindow.cpp index 209b10678..9454c8c42 100644 --- a/src/dolphinmainwindow.cpp +++ b/src/dolphinmainwindow.cpp @@ -21,22 +21,14 @@ #include "dolphinmainwindow.h" -#include - #include "dolphinapplication.h" #include "dolphindockwidget.h" #include "dolphincontextmenu.h" #include "dolphinnewfilemenu.h" #include "dolphinviewcontainer.h" -#ifdef HAVE_NEPOMUK - #include "panels/search/searchpanel.h" - #include -#endif #include "panels/folders/folderspanel.h" #include "panels/places/placespanel.h" #include "panels/information/informationpanel.h" -#include "search/dolphinsearchbox.h" -#include "search/dolphinsearchinformation.h" #include "settings/dolphinsettingsdialog.h" #include "statusbar/dolphinstatusbar.h" #include "views/dolphinviewactionhandler.h" @@ -49,7 +41,6 @@ #endif #include "dolphin_generalsettings.h" -#include "dolphin_searchsettings.h" #include #include @@ -60,7 +51,6 @@ #include #include #include -#include #include #include #include @@ -89,8 +79,6 @@ #include #include -#include "views/dolphinplacesmodel.h" - #include #include #include @@ -130,13 +118,8 @@ DolphinMainWindow::DolphinMainWindow() : m_settingsDialog(), m_controlButton(0), m_updateToolBarTimer(0), - m_lastHandleUrlStatJob(0), - m_searchDockIsTemporaryVisible(false) + m_lastHandleUrlStatJob(0) { - DolphinPlacesModel::setModel(new KFilePlacesModel(this)); - connect(DolphinPlacesModel::instance(), SIGNAL(errorMessage(QString)), - this, SLOT(showErrorMessage(QString))); - // Workaround for a X11-issue in combination with KModifierInfo // (see DolphinContextMenu::initializeModifierKeyInfo() for // more information): @@ -386,6 +369,13 @@ void DolphinMainWindow::changeUrl(const KUrl& url) } } +void DolphinMainWindow::slotTerminalDirectoryChanged(const KUrl& url) +{ + m_activeViewContainer->setAutoGrabFocus(false); + changeUrl(url); + m_activeViewContainer->setAutoGrabFocus(true); +} + void DolphinMainWindow::slotEditableStateChanged(bool editable) { KToggleAction* editableLocationAction = @@ -444,7 +434,7 @@ void DolphinMainWindow::updateFilterBarAction(bool show) void DolphinMainWindow::openNewMainWindow() { - KRun::run("dolphin", KUrl::List(), this); + KRun::run("dolphin %u", KUrl::List(), this); } void DolphinMainWindow::openNewTab() @@ -555,7 +545,7 @@ void DolphinMainWindow::openInNewWindow() } if (!newWindowUrl.isEmpty()) { - KRun::run("dolphin", KUrl::List() << newWindowUrl, this); + KRun::run("dolphin %u", KUrl::List() << newWindowUrl, this); } } @@ -627,7 +617,7 @@ void DolphinMainWindow::closeEvent(QCloseEvent* event) break; case KDialog::No: // Close only the current tab - closeTab(); + closeTab(); default: event->ignore(); return; @@ -637,14 +627,6 @@ void DolphinMainWindow::closeEvent(QCloseEvent* event) GeneralSettings::setVersion(CurrentDolphinVersion); GeneralSettings::self()->writeConfig(); - if (m_searchDockIsTemporaryVisible) { - QDockWidget* searchDock = findChild("searchDock"); - if (searchDock) { - searchDock->hide(); - } - m_searchDockIsTemporaryVisible = false; - } - KXmlGuiWindow::closeEvent(event); } @@ -701,7 +683,7 @@ void DolphinMainWindow::readProperties(const KConfigGroup& group) // openNewTab() needs to be called only tabCount - 1 times if (i != tabCount - 1) { - openNewTab(); + openNewTab(); } } @@ -805,23 +787,6 @@ void DolphinMainWindow::find() m_activeViewContainer->setSearchModeEnabled(true); } -void DolphinMainWindow::slotSearchLocationChanged() -{ -#ifdef HAVE_NEPOMUK - QDockWidget* searchDock = findChild("searchDock"); - if (!searchDock) { - return; - } - - SearchPanel* searchPanel = qobject_cast(searchDock->widget()); - if (searchPanel) { - searchPanel->setSearchLocation(SearchSettings::location() == QLatin1String("FromHere") - ? SearchPanel::FromCurrentDir - : SearchPanel::Everywhere); - } -#endif -} - void DolphinMainWindow::updatePasteAction() { QAction* pasteAction = actionCollection()->action(KStandardAction::name(KStandardAction::Paste)); @@ -1323,52 +1288,6 @@ void DolphinMainWindow::slotWriteStateChanged(bool isFolderWritable) newFileMenu()->setEnabled(isFolderWritable); } -void DolphinMainWindow::slotSearchModeChanged(bool enabled) -{ -#ifdef HAVE_NEPOMUK - const DolphinSearchInformation& searchInfo = DolphinSearchInformation::instance(); - if (!searchInfo.isIndexingEnabled()) { - return; - } - - QDockWidget* searchDock = findChild("searchDock"); - if (!searchDock) { - return; - } - - if (enabled) { - if (!searchDock->isVisible()) { - m_searchDockIsTemporaryVisible = true; - } - searchDock->show(); - } else { - if (searchDock->isVisible() && m_searchDockIsTemporaryVisible) { - searchDock->hide(); - } - m_searchDockIsTemporaryVisible = false; - } - - SearchPanel* searchPanel = qobject_cast(searchDock->widget()); - if (!searchPanel) { - return; - } - - if (enabled) { - SearchPanel::SearchLocation searchLocation = SearchPanel::Everywhere; - const KUrl url = m_activeViewContainer->url(); - const bool isSearchUrl = (url.protocol() == QLatin1String("nepomuksearch")); - if ((SearchSettings::location() == QLatin1String("FromHere") && !isSearchUrl)) { - searchLocation = SearchPanel::FromCurrentDir; - } - searchPanel->setSearchLocation(searchLocation); - } else { - searchPanel->setSearchLocation(SearchPanel::Everywhere); - } -#else - Q_UNUSED(enabled); -#endif -} - void DolphinMainWindow::openContextMenu(const QPoint& pos, const KFileItem& item, const KUrl& url, @@ -1380,7 +1299,7 @@ void DolphinMainWindow::openContextMenu(const QPoint& pos, switch (command) { case DolphinContextMenu::OpenParentFolderInNewWindow: { - KRun::run("dolphin", KUrl::List() << item.url().upUrl(), this); + KRun::run("dolphin %u", KUrl::List() << item.url().upUrl(), this); break; } @@ -1505,6 +1424,11 @@ void DolphinMainWindow::slotControlButtonDeleted() m_updateToolBarTimer->start(); } +void DolphinMainWindow::slotPanelErrorMessage(const QString& error) +{ + activeViewContainer()->showMessage(error, DolphinViewContainer::Error); +} + void DolphinMainWindow::setActiveViewContainer(DolphinViewContainer* viewContainer) { Q_ASSERT(viewContainer); @@ -1560,6 +1484,7 @@ void DolphinMainWindow::setupActions() KMenu* menu = m_newFileMenu->menu(); menu->setTitle(i18nc("@title:menu Create new folder, file, link, etc.", "Create New")); menu->setIcon(KIcon("document-new")); + m_newFileMenu->setDelayed(false); connect(menu, SIGNAL(aboutToShow()), this, SLOT(updateNewMenu())); @@ -1636,12 +1561,12 @@ void DolphinMainWindow::setupActions() KToggleAction* editableLocation = actionCollection()->add("editable_location"); editableLocation->setText(i18nc("@action:inmenu Navigation Bar", "Editable Location")); - editableLocation->setShortcut(Qt::CTRL | Qt::Key_L); + editableLocation->setShortcut(Qt::Key_F6); connect(editableLocation, SIGNAL(triggered()), this, SLOT(toggleEditLocation())); KAction* replaceLocation = actionCollection()->addAction("replace_location"); replaceLocation->setText(i18nc("@action:inmenu Navigation Bar", "Replace Location")); - replaceLocation->setShortcut(Qt::Key_F6); + replaceLocation->setShortcut(Qt::CTRL | Qt::Key_L); connect(replaceLocation, SIGNAL(triggered()), this, SLOT(replaceLocation())); // setup 'Go' menu @@ -1653,6 +1578,7 @@ void DolphinMainWindow::setupActions() m_recentTabsMenu = new KActionMenu(i18n("Recently Closed Tabs"), this); m_recentTabsMenu->setIcon(KIcon("edit-undo")); + m_recentTabsMenu->setDelayed(false); actionCollection()->addAction("closed_tabs", m_recentTabsMenu); connect(m_recentTabsMenu->menu(), SIGNAL(triggered(QAction*)), this, SLOT(restoreClosedTab(QAction*))); @@ -1780,7 +1706,9 @@ void DolphinMainWindow::setupDockWidgets() connect(foldersPanel, SIGNAL(folderActivated(KUrl)), this, SLOT(changeUrl(KUrl))); connect(foldersPanel, SIGNAL(folderMiddleClicked(KUrl)), - this, SLOT(openNewActivatedTab(KUrl))); + this, SLOT(openNewTab(KUrl))); + connect(foldersPanel, SIGNAL(errorMessage(QString)), + this, SLOT(slotPanelErrorMessage(QString))); // Setup "Terminal" #ifndef Q_OS_WIN @@ -1793,6 +1721,7 @@ void DolphinMainWindow::setupDockWidgets() terminalDock->setWidget(terminalPanel); connect(terminalPanel, SIGNAL(hideTerminalPanel()), terminalDock, SLOT(hide())); + connect(terminalPanel, SIGNAL(changeUrl(KUrl)), this, SLOT(slotTerminalDirectoryChanged(KUrl))); connect(terminalDock, SIGNAL(visibilityChanged(bool)), terminalPanel, SLOT(dockVisibilityChanged())); @@ -1804,32 +1733,11 @@ void DolphinMainWindow::setupDockWidgets() terminalPanel, SLOT(setUrl(KUrl))); #endif - // Setup "Search" -#ifdef HAVE_NEPOMUK - DolphinDockWidget* searchDock = new DolphinDockWidget(i18nc("@title:window", "Search")); - searchDock->setLocked(lock); - searchDock->setObjectName("searchDock"); - searchDock->setAllowedAreas(Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea); - Panel* searchPanel = new SearchPanel(searchDock); - searchPanel->setCustomContextMenuActions(QList() << lockLayoutAction); - connect(searchPanel, SIGNAL(urlActivated(KUrl)), this, SLOT(handleUrl(KUrl))); - searchDock->setWidget(searchPanel); - - QAction* searchAction = searchDock->toggleViewAction(); - createPanelAction(KIcon("system-search"), Qt::Key_F12, searchAction, "show_search_panel"); - addDockWidget(Qt::RightDockWidgetArea, searchDock); - connect(this, SIGNAL(urlChanged(KUrl)), - searchPanel, SLOT(setUrl(KUrl))); -#endif - if (GeneralSettings::version() < 200) { infoDock->hide(); foldersDock->hide(); #ifndef Q_OS_WIN terminalDock->hide(); -#endif -#ifdef HAVE_NEPOMUK - searchDock->hide(); #endif } @@ -1840,14 +1748,7 @@ void DolphinMainWindow::setupDockWidgets() placesDock->setAllowedAreas(Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea); PlacesPanel* placesPanel = new PlacesPanel(placesDock); - QAction* separator = new QAction(placesPanel); - separator->setSeparator(true); - QList placesActions; - placesActions.append(separator); - placesActions.append(lockLayoutAction); - //placesPanel->addActions(placesActions); - //placesPanel->setModel(DolphinPlacesModel::instance()); - //placesPanel->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); + placesPanel->setCustomContextMenuActions(QList() << lockLayoutAction); placesDock->setWidget(placesPanel); QAction* placesAction = placesDock->toggleViewAction(); @@ -1857,11 +1758,15 @@ void DolphinMainWindow::setupDockWidgets() connect(placesPanel, SIGNAL(placeActivated(KUrl)), this, SLOT(changeUrl(KUrl))); connect(placesPanel, SIGNAL(placeMiddleClicked(KUrl)), - this, SLOT(openNewActivatedTab(KUrl))); + this, SLOT(openNewTab(KUrl))); + connect(placesPanel, SIGNAL(errorMessage(QString)), + this, SLOT(slotPanelErrorMessage(QString))); connect(this, SIGNAL(urlChanged(KUrl)), placesPanel, SLOT(setUrl(KUrl))); connect(placesDock, SIGNAL(visibilityChanged(bool)), this, SLOT(slotPlacesPanelVisibilityChanged(bool))); + connect(this, SIGNAL(settingsChanged()), + placesPanel, SLOT(readSettings())); // Add actions into the "Panels" menu KActionMenu* panelsMenu = new KActionMenu(i18nc("@action:inmenu View", "Panels"), this); @@ -1873,9 +1778,6 @@ void DolphinMainWindow::setupDockWidgets() panelsMenu->addAction(ac->action("show_folders_panel")); #ifndef Q_OS_WIN panelsMenu->addAction(ac->action("show_terminal_panel")); -#endif -#ifdef HAVE_NEPOMUK - panelsMenu->addAction(ac->action("show_search_panel")); #endif panelsMenu->addSeparator(); panelsMenu->addAction(lockLayoutAction); @@ -2055,6 +1957,8 @@ void DolphinMainWindow::refreshViews() toggleSplitView(); } } + + emit settingsChanged(); } void DolphinMainWindow::clearStatusBar() @@ -2068,12 +1972,6 @@ void DolphinMainWindow::connectViewSignals(DolphinViewContainer* container) this, SLOT(updateFilterBarAction(bool))); connect(container, SIGNAL(writeStateChanged(bool)), this, SLOT(slotWriteStateChanged(bool))); - connect(container, SIGNAL(searchModeChanged(bool)), - this, SLOT(slotSearchModeChanged(bool))); - - const DolphinSearchBox* searchBox = container->searchBox(); - connect(searchBox, SIGNAL(searchLocationChanged(SearchLocation)), - this, SLOT(slotSearchLocationChanged())); DolphinView* view = container->view(); connect(view, SIGNAL(selectionChanged(KFileItemList)), @@ -2165,7 +2063,13 @@ void DolphinMainWindow::createSecondaryView(int tabIndex) const int newWidth = (viewTab.primaryView->width() - splitter->handleWidth()) / 2; const DolphinView* view = viewTab.primaryView->view(); - viewTab.secondaryView = createViewContainer(view->url(), 0); + // The final parent of the new view container will be set by adding it + // to the splitter. However, we must make sure that the DolphinMainWindow + // is a parent of the view container already when it is constructed + // because this enables the container's KFileItemModel to assign its + // dir lister to the right main window. The dir lister can then cache + // authentication data. + viewTab.secondaryView = createViewContainer(view->url(), this); splitter->addWidget(viewTab.secondaryView); splitter->setSizes(QList() << newWidth << newWidth);