diff --git a/libpeony-qt/controls/property-page/details-properties-page.cpp b/libpeony-qt/controls/property-page/details-properties-page.cpp index a6dde803..55d5aa23 100644 --- a/libpeony-qt/controls/property-page/details-properties-page.cpp +++ b/libpeony-qt/controls/property-page/details-properties-page.cpp @@ -32,6 +32,7 @@ #include #include #include "global-settings.h" +#include "file-watcher.h" using namespace Peony; @@ -43,6 +44,9 @@ DetailsPropertiesPage::DetailsPropertiesPage(const QString &uri, QWidget *parent { m_uri = uri; + m_watcher = std::make_shared(m_uri); + m_watcher->startMonitor(); + m_layout = new QVBoxLayout(this); m_layout->setContentsMargins(0,10,0,0); m_tableWidget = new QTableWidget(this); @@ -239,6 +243,10 @@ void DetailsPropertiesPage::initDetailsPropertiesPage() m_tableWidget->hideRow(m_tableWidget->rowCount() - 1); this->updateFileInfo(m_uri); + connect(m_watcher.get(), &FileWatcher::locationChanged, [=](const QString&, const QString &uri) { + this->updateFileInfo(m_uri); + }); + } DetailsPropertiesPage::~DetailsPropertiesPage() @@ -291,7 +299,6 @@ void DetailsPropertiesPage::updateFileInfo(const QString &uri) nullptr, nullptr); g_object_unref(file); - quint64 timeNum2 = g_file_info_get_attribute_uint64(info,"time::modified"); QDateTime date2 = QDateTime::fromMSecsSinceEpoch(timeNum2*1000); QString time2 = date2.toString(m_systemTimeFormat); diff --git a/libpeony-qt/controls/property-page/details-properties-page.h b/libpeony-qt/controls/property-page/details-properties-page.h index 805fbf0c..2f0d85a3 100644 --- a/libpeony-qt/controls/property-page/details-properties-page.h +++ b/libpeony-qt/controls/property-page/details-properties-page.h @@ -34,6 +34,8 @@ namespace Peony { +class FileWatcher; + class DetailsPropertiesPage : public PropertiesWindowTabIface { Q_OBJECT @@ -63,6 +65,7 @@ class DetailsPropertiesPage : public PropertiesWindowTabIface private: QString m_uri = nullptr; std::shared_ptr m_fileInfo = nullptr; + std::shared_ptr m_watcher; QString m_systemTimeFormat = nullptr; QVBoxLayout *m_layout = nullptr;