X-Git-Url: https://cloud.milkyroute.net/gitweb/dolphin.git/blobdiff_plain/0a6257bce3de877e4ae869f974df645c428d32c9..119f7a3f:/src/dolphinmainwindow.cpp diff --git a/src/dolphinmainwindow.cpp b/src/dolphinmainwindow.cpp index 3f83d054b..526f80474 100644 --- a/src/dolphinmainwindow.cpp +++ b/src/dolphinmainwindow.cpp @@ -53,7 +53,7 @@ #include #include #include -#include +#include #include #include #include @@ -64,7 +64,6 @@ #include #include #include -#include #include #include #include @@ -128,8 +127,8 @@ DolphinMainWindow::DolphinMainWindow() : this, SLOT(activeViewChanged(DolphinViewContainer*))); connect(m_tabWidget, SIGNAL(tabCountChanged(int)), this, SLOT(tabCountChanged(int))); - connect(m_tabWidget, SIGNAL(currentUrlChanged(KUrl)), - this, SLOT(setUrlAsCaption(KUrl))); + connect(m_tabWidget, SIGNAL(currentUrlChanged(QUrl)), + this, SLOT(setUrlAsCaption(QUrl))); setCentralWidget(m_tabWidget); setupActions(); @@ -172,12 +171,12 @@ DolphinMainWindow::~DolphinMainWindow() { } -void DolphinMainWindow::openDirectories(const QList& dirs) +void DolphinMainWindow::openDirectories(const QList& dirs) { m_tabWidget->openDirectories(dirs); } -void DolphinMainWindow::openFiles(const QList& files) +void DolphinMainWindow::openFiles(const QList& files) { m_tabWidget->openFiles(files); } @@ -216,7 +215,7 @@ void DolphinMainWindow::pasteIntoFolder() m_activeViewContainer->view()->pasteIntoFolder(); } -void DolphinMainWindow::changeUrl(const KUrl& url) +void DolphinMainWindow::changeUrl(const QUrl &url) { if (!KProtocolManager::supportsListing(url)) { // The URL navigator only checks for validity, not @@ -234,7 +233,7 @@ void DolphinMainWindow::changeUrl(const KUrl& url) emit urlChanged(url); } -void DolphinMainWindow::slotTerminalDirectoryChanged(const KUrl& url) +void DolphinMainWindow::slotTerminalDirectoryChanged(const QUrl& url) { m_activeViewContainer->setAutoGrabFocus(false); changeUrl(url); @@ -295,7 +294,7 @@ void DolphinMainWindow::updateFilterBarAction(bool show) void DolphinMainWindow::openNewMainWindow() { - KRun::run("dolphin %u", KUrl::List(), this); + KRun::run("dolphin %u", QList(), this); } void DolphinMainWindow::openNewActivatedTab() @@ -303,12 +302,12 @@ void DolphinMainWindow::openNewActivatedTab() m_tabWidget->openNewActivatedTab(); } -void DolphinMainWindow::openNewTab(const KUrl& url) +void DolphinMainWindow::openNewTab(const QUrl& url) { m_tabWidget->openNewTab(url); } -void DolphinMainWindow::openNewActivatedTab(const KUrl& url) +void DolphinMainWindow::openNewActivatedTab(const QUrl& url) { m_tabWidget->openNewActivatedTab(url); } @@ -320,7 +319,7 @@ void DolphinMainWindow::openInNewTab() openNewTab(m_activeViewContainer->url()); } else { foreach (const KFileItem& item, list) { - const KUrl& url = DolphinView::openItemAsFolderUrl(item); + const QUrl& url = DolphinView::openItemAsFolderUrl(item); if (!url.isEmpty()) { openNewTab(url); } @@ -330,7 +329,7 @@ void DolphinMainWindow::openInNewTab() void DolphinMainWindow::openInNewWindow() { - KUrl newWindowUrl; + QUrl newWindowUrl; const KFileItemList list = m_activeViewContainer->view()->selectedItems(); if (list.isEmpty()) { @@ -341,7 +340,7 @@ void DolphinMainWindow::openInNewWindow() } if (!newWindowUrl.isEmpty()) { - KRun::run("dolphin %u", QList() << newWindowUrl, this); + KRun::run("dolphin %u", {newWindowUrl}, this); } } @@ -498,6 +497,11 @@ void DolphinMainWindow::updatePasteAction() pasteAction->setText(pasteInfo.second); } +void DolphinMainWindow::slotDirectoryLoadingCompleted() +{ + updatePasteAction(); +} + void DolphinMainWindow::selectAll() { clearStatusBar(); @@ -619,7 +623,7 @@ void DolphinMainWindow::goHome() void DolphinMainWindow::goBack(Qt::MouseButtons buttons) { // The default case (left button pressed) is handled in goBack(). - if (buttons == Qt::MidButton) { + if (buttons == Qt::MiddleButton) { KUrlNavigator* urlNavigator = activeViewContainer()->urlNavigator(); const int index = urlNavigator->historyIndex() + 1; openNewTab(urlNavigator->locationUrl(index)); @@ -629,7 +633,7 @@ void DolphinMainWindow::goBack(Qt::MouseButtons buttons) void DolphinMainWindow::goForward(Qt::MouseButtons buttons) { // The default case (left button pressed) is handled in goForward(). - if (buttons == Qt::MidButton) { + if (buttons == Qt::MiddleButton) { KUrlNavigator* urlNavigator = activeViewContainer()->urlNavigator(); const int index = urlNavigator->historyIndex() - 1; openNewTab(urlNavigator->locationUrl(index)); @@ -639,15 +643,15 @@ void DolphinMainWindow::goForward(Qt::MouseButtons buttons) void DolphinMainWindow::goUp(Qt::MouseButtons buttons) { // The default case (left button pressed) is handled in goUp(). - if (buttons == Qt::MidButton) { - openNewTab(activeViewContainer()->url().upUrl()); + if (buttons == Qt::MiddleButton) { + openNewTab(KIO::upUrl(activeViewContainer()->url())); } } void DolphinMainWindow::goHome(Qt::MouseButtons buttons) { // The default case (left button pressed) is handled in goHome(). - if (buttons == Qt::MidButton) { + if (buttons == Qt::MiddleButton) { openNewTab(GeneralSettings::self()->homeUrl()); } } @@ -661,13 +665,13 @@ void DolphinMainWindow::compareFiles() return; } - KUrl urlA = items.at(0).url(); - KUrl urlB = items.at(1).url(); + QUrl urlA = items.at(0).url(); + QUrl urlB = items.at(1).url(); QString command("kompare -c \""); - command.append(urlA.pathOrUrl()); + command.append(urlA.toDisplayString(QUrl::PreferLocalFile)); command.append("\" \""); - command.append(urlB.pathOrUrl()); + command.append(urlB.toDisplayString(QUrl::PreferLocalFile)); command.append('\"'); KRun::runCommand(command, "Kompare", "kompare", this); } @@ -689,7 +693,7 @@ void DolphinMainWindow::openTerminal() // If the given directory is not local, it can still be the URL of an // ioslave using UDS_LOCAL_PATH which to be converted first. - KUrl url = KIO::NetAccess::mostLocalUrl(m_activeViewContainer->url(), this); + QUrl url = KIO::NetAccess::mostLocalUrl(m_activeViewContainer->url(), this); //If the URL is local after the above conversion, set the directory. if (url.isLocalFile()) { @@ -705,7 +709,7 @@ void DolphinMainWindow::editSettings() DolphinViewContainer* container = activeViewContainer(); container->view()->writeSettings(); - const KUrl url = container->url(); + const QUrl url = container->url(); DolphinSettingsDialog* settingsDialog = new DolphinSettingsDialog(url, this); connect(settingsDialog, &DolphinSettingsDialog::settingsChanged, this, &DolphinMainWindow::refreshViews); settingsDialog->setAttribute(Qt::WA_DeleteOnClose); @@ -716,7 +720,7 @@ void DolphinMainWindow::editSettings() } } -void DolphinMainWindow::handleUrl(const KUrl& url) +void DolphinMainWindow::handleUrl(const QUrl& url) { delete m_lastHandleUrlStatJob; m_lastHandleUrlStatJob = 0; @@ -741,7 +745,7 @@ void DolphinMainWindow::slotHandleUrlStatFinished(KJob* job) { m_lastHandleUrlStatJob = 0; const KIO::UDSEntry entry = static_cast(job)->statResult(); - const KUrl url = static_cast(job)->url(); + const QUrl url = static_cast(job)->url(); if (entry.isDir()) { activeViewContainer()->setUrl(url); } else { @@ -756,7 +760,7 @@ void DolphinMainWindow::slotWriteStateChanged(bool isFolderWritable) void DolphinMainWindow::openContextMenu(const QPoint& pos, const KFileItem& item, - const KUrl& url, + const QUrl& url, const QList& customActions) { QWeakPointer contextMenu = new DolphinContextMenu(this, pos, item, url); @@ -770,7 +774,7 @@ void DolphinMainWindow::openContextMenu(const QPoint& pos, case DolphinContextMenu::OpenParentFolderInNewWindow: { - KRun::run("dolphin %u", QList() << KIO::upUrl(item.url()), this); + KRun::run("dolphin %u", {KIO::upUrl(item.url())}, this); break; } @@ -900,7 +904,7 @@ void DolphinMainWindow::slotPanelErrorMessage(const QString& error) activeViewContainer()->showMessage(error, DolphinViewContainer::Error); } -void DolphinMainWindow::slotPlaceActivated(const KUrl& url) +void DolphinMainWindow::slotPlaceActivated(const QUrl& url) { DolphinViewContainer* view = activeViewContainer(); @@ -943,7 +947,7 @@ void DolphinMainWindow::activeViewChanged(DolphinViewContainer* viewContainer) updateViewActions(); updateGoActions(); - const KUrl url = viewContainer->url(); + const QUrl url = viewContainer->url(); emit urlChanged(url); } @@ -955,17 +959,21 @@ void DolphinMainWindow::tabCountChanged(int count) actionCollection()->action("activate_prev_tab")->setEnabled(enableTabActions); } -void DolphinMainWindow::setUrlAsCaption(const KUrl& url) +void DolphinMainWindow::setUrlAsCaption(const QUrl& url) { QString caption; if (!url.isLocalFile()) { - caption.append(url.protocol() + " - "); - if (url.hasHost()) { + caption.append(url.scheme() + " - "); + if (!url.host().isEmpty()) { caption.append(url.host() + " - "); } } - const QString fileName = url.fileName().isEmpty() ? "/" : url.fileName(); + QString fileName = url.adjusted(QUrl::StripTrailingSlash).fileName(); + if (fileName.isEmpty()) { + fileName = '/'; + } + caption.append(fileName); setCaption(caption); @@ -991,7 +999,7 @@ void DolphinMainWindow::setupActions() QAction* newTab = actionCollection()->addAction("new_tab"); newTab->setIcon(QIcon::fromTheme("tab-new")); newTab->setText(i18nc("@action:inmenu File", "New Tab")); - actionCollection()->setDefaultShortcuts(newTab, QList() << QKeySequence(Qt::CTRL | Qt::Key_T) << QKeySequence(Qt::CTRL | Qt::SHIFT | Qt::Key_N)); + actionCollection()->setDefaultShortcuts(newTab, {Qt::CTRL | Qt::Key_T, Qt::CTRL | Qt::SHIFT | Qt::Key_N}); connect(newTab, &QAction::triggered, this, static_cast(&DolphinMainWindow::openNewActivatedTab)); QAction* closeTab = actionCollection()->addAction("close_tab"); @@ -1070,8 +1078,8 @@ void DolphinMainWindow::setupActions() DolphinRecentTabsMenu* recentTabsMenu = new DolphinRecentTabsMenu(this); actionCollection()->addAction("closed_tabs", recentTabsMenu); - connect(m_tabWidget, SIGNAL(rememberClosedTab(KUrl,QByteArray)), - recentTabsMenu, SLOT(rememberClosedTab(KUrl,QByteArray))); + connect(m_tabWidget, SIGNAL(rememberClosedTab(QUrl,QByteArray)), + recentTabsMenu, SLOT(rememberClosedTab(QUrl,QByteArray))); connect(recentTabsMenu, SIGNAL(restoreClosedTab(QByteArray)), m_tabWidget, SLOT(restoreClosedTab(QByteArray))); connect(recentTabsMenu, SIGNAL(closedTabsCountChanged(uint)), @@ -1114,12 +1122,10 @@ void DolphinMainWindow::setupActions() KStandardAction::preferences(this, SLOT(editSettings()), actionCollection()); // not in menu actions - QList nextTabKeys; - nextTabKeys.append(KStandardShortcut::tabNext().first()); //TODO: is this correct + QList nextTabKeys = KStandardShortcut::tabNext(); nextTabKeys.append(QKeySequence(Qt::CTRL | Qt::Key_Tab)); - QList prevTabKeys; - prevTabKeys.append(KStandardShortcut::tabPrev().first()); //TODO: is this correct + QList prevTabKeys = KStandardShortcut::tabPrev(); prevTabKeys.append(QKeySequence(Qt::CTRL | Qt::SHIFT | Qt::Key_Tab)); QAction* activateNextTab = actionCollection()->addAction("activate_next_tab"); @@ -1171,7 +1177,7 @@ void DolphinMainWindow::setupDockWidgets() infoDock->setObjectName("infoDock"); infoDock->setAllowedAreas(Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea); InformationPanel* infoPanel = new InformationPanel(infoDock); - infoPanel->setCustomContextMenuActions(QList() << lockLayoutAction); + infoPanel->setCustomContextMenuActions({lockLayoutAction}); connect(infoPanel, &InformationPanel::urlActivated, this, &DolphinMainWindow::handleUrl); infoDock->setWidget(infoPanel); @@ -1192,7 +1198,7 @@ void DolphinMainWindow::setupDockWidgets() foldersDock->setObjectName("foldersDock"); foldersDock->setAllowedAreas(Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea); FoldersPanel* foldersPanel = new FoldersPanel(foldersDock); - foldersPanel->setCustomContextMenuActions(QList() << lockLayoutAction); + foldersPanel->setCustomContextMenuActions({lockLayoutAction}); foldersDock->setWidget(foldersPanel); QAction* foldersAction = foldersDock->toggleViewAction(); @@ -1215,7 +1221,7 @@ void DolphinMainWindow::setupDockWidgets() terminalDock->setObjectName("terminalDock"); terminalDock->setAllowedAreas(Qt::TopDockWidgetArea | Qt::BottomDockWidgetArea); TerminalPanel* terminalPanel = new TerminalPanel(terminalDock); - terminalPanel->setCustomContextMenuActions(QList() << lockLayoutAction); + terminalPanel->setCustomContextMenuActions({lockLayoutAction}); terminalDock->setWidget(terminalPanel); connect(terminalPanel, &TerminalPanel::hideTerminalPanel, terminalDock, &DolphinDockWidget::hide); @@ -1246,7 +1252,7 @@ void DolphinMainWindow::setupDockWidgets() placesDock->setAllowedAreas(Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea); PlacesPanel* placesPanel = new PlacesPanel(placesDock); - placesPanel->setCustomContextMenuActions(QList() << lockLayoutAction); + placesPanel->setCustomContextMenuActions({lockLayoutAction}); placesDock->setWidget(placesPanel); QAction* placesAction = placesDock->toggleViewAction(); @@ -1255,8 +1261,8 @@ void DolphinMainWindow::setupDockWidgets() addDockWidget(Qt::LeftDockWidgetArea, placesDock); connect(placesPanel, &PlacesPanel::placeActivated, this, &DolphinMainWindow::slotPlaceActivated); - connect(placesPanel, SIGNAL(placeMiddleClicked(KUrl)), - this, SLOT(openNewTab(KUrl))); + connect(placesPanel, SIGNAL(placeMiddleClicked(QUrl)), + this, SLOT(openNewTab(QUrl))); connect(placesPanel, &PlacesPanel::errorMessage, this, &DolphinMainWindow::slotPanelErrorMessage); connect(this, &DolphinMainWindow::urlChanged, @@ -1326,8 +1332,8 @@ void DolphinMainWindow::updateViewActions() void DolphinMainWindow::updateGoActions() { QAction* goUpAction = actionCollection()->action(KStandardAction::name(KStandardAction::Up)); - const KUrl currentUrl = m_activeViewContainer->url(); - goUpAction->setEnabled(currentUrl.upUrl() != currentUrl); + const QUrl currentUrl = m_activeViewContainer->url(); + goUpAction->setEnabled(KIO::upUrl(currentUrl) != currentUrl); } void DolphinMainWindow::createControlButton() @@ -1428,6 +1434,8 @@ void DolphinMainWindow::connectViewSignals(DolphinViewContainer* container) this, &DolphinMainWindow::enableStopAction); connect(view, &DolphinView::directoryLoadingCompleted, this, &DolphinMainWindow::disableStopAction); + connect(view, &DolphinView::directoryLoadingCompleted, + this, &DolphinMainWindow::slotDirectoryLoadingCompleted); connect(view, &DolphinView::goBackRequested, this, static_cast(&DolphinMainWindow::goBack)); connect(view, &DolphinView::goForwardRequested,