Commit eb68fae1 authored by Roman Inflianskas's avatar Roman Inflianskas

Show "Empty Trash" button inside trash directory

Summary:
Show "Empty Trash" button inside trash directory.

FEATURE: 163306

Test Plan: {F5734949}

Reviewers: ngraham, rkflx, markg, elvisangelaccio

Reviewed By: ngraham, markg, elvisangelaccio

Subscribers: markg, emateli, broulik, elvisangelaccio, rkflx, mmustac, ngraham, #dolphin

Tags: #dolphin

Differential Revision: https://phabricator.kde.org/D10804
parent 86f4fcb8
...@@ -51,7 +51,9 @@ ...@@ -51,7 +51,9 @@
DolphinViewContainer::DolphinViewContainer(const QUrl& url, QWidget* parent) : DolphinViewContainer::DolphinViewContainer(const QUrl& url, QWidget* parent) :
QWidget(parent), QWidget(parent),
m_topLayout(nullptr), m_topLayout(nullptr),
m_navigatorWidget(nullptr),
m_urlNavigator(nullptr), m_urlNavigator(nullptr),
m_emptyTrashButton(nullptr),
m_searchBox(nullptr), m_searchBox(nullptr),
m_messageWidget(nullptr), m_messageWidget(nullptr),
m_view(nullptr), m_view(nullptr),
...@@ -70,6 +72,11 @@ DolphinViewContainer::DolphinViewContainer(const QUrl& url, QWidget* parent) : ...@@ -70,6 +72,11 @@ DolphinViewContainer::DolphinViewContainer(const QUrl& url, QWidget* parent) :
m_topLayout->setSpacing(0); m_topLayout->setSpacing(0);
m_topLayout->setMargin(0); m_topLayout->setMargin(0);
m_navigatorWidget = new QWidget(this);
QHBoxLayout* navigatorLayout = new QHBoxLayout(m_navigatorWidget);
navigatorLayout->setSpacing(0);
navigatorLayout->setMargin(0);
m_urlNavigator = new KUrlNavigator(new KFilePlacesModel(this), url, this); m_urlNavigator = new KUrlNavigator(new KFilePlacesModel(this), url, this);
connect(m_urlNavigator, &KUrlNavigator::activated, connect(m_urlNavigator, &KUrlNavigator::activated,
this, &DolphinViewContainer::activate); this, &DolphinViewContainer::activate);
...@@ -83,6 +90,13 @@ DolphinViewContainer::DolphinViewContainer(const QUrl& url, QWidget* parent) : ...@@ -83,6 +90,13 @@ DolphinViewContainer::DolphinViewContainer(const QUrl& url, QWidget* parent) :
KUrlComboBox* editor = m_urlNavigator->editor(); KUrlComboBox* editor = m_urlNavigator->editor();
editor->setCompletionMode(KCompletion::CompletionMode(settings->urlCompletionMode())); editor->setCompletionMode(KCompletion::CompletionMode(settings->urlCompletionMode()));
m_emptyTrashButton = new QPushButton(QIcon::fromTheme(QStringLiteral("user-trash")), "&Empty Trash", this);
m_emptyTrashButton->setFlat(true);
connect(m_emptyTrashButton, &QPushButton::clicked, this, [this]() { Trash::empty(this); });
connect(&Trash::instance(), &Trash::emptinessChanged, m_emptyTrashButton, &QPushButton::setDisabled);
m_emptyTrashButton->setDisabled(Trash::isEmpty());
m_emptyTrashButton->hide();
m_searchBox = new DolphinSearchBox(this); m_searchBox = new DolphinSearchBox(this);
m_searchBox->hide(); m_searchBox->hide();
connect(m_searchBox, &DolphinSearchBox::activated, this, &DolphinViewContainer::activate); connect(m_searchBox, &DolphinSearchBox::activated, this, &DolphinViewContainer::activate);
...@@ -147,6 +161,10 @@ DolphinViewContainer::DolphinViewContainer(const QUrl& url, QWidget* parent) : ...@@ -147,6 +161,10 @@ DolphinViewContainer::DolphinViewContainer(const QUrl& url, QWidget* parent) :
#endif #endif
}); });
connect(m_view, &DolphinView::directoryLoadingCompleted, this, [this]() {
m_emptyTrashButton->setVisible(m_view->url().scheme() == QLatin1String("trash"));
});
// Initialize status bar // Initialize status bar
m_statusBar = new DolphinStatusBar(this); m_statusBar = new DolphinStatusBar(this);
m_statusBar->setUrl(m_view->url()); m_statusBar->setUrl(m_view->url());
...@@ -185,7 +203,10 @@ DolphinViewContainer::DolphinViewContainer(const QUrl& url, QWidget* parent) : ...@@ -185,7 +203,10 @@ DolphinViewContainer::DolphinViewContainer(const QUrl& url, QWidget* parent) :
connect(m_view, &DolphinView::urlChanged, connect(m_view, &DolphinView::urlChanged,
m_filterBar, &FilterBar::slotUrlChanged); m_filterBar, &FilterBar::slotUrlChanged);
m_topLayout->addWidget(m_urlNavigator); navigatorLayout->addWidget(m_urlNavigator);
navigatorLayout->addWidget(m_emptyTrashButton);
m_topLayout->addWidget(m_navigatorWidget);
m_topLayout->addWidget(m_searchBox); m_topLayout->addWidget(m_searchBox);
m_topLayout->addWidget(m_messageWidget); m_topLayout->addWidget(m_messageWidget);
m_topLayout->addWidget(m_view); m_topLayout->addWidget(m_view);
...@@ -337,7 +358,7 @@ void DolphinViewContainer::setSearchModeEnabled(bool enabled) ...@@ -337,7 +358,7 @@ void DolphinViewContainer::setSearchModeEnabled(bool enabled)
} }
m_searchBox->setVisible(enabled); m_searchBox->setVisible(enabled);
m_urlNavigator->setVisible(!enabled); m_navigatorWidget->setVisible(!enabled);
if (enabled) { if (enabled) {
const QUrl& locationUrl = m_urlNavigator->locationUrl(); const QUrl& locationUrl = m_urlNavigator->locationUrl();
......
...@@ -29,6 +29,7 @@ ...@@ -29,6 +29,7 @@
#include <KUrlNavigator> #include <KUrlNavigator>
#include <QElapsedTimer> #include <QElapsedTimer>
#include <QPushButton>
#include <QWidget> #include <QWidget>
#ifdef KF5Activities_FOUND #ifdef KF5Activities_FOUND
...@@ -319,7 +320,9 @@ private: ...@@ -319,7 +320,9 @@ private:
private: private:
QVBoxLayout* m_topLayout; QVBoxLayout* m_topLayout;
QWidget* m_navigatorWidget;
KUrlNavigator* m_urlNavigator; KUrlNavigator* m_urlNavigator;
QPushButton* m_emptyTrashButton;
DolphinSearchBox* m_searchBox; DolphinSearchBox* m_searchBox;
KMessageWidget* m_messageWidget; KMessageWidget* m_messageWidget;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment