-InformationPanel::InformationPanel(QWidget* parent) :
- Panel(parent),
- m_initialized(false),
- m_infoTimer(nullptr),
- m_urlChangedTimer(nullptr),
- m_resetUrlTimer(nullptr),
- m_shownUrl(),
- m_urlCandidate(),
- m_invalidUrlCandidate(),
- m_fileItem(),
- m_selection(),
- m_folderStatJob(nullptr),
- m_content(nullptr)
+InformationPanel::InformationPanel(QWidget *parent)
+ : Panel(parent)
+ , m_initialized(false)
+ , m_infoTimer(nullptr)
+ , m_urlChangedTimer(nullptr)
+ , m_resetUrlTimer(nullptr)
+ , m_shownUrl()
+ , m_urlCandidate()
+ , m_invalidUrlCandidate()
+ , m_hoveredItem()
+ , m_selection()
+ , m_folderStatJob(nullptr)
+ , m_content(nullptr)
- // The cursor is above the viewport. If files are selected,
- // show information regarding the selection.
- if (!m_selection.isEmpty()) {
- m_fileItem = KFileItem();
- m_infoTimer->start();
- }
- } else if (item.url().isValid() && !isEqualToShownUrl(item.url())) {
- // The cursor is above an item that is not shown currently
- m_urlCandidate = item.url();
- m_fileItem = item;
- m_infoTimer->start();
+ m_hoveredItem = KFileItem();
+ return;
// Update the content with a delay. This gives
// the directory lister the chance to show the content
// Update the content with a delay. This gives
// the directory lister the chance to show the content
previewAction->setIcon(QIcon::fromTheme(QStringLiteral("view-preview")));
previewAction->setCheckable(true);
previewAction->setChecked(InformationPanelSettings::previewsShown());
previewAction->setIcon(QIcon::fromTheme(QStringLiteral("view-preview")));
previewAction->setCheckable(true);
previewAction->setChecked(InformationPanelSettings::previewsShown());
previewAutoPlayAction->setIcon(QIcon::fromTheme(QStringLiteral("media-playback-start")));
previewAutoPlayAction->setCheckable(true);
previewAutoPlayAction->setChecked(InformationPanelSettings::previewsAutoPlay());
previewAutoPlayAction->setIcon(QIcon::fromTheme(QStringLiteral("media-playback-start")));
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);
}
configureAction->setIcon(QIcon::fromTheme(QStringLiteral("configure")));
if (m_inConfigurationMode) {
configureAction->setEnabled(false);
}
dateformatAction->setIcon(QIcon::fromTheme(QStringLiteral("change-date-symbolic")));
dateformatAction->setCheckable(true);
dateformatAction->setChecked(InformationPanelSettings::dateFormat() == static_cast<int>(Baloo::DateFormats::ShortFormat));
dateformatAction->setIcon(QIcon::fromTheme(QStringLiteral("change-date-symbolic")));
dateformatAction->setCheckable(true);
dateformatAction->setChecked(InformationPanelSettings::dateFormat() == static_cast<int>(Baloo::DateFormats::ShortFormat));
if (action == previewAction) {
InformationPanelSettings::setPreviewsShown(isChecked);
m_content->refreshPreview();
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();
} else if (action == configureAction) {
m_inConfigurationMode = true;
m_content->configureShownProperties();
int dateFormat = static_cast<int>(isChecked ? Baloo::DateFormats::ShortFormat : Baloo::DateFormats::LongFormat);
InformationPanelSettings::setDateFormat(dateFormat);
m_content->refreshMetaData();
int dateFormat = static_cast<int>(isChecked ? Baloo::DateFormats::ShortFormat : Baloo::DateFormats::LongFormat);
InformationPanelSettings::setDateFormat(dateFormat);
m_content->refreshMetaData();
// The information for a selection of items should be shown
m_content->showItems(m_selection);
} else {
// The information for exactly one item should be shown
KFileItem item;
// The information for a selection of items should be shown
m_content->showItems(m_selection);
} else {
// The information for exactly one item should be shown
KFileItem item;
} else if (!m_selection.isEmpty()) {
Q_ASSERT(m_selection.count() == 1);
item = m_selection.first();
}
} else if (!m_selection.isEmpty()) {
Q_ASSERT(m_selection.count() == 1);
item = m_selection.first();
}
- if (item.isNull()) {
- // No item is hovered and no selection has been done: provide
- // an item for the currently shown directory.
- m_folderStatJob = KIO::statDetails(url(), KIO::StatJob::SourceSide, KIO::StatDefaultDetails | KIO::StatRecursiveSize, KIO::HideProgressInfo);
- if (m_folderStatJob->uiDelegate()) {
- KJobWidgets::setWindow(m_folderStatJob, this);
- }
- connect(m_folderStatJob, &KIO::Job::result,
- this, &InformationPanel::slotFolderStatFinished);
- } else {
+ if (!item.isNull()) {
+ m_shownUrl = item.url();
+
+ // No item is hovered and no selection has been done: provide
+ // an item for the currently shown directory.
+ m_shownUrl = url();
+ m_folderStatJob = KIO::stat(m_shownUrl, KIO::StatJob::SourceSide, KIO::StatDefaultDetails | KIO::StatRecursiveSize, KIO::HideProgressInfo);
+ if (m_folderStatJob->uiDelegate()) {
+ KJobWidgets::setWindow(m_folderStatJob, this);
+ }
+ connect(m_folderStatJob, &KIO::Job::result, this, &InformationPanel::slotFolderStatFinished);
- if (m_shownUrl == QUrl::fromUserInput(source)) {
- m_shownUrl = QUrl::fromUserInput(dest);
- m_fileItem = KFileItem(m_shownUrl);
+ auto sourceUrl = QUrl::fromUserInput(source);
+ if (m_shownUrl == sourceUrl) {
+ auto destUrl = QUrl::fromUserInput(dest);
- if ((m_selection.count() == 1) && (m_selection[0].url() == QUrl::fromLocalFile(source))) {
- m_selection[0] = m_fileItem;
+ if ((m_selection.count() == 1) && (m_selection[0].url() == sourceUrl)) {
+ m_selection[0] = KFileItem(destUrl);
// Implementation note: Updating the selection is only required if exactly one
// 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
// Implementation note: Updating the selection is only required if exactly one
// 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
{
if (m_shownUrl == QUrl::fromUserInput(directory)) {
// If the 'trash' icon changes because the trash has been emptied or got filled,
// the signal filesAdded("trash:/") will be emitted.
{
if (m_shownUrl == QUrl::fromUserInput(directory)) {
// If the 'trash' icon changes because the trash has been emptied or got filled,
// the signal filesAdded("trash:/") will be emitted.
- for (const QString& fileName : files) {
+ const auto item = changedFileItems.findByUrl(m_shownUrl);
+ if (!item.isNull()) {
+ showItemInfo();
+ }
+}
+
+void InformationPanel::slotFilesChanged(const QStringList &files)
+{
+ for (const QString &fileName : files) {
if (m_shownUrl == QUrl::fromUserInput(fileName)) {
// the currently shown item has been removed, show
// the parent directory as fallback
if (m_shownUrl == QUrl::fromUserInput(fileName)) {
// the currently shown item has been removed, show
// the parent directory as fallback
{
if (m_shownUrl == QUrl::fromUserInput(directory)) {
// The signal 'leftDirectory' is also emitted when a media
{
if (m_shownUrl == QUrl::fromUserInput(directory)) {
// The signal 'leftDirectory' is also emitted when a media
void InformationPanel::init()
{
m_infoTimer = new QTimer(this);
m_infoTimer->setInterval(300);
m_infoTimer->setSingleShot(true);
void InformationPanel::init()
{
m_infoTimer = new QTimer(this);
m_infoTimer->setInterval(300);
m_infoTimer->setSingleShot(true);
- connect(m_infoTimer, &QTimer::timeout,
- this, &InformationPanel::slotInfoTimeout);
+ connect(m_infoTimer, &QTimer::timeout, this, &InformationPanel::slotInfoTimeout);
m_urlChangedTimer = new QTimer(this);
m_urlChangedTimer->setInterval(200);
m_urlChangedTimer->setSingleShot(true);
m_urlChangedTimer = new QTimer(this);
m_urlChangedTimer->setInterval(200);
m_urlChangedTimer->setSingleShot(true);
- connect(m_urlChangedTimer, &QTimer::timeout,
- this, &InformationPanel::showItemInfo);
+ connect(m_urlChangedTimer, &QTimer::timeout, this, &InformationPanel::showItemInfo);
m_resetUrlTimer = new QTimer(this);
m_resetUrlTimer->setInterval(1000);
m_resetUrlTimer->setSingleShot(true);
m_resetUrlTimer = new QTimer(this);
m_resetUrlTimer->setInterval(1000);
m_resetUrlTimer->setSingleShot(true);
- connect(m_resetUrlTimer, &QTimer::timeout,
- this, &InformationPanel::reset);
+ connect(m_resetUrlTimer, &QTimer::timeout, this, &InformationPanel::reset);
Q_ASSERT(m_urlChangedTimer->interval() < m_infoTimer->interval());
Q_ASSERT(m_urlChangedTimer->interval() < m_resetUrlTimer->interval());
Q_ASSERT(m_urlChangedTimer->interval() < m_infoTimer->interval());
Q_ASSERT(m_urlChangedTimer->interval() < m_resetUrlTimer->interval());
- org::kde::KDirNotify* dirNotify = new org::kde::KDirNotify(QString(), QString(),
- QDBusConnection::sessionBus(), this);
+#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::FilesChanged, this, &InformationPanel::slotFilesChanged);
connect(dirNotify, &OrgKdeKDirNotifyInterface::FilesRemoved, this, &InformationPanel::slotFilesRemoved);
connect(dirNotify, &OrgKdeKDirNotifyInterface::enteredDirectory, this, &InformationPanel::slotEnteredDirectory);
connect(dirNotify, &OrgKdeKDirNotifyInterface::leftDirectory, this, &InformationPanel::slotLeftDirectory);
connect(dirNotify, &OrgKdeKDirNotifyInterface::FileRenamed, this, &InformationPanel::slotFileRenamed);
connect(dirNotify, &OrgKdeKDirNotifyInterface::FilesAdded, this, &InformationPanel::slotFilesAdded);
connect(dirNotify, &OrgKdeKDirNotifyInterface::FilesChanged, this, &InformationPanel::slotFilesChanged);
connect(dirNotify, &OrgKdeKDirNotifyInterface::FilesRemoved, this, &InformationPanel::slotFilesRemoved);
connect(dirNotify, &OrgKdeKDirNotifyInterface::enteredDirectory, this, &InformationPanel::slotEnteredDirectory);
connect(dirNotify, &OrgKdeKDirNotifyInterface::leftDirectory, this, &InformationPanel::slotLeftDirectory);
m_content = new InformationPanelContent(this);
connect(m_content, &InformationPanelContent::urlActivated, this, &InformationPanel::urlActivated);
m_content = new InformationPanelContent(this);
connect(m_content, &InformationPanelContent::urlActivated, this, &InformationPanel::urlActivated);
- connect(m_content, &InformationPanelContent::configurationFinished, this, [this]() { m_inConfigurationMode = false; });
+ connect(m_content, &InformationPanelContent::configurationFinished, this, [this]() {
+ m_inConfigurationMode = false;
+ });
+ connect(m_content, &InformationPanelContent::contextMenuRequested, this, &InformationPanel::showContextMenu);
layout->setContentsMargins(0, 0, 0, 0);
layout->addWidget(m_content);
m_initialized = true;
}
layout->setContentsMargins(0, 0, 0, 0);
layout->addWidget(m_content);
m_initialized = true;
}