1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65
|
#ifndef SYNCTHINGWIDGETS_TEXTVIEWDIALOG_H
#define SYNCTHINGWIDGETS_TEXTVIEWDIALOG_H
#include "../global.h"
#include <QDialog>
#include <functional>
QT_FORWARD_DECLARE_CLASS(QTextBrowser)
QT_FORWARD_DECLARE_CLASS(QVBoxLayout)
namespace Data {
class SyncthingConnection;
struct SyncthingDir;
struct SyncthingLogEntry;
} // namespace Data
namespace QtGui {
class SYNCTHINGWIDGETS_EXPORT TextViewDialog : public QDialog {
Q_OBJECT
public:
explicit TextViewDialog(const QString &title = QString(), QWidget *parent = nullptr);
QTextBrowser *browser();
QVBoxLayout *layout();
void setCloseHandler(std::function<bool(TextViewDialog *)> &&closeHandler);
static TextViewDialog *forLogEntries(Data::SyncthingConnection &connection, QObject *gui = nullptr);
static TextViewDialog *forLogEntries(const std::vector<Data::SyncthingLogEntry> &logEntries, const QString &title = QString());
Q_SIGNALS:
void reload();
void save();
protected:
void keyPressEvent(QKeyEvent *event) override;
void closeEvent(QCloseEvent *event) override;
private:
void showLogEntries(const std::vector<Data::SyncthingLogEntry> &logEntries);
QTextBrowser *m_browser;
QVBoxLayout *m_layout;
std::function<bool(TextViewDialog *)> m_closeHandler;
};
inline QTextBrowser *TextViewDialog::browser()
{
return m_browser;
}
inline QVBoxLayout *TextViewDialog::layout()
{
return m_layout;
}
inline void TextViewDialog::setCloseHandler(std::function<bool(TextViewDialog *)> &&closeHandler)
{
m_closeHandler = std::move(closeHandler);
}
} // namespace QtGui
#endif // SYNCTHINGWIDGETS_TEXTVIEWDIALOG_H
|