syncthingtray/fileitemactionplugin/syncthingfileitemactionstaticdata.h
Martchus 975e86c895 Allow backend libraries to be used from other projects
So far the backend libraries' include paths were relative within this
repository. This means the header files could not be used at their
installed location.

This change replaces them with "<>" includes to fix that problem and adds
a new include directory so building everything at once still works.

With this change it should be easier to actually split some parts into
another repository if this one would become too big.
2021-01-25 19:48:11 +01:00

98 lines
3.1 KiB
C++

#ifndef SYNCTHINGFILEITEMACTIONSTATICDATA_H
#define SYNCTHINGFILEITEMACTIONSTATICDATA_H
#include <syncthingconnector/syncthingconnection.h>
/*!
* \brief The SyncthingFileItemActionStaticData class holds objects required during the whole application's live time.
*
* For instance the connection to Syncthing is kept alive until Dolphin is closed to prevent re-establishing it on each and
* every time the context menu is shown.
*/
class SyncthingFileItemActionStaticData : public QObject {
Q_OBJECT
Q_PROPERTY(QString configPath READ configPath)
Q_PROPERTY(bool useBrightCustomColors READ isUsingBrightCustomColors)
Q_PROPERTY(QString currentError READ currentError WRITE setCurrentError NOTIFY currentErrorChanged RESET clearCurrentError)
Q_PROPERTY(bool hasError READ hasError NOTIFY hasErrorChanged)
Q_PROPERTY(bool initialized READ isInitialized)
public:
explicit SyncthingFileItemActionStaticData();
Data::SyncthingConnection &connection();
const Data::SyncthingConnection &connection() const;
const QString &configPath() const;
bool isUsingBrightCustomColors() const;
const QString &currentError() const;
bool hasError() const;
bool isInitialized() const;
public Q_SLOTS:
void initialize();
bool applySyncthingConfiguration(const QString &syncthingConfigFilePath, const QString &syncthingApiKey, bool skipSavingConfig);
void applyBrightCustomColorsSetting(bool useBrightCustomColors, bool skipSavingConfig);
void logConnectionStatus();
void logConnectionError(const QString &errorMessage, Data::SyncthingErrorCategory errorCategory);
void rescanDir(const QString &dirId, const QString &relpath = QString());
static void showAboutDialog();
void selectSyncthingConfig();
void handleBrightCustomColorsChanged();
void setCurrentError(const QString &currentError);
void clearCurrentError();
Q_SIGNALS:
void currentErrorChanged(const QString &error);
void hasErrorChanged(bool hasError);
private:
void appendNoteToError(QString &errorMessage, const QString &newSyncthingConfigFilePath) const;
Data::SyncthingConnection m_connection;
QString m_configFilePath;
QString m_currentError;
bool m_useBrightCustomColors;
bool m_initialized;
};
inline Data::SyncthingConnection &SyncthingFileItemActionStaticData::connection()
{
return m_connection;
}
inline const Data::SyncthingConnection &SyncthingFileItemActionStaticData::connection() const
{
return m_connection;
}
inline const QString &SyncthingFileItemActionStaticData::configPath() const
{
return m_configFilePath;
}
inline bool SyncthingFileItemActionStaticData::isUsingBrightCustomColors() const
{
return m_useBrightCustomColors;
}
inline const QString &SyncthingFileItemActionStaticData::currentError() const
{
return m_currentError;
}
inline bool SyncthingFileItemActionStaticData::hasError() const
{
return !currentError().isEmpty();
}
inline bool SyncthingFileItemActionStaticData::isInitialized() const
{
return m_initialized;
}
inline void SyncthingFileItemActionStaticData::clearCurrentError()
{
m_currentError.clear();
}
#endif // SYNCTHINGFILEITEMACTIONSTATICDATA_H