Phosphor
Qt6 / Wayland library suite for window-management tools
 
Loading...
Searching...
No Matches
FileView.h
Go to the documentation of this file.
1// SPDX-FileCopyrightText: 2026 fuddlesworth
2// SPDX-License-Identifier: LGPL-2.1-or-later
3
4#pragma once
5
6#include <PhosphorShell/phosphorshell_export.h>
7
8#include <QObject>
9#include <QString>
10
11QT_BEGIN_NAMESPACE
12class QFileSystemWatcher;
13class QTimer;
14QT_END_NAMESPACE
15
16namespace PhosphorShell {
17
18class PHOSPHORSHELL_EXPORT FileView : public QObject
19{
20 Q_OBJECT
21
22 Q_PROPERTY(QString path READ path WRITE setPath NOTIFY pathChanged)
23 Q_PROPERTY(QString content READ content NOTIFY contentChanged)
24 Q_PROPERTY(int interval READ interval WRITE setInterval NOTIFY intervalChanged)
25 Q_PROPERTY(bool exists READ exists NOTIFY existsChanged)
26
27public:
28 explicit FileView(QObject* parent = nullptr);
29 ~FileView() override;
30
31 [[nodiscard]] QString path() const;
32 void setPath(const QString& path);
33
34 [[nodiscard]] QString content() const;
35
36 [[nodiscard]] int interval() const;
37 void setInterval(int interval);
38
39 [[nodiscard]] bool exists() const;
40
41Q_SIGNALS:
46
47private Q_SLOTS:
48 void readFile();
49 void onFileChanged();
50 void onDirectoryChanged();
51
52private:
53 void setupWatcher();
54 void setupTimer();
55
56 QString m_path;
57 QString m_content;
58 int m_interval = 0;
59 bool m_exists = false;
60 QFileSystemWatcher* m_watcher = nullptr;
61 QTimer* m_timer = nullptr;
62};
63
64} // namespace PhosphorShell
Definition FileView.h:19
FileView(QObject *parent=nullptr)
QString content() const
QString path() const
void setPath(const QString &path)
void setInterval(int interval)
Definition Environment.h:11