2017-02-20 18:37:11 +01:00
|
|
|
#ifndef SYNCTHINGFILEITEMACTION_H
|
|
|
|
#define SYNCTHINGFILEITEMACTION_H
|
|
|
|
|
|
|
|
#include "../connector/syncthingconnection.h"
|
|
|
|
|
|
|
|
#include <KAbstractFileItemActionPlugin>
|
2017-03-11 19:57:49 +01:00
|
|
|
#include <KFileItemListProperties>
|
|
|
|
|
2017-04-08 14:27:15 +02:00
|
|
|
#include <QWidgetAction>
|
2017-02-20 18:37:11 +01:00
|
|
|
|
|
|
|
QT_FORWARD_DECLARE_CLASS(QWidget)
|
|
|
|
|
|
|
|
class KFileItemListProperties;
|
|
|
|
|
2017-05-01 03:34:43 +02:00
|
|
|
class SyncthingMenuAction : public QAction {
|
2017-03-11 19:57:49 +01:00
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
public:
|
2017-05-01 03:34:43 +02:00
|
|
|
SyncthingMenuAction(const KFileItemListProperties &properties = KFileItemListProperties(), const QList<QAction *> &actions = QList<QAction *>(),
|
|
|
|
QWidget *parentWidget = nullptr);
|
2017-03-11 19:57:49 +01:00
|
|
|
|
|
|
|
public Q_SLOTS:
|
|
|
|
void updateStatus(Data::SyncthingStatus status);
|
|
|
|
|
|
|
|
private:
|
|
|
|
KFileItemListProperties m_properties;
|
|
|
|
};
|
|
|
|
|
2017-05-01 03:34:43 +02:00
|
|
|
class SyncthingInfoAction : public QWidgetAction {
|
2017-04-08 14:27:15 +02:00
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
public:
|
|
|
|
SyncthingInfoAction(QObject *parent = nullptr);
|
|
|
|
|
|
|
|
protected:
|
2018-10-10 21:26:46 +02:00
|
|
|
QWidget *createWidget(QWidget *parent) override;
|
2017-04-08 14:27:15 +02:00
|
|
|
};
|
|
|
|
|
2017-05-01 03:34:43 +02:00
|
|
|
class SyncthingDirActions : public QObject {
|
2017-03-13 00:40:48 +01:00
|
|
|
Q_OBJECT
|
2017-05-01 03:34:43 +02:00
|
|
|
friend QList<QAction *> &operator<<(QList<QAction *> &, SyncthingDirActions &);
|
2017-03-13 00:40:48 +01:00
|
|
|
|
|
|
|
public:
|
|
|
|
SyncthingDirActions(const Data::SyncthingDir &dir, QObject *parent = nullptr);
|
|
|
|
|
|
|
|
public Q_SLOTS:
|
|
|
|
void updateStatus(const std::vector<Data::SyncthingDir> &dirs);
|
|
|
|
bool updateStatus(const Data::SyncthingDir &dir);
|
|
|
|
|
|
|
|
private:
|
|
|
|
QString m_dirId;
|
|
|
|
QAction m_infoAction;
|
2017-04-08 14:27:15 +02:00
|
|
|
SyncthingInfoAction m_statusAction;
|
2017-08-30 00:36:49 +02:00
|
|
|
SyncthingInfoAction m_globalStatusAction;
|
|
|
|
SyncthingInfoAction m_localStatusAction;
|
2017-04-08 14:27:15 +02:00
|
|
|
SyncthingInfoAction m_lastScanAction;
|
|
|
|
SyncthingInfoAction m_rescanIntervalAction;
|
2017-08-30 00:36:49 +02:00
|
|
|
SyncthingInfoAction m_errorsAction;
|
2017-03-13 00:40:48 +01:00
|
|
|
};
|
|
|
|
|
2017-05-01 03:34:43 +02:00
|
|
|
QList<QAction *> &operator<<(QList<QAction *> &actions, SyncthingDirActions &dirActions);
|
2017-03-13 00:40:48 +01:00
|
|
|
|
2017-05-01 03:34:43 +02:00
|
|
|
class SyncthingFileItemAction : public KAbstractFileItemActionPlugin {
|
2017-02-20 18:37:11 +01:00
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
public:
|
2017-05-01 03:34:43 +02:00
|
|
|
SyncthingFileItemAction(QObject *parent, const QVariantList &args);
|
2017-02-20 18:37:11 +01:00
|
|
|
QList<QAction *> actions(const KFileItemListProperties &fileItemInfo, QWidget *parentWidget) override;
|
2017-03-11 19:57:49 +01:00
|
|
|
static Data::SyncthingConnection &connection();
|
|
|
|
static QList<QAction *> createActions(const KFileItemListProperties &fileItemInfo, QWidget *parentWidget);
|
2017-02-20 18:37:11 +01:00
|
|
|
|
|
|
|
private Q_SLOTS:
|
|
|
|
static void logConnectionStatus();
|
2017-03-27 11:12:06 +02:00
|
|
|
static void logConnectionError(const QString &errorMessage, Data::SyncthingErrorCategory errorCategory);
|
2017-02-20 18:37:11 +01:00
|
|
|
static void rescanDir(const QString &dirId, const QString &relpath = QString());
|
|
|
|
static void showAboutDialog();
|
|
|
|
|
|
|
|
private:
|
|
|
|
static Data::SyncthingConnection s_connection;
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif // SYNCTHINGFILEITEMACTION_H
|