mirror of
https://github.com/saitohirga/WSJT-X.git
synced 2024-11-22 20:28:42 -05:00
31ebdc9618
The new class WFPalette encapsulates waterfall palettes including exporting and importing to disk files and interpolation for use in the waterfall plotter. A special entry in the palette list "User Defined" is now available along with a button to invoke a colour palette designer. The user defined palette definition is persistent across runs as it is saved in the application settings file. Palettes can now have any number of colours up to 256. The export function may be used to save user designed palettes; to be added to the built in resource palettes that are shipped with the application. git-svn-id: svn+ssh://svn.code.sf.net/p/wsjt/wsjt/branches/wsjtx@3964 ab8295b8-cf94-4d9e-aec4-7959e3be5d79
70 lines
2.0 KiB
C++
70 lines
2.0 KiB
C++
#ifndef QT_HELPERS_HPP_
|
|
#define QT_HELPERS_HPP_
|
|
|
|
#include <stdexcept>
|
|
|
|
#include <QDataStream>
|
|
#include <QMetaObject>
|
|
#include <QMetaEnum>
|
|
#include <QString>
|
|
#include <QByteArray>
|
|
#include <QDebug>
|
|
|
|
#define ENUM_QDATASTREAM_OPS_DECL(CLASS, ENUM) \
|
|
QDataStream& operator << (QDataStream&, CLASS::ENUM); \
|
|
QDataStream& operator >> (QDataStream&, CLASS::ENUM&);
|
|
|
|
#define ENUM_QDATASTREAM_OPS_IMPL(CLASS, ENUM) \
|
|
QDataStream& operator << (QDataStream& os, CLASS::ENUM v) \
|
|
{ \
|
|
auto const& mo = CLASS::staticMetaObject; \
|
|
return os << mo.enumerator (mo.indexOfEnumerator (#ENUM)).valueToKey (v); \
|
|
} \
|
|
\
|
|
QDataStream& operator >> (QDataStream& is, CLASS::ENUM& v) \
|
|
{ \
|
|
char * buffer; \
|
|
is >> buffer; \
|
|
bool ok {false}; \
|
|
auto const& mo = CLASS::staticMetaObject; \
|
|
auto const& me = mo.enumerator (mo.indexOfEnumerator (#ENUM)); \
|
|
if (buffer) \
|
|
{ \
|
|
v = static_cast<CLASS::ENUM> (me.keyToValue (buffer, &ok)); \
|
|
delete [] buffer; \
|
|
} \
|
|
if (!ok) \
|
|
{ \
|
|
v = static_cast<CLASS::ENUM> (me.value (0)); \
|
|
} \
|
|
return is; \
|
|
}
|
|
|
|
#define ENUM_QDEBUG_OPS_DECL(CLASS, ENUM) \
|
|
QDebug operator << (QDebug, CLASS::ENUM);
|
|
|
|
#define ENUM_QDEBUG_OPS_IMPL(CLASS, ENUM) \
|
|
QDebug operator << (QDebug d, CLASS::ENUM m) \
|
|
{ \
|
|
auto const& mo = CLASS::staticMetaObject; \
|
|
return d << mo.enumerator (mo.indexOfEnumerator (#ENUM)).valueToKey (m); \
|
|
}
|
|
|
|
#define ENUM_CONVERSION_OPS_DECL(CLASS, ENUM) \
|
|
QString enum_to_qstring (CLASS::ENUM);
|
|
|
|
#define ENUM_CONVERSION_OPS_IMPL(CLASS, ENUM) \
|
|
QString enum_to_qstring (CLASS::ENUM m) \
|
|
{ \
|
|
auto const& mo = CLASS::staticMetaObject; \
|
|
return QString {mo.enumerator (mo.indexOfEnumerator (#ENUM)).valueToKey (m)}; \
|
|
}
|
|
|
|
inline
|
|
void throw_qstring (QString const& qs)
|
|
{
|
|
throw std::runtime_error (qs.toLocal8Bit ().data ());
|
|
}
|
|
|
|
#endif
|