X-Git-Url: https://cloud.milkyroute.net/gitweb/dolphin.git/blobdiff_plain/de077f8477c0b7077ed9239be8741fcb67658ffa..5070666ad2cd5fe3e559adca00a52aed5d137153:/src/dolphinmainwindow.cpp diff --git a/src/dolphinmainwindow.cpp b/src/dolphinmainwindow.cpp index 89ba6e592..3def8d88c 100644 --- a/src/dolphinmainwindow.cpp +++ b/src/dolphinmainwindow.cpp @@ -35,13 +35,13 @@ #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/dolphinsettings.h" #include "settings/dolphinsettingsdialog.h" #include "statusbar/dolphinstatusbar.h" #include "views/dolphinviewactionhandler.h" #include "views/dolphinremoteencoding.h" -#include "views/draganddrophelper.h" #include "views/viewproperties.h" #ifndef Q_OS_WIN @@ -49,7 +49,6 @@ #endif #include "dolphin_generalsettings.h" -#include "dolphin_iconsmodesettings.h" #include "dolphin_searchsettings.h" #include @@ -96,6 +95,12 @@ #include #include +namespace { + // Used for GeneralSettings::version() to determine whether + // an updated version of Dolphin is running. + const int CurrentDolphinVersion = 200; +}; + /* * Menu shown when pressing the configure-button in the toolbar. */ @@ -152,21 +157,21 @@ DolphinMainWindow::DolphinMainWindow() : connect(undoManager, SIGNAL(undoAvailable(bool)), this, SLOT(slotUndoAvailable(bool))); - connect(undoManager, SIGNAL(undoTextChanged(const QString&)), - this, SLOT(slotUndoTextChanged(const QString&))); + connect(undoManager, SIGNAL(undoTextChanged(QString)), + this, SLOT(slotUndoTextChanged(QString))); connect(undoManager, SIGNAL(jobRecordingStarted(CommandType)), this, SLOT(clearStatusBar())); connect(undoManager, SIGNAL(jobRecordingFinished(CommandType)), this, SLOT(showCommand(CommandType))); - connect(DolphinSettings::instance().placesModel(), SIGNAL(errorMessage(const QString&)), - this, SLOT(showErrorMessage(const QString&))); - connect(&DragAndDropHelper::instance(), SIGNAL(errorMessage(const QString&)), - this, SLOT(showErrorMessage(const QString&))); + connect(DolphinSettings::instance().placesModel(), SIGNAL(errorMessage(QString)), + this, SLOT(showErrorMessage(QString))); + //connect(&DragAndDropHelper::instance(), SIGNAL(errorMessage(QString)), + // this, SLOT(showErrorMessage(QString))); const DolphinSettings& settings = DolphinSettings::instance(); GeneralSettings* generalSettings = settings.generalSettings(); - const bool firstRun = generalSettings->firstRun(); + const bool firstRun = (generalSettings->version() < 200); if (firstRun) { generalSettings->setViewPropsTimestamp(QDateTime::currentDateTime()); } @@ -193,7 +198,7 @@ DolphinMainWindow::DolphinMainWindow() : m_actionHandler->setCurrentView(view); m_remoteEncoding = new DolphinRemoteEncoding(this, m_actionHandler); - connect(this, SIGNAL(urlChanged(const KUrl&)), + connect(this, SIGNAL(urlChanged(KUrl)), m_remoteEncoding, SLOT(slotAboutToOpenUrl())); m_tabBar = new KTabBar(this); @@ -203,18 +208,18 @@ DolphinMainWindow::DolphinMainWindow() : this, SLOT(setActiveTab(int))); connect(m_tabBar, SIGNAL(tabCloseRequested(int)), this, SLOT(closeTab(int))); - connect(m_tabBar, SIGNAL(contextMenu(int, const QPoint&)), - this, SLOT(openTabContextMenu(int, const QPoint&))); + connect(m_tabBar, SIGNAL(contextMenu(int,QPoint)), + this, SLOT(openTabContextMenu(int,QPoint))); connect(m_tabBar, SIGNAL(newTabRequest()), this, SLOT(openNewTab())); - connect(m_tabBar, SIGNAL(testCanDecode(const QDragMoveEvent*, bool&)), - this, SLOT(slotTestCanDecode(const QDragMoveEvent*, bool&))); + connect(m_tabBar, SIGNAL(testCanDecode(const QDragMoveEvent*,bool&)), + this, SLOT(slotTestCanDecode(const QDragMoveEvent*,bool&))); connect(m_tabBar, SIGNAL(mouseMiddleClick(int)), this, SLOT(closeTab(int))); - connect(m_tabBar, SIGNAL(tabMoved(int, int)), - this, SLOT(slotTabMoved(int, int))); - connect(m_tabBar, SIGNAL(receivedDropEvent(int, QDropEvent*)), - this, SLOT(tabDropEvent(int, QDropEvent*))); + connect(m_tabBar, SIGNAL(tabMoved(int,int)), + this, SLOT(slotTabMoved(int,int))); + connect(m_tabBar, SIGNAL(receivedDropEvent(int,QDropEvent*)), + this, SLOT(tabDropEvent(int,QDropEvent*))); m_tabBar->blockSignals(true); // signals get unblocked after at least 2 tabs are open @@ -366,39 +371,6 @@ void DolphinMainWindow::showCommand(CommandType command) } } -void DolphinMainWindow::refreshViews() -{ - Q_ASSERT(m_viewTab[m_tabIndex].primaryView); - - // remember the current active view, as because of - // the refreshing the active view might change to - // the secondary view - DolphinViewContainer* activeViewContainer = m_activeViewContainer; - - const int tabCount = m_viewTab.count(); - for (int i = 0; i < tabCount; ++i) { - m_viewTab[i].primaryView->refresh(); - if (m_viewTab[i].secondaryView) { - m_viewTab[i].secondaryView->refresh(); - } - } - - setActiveViewContainer(activeViewContainer); - - const GeneralSettings* generalSettings = DolphinSettings::instance().generalSettings(); - if (generalSettings->modifiedStartupSettings()) { - // The startup settings have been changed by the user (see bug #254947). - // Synchronize the split-view setting with the active view: - const bool splitView = generalSettings->splitView(); - const ViewTab& activeTab = m_viewTab[m_tabIndex]; - const bool toggle = ( splitView && !activeTab.secondaryView) - || (!splitView && activeTab.secondaryView); - if (toggle) { - toggleSplitView(); - } - } -} - void DolphinMainWindow::pasteIntoFolder() { m_activeViewContainer->view()->pasteIntoFolder(); @@ -679,8 +651,7 @@ void DolphinMainWindow::closeEvent(QCloseEvent* event) } } - generalSettings->setFirstRun(false); - + generalSettings->setVersion(CurrentDolphinVersion); settings.save(); if (m_searchDockIsTemporaryVisible) { @@ -757,14 +728,14 @@ void DolphinMainWindow::readProperties(const KConfigGroup& group) void DolphinMainWindow::updateNewMenu() { - m_newFileMenu->setViewShowsHiddenFiles(activeViewContainer()->view()->showHiddenFiles()); + m_newFileMenu->setViewShowsHiddenFiles(activeViewContainer()->view()->hiddenFilesShown()); m_newFileMenu->checkUpToDate(); m_newFileMenu->setPopupFiles(activeViewContainer()->url()); } void DolphinMainWindow::createDirectory() { - m_newFileMenu->setViewShowsHiddenFiles(activeViewContainer()->view()->showHiddenFiles()); + m_newFileMenu->setViewShowsHiddenFiles(activeViewContainer()->view()->hiddenFilesShown()); m_newFileMenu->setPopupFiles(activeViewContainer()->url()); m_newFileMenu->createDirectory(); } @@ -854,6 +825,23 @@ 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)); @@ -1131,7 +1119,7 @@ void DolphinMainWindow::editSettings() if (!m_settingsDialog) { const KUrl url = activeViewContainer()->url(); DolphinSettingsDialog* settingsDialog = new DolphinSettingsDialog(url, this); - connect(settingsDialog, SIGNAL(settingsChanged()), this, SLOT(reloadView())); + connect(settingsDialog, SIGNAL(settingsChanged()), this, SLOT(refreshViews())); settingsDialog->setAttribute(Qt::WA_DeleteOnClose); settingsDialog->show(); m_settingsDialog = settingsDialog; @@ -1328,7 +1316,8 @@ void DolphinMainWindow::tabDropEvent(int tab, QDropEvent* event) if (!urls.isEmpty() && tab != -1) { const ViewTab& viewTab = m_viewTab[tab]; const KUrl destPath = viewTab.isPrimaryViewActive ? viewTab.primaryView->url() : viewTab.secondaryView->url(); - DragAndDropHelper::instance().dropUrls(KFileItem(), destPath, event, m_tabBar); + Q_UNUSED(destPath); + //DragAndDropHelper::instance().dropUrls(KFileItem(), destPath, event, m_tabBar); } } @@ -1340,9 +1329,8 @@ void DolphinMainWindow::slotWriteStateChanged(bool isFolderWritable) void DolphinMainWindow::slotSearchModeChanged(bool enabled) { #ifdef HAVE_NEPOMUK - const KUrl url = m_activeViewContainer->url(); const DolphinSearchInformation& searchInfo = DolphinSearchInformation::instance(); - if (!searchInfo.isIndexingEnabled() || !searchInfo.isPathIndexed(url)) { + if (!searchInfo.isIndexingEnabled()) { return; } @@ -1364,17 +1352,20 @@ void DolphinMainWindow::slotSearchModeChanged(bool enabled) } SearchPanel* searchPanel = qobject_cast(searchDock->widget()); - if (searchPanel) { - // Per default any search-operation triggered by the Search Panel is done - // "Everywhere". - SearchPanel::SearchMode searchMode = SearchPanel::Everywhere; - - if (enabled && (SearchSettings::location() == QLatin1String("FromHere"))) { - // Only if the search-mode is enabled it is visible for the user whether - // a searching is done "Everywhere" or "From Here" (= current directory). - searchMode = SearchPanel::FromCurrentDir; + 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->setSearchMode(searchMode); + searchPanel->setSearchLocation(searchLocation); + } else { + searchPanel->setSearchLocation(SearchPanel::Everywhere); } #else Q_UNUSED(enabled); @@ -1492,6 +1483,11 @@ void DolphinMainWindow::updateToolBarMenu() connect(menu, SIGNAL(aboutToHide()), helpMenu, SLOT(deleteLater())); helpMenu->addAction(ac->action(KStandardAction::name(KStandardAction::HelpContents))); helpMenu->addAction(ac->action(KStandardAction::name(KStandardAction::WhatsThis))); + helpMenu->addSeparator(); + helpMenu->addAction(ac->action(KStandardAction::name(KStandardAction::ReportBug))); + helpMenu->addSeparator(); + helpMenu->addAction(ac->action(KStandardAction::name(KStandardAction::SwitchApplicationLanguage))); + helpMenu->addSeparator(); helpMenu->addAction(ac->action(KStandardAction::name(KStandardAction::AboutApp))); helpMenu->addAction(ac->action(KStandardAction::name(KStandardAction::AboutKDE))); menu->addMenu(helpMenu); @@ -1667,7 +1663,7 @@ void DolphinMainWindow::setupActions() // setup 'Go' menu KAction* backAction = KStandardAction::back(this, SLOT(goBack()), actionCollection()); - connect(backAction, SIGNAL(triggered(Qt::MouseButtons, Qt::KeyboardModifiers)), this, SLOT(goBack(Qt::MouseButtons))); + connect(backAction, SIGNAL(triggered(Qt::MouseButtons,Qt::KeyboardModifiers)), this, SLOT(goBack(Qt::MouseButtons))); KShortcut backShortcut = backAction->shortcut(); backShortcut.setAlternate(Qt::Key_Backspace); backAction->setShortcut(backShortcut); @@ -1675,8 +1671,8 @@ void DolphinMainWindow::setupActions() m_recentTabsMenu = new KActionMenu(i18n("Recently Closed Tabs"), this); m_recentTabsMenu->setIcon(KIcon("edit-undo")); actionCollection()->addAction("closed_tabs", m_recentTabsMenu); - connect(m_recentTabsMenu->menu(), SIGNAL(triggered(QAction *)), - this, SLOT(restoreClosedTab(QAction *))); + connect(m_recentTabsMenu->menu(), SIGNAL(triggered(QAction*)), + this, SLOT(restoreClosedTab(QAction*))); QAction* action = new QAction(i18n("Empty Recently Closed Tabs"), m_recentTabsMenu); action->setIcon(KIcon("edit-clear-list")); @@ -1686,10 +1682,10 @@ void DolphinMainWindow::setupActions() m_recentTabsMenu->setEnabled(false); KAction* forwardAction = KStandardAction::forward(this, SLOT(goForward()), actionCollection()); - connect(forwardAction, SIGNAL(triggered(Qt::MouseButtons, Qt::KeyboardModifiers)), this, SLOT(goForward(Qt::MouseButtons))); + connect(forwardAction, SIGNAL(triggered(Qt::MouseButtons,Qt::KeyboardModifiers)), this, SLOT(goForward(Qt::MouseButtons))); KAction* upAction = KStandardAction::up(this, SLOT(goUp()), actionCollection()); - connect(upAction, SIGNAL(triggered(Qt::MouseButtons, Qt::KeyboardModifiers)), this, SLOT(goUp(Qt::MouseButtons))); + connect(upAction, SIGNAL(triggered(Qt::MouseButtons,Qt::KeyboardModifiers)), this, SLOT(goUp(Qt::MouseButtons))); KStandardAction::home(this, SLOT(goHome()), actionCollection()); @@ -1799,8 +1795,8 @@ void DolphinMainWindow::setupDockWidgets() addDockWidget(Qt::LeftDockWidgetArea, foldersDock); connect(this, SIGNAL(urlChanged(KUrl)), foldersPanel, SLOT(setUrl(KUrl))); - connect(foldersPanel, SIGNAL(changeUrl(KUrl, Qt::MouseButtons)), - this, SLOT(handlePlacesClick(KUrl, Qt::MouseButtons))); + connect(foldersPanel, SIGNAL(changeUrl(KUrl,Qt::MouseButtons)), + this, SLOT(handlePlacesClick(KUrl,Qt::MouseButtons))); // Setup "Terminal" #ifndef Q_OS_WIN @@ -1813,6 +1809,8 @@ void DolphinMainWindow::setupDockWidgets() terminalDock->setWidget(terminalPanel); connect(terminalPanel, SIGNAL(hideTerminalPanel()), terminalDock, SLOT(hide())); + connect(terminalDock, SIGNAL(visibilityChanged(bool)), + terminalPanel, SLOT(dockVisibilityChanged())); QAction* terminalAction = terminalDock->toggleViewAction(); terminalAction->setShortcut(Qt::Key_F4); @@ -1844,8 +1842,7 @@ void DolphinMainWindow::setupDockWidgets() searchPanel, SLOT(setUrl(KUrl))); #endif - const bool firstRun = DolphinSettings::instance().generalSettings()->firstRun(); - if (firstRun) { + if (DolphinSettings::instance().generalSettings()->version() < 200) { infoDock->hide(); foldersDock->hide(); #ifndef Q_OS_WIN @@ -1879,8 +1876,8 @@ void DolphinMainWindow::setupDockWidgets() addActionCloneToCollection(placesAction, "show_places_panel"); addDockWidget(Qt::LeftDockWidgetArea, placesDock); - connect(placesPanel, SIGNAL(urlChanged(KUrl, Qt::MouseButtons)), - this, SLOT(handlePlacesClick(KUrl, Qt::MouseButtons))); + connect(placesPanel, SIGNAL(urlChanged(KUrl,Qt::MouseButtons)), + this, SLOT(handlePlacesClick(KUrl,Qt::MouseButtons))); connect(this, SIGNAL(urlChanged(KUrl)), placesPanel, SLOT(setUrl(KUrl))); connect(placesDock, SIGNAL(visibilityChanged(bool)), @@ -2052,6 +2049,39 @@ void DolphinMainWindow::rememberClosedTab(int index) KAcceleratorManager::manage(tabsMenu); } +void DolphinMainWindow::refreshViews() +{ + Q_ASSERT(m_viewTab[m_tabIndex].primaryView); + + // remember the current active view, as because of + // the refreshing the active view might change to + // the secondary view + DolphinViewContainer* activeViewContainer = m_activeViewContainer; + + const int tabCount = m_viewTab.count(); + for (int i = 0; i < tabCount; ++i) { + m_viewTab[i].primaryView->refresh(); + if (m_viewTab[i].secondaryView) { + m_viewTab[i].secondaryView->refresh(); + } + } + + setActiveViewContainer(activeViewContainer); + + const GeneralSettings* generalSettings = DolphinSettings::instance().generalSettings(); + if (generalSettings->modifiedStartupSettings()) { + // The startup settings have been changed by the user (see bug #254947). + // Synchronize the split-view setting with the active view: + const bool splitView = generalSettings->splitView(); + const ViewTab& activeTab = m_viewTab[m_tabIndex]; + const bool toggle = ( splitView && !activeTab.secondaryView) + || (!splitView && activeTab.secondaryView); + if (toggle) { + toggleSplitView(); + } + } +} + void DolphinMainWindow::clearStatusBar() { m_activeViewContainer->statusBar()->clear(); @@ -2066,6 +2096,10 @@ void DolphinMainWindow::connectViewSignals(DolphinViewContainer* container) 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)), this, SLOT(slotSelectionChanged(KFileItemList))); @@ -2073,23 +2107,23 @@ void DolphinMainWindow::connectViewSignals(DolphinViewContainer* container) this, SLOT(slotRequestItemInfo(KFileItem))); connect(view, SIGNAL(activated()), this, SLOT(toggleActiveView())); - connect(view, SIGNAL(tabRequested(const KUrl&)), - this, SLOT(openNewTab(const KUrl&))); - connect(view, SIGNAL(requestContextMenu(KFileItem, const KUrl&, const QList&)), - this, SLOT(openContextMenu(KFileItem, const KUrl&, const QList&))); + connect(view, SIGNAL(tabRequested(KUrl)), + this, SLOT(openNewTab(KUrl))); + connect(view, SIGNAL(requestContextMenu(KFileItem,KUrl,QList)), + this, SLOT(openContextMenu(KFileItem,KUrl,QList))); connect(view, SIGNAL(startedPathLoading(KUrl)), this, SLOT(enableStopAction())); connect(view, SIGNAL(finishedPathLoading(KUrl)), this, SLOT(disableStopAction())); const KUrlNavigator* navigator = container->urlNavigator(); - connect(navigator, SIGNAL(urlChanged(const KUrl&)), - this, SLOT(changeUrl(const KUrl&))); + connect(navigator, SIGNAL(urlChanged(KUrl)), + this, SLOT(changeUrl(KUrl))); connect(navigator, SIGNAL(historyChanged()), this, SLOT(updateHistory())); connect(navigator, SIGNAL(editableStateChanged(bool)), this, SLOT(slotEditableStateChanged(bool))); - connect(navigator, SIGNAL(tabRequested(const KUrl&)), + connect(navigator, SIGNAL(tabRequested(KUrl)), this, SLOT(openNewTab(KUrl))); } @@ -2150,7 +2184,7 @@ void DolphinMainWindow::createSecondaryView(int tabIndex) const int newWidth = (m_viewTab[tabIndex].primaryView->width() - splitter->handleWidth()) / 2; const DolphinView* view = m_viewTab[tabIndex].primaryView->view(); - m_viewTab[tabIndex].secondaryView = createViewContainer(view->rootUrl(), 0); + m_viewTab[tabIndex].secondaryView = createViewContainer(view->url(), 0); splitter->addWidget(m_viewTab[tabIndex].secondaryView); splitter->setSizes(QList() << newWidth << newWidth); connectViewSignals(m_viewTab[tabIndex].secondaryView); @@ -2241,15 +2275,15 @@ void ToolBarMenu::showEvent(QShowEvent* event) // Assure that the menu is not shown outside the screen boundaries and // that it does not overlap with the parent button. const QRect screen = QApplication::desktop()->screenGeometry(QCursor::pos()); - if (pos.x() < 0) { - pos.rx() = 0; - } else if (pos.x() + width() >= screen.width()) { - pos.rx() = screen.width() - width(); + if (pos.x() < screen.x()) { + pos.rx() = screen.x(); + } else if (pos.x() + width() > screen.x() + screen.width()) { + pos.rx() = screen.x() + screen.width() - width(); } - if (pos.y() < 0) { - pos.ry() = 0; - } else if (pos.y() + height() >= screen.height()) { + if (pos.y() < screen.y()) { + pos.ry() = screen.y(); + } else if (pos.y() + height() > screen.y() + screen.height()) { pos.ry() = button->mapToGlobal(QPoint(0, 0)).y() - height(); }