X-Git-Url: https://cloud.milkyroute.net/gitweb/dolphin.git/blobdiff_plain/1dfb2f385a8f036b96cc893d6384f76d887f3fd2..39f89141b06c:/src/dolphinmainwindow.cpp?ds=sidebyside diff --git a/src/dolphinmainwindow.cpp b/src/dolphinmainwindow.cpp index 73f894554..0913503d2 100644 --- a/src/dolphinmainwindow.cpp +++ b/src/dolphinmainwindow.cpp @@ -114,9 +114,13 @@ DolphinMainWindow::DolphinMainWindow(int id) : m_actionHandler(0), m_remoteEncoding(0), m_settingsDialog(0), - m_captionStatJob(0), m_lastHandleUrlStatJob(0) { + // Workaround for a X11-issue in combination with KModifierInfo + // (see DolphinContextMenu::initializeModifierKeyInfo() for + // more information): + DolphinContextMenu::initializeModifierKeyInfo(); + setObjectName("Dolphin#"); m_viewTab.append(ViewTab()); @@ -458,17 +462,27 @@ void DolphinMainWindow::activatePrevTab() void DolphinMainWindow::openInNewTab() { const KFileItemList list = m_activeViewContainer->view()->selectedItems(); - if ((list.count() == 1) && list[0].isDir()) { - openNewTab(m_activeViewContainer->view()->selectedUrls()[0]); + if (list.isEmpty()) { + openNewTab(m_activeViewContainer->url()); + } else if ((list.count() == 1) && list[0].isDir()) { + openNewTab(list[0].url()); } } void DolphinMainWindow::openInNewWindow() { + KUrl newWindowUrl; + const KFileItemList list = m_activeViewContainer->view()->selectedItems(); - if ((list.count() == 1) && list[0].isDir()) { + if (list.isEmpty()) { + newWindowUrl = m_activeViewContainer->url(); + } else if ((list.count() == 1) && list[0].isDir()) { + newWindowUrl = list[0].url(); + } + + if (!newWindowUrl.isEmpty()) { DolphinMainWindow* window = DolphinApplication::app()->createMainWindow(); - window->changeUrl(m_activeViewContainer->view()->selectedUrls()[0]); + window->changeUrl(newWindowUrl); window->show(); } } @@ -787,6 +801,17 @@ void DolphinMainWindow::reloadView() void DolphinMainWindow::stopLoading() { + m_activeViewContainer->view()->stopLoading(); +} + +void DolphinMainWindow::enableStopAction() +{ + actionCollection()->action("stop")->setEnabled(true); +} + +void DolphinMainWindow::disableStopAction() +{ + actionCollection()->action("stop")->setEnabled(false); } void DolphinMainWindow::toggleFilterBarVisibility(bool show) @@ -887,30 +912,31 @@ void DolphinMainWindow::compareFiles() KUrl urlA; KUrl urlB; - KUrl::List urls = m_viewTab[m_tabIndex].primaryView->view()->selectedUrls(); - switch (urls.count()) { + KFileItemList items = m_viewTab[m_tabIndex].primaryView->view()->selectedItems(); + + switch (items.count()) { case 0: { Q_ASSERT(m_viewTab[m_tabIndex].secondaryView != 0); - urls = m_viewTab[m_tabIndex].secondaryView->view()->selectedUrls(); - Q_ASSERT(urls.count() == 2); - urlA = urls[0]; - urlB = urls[1]; + items = m_viewTab[m_tabIndex].secondaryView->view()->selectedItems(); + Q_ASSERT(items.count() == 2); + urlA = items[0].url(); + urlB = items[1].url(); break; } case 1: { - urlA = urls[0]; + urlA = items[0].url(); Q_ASSERT(m_viewTab[m_tabIndex].secondaryView != 0); - urls = m_viewTab[m_tabIndex].secondaryView->view()->selectedUrls(); - Q_ASSERT(urls.count() == 1); - urlB = urls[0]; + items = m_viewTab[m_tabIndex].secondaryView->view()->selectedItems(); + Q_ASSERT(items.count() == 1); + urlB = items[0].url(); break; } case 2: { - urlA = urls[0]; - urlB = urls[1]; + urlA = items[0].url(); + urlB = items[1].url(); break; } @@ -954,7 +980,7 @@ void DolphinMainWindow::openTerminal() void DolphinMainWindow::editSettings() { if (m_settingsDialog == 0) { - const KUrl& url = activeViewContainer()->url(); + const KUrl url = activeViewContainer()->url(); m_settingsDialog = new DolphinSettingsDialog(url, this); m_settingsDialog->setAttribute(Qt::WA_DeleteOnClose); m_settingsDialog->show(); @@ -1158,14 +1184,6 @@ void DolphinMainWindow::tabDropEvent(int tab, QDropEvent* event) } } -void DolphinMainWindow::slotCaptionStatFinished(KJob* job) -{ - m_captionStatJob = 0; - const KIO::UDSEntry entry = static_cast(job)->statResult(); - const QString name = entry.stringValue(KIO::UDSEntry::UDS_DISPLAY_NAME); - setCaption(name); -} - void DolphinMainWindow::slotWriteStateChanged(bool isFolderWritable) { newFileMenu()->setEnabled(isFolderWritable); @@ -1177,7 +1195,24 @@ void DolphinMainWindow::openContextMenu(const KFileItem& item, { DolphinContextMenu contextMenu(this, item, url); contextMenu.setCustomActions(customActions); - contextMenu.open(); + const DolphinContextMenu::Command command = contextMenu.open(); + + switch (command) { + case DolphinContextMenu::OpenParentFolderInNewWindow: { + DolphinMainWindow* window = DolphinApplication::app()->createMainWindow(); + window->changeUrl(item.url().upUrl()); + window->show(); + break; + } + + case DolphinContextMenu::OpenParentFolderInNewTab: + openNewTab(item.url().upUrl()); + break; + + case DolphinContextMenu::None: + default: + break; + } } void DolphinMainWindow::init() @@ -1199,7 +1234,7 @@ void DolphinMainWindow::init() setupActions(); - const KUrl& homeUrl = generalSettings->homeUrl(); + const KUrl homeUrl(generalSettings->homeUrl()); setUrlAsCaption(homeUrl); m_actionHandler = new DolphinViewActionHandler(actionCollection(), this); connect(m_actionHandler, SIGNAL(actionBeingHandled()), SLOT(clearStatusBar())); @@ -1303,9 +1338,9 @@ void DolphinMainWindow::setActiveViewContainer(DolphinViewContainer* viewContain updateViewActions(); updateGoActions(); - const KUrl& url = m_activeViewContainer->url(); + const KUrl url = m_activeViewContainer->url(); setUrlAsCaption(url); - if (m_viewTab.count() > 1 && m_viewTab[m_tabIndex].secondaryView != 0) { + if (m_viewTab.count() > 1) { m_tabBar->setTabText(m_tabIndex, tabName(url)); m_tabBar->setTabIcon(m_tabIndex, KIcon(KMimeType::iconNameForUrl(url))); } @@ -1628,7 +1663,7 @@ void DolphinMainWindow::updateViewActions() void DolphinMainWindow::updateGoActions() { QAction* goUpAction = actionCollection()->action(KStandardAction::name(KStandardAction::Up)); - const KUrl& currentUrl = m_activeViewContainer->url(); + const KUrl currentUrl = m_activeViewContainer->url(); goUpAction->setEnabled(currentUrl.upUrl() != currentUrl); } @@ -1693,6 +1728,10 @@ void DolphinMainWindow::connectViewSignals(DolphinViewContainer* container) 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(startedPathLoading(KUrl)), + this, SLOT(enableStopAction())); + connect(view, SIGNAL(finishedPathLoading(KUrl)), + this, SLOT(disableStopAction())); const KUrlNavigator* navigator = container->urlNavigator(); connect(navigator, SIGNAL(urlChanged(const KUrl&)), @@ -1778,26 +1817,18 @@ QString DolphinMainWindow::tabProperty(const QString& property, int tabIndex) co void DolphinMainWindow::setUrlAsCaption(const KUrl& url) { - delete m_captionStatJob; - m_captionStatJob = 0; - - if (url.protocol() == QLatin1String("file")) { - QString caption; - if (url.equals(KUrl("file:///"))) { - caption = '/'; - } else { - caption = url.fileName(); - if (caption.isEmpty()) { - caption = url.protocol(); - } + QString caption; + if (!url.isLocalFile()) { + caption.append(url.protocol() + " - "); + if (url.hasHost()) { + caption.append(url.host() + " - "); } - - setCaption(caption); - } else { - m_captionStatJob = KIO::stat(url, KIO::HideProgressInfo); - connect(m_captionStatJob, SIGNAL(result(KJob*)), - this, SLOT(slotCaptionStatFinished(KJob*))); } + + const QString fileName = url.fileName().isEmpty() ? "/" : url.fileName(); + caption.append(fileName); + + setCaption(caption); } QString DolphinMainWindow::squeezedText(const QString& text) const