From 3b95644fa1495785f617165f4e8035528ec714e8 Mon Sep 17 00:00:00 2001 From: David Edmundson Date: Wed, 18 May 2016 02:06:49 +0100 Subject: Don't allow opening the terminal if shell_access Kiosk mode is set DolphinPart already did this. Dolphin itself didn't have this feature. REVIEW: 127951 --- src/dolphinmainwindow.cpp | 60 ++++++++++++++++++++++++++--------------------- 1 file changed, 33 insertions(+), 27 deletions(-) (limited to 'src/dolphinmainwindow.cpp') diff --git a/src/dolphinmainwindow.cpp b/src/dolphinmainwindow.cpp index d4f2b06e7..1fadaf7fd 100644 --- a/src/dolphinmainwindow.cpp +++ b/src/dolphinmainwindow.cpp @@ -48,6 +48,7 @@ #include #include +#include #include #include #include @@ -1098,11 +1099,13 @@ void DolphinMainWindow::setupActions() compareFiles->setEnabled(false); connect(compareFiles, &QAction::triggered, this, &DolphinMainWindow::compareFiles); - QAction* openTerminal = actionCollection()->addAction(QStringLiteral("open_terminal")); - openTerminal->setText(i18nc("@action:inmenu Tools", "Open Terminal")); - openTerminal->setIcon(QIcon::fromTheme(QStringLiteral("utilities-terminal"))); - actionCollection()->setDefaultShortcut(openTerminal, Qt::SHIFT | Qt::Key_F4); - connect(openTerminal, &QAction::triggered, this, &DolphinMainWindow::openTerminal); + if (KAuthorized::authorizeKAction(QStringLiteral("shell_access"))) { + QAction* openTerminal = actionCollection()->addAction(QStringLiteral("open_terminal")); + openTerminal->setText(i18nc("@action:inmenu Tools", "Open Terminal")); + openTerminal->setIcon(QIcon::fromTheme(QStringLiteral("utilities-terminal"))); + actionCollection()->setDefaultShortcut(openTerminal, Qt::SHIFT | Qt::Key_F4); + connect(openTerminal, &QAction::triggered, this, &DolphinMainWindow::openTerminal); + } // setup 'Settings' menu KToggleAction* showMenuBar = KStandardAction::showMenubar(0, 0, actionCollection()); @@ -1205,33 +1208,36 @@ void DolphinMainWindow::setupDockWidgets() // Setup "Terminal" #ifndef Q_OS_WIN - DolphinDockWidget* terminalDock = new DolphinDockWidget(i18nc("@title:window Shell terminal", "Terminal")); - terminalDock->setLocked(lock); - terminalDock->setObjectName(QStringLiteral("terminalDock")); - terminalDock->setAllowedAreas(Qt::TopDockWidgetArea | Qt::BottomDockWidgetArea); - TerminalPanel* terminalPanel = new TerminalPanel(terminalDock); - terminalPanel->setCustomContextMenuActions({lockLayoutAction}); - terminalDock->setWidget(terminalPanel); - - connect(terminalPanel, &TerminalPanel::hideTerminalPanel, terminalDock, &DolphinDockWidget::hide); - connect(terminalPanel, &TerminalPanel::changeUrl, this, &DolphinMainWindow::slotTerminalDirectoryChanged); - connect(terminalDock, &DolphinDockWidget::visibilityChanged, - terminalPanel, &TerminalPanel::dockVisibilityChanged); - - QAction* terminalAction = terminalDock->toggleViewAction(); - createPanelAction(QIcon::fromTheme(QStringLiteral("utilities-terminal")), Qt::Key_F4, terminalAction, QStringLiteral("show_terminal_panel")); - - addDockWidget(Qt::BottomDockWidgetArea, terminalDock); - connect(this, &DolphinMainWindow::urlChanged, - terminalPanel, &TerminalPanel::setUrl); + if (KAuthorized::authorizeKAction(QStringLiteral("shell_access"))) { + DolphinDockWidget* terminalDock = new DolphinDockWidget(i18nc("@title:window Shell terminal", "Terminal")); + terminalDock->setLocked(lock); + terminalDock->setObjectName(QStringLiteral("terminalDock")); + terminalDock->setAllowedAreas(Qt::TopDockWidgetArea | Qt::BottomDockWidgetArea); + TerminalPanel* terminalPanel = new TerminalPanel(terminalDock); + terminalPanel->setCustomContextMenuActions({lockLayoutAction}); + terminalDock->setWidget(terminalPanel); + + connect(terminalPanel, &TerminalPanel::hideTerminalPanel, terminalDock, &DolphinDockWidget::hide); + connect(terminalPanel, &TerminalPanel::changeUrl, this, &DolphinMainWindow::slotTerminalDirectoryChanged); + connect(terminalDock, &DolphinDockWidget::visibilityChanged, + terminalPanel, &TerminalPanel::dockVisibilityChanged); + + QAction* terminalAction = terminalDock->toggleViewAction(); + createPanelAction(QIcon::fromTheme(QStringLiteral("utilities-terminal")), Qt::Key_F4, terminalAction, QStringLiteral("show_terminal_panel")); + + addDockWidget(Qt::BottomDockWidgetArea, terminalDock); + connect(this, &DolphinMainWindow::urlChanged, + terminalPanel, &TerminalPanel::setUrl); + + if (GeneralSettings::version() < 200) { + terminalDock->hide(); + } + } #endif if (GeneralSettings::version() < 200) { infoDock->hide(); foldersDock->hide(); -#ifndef Q_OS_WIN - terminalDock->hide(); -#endif } // Setup "Places" -- cgit v1.3 From 25cc15a5a2097faad3d647c72bd4c2dadac3f7ef Mon Sep 17 00:00:00 2001 From: David Edmundson Date: Thu, 26 May 2016 13:51:23 +0100 Subject: Port all instances of Kauthorized action/shell_command to shell_command The KAuthorized key to prevent shell access according the documentation is simply "shell_action" not "action/shellAction" so should use authorize not authorizeKAction This appears to have come about as part of a porting bug when going from KApplication::authorize to KAuthorized in kdelibs3 to kdelibs4. To currently block shell access a sysadmin currently needs to have both keys set already, so we can be confident it won't have any actual compatibility problems. --- src/dolphinmainwindow.cpp | 4 ++-- src/dolphinpart.cpp | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) (limited to 'src/dolphinmainwindow.cpp') diff --git a/src/dolphinmainwindow.cpp b/src/dolphinmainwindow.cpp index 1fadaf7fd..3a06d2c0e 100644 --- a/src/dolphinmainwindow.cpp +++ b/src/dolphinmainwindow.cpp @@ -1099,7 +1099,7 @@ void DolphinMainWindow::setupActions() compareFiles->setEnabled(false); connect(compareFiles, &QAction::triggered, this, &DolphinMainWindow::compareFiles); - if (KAuthorized::authorizeKAction(QStringLiteral("shell_access"))) { + if (KAuthorized::authorize(QStringLiteral("shell_access"))) { QAction* openTerminal = actionCollection()->addAction(QStringLiteral("open_terminal")); openTerminal->setText(i18nc("@action:inmenu Tools", "Open Terminal")); openTerminal->setIcon(QIcon::fromTheme(QStringLiteral("utilities-terminal"))); @@ -1208,7 +1208,7 @@ void DolphinMainWindow::setupDockWidgets() // Setup "Terminal" #ifndef Q_OS_WIN - if (KAuthorized::authorizeKAction(QStringLiteral("shell_access"))) { + if (KAuthorized::authorize(QStringLiteral("shell_access"))) { DolphinDockWidget* terminalDock = new DolphinDockWidget(i18nc("@title:window Shell terminal", "Terminal")); terminalDock->setLocked(lock); terminalDock->setObjectName(QStringLiteral("terminalDock")); diff --git a/src/dolphinpart.cpp b/src/dolphinpart.cpp index f62bc5139..332f8e9b9 100644 --- a/src/dolphinpart.cpp +++ b/src/dolphinpart.cpp @@ -222,7 +222,7 @@ void DolphinPart::createActions() m_findFileAction->setIcon(QIcon::fromTheme(QStringLiteral("edit-find"))); connect(m_findFileAction, &QAction::triggered, this, &DolphinPart::slotFindFile); - if (KAuthorized::authorizeKAction(QStringLiteral("shell_access"))) { + if (KAuthorized::authorize(QStringLiteral("shell_access"))) { m_openTerminalAction = actionCollection()->addAction(QStringLiteral("open_terminal")); m_openTerminalAction->setIcon(QIcon::fromTheme(QStringLiteral("utilities-terminal"))); m_openTerminalAction->setText(i18nc("@action:inmenu Tools", "Open &Terminal")); -- cgit v1.3 From e615bfaed4cd562d31ea0506529f730c414b6ec0 Mon Sep 17 00:00:00 2001 From: David Faure Date: Sat, 25 Jun 2016 16:39:49 +0200 Subject: add_definitions(-DQT_NO_URL_CAST_FROM_STRING) + fix compilation This fixes some URLs built from local paths without scheme. --- CMakeLists.txt | 2 ++ src/dolphinmainwindow.cpp | 2 +- src/dolphinviewcontainer.cpp | 2 +- src/kitemviews/kfileitemmodelrolesupdater.cpp | 10 +++++----- src/panels/places/placesitem.cpp | 6 +++--- src/panels/places/placesitemmodel.cpp | 10 +++++----- src/settings/kcm/kcmdolphingeneral.cpp | 2 +- src/statusbar/mountpointobservercache.cpp | 4 ++-- src/views/dolphinview.cpp | 2 +- 9 files changed, 21 insertions(+), 19 deletions(-) (limited to 'src/dolphinmainwindow.cpp') diff --git a/CMakeLists.txt b/CMakeLists.txt index 7e6111307..86b06e889 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -102,6 +102,8 @@ else() ) endif() +add_definitions(-DQT_NO_URL_CAST_FROM_STRING) + add_subdirectory(src) add_subdirectory(doc) diff --git a/src/dolphinmainwindow.cpp b/src/dolphinmainwindow.cpp index 3a06d2c0e..34008b5eb 100644 --- a/src/dolphinmainwindow.cpp +++ b/src/dolphinmainwindow.cpp @@ -83,7 +83,7 @@ namespace { // Used for GeneralSettings::version() to determine whether // an updated version of Dolphin is running. const int CurrentDolphinVersion = 200; -}; +} DolphinMainWindow::DolphinMainWindow() : KXmlGuiWindow(0), diff --git a/src/dolphinviewcontainer.cpp b/src/dolphinviewcontainer.cpp index 73ffd5c2d..1c43fc977 100644 --- a/src/dolphinviewcontainer.cpp +++ b/src/dolphinviewcontainer.cpp @@ -95,7 +95,7 @@ DolphinViewContainer::DolphinViewContainer(const QUrl& url, QWidget* parent) : m_view = new DolphinView(url, this); connect(m_view, &DolphinView::urlChanged, - m_urlNavigator, &KUrlNavigator::setUrl); + m_urlNavigator, &KUrlNavigator::setLocationUrl); connect(m_view, &DolphinView::urlChanged, m_messageWidget, &KMessageWidget::hide); connect(m_view, &DolphinView::directoryLoadingCompleted, diff --git a/src/kitemviews/kfileitemmodelrolesupdater.cpp b/src/kitemviews/kfileitemmodelrolesupdater.cpp index fe30f62f9..92a020003 100644 --- a/src/kitemviews/kfileitemmodelrolesupdater.cpp +++ b/src/kitemviews/kfileitemmodelrolesupdater.cpp @@ -374,9 +374,9 @@ void KFileItemModelRolesUpdater::slotItemsRemoved(const KItemRangeList& itemRang m_balooFileMonitor->clear(); } else { QStringList newFileList; - foreach (const QString& itemUrl, m_balooFileMonitor->files()) { - if (m_model->index(itemUrl) >= 0) { - newFileList.append(itemUrl); + foreach (const QString& file, m_balooFileMonitor->files()) { + if (m_model->index(QUrl::fromLocalFile(file)) >= 0) { + newFileList.append(file); } } m_balooFileMonitor->setFiles(newFileList); @@ -707,10 +707,10 @@ void KFileItemModelRolesUpdater::resolveRecentlyChangedItems() updateChangedItems(); } -void KFileItemModelRolesUpdater::applyChangedBalooRoles(const QString& itemUrl) +void KFileItemModelRolesUpdater::applyChangedBalooRoles(const QString& file) { #ifdef HAVE_BALOO - const KFileItem item = m_model->fileItem(itemUrl); + const KFileItem item = m_model->fileItem(QUrl::fromLocalFile(file)); if (item.isNull()) { // itemUrl is not in the model anymore, probably because diff --git a/src/panels/places/placesitem.cpp b/src/panels/places/placesitem.cpp index a04064d0b..b32f8204d 100644 --- a/src/panels/places/placesitem.cpp +++ b/src/panels/places/placesitem.cpp @@ -276,12 +276,12 @@ void PlacesItem::initializeDevice(const QString& udi) Solid::Block *block = m_device.as(); if (block) { const QString device = block->device(); - setUrl(QStringLiteral("audiocd:/?device=%1").arg(device)); + setUrl(QUrl(QStringLiteral("audiocd:/?device=%1").arg(device))); } else { - setUrl(QStringLiteral("audiocd:/")); + setUrl(QUrl(QStringLiteral("audiocd:/"))); } } else if (m_mtp) { - setUrl(QStringLiteral("mtp:udi=%1").arg(m_device.udi())); + setUrl(QUrl(QStringLiteral("mtp:udi=%1").arg(m_device.udi()))); } } diff --git a/src/panels/places/placesitemmodel.cpp b/src/panels/places/placesitemmodel.cpp index a42cb0403..25c4d51f6 100644 --- a/src/panels/places/placesitemmodel.cpp +++ b/src/panels/places/placesitemmodel.cpp @@ -1099,17 +1099,17 @@ QUrl PlacesItemModel::createTimelineUrl(const QUrl& url) const int year = date.year(); const int month = date.month(); const int day = date.day(); - timelineUrl = "timeline:/" + timelineDateString(year, month) + - '/' + timelineDateString(year, month, day); + timelineUrl = QUrl("timeline:/" + timelineDateString(year, month) + + '/' + timelineDateString(year, month, day)); } else if (path.endsWith(QLatin1String("thismonth"))) { const QDate date = QDate::currentDate(); - timelineUrl = "timeline:/" + timelineDateString(date.year(), date.month()); + timelineUrl = QUrl("timeline:/" + timelineDateString(date.year(), date.month())); } else if (path.endsWith(QLatin1String("lastmonth"))) { const QDate date = QDate::currentDate().addMonths(-1); - timelineUrl = "timeline:/" + timelineDateString(date.year(), date.month()); + timelineUrl = QUrl("timeline:/" + timelineDateString(date.year(), date.month())); } else { Q_ASSERT(path.endsWith(QLatin1String("today"))); - timelineUrl= url; + timelineUrl = url; } return timelineUrl; diff --git a/src/settings/kcm/kcmdolphingeneral.cpp b/src/settings/kcm/kcmdolphingeneral.cpp index 6a02e0297..3cf7e7652 100644 --- a/src/settings/kcm/kcmdolphingeneral.cpp +++ b/src/settings/kcm/kcmdolphingeneral.cpp @@ -48,7 +48,7 @@ DolphinGeneralConfigModule::DolphinGeneralConfigModule(QWidget* parent, const QV QTabWidget* tabWidget = new QTabWidget(this); // initialize 'Behavior' tab - BehaviorSettingsPage* behaviorPage = new BehaviorSettingsPage(QDir::homePath(), tabWidget); + BehaviorSettingsPage* behaviorPage = new BehaviorSettingsPage(QUrl::fromLocalFile(QDir::homePath()), tabWidget); tabWidget->addTab(behaviorPage, i18nc("@title:tab Behavior settings", "Behavior")); connect(behaviorPage, &BehaviorSettingsPage::changed, this, static_cast(&DolphinGeneralConfigModule::changed)); diff --git a/src/statusbar/mountpointobservercache.cpp b/src/statusbar/mountpointobservercache.cpp index ab3744eac..48796ac5a 100644 --- a/src/statusbar/mountpointobservercache.cpp +++ b/src/statusbar/mountpointobservercache.cpp @@ -62,10 +62,10 @@ MountPointObserver* MountPointObserverCache::observerForUrl(const QUrl& url) } else { // Even if determining the mount point failed, the observer might still // be able to retrieve information about the url. - cachedObserverUrl = url.toLocalFile(); + cachedObserverUrl = url; } } else { - cachedObserverUrl = url.url(); + cachedObserverUrl = url; } MountPointObserver* observer = m_observerForMountPoint.value(cachedObserverUrl); diff --git a/src/views/dolphinview.cpp b/src/views/dolphinview.cpp index 25aad9b51..5466fd38e 100644 --- a/src/views/dolphinview.cpp +++ b/src/views/dolphinview.cpp @@ -1278,7 +1278,7 @@ QUrl DolphinView::openItemAsFolderUrl(const KFileItem& item, const bool browseTh if (desktopFile.hasLinkType()) { const QString linkUrl = desktopFile.readUrl(); if (!linkUrl.startsWith(QLatin1String("http"))) { - return linkUrl; + return QUrl::fromUserInput(linkUrl); } } } -- cgit v1.3 From ca53974181c17234f4522bd1635d4c0ab4281e1d Mon Sep 17 00:00:00 2001 From: Elvis Angelaccio Date: Tue, 20 Sep 2016 11:24:15 +0200 Subject: Add Donate standard action to control menu REVIEW: 128946 --- src/dolphinmainwindow.cpp | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'src/dolphinmainwindow.cpp') diff --git a/src/dolphinmainwindow.cpp b/src/dolphinmainwindow.cpp index 34008b5eb..4d97fc1b1 100644 --- a/src/dolphinmainwindow.cpp +++ b/src/dolphinmainwindow.cpp @@ -50,6 +50,7 @@ #include #include #include +#include #include #include #include @@ -868,6 +869,10 @@ void DolphinMainWindow::updateControlMenu() helpMenu->addSeparator(); helpMenu->addAction(ac->action(KStandardAction::name(KStandardAction::ReportBug))); helpMenu->addSeparator(); +#if KCONFIGWIDGETS_VERSION >= QT_VERSION_CHECK(5, 26, 0) + helpMenu->addAction(ac->action(KStandardAction::name(KStandardAction::Donate))); + helpMenu->addSeparator(); +#endif helpMenu->addAction(ac->action(KStandardAction::name(KStandardAction::SwitchApplicationLanguage))); helpMenu->addSeparator(); helpMenu->addAction(ac->action(KStandardAction::name(KStandardAction::AboutApp))); -- cgit v1.3