mirror of
https://gitee.com/vnotex/vnote.git
synced 2025-07-05 05:49:53 +08:00

* 增加git同步功能 * windows下增加图标 * Git操作改为异步 * 优化同步功能 * 更新完成后重新加载当前笔记本 * 上传前关闭所有已打开笔记 * Revert "更新完成后重新加载当前笔记本" This reverts commit 67bf9836b83203093dd71f8df99b903bcaa0adb1. * optimize code * revert VDirectoryTree.h * format code Co-authored-by: musmus9405 <542719479@qq.com>
85 lines
1.6 KiB
C++
85 lines
1.6 KiB
C++
#ifndef _V_SYNC_H_
|
|
#define _V_SYNC_H_
|
|
#include <qstring.h>
|
|
#include <QObject>
|
|
#include <qprocess.h>
|
|
|
|
class QMessageBox;
|
|
class QPushButton;
|
|
class VSync : public QObject
|
|
{
|
|
Q_OBJECT
|
|
private:
|
|
enum class SyncType
|
|
{
|
|
None,
|
|
Status,
|
|
Add,
|
|
Commit,
|
|
Push,
|
|
Pull,
|
|
Authentication
|
|
};
|
|
|
|
enum class SyncTarget
|
|
{
|
|
None,
|
|
Upload,
|
|
Download,
|
|
};
|
|
signals:
|
|
void downloadSuccess();
|
|
void uploadSuccess();
|
|
public:
|
|
VSync(QWidget *parent = NULL);
|
|
~VSync();
|
|
void setDir(const QString &dir);
|
|
void upload();
|
|
void download();
|
|
private slots:
|
|
void onReadOutput();
|
|
void onReadError();
|
|
void onProcessFinish(int exitCode);
|
|
|
|
private:
|
|
void status();
|
|
void add();
|
|
void commit();
|
|
void push();
|
|
void pull();
|
|
void authentication();
|
|
void processDownload();
|
|
void processUpload();
|
|
void downloadFinish();
|
|
void uploadFinish();
|
|
|
|
void start(const QString &cmd);
|
|
void showMessageBox(const QString &message, bool showButton);
|
|
void hideMessageBox();
|
|
void onMessageButtonClick();
|
|
QString VSync::getSyncHead(const QString &args) const;
|
|
|
|
private:
|
|
QString m_dir;
|
|
|
|
QMessageBox *m_messageBox;
|
|
QPushButton *m_messageButton;
|
|
QProcess *m_process;
|
|
SyncType m_type;
|
|
SyncTarget m_target;
|
|
QString m_output;
|
|
QString m_error;
|
|
};
|
|
|
|
inline void VSync::setDir(const QString &dir)
|
|
{
|
|
this->m_dir = dir;
|
|
};
|
|
|
|
inline QString VSync::getSyncHead(const QString &args) const
|
|
{
|
|
return QString("git -C %1 %2").arg(this->m_dir).arg(args);
|
|
}
|
|
|
|
#endif
|