#include "trash/dolphintrash.h"
+#include <KCoreAddons>
#include <KLocalizedString>
#include <KNotificationJobUiDelegate>
#include <KService>
#include <QApplication>
#include <QHBoxLayout>
#include <QPushButton>
+#include <QStyle>
#include <QToolBar>
#include <limits>
m_splitter->setChildrenCollapsible(false);
m_splitter->addWidget(createNavigatorWidget(Primary));
+ m_splitter->setFocusProxy(primaryUrlNavigator());
m_adjustSpacingTimer->setInterval(100);
m_adjustSpacingTimer->setSingleShot(true);
m_previousWindowWidth = qobject_cast<QWidget *>(parent())->window()->width();
auto viewGeometries = m_viewGeometriesHelper.viewGeometries();
const int widthOfSplitterPrimary = viewGeometries.globalXOfPrimary + viewGeometries.widthOfPrimary - viewGeometries.globalXOfNavigatorsWidget;
- const QList<int> splitterSizes = {widthOfSplitterPrimary, m_splitter->width() - widthOfSplitterPrimary};
+ const QList<int> splitterSizes = {widthOfSplitterPrimary, m_splitter->width() - widthOfSplitterPrimary - m_splitter->handleWidth()};
m_splitter->setSizes(splitterSizes);
// primary side of m_splitter
Q_ASSERT(m_splitter->count() == 1);
m_splitter->addWidget(createNavigatorWidget(Secondary));
Q_ASSERT(m_splitter->count() == 2);
+#if KIO_VERSION >= QT_VERSION_CHECK(6, 14, 0)
+ secondaryUrlNavigator()->setBackgroundEnabled(primaryUrlNavigator()->isBackgroundEnabled());
+#endif
updateText();
}
{
if (visible) {
Q_ASSERT(m_splitter->count() == 2);
+ m_splitter->widget(0)->setContentsMargins(0, 0, m_splitter->style()->pixelMetric(QStyle::PM_LayoutRightMargin), 0);
+ m_splitter->widget(1)->setContentsMargins(m_splitter->style()->pixelMetric(QStyle::PM_LayoutLeftMargin), 0, 0, 0);
m_splitter->widget(1)->setVisible(true);
} else if (m_splitter->count() > 1) {
m_splitter->widget(1)->setVisible(false);
+ m_splitter->widget(0)->setContentsMargins(0, 0, 0, 0);
+ m_splitter->widget(1)->setContentsMargins(0, 0, 0, 0);
// Fix an unlikely event of wrong trash button visibility.
emptyTrashButton(Secondary)->setVisible(false);
}
updateText();
}
+void DolphinNavigatorsWidgetAction::setBackgroundEnabled(bool enabled)
+{
+#if KIO_VERSION >= QT_VERSION_CHECK(6, 14, 0)
+ m_splitter->setAutoFillBackground(!enabled);
+ m_splitter->setBackgroundRole(enabled ? QPalette::Window : QPalette::Base);
+ primaryUrlNavigator()->setBackgroundEnabled(enabled);
+ if (secondaryUrlNavigator()) {
+ secondaryUrlNavigator()->setBackgroundEnabled(enabled);
+ }
+#else
+ Q_UNUSED(enabled);
+#endif
+}
+
QWidget *DolphinNavigatorsWidgetAction::createWidget(QWidget *parent)
{
QWidget *oldParent = m_splitter->parentWidget();
auto layout = new QHBoxLayout{navigatorWidget};
layout->setSpacing(0);
layout->setContentsMargins(0, 0, 0, 0);
+
if (side == Primary) {
auto leadingSpacing = new QWidget{navigatorWidget};
layout->addWidget(leadingSpacing);
QPushButton *DolphinNavigatorsWidgetAction::newEmptyTrashButton(const DolphinUrlNavigator *urlNavigator, QWidget *parent) const
{
- auto emptyTrashButton = new QPushButton(QIcon::fromTheme(QStringLiteral("user-trash")), i18nc("@action:button", "Empty Trash"), parent);
+ auto emptyTrashButton = new QPushButton(QIcon::fromTheme(QStringLiteral("edit-delete")), i18nc("@action:button", "Empty Trash"), parent);
emptyTrashButton->setToolTip(i18n("Empties Trash to create free space"));
emptyTrashButton->setFlat(true);
{
auto networkFolderButton = new QPushButton(QIcon::fromTheme(QStringLiteral("folder-add")), i18nc("@action:button", "Add Network Folder"), parent);
networkFolderButton->setFlat(true);
- KService::Ptr service = KService::serviceByDesktopName(QStringLiteral("org.kde.knetattach"));
- connect(networkFolderButton, &QPushButton::clicked, this, [networkFolderButton, service]() {
+ connect(networkFolderButton, &QPushButton::clicked, this, [networkFolderButton]() {
+ const KService::Ptr service = KService::serviceByDesktopName(QStringLiteral("org.kde.knetattach"));
auto *job = new KIO::ApplicationLauncherJob(service, networkFolderButton);
auto *delegate = new KNotificationJobUiDelegate;
delegate->setAutoErrorHandlingEnabled(true);
job->start();
});
networkFolderButton->hide();
- connect(urlNavigator, &KUrlNavigator::urlChanged, this, [networkFolderButton, urlNavigator, service]() {
- networkFolderButton->setVisible(service && urlNavigator->locationUrl().scheme() == QLatin1String("remote"));
+ connect(urlNavigator, &KUrlNavigator::urlChanged, this, [networkFolderButton, urlNavigator]() {
+ if (urlNavigator->locationUrl().scheme() == QLatin1String("remote")) {
+ // Looking up a service can be a bit slow, so we only do it now when it becomes necessary.
+ const KService::Ptr service = KService::serviceByDesktopName(QStringLiteral("org.kde.knetattach"));
+ networkFolderButton->setVisible(service);
+ } else {
+ networkFolderButton->setVisible(false);
+ }
});
return networkFolderButton;
}