X-Git-Url: https://cloud.milkyroute.net/gitweb/dolphin.git/blobdiff_plain/e5eae108ca4511be9dae5f8bb4a4e1fbb0d89c7a..1829b1c2fb3f4c1786f774ca706d4ee0054897e0:/src/dolphinmainwindow.cpp diff --git a/src/dolphinmainwindow.cpp b/src/dolphinmainwindow.cpp index 002551318..eaa8ebb8a 100644 --- a/src/dolphinmainwindow.cpp +++ b/src/dolphinmainwindow.cpp @@ -121,7 +121,8 @@ DolphinMainWindow::DolphinMainWindow(int id) : m_actionHandler(0), m_remoteEncoding(0), m_settingsDialog(0), - m_captionStatJob(0) + m_captionStatJob(0), + m_lastHandleUrlStatJob(0) { setObjectName("Dolphin#"); @@ -386,12 +387,18 @@ void DolphinMainWindow::openNewMainWindow() void DolphinMainWindow::openNewTab() { + const bool isUrlEditable = m_activeViewContainer->urlNavigator()->isUrlEditable(); + openNewTab(m_activeViewContainer->url()); m_tabBar->setCurrentIndex(m_viewTab.count() - 1); + // The URL navigator of the new tab should have the same editable state + // as the current tab KUrlNavigator* navigator = m_activeViewContainer->urlNavigator(); - if (navigator->isUrlEditable()) { - // if a new tab is opened and the URL is editable, assure that + navigator->setUrlEditable(isUrlEditable); + + if (isUrlEditable) { + // If a new tab is opened and the URL is editable, assure that // the user can edit the URL without manually setting the focus navigator->setFocus(); } @@ -632,7 +639,7 @@ void DolphinMainWindow::readProperties(const KConfigGroup& group) void DolphinMainWindow::updateNewMenu() { m_newMenu->setViewShowsHiddenFiles(activeViewContainer()->view()->showHiddenFiles()); - m_newMenu->slotCheckUpToDate(); + m_newMenu->checkUpToDate(); m_newMenu->setPopupFiles(activeViewContainer()->url()); } @@ -1132,13 +1139,44 @@ void DolphinMainWindow::showSearchOptions() void DolphinMainWindow::handleUrl(const KUrl& url) { - if (KProtocolManager::supportsListing(url)) { + delete m_lastHandleUrlStatJob; + m_lastHandleUrlStatJob = 0; + + if (url.isLocalFile() && QFileInfo(url.toLocalFile()).isDir()) { + activeViewContainer()->setUrl(url); + } else if (KProtocolManager::supportsListing(url)) { + // stat the URL to see if it is a dir or not + m_lastHandleUrlStatJob = KIO::stat(url, KIO::HideProgressInfo); + connect(m_lastHandleUrlStatJob, SIGNAL(result(KJob*)), + this, SLOT(slotHandleUrlStatFinished(KJob*))); + + } else { + new KRun(url, this); + } +} + +void DolphinMainWindow::slotHandleUrlStatFinished(KJob* job) +{ + m_lastHandleUrlStatJob = 0; + const KIO::UDSEntry entry = static_cast(job)->statResult(); + const KUrl url = static_cast(job)->url(); + if ( entry.isDir() ) { activeViewContainer()->setUrl(url); } else { new KRun(url, this); } } +void DolphinMainWindow::tabDropEvent(int tab, QDropEvent* event) +{ + const KUrl::List urls = KUrl::List::fromMimeData(event->mimeData()); + 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); + } +} + void DolphinMainWindow::slotCaptionStatFinished(KJob* job) { m_captionStatJob = 0; @@ -1227,6 +1265,8 @@ void DolphinMainWindow::init() 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*))); m_tabBar->blockSignals(true); // signals get unblocked after at least 2 tabs are open @@ -1461,17 +1501,23 @@ void DolphinMainWindow::setupActions() KStandardAction::preferences(this, SLOT(editSettings()), actionCollection()); // not in menu actions + QList nextTabKeys; + nextTabKeys.append(KStandardShortcut::tabNext().primary()); + nextTabKeys.append(QKeySequence(Qt::CTRL + Qt::Key_Tab)); + + QList prevTabKeys; + prevTabKeys.append(KStandardShortcut::tabPrev().primary()); + prevTabKeys.append(QKeySequence(Qt::CTRL + Qt::SHIFT + Qt::Key_Tab)); + KAction* activateNextTab = actionCollection()->addAction("activate_next_tab"); activateNextTab->setText(i18nc("@action:inmenu", "Activate Next Tab")); connect(activateNextTab, SIGNAL(triggered()), SLOT(activateNextTab())); - activateNextTab->setShortcuts(QApplication::isRightToLeft() ? KStandardShortcut::tabPrev() : - KStandardShortcut::tabNext()); + activateNextTab->setShortcuts(QApplication::isRightToLeft() ? prevTabKeys : nextTabKeys); KAction* activatePrevTab = actionCollection()->addAction("activate_prev_tab"); activatePrevTab->setText(i18nc("@action:inmenu", "Activate Previous Tab")); connect(activatePrevTab, SIGNAL(triggered()), SLOT(activatePrevTab())); - activatePrevTab->setShortcuts(QApplication::isRightToLeft() ? KStandardShortcut::tabNext() : - KStandardShortcut::tabPrev()); + activatePrevTab->setShortcuts(QApplication::isRightToLeft() ? nextTabKeys : prevTabKeys); // for context menu KAction* openInNewTab = actionCollection()->addAction("open_in_new_tab"); @@ -1711,6 +1757,8 @@ void DolphinMainWindow::connectViewSignals(DolphinViewContainer* container) this, SLOT(updateHistory())); connect(navigator, SIGNAL(editableStateChanged(bool)), this, SLOT(slotEditableStateChanged(bool))); + connect(navigator, SIGNAL(tabRequested(const KUrl&)), + this, SLOT(openNewTab(KUrl))); } void DolphinMainWindow::updateSplitAction()