#include "views/tooltips/tooltipmanager.h"
#include "zoomlevelinfo.h"
-#ifdef HAVE_BALOO
+#if HAVE_BALOO
#include <Baloo/IndexerConfig>
#endif
#include <KColorScheme>
#include <KLocalizedString>
#include <KMessageBox>
#include <KProtocolManager>
+#include <KUrlMimeData>
#include <QAbstractItemView>
#include <QActionGroup>
m_assureVisibleCurrentIndex(false),
m_isFolderWritable(true),
m_dragging(false),
- m_loading(false),
m_url(url),
m_viewPropertiesContext(),
m_mode(DolphinView::IconsView),
this, &DolphinView::slotRoleEditingCanceled);
connect(m_view->header(), &KItemListHeader::columnWidthChangeFinished,
this, &DolphinView::slotHeaderColumnWidthChangeFinished);
- connect(m_view->header(), &KItemListHeader::leadingPaddingChanged,
- this, &DolphinView::slotLeadingPaddingWidthChanged);
+ connect(m_view->header(), &KItemListHeader::sidePaddingChanged,
+ this, &DolphinView::slotSidePaddingWidthChanged);
KItemListSelectionManager* selectionManager = controller->selectionManager();
connect(selectionManager, &KItemListSelectionManager::selectionChanged,
this, &DolphinView::slotSelectionChanged);
-#ifdef HAVE_BALOO
+#if HAVE_BALOO
m_toolTipManager = new ToolTipManager(this);
connect(m_toolTipManager, &ToolTipManager::urlActivated, this, &DolphinView::urlActivated);
#endif
{
QMimeData* mimeData = selectionMimeData();
KIO::setClipboardDataCut(mimeData, true);
+ KUrlMimeData::exportUrlsToPortal(mimeData);
QApplication::clipboard()->setMimeData(mimeData);
}
void DolphinView::copySelectedItemsToClipboard()
{
- QMimeData* mimeData = selectionMimeData();
+ QMimeData *mimeData = selectionMimeData();
+ KUrlMimeData::exportUrlsToPortal(mimeData);
QApplication::clipboard()->setMimeData(mimeData);
}
break;
case QEvent::ToolTip:
- tryShowNameToolTip(event);
+ tryShowNameToolTip(static_cast<QHelpEvent*>(event));
default:
break;
const QList<QByteArray> visibleRolesSet = view->visibleRoles();
bool indexingEnabled = false;
-#ifdef HAVE_BALOO
+#if HAVE_BALOO
Baloo::IndexerConfig config;
indexingEnabled = config.fileIndexingEnabled();
#endif
QActionGroup* widthsGroup = new QActionGroup(menu);
const bool autoColumnWidths = props.headerColumnWidths().isEmpty();
- QAction* toggleLeadingPaddingAction = menu->addAction(i18nc("@action:inmenu", "Leading Column Padding"));
- toggleLeadingPaddingAction->setCheckable(true);
- toggleLeadingPaddingAction->setChecked(view->header()->leadingPadding() > 0);
+ QAction* toggleSidePaddingAction = menu->addAction(i18nc("@action:inmenu", "Side Padding"));
+ toggleSidePaddingAction->setCheckable(true);
+ toggleSidePaddingAction->setChecked(view->header()->sidePadding() > 0);
QAction* autoAdjustWidthsAction = menu->addAction(i18nc("@action:inmenu", "Automatic Column Widths"));
autoAdjustWidthsAction->setCheckable(true);
}
props.setHeaderColumnWidths(columnWidths);
header->setAutomaticColumnResizing(false);
- } else if (action == toggleLeadingPaddingAction) {
- header->setLeadingPadding(toggleLeadingPaddingAction->isChecked() ? 20 : 0);
+ } else if (action == toggleSidePaddingAction) {
+ header->setSidePadding(toggleSidePaddingAction->isChecked() ? 20 : 0);
} else {
// Show or hide the selected role
const QByteArray selectedRole = action->data().toByteArray();
props.setHeaderColumnWidths(columnWidths);
}
-void DolphinView::slotLeadingPaddingWidthChanged(qreal width)
+void DolphinView::slotSidePaddingWidthChanged(qreal width)
{
ViewProperties props(viewPropertiesUrl());
- DetailsModeSettings::setLeadingPadding(int(width));
+ DetailsModeSettings::setSidePadding(int(width));
m_view->writeSettings();
}
const QPoint pos = m_container->mapToGlobal(itemRect.topLeft().toPoint());
itemRect.moveTo(pos);
-#ifdef HAVE_BALOO
- m_toolTipManager->showToolTip(item, itemRect, nativeParentWidget()->windowHandle());
+#if HAVE_BALOO
+ auto nativeParent = nativeParentWidget();
+ if (nativeParent) {
+ m_toolTipManager->showToolTip(item, itemRect, nativeParent->windowHandle());
+ }
#endif
}
void DolphinView::hideToolTip(const ToolTipManager::HideBehavior behavior)
{
if (GeneralSettings::showToolTips()) {
-#ifdef HAVE_BALOO
+#if HAVE_BALOO
m_toolTipManager->hideToolTip(behavior);
#else
Q_UNUSED(behavior)
void DolphinView::slotDirectoryLoadingStarted()
{
- m_loading = true;
+ m_loadingState = LoadingState::Loading;
updatePlaceholderLabel();
// Disable the writestate temporary until it can be determined in a fast way
void DolphinView::slotDirectoryLoadingCompleted()
{
- m_loading = false;
+ m_loadingState = LoadingState::Completed;
// Update the view-state. This has to be done asynchronously
// because the view might not be in its final state yet.
void DolphinView::slotDirectoryLoadingCanceled()
{
- m_loading = false;
+ m_loadingState = LoadingState::Canceled;
updatePlaceholderLabel();
} else {
header->setAutomaticColumnResizing(true);
}
- header->setLeadingPadding(DetailsModeSettings::leadingPadding());
+ header->setSidePadding(DetailsModeSettings::sidePadding());
}
m_view->endTransaction();
return;
}
- if (m_loading) {
+ if (m_loadingState == LoadingState::Loading) {
m_placeholderLabel->setVisible(false);
m_showLoadingPlaceholderTimer->start();
return;
}
- if (!nameFilter().isEmpty()) {
+ if (m_loadingState == LoadingState::Canceled) {
+ m_placeholderLabel->setText(i18n("Loading canceled"));
+ } else if (!nameFilter().isEmpty()) {
m_placeholderLabel->setText(i18n("No items matching the filter"));
} else if (m_url.scheme() == QLatin1String("baloosearch") || m_url.scheme() == QLatin1String("filenamesearch")) {
m_placeholderLabel->setText(i18n("No items matching the search"));
m_placeholderLabel->setVisible(true);
}
-void DolphinView::tryShowNameToolTip(QEvent* event)
+void DolphinView::tryShowNameToolTip(QHelpEvent* event)
{
if (!GeneralSettings::showToolTips() && m_mode == DolphinView::IconsView) {
- QHelpEvent *hoverEvent = reinterpret_cast<QHelpEvent *>(event);
- const std::optional<int> index = m_view->itemAt(hoverEvent->pos());
+ const std::optional<int> index = m_view->itemAt(event->pos());
if (!index.has_value()) {
return;
if(isElided) {
const KFileItem item = m_model->fileItem(index.value());
const QString text = item.text();
- const QPoint pos = mapToGlobal(hoverEvent->pos());
+ const QPoint pos = mapToGlobal(event->pos());
QToolTip::showText(pos, text);
}
}