File valuehandler.h#
File List > src > utils > valuehandler.h
Go to the documentation of this file.
#pragma once
#include "src/widgets/capture/capturetoolbutton.h"
#include "src/widgets/colorpickerwidget.h"
#include <QColor>
#include <QList>
#include <QString>
class QVariant;
class ValueHandler
{
public:
virtual bool check(const QVariant& val) = 0;
QVariant value(const QVariant& val);
virtual QVariant fallback();
virtual QVariant representation(const QVariant& val);
virtual QString expected();
protected:
virtual QVariant process(const QVariant& val);
};
class Bool : public ValueHandler
{
public:
Bool(bool def);
bool check(const QVariant& val) override;
QVariant fallback() override;
QString expected() override;
private:
bool m_def;
};
class String : public ValueHandler
{
public:
String(QString def);
bool check(const QVariant&) override;
QVariant fallback() override;
QString expected() override;
private:
QString m_def;
};
class Color : public ValueHandler
{
public:
Color(QColor def);
bool check(const QVariant& val) override;
QVariant process(const QVariant& val) override;
QVariant fallback() override;
QVariant representation(const QVariant& val) override;
QString expected() override;
private:
QColor m_def;
};
class BoundedInt : public ValueHandler
{
public:
BoundedInt(int min, int max, int def);
bool check(const QVariant& val) override;
virtual QVariant fallback() override;
QString expected() override;
private:
int m_min, m_max, m_def;
};
class LowerBoundedInt : public ValueHandler
{
public:
LowerBoundedInt(int min, int def);
bool check(const QVariant& val) override;
QVariant fallback() override;
QString expected() override;
private:
int m_min, m_def;
};
class KeySequence : public ValueHandler
{
public:
KeySequence(const QKeySequence& fallback = {});
bool check(const QVariant& val) override;
QVariant fallback() override;
QString expected() override;
QVariant representation(const QVariant& val) override;
private:
QKeySequence m_fallback;
QVariant process(const QVariant& val) override;
};
class ExistingDir : public ValueHandler
{
bool check(const QVariant& val) override;
QVariant fallback() override;
QString expected() override;
};
class FilenamePattern : public ValueHandler
{
bool check(const QVariant&) override;
QVariant fallback() override;
QVariant process(const QVariant&) override;
QString expected() override;
};
class ButtonList : public ValueHandler
{
public:
bool check(const QVariant& val) override;
QVariant process(const QVariant& val) override;
QVariant fallback() override;
QVariant representation(const QVariant& val) override;
QString expected() override;
// UTILITY FUNCTIONS
static QList<CaptureTool::Type> fromIntList(const QList<int>&);
static QList<int> toIntList(const QList<CaptureTool::Type>& l);
static bool normalizeButtons(QList<int>& buttons);
};
class UserColors : public ValueHandler
{
public:
UserColors(int min, int max);
bool check(const QVariant& val) override;
QVariant process(const QVariant& val) override;
QVariant fallback() override;
QString expected() override;
QVariant representation(const QVariant& val) override;
private:
int m_min, m_max;
};
class SaveFileExtension : public ValueHandler
{
bool check(const QVariant& val) override;
QVariant process(const QVariant& val) override;
QString expected() override;
};
class Region : public ValueHandler
{
public:
bool check(const QVariant& val) override;
private:
QVariant process(const QVariant& val) override;
};