#include "dolphintabpage.h"
#include "middleclickactioneventfilter.h"
#include "panels/folders/folderspanel.h"
+#include "panels/places/placesitemmodel.h"
#include "panels/places/placespanel.h"
#include "panels/information/informationpanel.h"
#include "panels/terminal/terminalpanel.h"
}
m_activeViewContainer->setUrl(url);
- updateEditActions();
+ updateFileAndEditActions();
updatePasteAction();
updateViewActions();
updateGoActions();
void DolphinMainWindow::slotSelectionChanged(const KFileItemList& selection)
{
- updateEditActions();
+ updateFileAndEditActions();
const int selectedUrlsCount = m_tabWidget->currentTabPage()->selectedItemsCount();
m_tabWidget->openNewActivatedTab();
}
+void DolphinMainWindow::addToPlaces()
+{
+ QUrl url;
+ QString name;
+
+ // If nothing is selected, act on the current dir
+ if (m_activeViewContainer->view()->selectedItems().count() == 0) {
+ url = m_activeViewContainer->url();
+ name = m_activeViewContainer->placesText();
+ } else {
+ const auto dirToAdd = m_activeViewContainer->view()->selectedItems().first();
+ url = dirToAdd.url();
+ name = dirToAdd.name();
+ }
+ if (url.isValid()) {
+ PlacesItemModel model;
+ QString icon;
+ if (m_activeViewContainer->isSearchModeEnabled()) {
+ icon = QStringLiteral("folder-saved-search-symbolic");
+ } else {
+ icon = KIO::iconNameForUrl(url);
+ }
+ model.createPlacesItem(name, url, icon);
+ }
+}
+
void DolphinMainWindow::openNewTab(const QUrl& url, DolphinTabWidget::TabPlacement tabPlacement)
{
m_tabWidget->openNewTab(url, QUrl(), tabPlacement);
if (!m_terminalPanel->isVisible()) {
KGuiItem::assign(
buttons->button(QDialogButtonBox::No),
- KGuiItem(i18n("Show &Terminal Panel"), QIcon::fromTheme(QStringLiteral("utilities-terminal"))));
+ KGuiItem(i18n("Show &Terminal Panel"), QIcon::fromTheme(QStringLiteral("dialog-scripts"))));
}
KGuiItem::assign(buttons->button(QDialogButtonBox::Cancel), KStandardGuiItem::cancel());
// Add "View" actions
if (!GeneralSettings::showZoomSlider()) {
addActionToMenu(ac->action(KStandardAction::name(KStandardAction::ZoomIn)), menu);
+ addActionToMenu(ac->action(QStringLiteral("view_zoom_reset")), menu);
addActionToMenu(ac->action(KStandardAction::name(KStandardAction::ZoomOut)), menu);
menu->addSeparator();
}
m_actionHandler->setCurrentView(viewContainer->view());
updateHistory();
- updateEditActions();
+ updateFileAndEditActions();
updatePasteAction();
updateViewActions();
updateGoActions();
actionCollection()->setDefaultShortcuts(newTab, {Qt::CTRL + Qt::Key_T, Qt::CTRL + Qt::SHIFT + Qt::Key_N});
connect(newTab, &QAction::triggered, this, &DolphinMainWindow::openNewActivatedTab);
+ QAction* addToPlaces = actionCollection()->addAction(QStringLiteral("add_to_places"));
+ addToPlaces->setIcon(QIcon::fromTheme(QStringLiteral("bookmark-new")));
+ addToPlaces->setWhatsThis(xi18nc("@info:whatsthis", "This adds the selected folder "
+ "to the Places panel."));
+ connect(addToPlaces, &QAction::triggered, this, &DolphinMainWindow::addToPlaces);
+
QAction* closeTab = KStandardAction::close(m_tabWidget, QOverload<>::of(&DolphinTabWidget::closeTab), actionCollection());
closeTab->setText(i18nc("@action:inmenu File", "Close Tab"));
closeTab->setWhatsThis(i18nc("@info:whatsthis", "This closes the "
openTerminal->setWhatsThis(xi18nc("@info:whatsthis",
"<para>This opens a <emphasis>terminal</emphasis> application for the viewed location.</para>"
"<para>To learn more about terminals use the help in the terminal application.</para>"));
- openTerminal->setIcon(QIcon::fromTheme(QStringLiteral("utilities-terminal")));
+ openTerminal->setIcon(QIcon::fromTheme(QStringLiteral("dialog-scripts")));
actionCollection()->setDefaultShortcut(openTerminal, Qt::SHIFT + Qt::Key_F4);
connect(openTerminal, &QAction::triggered, this, &DolphinMainWindow::openTerminal);
}
this, &DolphinMainWindow::slotTerminalPanelVisibilityChanged);
QAction* terminalAction = terminalDock->toggleViewAction();
- createPanelAction(QIcon::fromTheme(QStringLiteral("utilities-terminal")), Qt::Key_F4, terminalAction, QStringLiteral("show_terminal_panel"));
+ createPanelAction(QIcon::fromTheme(QStringLiteral("dialog-scripts")), Qt::Key_F4, terminalAction, QStringLiteral("show_terminal_panel"));
addDockWidget(Qt::BottomDockWidgetArea, terminalDock);
connect(this, &DolphinMainWindow::urlChanged,
this, &DolphinMainWindow::slotStorageTearDownExternallyRequested);
m_tabWidget->slotPlacesPanelVisibilityChanged(m_placesPanel->isVisible());
- auto actionShowAllPlaces = new QAction(QIcon::fromTheme(QStringLiteral("hint")), i18nc("@item:inmenu", "Show Hidden Places"), this);
+ auto actionShowAllPlaces = new QAction(QIcon::fromTheme(QStringLiteral("view-hidden")), i18nc("@item:inmenu", "Show Hidden Places"), this);
actionShowAllPlaces->setCheckable(true);
actionShowAllPlaces->setDisabled(true);
actionShowAllPlaces->setWhatsThis(i18nc("@info:whatsthis", "This displays "
"appear semi-transparent unless you uncheck their hide property."));
connect(actionShowAllPlaces, &QAction::triggered, this, [actionShowAllPlaces, this](bool checked){
- actionShowAllPlaces->setIcon(QIcon::fromTheme(checked ? QStringLiteral("visibility") : QStringLiteral("hint")));
+ actionShowAllPlaces->setIcon(QIcon::fromTheme(checked ? QStringLiteral("view-visible") : QStringLiteral("view-hidden")));
m_placesPanel->showHiddenEntries(checked);
});
connect(m_placesPanel, &PlacesPanel::showHiddenEntriesChanged, this, [actionShowAllPlaces] (bool checked){
actionShowAllPlaces->setChecked(checked);
- actionShowAllPlaces->setIcon(QIcon::fromTheme(checked ? QStringLiteral("visibility") : QStringLiteral("hint")));
+ actionShowAllPlaces->setIcon(QIcon::fromTheme(checked ? QStringLiteral("view-visible") : QStringLiteral("view-hidden")));
});
actionCollection()->action(QStringLiteral("show_places_panel"))
});
}
-void DolphinMainWindow::updateEditActions()
+
+void DolphinMainWindow::updateFileAndEditActions()
{
const KFileItemList list = m_activeViewContainer->view()->selectedItems();
+ const KActionCollection* col = actionCollection();
+ QAction* addToPlacesAction = col->action(QStringLiteral("add_to_places"));
+
if (list.isEmpty()) {
stateChanged(QStringLiteral("has_no_selection"));
+
+ addToPlacesAction->setText(i18nc("@action:inmenu Add current folder to places", "Add '%1' to Places", m_activeViewContainer->placesText()));
} else {
stateChanged(QStringLiteral("has_selection"));
- KActionCollection* col = actionCollection();
QAction* renameAction = col->action(KStandardAction::name(KStandardAction::RenameFile));
QAction* moveToTrashAction = col->action(KStandardAction::name(KStandardAction::MoveToTrash));
QAction* deleteAction = col->action(KStandardAction::name(KStandardAction::DeleteFile));
QAction* deleteWithTrashShortcut = col->action(QStringLiteral("delete_shortcut")); // see DolphinViewActionHandler
QAction* showTarget = col->action(QStringLiteral("show_target"));
+ if (list.length() == 1 && list.first().isDir()) {
+ addToPlacesAction->setEnabled(true);
+ addToPlacesAction->setText(i18nc("@action:inmenu Add current folder to places", "Add '%1' to Places", list.first().name()));
+ } else {
+ addToPlacesAction->setEnabled(false);
+ addToPlacesAction->setText(i18nc("@action:inmenu Add current folder to places", "Add to Places"));
+ }
+
KFileItemListProperties capabilities(list);
const bool enableMoveToTrash = capabilities.isLocal() && capabilities.supportsMoving();
bool DolphinMainWindow::isUrlOpen(const QString& url)
{
- if (m_tabWidget->getIndexByUrl(QUrl::fromUserInput((url))) >= 0) {
+ if (m_tabWidget->getIndexByUrl(QUrl::fromUserInput((url))).first >= 0) {
return true;
} else {
return false;