hotfix bug#188622 【文件管理器】连接共享文件夹后进行压缩/解压缩操作,需要手动刷新后才会显示

This commit is contained in:
yangling 2023-09-06 18:27:19 +08:00 committed by Yue-Lan
parent 36092db4ab
commit 651c979e6e
4 changed files with 69 additions and 3 deletions

55
libpeony-qt/file-operation/file-operation-manager.cpp Normal file → Executable file
View File

@ -29,6 +29,8 @@
#include <QApplication> #include <QApplication>
#include <QTimer> #include <QTimer>
#include <QtConcurrent> #include <QtConcurrent>
#include <QDBusInterface>
#include <QDBusConnection>
#include "file-copy-operation.h" #include "file-copy-operation.h"
#include "file-delete-operation.h" #include "file-delete-operation.h"
@ -90,10 +92,33 @@ FileOperationManager::FileOperationManager(QObject *parent) : QObject(parent)
if (pconnection) { if (pconnection) {
g_dbus_connection_signal_subscribe(pconnection, "org.freedesktop.login1", "org.freedesktop.login1.Manager", "PrepareForSleep", "/org/freedesktop/login1", NULL, G_DBUS_SIGNAL_FLAGS_NONE, systemSleep, this, NULL); g_dbus_connection_signal_subscribe(pconnection, "org.freedesktop.login1", "org.freedesktop.login1.Manager", "PrepareForSleep", "/org/freedesktop/login1", NULL, G_DBUS_SIGNAL_FLAGS_NONE, systemSleep, this, NULL);
} }
QDBusConnection conn = QDBusConnection::sessionBus();
if (!conn.isConnected()) {
qCritical()<<"failed to init mDbusDateServer, can not connect to session dbus";
return;
}
m_iface = new QDBusInterface("org.ukui.peony", "/org/ukui/peony", "org.ukui.peony", QDBusConnection::sessionBus());
if (!m_iface->isValid()){
qCritical() << "Create /org/ukui/peony Interface Failed " << QDBusConnection::sessionBus().lastError();
return;
}
QDBusConnection::sessionBus().connect("org.ukui.peony",
"/org/ukui/peony",
"org.ukui.peony",
"opreateFinishedOfEngrampa",
this,
SLOT(slot_opreateFinishedOfEngrampa(QString, bool)));
} }
FileOperationManager::~FileOperationManager() FileOperationManager::~FileOperationManager()
{ {
if(m_iface){
delete m_iface;
m_iface = nullptr;
}
} }
@ -818,6 +843,36 @@ void FileOperationManager::manuallyNotifyDirectoryChanged(FileOperationInfo *inf
} }
} }
void FileOperationManager::slot_opreateFinishedOfEngrampa(const QString &path, bool finish)
{
if(!finish || path.isEmpty())
return;
if(!path.startsWith("smb://") && !path.startsWith("ftp://") && !path.startsWith("sftp://"))
return;
for (auto watcher : m_watchers) {
if(watcher->supportMonitor())
continue;
QString watcherUri = watcher->currentUri();
//'file:///run/user/1000/gvfs/smb-share:server=xxx,share=xxx/' converted to 'smb://xxx'
if(watcherUri.startsWith("file:///run/user/1000/gvfs/smb-share:")){
GFile * file = g_file_new_for_uri(watcherUri.toUtf8().data());
char *uri = g_file_get_uri(file);
if (uri) {
watcherUri = uri;
}
g_object_unref(file);
g_free(uri);
}
//auto watcherDecodeUri = FileUtils::urlDecode(watcherUri);
//auto destDecodePath = FileUtils::urlDecode(path);
if (watcherUri == path || watcherUri == path + QString("/")){
watcher->requestUpdateDirectory();
}
}
}
//FIXME: get opposite info correcty. //FIXME: get opposite info correcty.
FileOperationInfo::FileOperationInfo(QStringList srcUris, FileOperationInfo::FileOperationInfo(QStringList srcUris,
QString destDirUri, QString destDirUri,

6
libpeony-qt/file-operation/file-operation-manager.h Normal file → Executable file
View File

@ -36,7 +36,7 @@
#include "peony-core_global.h" #include "peony-core_global.h"
#include "file-operation-progress-bar.h" #include "file-operation-progress-bar.h"
#include "file-operation-error-dialogs.h" #include "file-operation-error-dialogs.h"
class QDBusInterface;
namespace Peony { namespace Peony {
@ -134,6 +134,9 @@ public Q_SLOTS:
* not support monitoring. * not support monitoring.
*/ */
void manuallyNotifyDirectoryChanged(FileOperationInfo *info); void manuallyNotifyDirectoryChanged(FileOperationInfo *info);
void slot_opreateFinishedOfEngrampa(const QString& path, bool finish);/* hotfix bug#188622 【文件管理器】连接共享文件夹后进行压缩/解压缩操作,需要手动刷新后才会显示 */
private: private:
explicit FileOperationManager(QObject *parent = nullptr); explicit FileOperationManager(QObject *parent = nullptr);
~FileOperationManager(); ~FileOperationManager();
@ -160,6 +163,7 @@ private:
QStack<std::shared_ptr<FileOperationInfo>> m_redo_stack; QStack<std::shared_ptr<FileOperationInfo>> m_redo_stack;
QHash<QString, totalOperationInfo> *m_mount_operation_list = nullptr; QHash<QString, totalOperationInfo> *m_mount_operation_list = nullptr;
QHash<FileOperation*, currentOpertionInfo> *m_operation_use_list = nullptr; QHash<FileOperation*, currentOpertionInfo> *m_operation_use_list = nullptr;
QDBusInterface* m_iface = nullptr;
}; };
class FileOperationInfo : public QObject class FileOperationInfo : public QObject

5
peony-qt-desktop/peony-dbus-service.cpp Normal file → Executable file
View File

@ -91,3 +91,8 @@ QStringList PeonyDbusService::getBWListInfo()
qDebug() << "getBWListInfo in service:"<<info; qDebug() << "getBWListInfo in service:"<<info;
return info.toList(); return info.toList();
} }
void PeonyDbusService::sendEngrampaOpreateFinishSig(const QString &path, bool finish)
{
Q_EMIT opreateFinishedOfEngrampa(path, finish);
}

2
peony-qt-desktop/peony-dbus-service.h Normal file → Executable file
View File

@ -56,6 +56,7 @@ public:
Q_SIGNALS: Q_SIGNALS:
void sendSrcAndDestUrisOfCopyDspsFiles(const QStringList& sourceUris, const QStringList& destUris); void sendSrcAndDestUrisOfCopyDspsFiles(const QStringList& sourceUris, const QStringList& destUris);
void black_and_white_update(); void black_and_white_update();
void opreateFinishedOfEngrampa(const QString& path, bool finish);/* 第一个参数是解压/压缩的路径,第二个参数是操作是否完成;该信号用于归档管理器进行解压/压缩完成后通知文管 */
public Q_SLOTS: public Q_SLOTS:
QString GetSecurityConfigPath(); QString GetSecurityConfigPath();
@ -64,6 +65,7 @@ public Q_SLOTS:
QString getBlackAndWhiteModel(); QString getBlackAndWhiteModel();
bool getBlackAndWhiteListExist(QString name); bool getBlackAndWhiteListExist(QString name);
QStringList getBWListInfo(); QStringList getBWListInfo();
void sendEngrampaOpreateFinishSig(const QString& path, bool finish);
private: private:
DesktopIconView *m_desktopIconView = nullptr; DesktopIconView *m_desktopIconView = nullptr;