#include "informationpanelcontent.h"
+#define HAVE_KDIRNOTIFY __has_include(<KDirNotify>)
+#if HAVE_KDIRNOTIFY
#include <KDirNotify>
-#include <KIO/Job>
+#endif
+#include <KIO/StatJob>
#include <KJobWidgets>
#include <KLocalizedString>
if ((count == 1) && !selection.first().url().isEmpty()) {
m_urlCandidate = selection.first().url();
}
- m_infoTimer->start();
+ showItemInfo();
}
}
void InformationPanel::requestDelayedItemInfo(const KFileItem &item)
{
- if (!isVisible()) {
+ if (!isVisible() || !InformationPanelSettings::showHovered()) {
return;
}
previewAutoPlayAction->setCheckable(true);
previewAutoPlayAction->setChecked(InformationPanelSettings::previewsAutoPlay());
- QAction *configureAction = popup.addAction(i18nc("@action:inmenu", "Configure..."));
+ QAction *showHoveredAction = popup.addAction(i18nc("@action:inmenu", "Show item on hover"));
+ showHoveredAction->setIcon(QIcon::fromTheme(QStringLiteral("followmouse")));
+ showHoveredAction->setCheckable(true);
+ showHoveredAction->setChecked(InformationPanelSettings::showHovered());
+
+ QAction *configureAction = popup.addAction(i18nc("@action:inmenu", "Configureā¦"));
configureAction->setIcon(QIcon::fromTheme(QStringLiteral("configure")));
if (m_inConfigurationMode) {
configureAction->setEnabled(false);
if (action == previewAction) {
InformationPanelSettings::setPreviewsShown(isChecked);
m_content->refreshPreview();
+ } else if (action == previewAutoPlayAction) {
+ InformationPanelSettings::setPreviewsAutoPlay(isChecked);
+ m_content->setPreviewAutoPlay(isChecked);
+ } else if (action == showHoveredAction) {
+ InformationPanelSettings::setShowHovered(isChecked);
+ if (!isChecked) {
+ m_hoveredItem = KFileItem();
+ showItemInfo();
+ }
} else if (action == configureAction) {
m_inConfigurationMode = true;
m_content->configureShownProperties();
- }
- if (action == dateformatAction) {
+ } else if (action == dateformatAction) {
int dateFormat = static_cast<int>(isChecked ? Baloo::DateFormats::ShortFormat : Baloo::DateFormats::LongFormat);
InformationPanelSettings::setDateFormat(dateFormat);
m_content->refreshMetaData();
- } else if (action == previewAutoPlayAction) {
- InformationPanelSettings::setPreviewsAutoPlay(isChecked);
- m_content->setPreviewAutoPlay(isChecked);
}
}
} else {
// The information for exactly one item should be shown
KFileItem item;
- if (!m_hoveredItem.isNull()) {
+ if (!m_hoveredItem.isNull() && InformationPanelSettings::showHovered()) {
item = m_hoveredItem;
} else if (!m_selection.isEmpty()) {
Q_ASSERT(m_selection.count() == 1);
// No item is hovered and no selection has been done: provide
// an item for the currently shown directory.
m_shownUrl = url();
- m_folderStatJob = KIO::statDetails(m_shownUrl, KIO::StatJob::SourceSide, KIO::StatDefaultDetails | KIO::StatRecursiveSize, KIO::HideProgressInfo);
+ m_folderStatJob = KIO::stat(m_shownUrl, KIO::StatJob::SourceSide, KIO::StatDefaultDetails | KIO::StatRecursiveSize, KIO::HideProgressInfo);
if (m_folderStatJob->uiDelegate()) {
KJobWidgets::setWindow(m_folderStatJob, this);
}
// item is selected, as the name of the item is shown. If this should change
// in future: Before parsing the whole selection take care to test possible
// performance bottlenecks when renaming several hundreds of files.
- } else {
- m_hoveredItem = KFileItem(destUrl);
}
showItemInfo();
m_resetUrlTimer->start();
}
+void InformationPanel::readSettings()
+{
+ if (m_initialized) {
+ m_content->refreshPreview();
+ m_content->refreshMetaData();
+ }
+}
+
void InformationPanel::init()
{
m_infoTimer = new QTimer(this);
Q_ASSERT(m_urlChangedTimer->interval() < m_infoTimer->interval());
Q_ASSERT(m_urlChangedTimer->interval() < m_resetUrlTimer->interval());
+#if HAVE_KDIRNOTIFY
org::kde::KDirNotify *dirNotify = new org::kde::KDirNotify(QString(), QString(), QDBusConnection::sessionBus(), this);
connect(dirNotify, &OrgKdeKDirNotifyInterface::FileRenamed, this, &InformationPanel::slotFileRenamed);
connect(dirNotify, &OrgKdeKDirNotifyInterface::FilesAdded, this, &InformationPanel::slotFilesAdded);
connect(dirNotify, &OrgKdeKDirNotifyInterface::FilesRemoved, this, &InformationPanel::slotFilesRemoved);
connect(dirNotify, &OrgKdeKDirNotifyInterface::enteredDirectory, this, &InformationPanel::slotEnteredDirectory);
connect(dirNotify, &OrgKdeKDirNotifyInterface::leftDirectory, this, &InformationPanel::slotLeftDirectory);
+#endif
m_content = new InformationPanelContent(this);
connect(m_content, &InformationPanelContent::urlActivated, this, &InformationPanel::urlActivated);
m_initialized = true;
}
+
+#include "moc_informationpanel.cpp"