X-Git-Url: https://cloud.milkyroute.net/gitweb/dolphin.git/blobdiff_plain/87f30d3fc8172649b3c905b04e20655ca18ac68f..64ffcdad4ff60e1f0b443c00229e6aacf523c72f:/src/views/tooltips/tooltipmanager.cpp diff --git a/src/views/tooltips/tooltipmanager.cpp b/src/views/tooltips/tooltipmanager.cpp index eaa785987..637261702 100644 --- a/src/views/tooltips/tooltipmanager.cpp +++ b/src/views/tooltips/tooltipmanager.cpp @@ -1,21 +1,8 @@ -/******************************************************************************* - * Copyright (C) 2008 by Konstantin Heil * - * * - * This program is free software; you can redistribute it and/or modify * - * it under the terms of the GNU General Public License as published by * - * the Free Software Foundation; either version 2 of the License, or * - * (at your option) any later version. * - * * - * This program is distributed in the hope that it will be useful, * - * but WITHOUT ANY WARRANTY; without even the implied warranty of * - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * - * GNU General Public License for more details. * - * * - * You should have received a copy of the GNU General Public License * - * along with this program; if not, write to the * - * Free Software Foundation, Inc., * - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * - *******************************************************************************/ +/* + * SPDX-FileCopyrightText: 2008 Konstantin Heil + * + * SPDX-License-Identifier: GPL-2.0-or-later + */ #include "tooltipmanager.h" @@ -23,7 +10,9 @@ #include #include +#include #include +#include #include #include @@ -49,7 +38,6 @@ ToolTipManager::ToolTipManager(QWidget* parent) : m_showToolTipTimer(nullptr), m_contentRetrievalTimer(nullptr), m_transientParent(nullptr), - m_fileMetaDataWidget(nullptr), m_toolTipRequested(false), m_metaDataRequested(false), m_appliedWaitCursor(false), @@ -76,11 +64,14 @@ ToolTipManager::ToolTipManager(QWidget* parent) : ToolTipManager::~ToolTipManager() { + if (!m_fileMetaDatWidgetOwnershipTransferred) { + delete m_fileMetaDataWidget; + } } void ToolTipManager::showToolTip(const KFileItem& item, const QRectF& itemRect, QWindow *transientParent) { - hideToolTip(); + hideToolTip(HideBehavior::Instantly); m_itemRect = itemRect.toRect(); @@ -92,11 +83,11 @@ void ToolTipManager::showToolTip(const KFileItem& item, const QRectF& itemRect, // Only start the retrieving of the content, when the mouse has been over this // item for 200 milliseconds. This prevents a lot of useless preview jobs and // meta data retrieval, when passing rapidly over a lot of items. - m_fileMetaDataWidget.reset(new DolphinFileMetaDataWidget()); - connect(m_fileMetaDataWidget.data(), &DolphinFileMetaDataWidget::metaDataRequestFinished, - this, &ToolTipManager::slotMetaDataRequestFinished); - connect(m_fileMetaDataWidget.data(), &DolphinFileMetaDataWidget::urlActivated, - this, &ToolTipManager::urlActivated); + if (!m_fileMetaDataWidget) { + m_fileMetaDataWidget = new DolphinFileMetaDataWidget(); + connect(m_fileMetaDataWidget, &DolphinFileMetaDataWidget::metaDataRequestFinished, this, &ToolTipManager::slotMetaDataRequestFinished); + connect(m_fileMetaDataWidget, &DolphinFileMetaDataWidget::urlActivated, this, &ToolTipManager::urlActivated); + } m_contentRetrievalTimer->start(); m_showToolTipTimer->start(); @@ -145,11 +136,12 @@ void ToolTipManager::startContentRetrieval() // Request a preview of the item m_fileMetaDataWidget->setPreview(QPixmap()); - QStringList plugins = KIO::PreviewJob::availablePlugins(); + const KConfigGroup globalConfig(KSharedConfig::openConfig(), "PreviewSettings"); + const QStringList plugins = globalConfig.readEntry("Plugins", KIO::PreviewJob::defaultPlugins()); KIO::PreviewJob* job = new KIO::PreviewJob(KFileItemList() << m_item, QSize(256, 256), &plugins); - job->setIgnoreMaximumSize(m_item.isLocalFile()); + job->setIgnoreMaximumSize(m_item.isLocalFile() && !m_item.isSlow()); if (job->uiDelegate()) { KJobWidgets::setWindow(job, qApp->activeWindow()); } @@ -230,7 +222,10 @@ void ToolTipManager::showToolTip() if (!m_tooltipWidget) { m_tooltipWidget.reset(new KToolTipWidget()); } - m_tooltipWidget->showBelow(m_itemRect, m_fileMetaDataWidget.data(), m_transientParent); + m_tooltipWidget->showBelow(m_itemRect, m_fileMetaDataWidget, m_transientParent); + // At this point KToolTipWidget adopted our parent-less metadata widget. + m_fileMetaDatWidgetOwnershipTransferred = true; + m_toolTipRequested = false; }