]> cloud.milkyroute.net Git - dolphin.git/blobdiff - src/dolphinmainwindow.cpp
Show icon overlays in the Informationen Panel.
[dolphin.git] / src / dolphinmainwindow.cpp
index 89ba6e5923b0ab46d0786a68d6cc2df8c538e831..0f075a11cb4d0456eb60f989b6b56e2fbc0043a2 100644 (file)
@@ -35,6 +35,7 @@
 #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"
@@ -366,39 +367,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();
@@ -854,6 +822,23 @@ void DolphinMainWindow::find()
     m_activeViewContainer->setSearchModeEnabled(true);
 }
 
+void DolphinMainWindow::slotSearchLocationChanged()
+{
+#ifdef HAVE_NEPOMUK
+    QDockWidget* searchDock = findChild<QDockWidget*>("searchDock");
+    if (!searchDock) {
+        return;
+    }
+
+    SearchPanel* searchPanel = qobject_cast<SearchPanel*>(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 +1116,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;
@@ -1340,9 +1325,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 +1348,20 @@ void DolphinMainWindow::slotSearchModeChanged(bool enabled)
     }
 
     SearchPanel* searchPanel = qobject_cast<SearchPanel*>(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 +1479,8 @@ 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->addAction(ac->action(KStandardAction::name(KStandardAction::ReportBug)));
+    helpMenu->addAction(ac->action(KStandardAction::name(KStandardAction::SwitchApplicationLanguage)));
     helpMenu->addAction(ac->action(KStandardAction::name(KStandardAction::AboutApp)));
     helpMenu->addAction(ac->action(KStandardAction::name(KStandardAction::AboutKDE)));
     menu->addMenu(helpMenu);
@@ -1813,6 +1802,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);
@@ -2052,6 +2043,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 +2090,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)));
@@ -2241,15 +2269,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();
     }