#include "dolphindockwidget.h"
#include "dolphincontextmenu.h"
#include "dolphinnewfilemenu.h"
-#include "dolphinplacesmodelsingleton.h"
#include "dolphinrecenttabsmenu.h"
#include "dolphintabwidget.h"
#include "dolphinviewcontainer.h"
#include <KAuthorized>
#include <KConfig>
#include <KFileItemListProperties>
-#include <KFilePlacesModel>
#include <KHelpMenu>
#include <KIO/JobUiDelegate>
#include <KIO/OpenFileManagerWindowJob>
connect(m_tabWidget, &DolphinTabWidget::tabCountChanged,
this, &DolphinMainWindow::tabCountChanged);
connect(m_tabWidget, &DolphinTabWidget::currentUrlChanged,
- this, &DolphinMainWindow::setUrlAsCaption);
+ this, &DolphinMainWindow::updateWindowTitle);
setCentralWidget(m_tabWidget);
setupActions();
m_actionHandler = new DolphinViewActionHandler(actionCollection(), this);
connect(m_actionHandler, &DolphinViewActionHandler::actionBeingHandled, this, &DolphinMainWindow::clearStatusBar);
- connect(m_actionHandler, &DolphinViewActionHandler::createDirectory, this, &DolphinMainWindow::createDirectory);
+ connect(m_actionHandler, &DolphinViewActionHandler::createDirectoryTriggered, this, &DolphinMainWindow::createDirectory);
m_remoteEncoding = new DolphinRemoteEncoding(this, m_actionHandler);
connect(this, &DolphinMainWindow::urlChanged,
m_newFileMenu->setViewShowsHiddenFiles(activeViewContainer()->view()->hiddenFilesShown());
m_newFileMenu->checkUpToDate();
m_newFileMenu->setPopupFiles(activeViewContainer()->url());
-
- // If we're in the trash, also disable all the 'create new' items
- // TODO: remove this once https://phabricator.kde.org/T8234 is implemented
- slotWriteStateChanged(m_activeViewContainer->view()->url().scheme() != QLatin1String("trash"));
}
void DolphinMainWindow::createDirectory()
// URL instead of all items of the view
KUrlNavigator* urlNavigator = m_activeViewContainer->urlNavigator();
- QLineEdit* lineEdit = urlNavigator->editor()->lineEdit(); // krazy:exclude=qclasses
+ QLineEdit* lineEdit = urlNavigator->editor()->lineEdit();
const bool selectUrl = urlNavigator->isUrlEditable() &&
lineEdit->hasFocus();
if (selectUrl) {
{
clearStatusBar();
m_activeViewContainer->reload();
+ m_activeViewContainer->statusBar()->updateSpaceInfo();
}
void DolphinMainWindow::stopLoading()
void DolphinMainWindow::replaceLocation()
{
KUrlNavigator* navigator = m_activeViewContainer->urlNavigator();
- navigator->setUrlEditable(true);
- navigator->setFocus();
-
- // select the whole text of the combo box editor
- QLineEdit* lineEdit = navigator->editor()->lineEdit(); // krazy:exclude=qclasses
- lineEdit->selectAll();
+ QLineEdit* lineEdit = navigator->editor()->lineEdit();
+
+ // If the text field currently has focus and everything is selected,
+ // pressing the keyboard shortcut returns the whole thing to breadcrumb mode
+ if (navigator->isUrlEditable()
+ && lineEdit->hasFocus()
+ && lineEdit->selectedText() == lineEdit->text() ) {
+ navigator->setUrlEditable(false);
+ } else {
+ navigator->setUrlEditable(true);
+ navigator->setFocus();
+ lineEdit->selectAll();
+ }
}
void DolphinMainWindow::togglePanelLockState()
void DolphinMainWindow::slotWriteStateChanged(bool isFolderWritable)
{
- const auto actions = m_newFileMenu->menu()->actions();
- for (auto menuItem : actions) {
- menuItem->setEnabled(isFolderWritable);
- }
+ // trash:/ is writable but we don't want to create new items in it.
+ // TODO: remove the trash check once https://phabricator.kde.org/T8234 is implemented
+ newFileMenu()->setEnabled(isFolderWritable && m_activeViewContainer->url().scheme() != QLatin1String("trash"));
}
void DolphinMainWindow::openContextMenu(const QPoint& pos,
KActionCollection* ac = actionCollection();
+ // Add "Create New" menu
+ menu->addMenu(m_newFileMenu->menu());
+
+ menu->addSeparator();
+
// Add "Edit" actions
bool added = addActionToMenu(ac->action(KStandardAction::name(KStandardAction::Undo)), menu) |
addActionToMenu(ac->action(KStandardAction::name(KStandardAction::Find)), menu) |
void DolphinMainWindow::tabCountChanged(int count)
{
const bool enableTabActions = (count > 1);
- actionCollection()->action(KStandardAction::name(KStandardAction::Close))->setEnabled(enableTabActions);
actionCollection()->action(QStringLiteral("activate_next_tab"))->setEnabled(enableTabActions);
actionCollection()->action(QStringLiteral("activate_prev_tab"))->setEnabled(enableTabActions);
}
-void DolphinMainWindow::setUrlAsCaption(const QUrl& url)
+void DolphinMainWindow::updateWindowTitle()
{
- QString schemePrefix;
- if (!url.isLocalFile()) {
- schemePrefix.append(url.scheme() + " - ");
- if (!url.host().isEmpty()) {
- schemePrefix.append(url.host() + " - ");
- }
- }
-
- if (GeneralSettings::showFullPathInTitlebar()) {
- const QString path = url.adjusted(QUrl::StripTrailingSlash).path();
- setWindowTitle(schemePrefix + path);
- return;
- }
-
- KFilePlacesModel *placesModel = DolphinPlacesModelSingleton::instance().placesModel();
- const auto& matchedPlaces = placesModel->match(placesModel->index(0,0), KFilePlacesModel::UrlRole, url, 1, Qt::MatchExactly);
-
- if (!matchedPlaces.isEmpty()) {
- setWindowTitle(placesModel->text(matchedPlaces.first()));
- return;
- }
-
- QString fileName = url.adjusted(QUrl::StripTrailingSlash).fileName();
- if (fileName.isEmpty()) {
- fileName = '/';
- }
-
- if (m_activeViewContainer->isSearchModeEnabled()) {
- if(m_activeViewContainer->currentSearchText().isEmpty()){
- setWindowTitle(i18n("Search"));
- } else {
- const auto searchText = i18n("Search for %1", m_activeViewContainer->currentSearchText());
- setWindowTitle(searchText);
- }
- return;
- }
-
- setWindowTitle(schemePrefix + fileName);
+ setWindowTitle(m_activeViewContainer->caption());
}
void DolphinMainWindow::slotStorageTearDownFromPlacesRequested(const QString& mountPath)
{
// setup 'File' menu
m_newFileMenu = new DolphinNewFileMenu(actionCollection(), this);
+ m_newFileMenu->setObjectName("newFileMenu");
QMenu* menu = m_newFileMenu->menu();
menu->setTitle(i18nc("@title:menu Create new folder, file, link, etc.", "Create New"));
menu->setIcon(QIcon::fromTheme(QStringLiteral("document-new")));
QAction* newWindow = KStandardAction::openNew(this, &DolphinMainWindow::openNewMainWindow, actionCollection());
newWindow->setText(i18nc("@action:inmenu File", "New &Window"));
+ newWindow->setIcon(QIcon::fromTheme(QStringLiteral("window-new")));
QAction* newTab = actionCollection()->addAction(QStringLiteral("new_tab"));
newTab->setIcon(QIcon::fromTheme(QStringLiteral("tab-new")));
newTab->setText(i18nc("@action:inmenu File", "New Tab"));
- actionCollection()->setDefaultShortcuts(newTab, {Qt::CTRL + Qt::Key_T, QKeySequence::AddTab});
+ actionCollection()->setDefaultShortcuts(newTab, {Qt::CTRL + Qt::Key_T, Qt::CTRL + Qt::SHIFT + Qt::Key_N});
connect(newTab, &QAction::triggered, this, static_cast<void(DolphinMainWindow::*)()>(&DolphinMainWindow::openNewActivatedTab));
QAction* closeTab = KStandardAction::close(
m_tabWidget, static_cast<void(DolphinTabWidget::*)()>(&DolphinTabWidget::closeTab), actionCollection());
closeTab->setText(i18nc("@action:inmenu File", "Close Tab"));
- closeTab->setEnabled(false);
KStandardAction::quit(this, &DolphinMainWindow::quit, actionCollection());
this, &DolphinMainWindow::slotStorageTearDownExternallyRequested);
m_tabWidget->slotPlacesPanelVisibilityChanged(m_placesPanel->isVisible());
+ auto actionShowAllPlaces = new QAction(QIcon::fromTheme(QStringLiteral("hint")), i18nc("@item:inmenu", "Show Hidden Places"), this);
+ actionShowAllPlaces->setCheckable(true);
+ actionShowAllPlaces->setDisabled(true);
+
+ connect(actionShowAllPlaces, &QAction::triggered, this, [actionShowAllPlaces, this](bool checked){
+ actionShowAllPlaces->setIcon(QIcon::fromTheme(checked ? QStringLiteral("visibility") : QStringLiteral("hint")));
+ 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")));
+ });
+
// Add actions into the "Panels" menu
KActionMenu* panelsMenu = new KActionMenu(i18nc("@action:inmenu View", "Panels"), this);
actionCollection()->addAction(QStringLiteral("panels"), panelsMenu);
panelsMenu->setDelayed(false);
const KActionCollection* ac = actionCollection();
panelsMenu->addAction(ac->action(QStringLiteral("show_places_panel")));
+#ifdef HAVE_BALOO
panelsMenu->addAction(ac->action(QStringLiteral("show_information_panel")));
+#endif
panelsMenu->addAction(ac->action(QStringLiteral("show_folders_panel")));
panelsMenu->addAction(ac->action(QStringLiteral("show_terminal_panel")));
panelsMenu->addSeparator();
+ panelsMenu->addAction(actionShowAllPlaces);
panelsMenu->addAction(lockLayoutAction);
+
+ connect(panelsMenu->menu(), &QMenu::aboutToShow, this, [actionShowAllPlaces, this]{
+ actionShowAllPlaces->setEnabled(m_placesPanel->hiddenListCount());
+ });
}
void DolphinMainWindow::updateEditActions()
const bool splitView = GeneralSettings::splitView();
m_tabWidget->currentTabPage()->setSplitViewEnabled(splitView);
updateSplitAction();
- setUrlAsCaption(activeViewContainer()->url());
+ updateWindowTitle();
}
emit settingsChanged();