dde-dock/plugins/trash/trashhelper.h
tsic404 223a9df0d7 fix: incorrect trash status when deleting file in other partition
The old implementation only monitor the trash folder in user's partition
It will make other partition's recycle bin out of monitor,
Now use GIO to monitor all trash and empty trash

log: Fix the trash icon status might out-of-sync in some cases
2023-05-31 03:21:28 +00:00

34 lines
773 B
C++

// SPDX-FileCopyrightText: 2023 UnionTech Software Technology Co., Ltd.
//
// SPDX-License-Identifier: LGPL-3.0-or-later
#pragma once
#include <QObject>
#undef signals
#include <gio/gio.h>
#define signals Q_SIGNALS
class TrashHelper: public QObject
{
Q_OBJECT
public:
explicit TrashHelper(QObject * parent);
~TrashHelper();
int trashItemCount();
bool emptyTrash();
Q_SIGNALS:
void trashAttributeChanged();
private:
GFile * m_trash;
GFileMonitor * m_trashMonitor;
void onTrashMonitorChanged(GFileMonitor *monitor, GFile *file, GFile *other_file, GFileMonitorEvent event_type);
static void slot_onTrashMonitorChanged(GFileMonitor *monitor, GFile *file, GFile *other_file, GFileMonitorEvent event_type, gpointer user_data);
};