mirror of
https://github.com/saitohirga/WSJT-X.git
synced 2024-11-04 08:21:17 -05:00
873b1d1c43
Includes a new settings facility with the highlighting being contrled by a new model class and a modified QListView to display the data for editing. Edits include enable and disable check boxes, a contextual pop-up menu to adjust backkground and foreground colours. Still to be implemented are priorities for highlighting categories. This will be adjustable by drag and drop in the Colors settings panel, it is already implemented by the priority order has no effect on highlighting of decodes yet. The LotW users data file fetch and time since user's last upload is now controled from the settings dialog. This change also drops support for Qt versions before 5.5 so that many workarounds for earlier versions can be removed. Debug trace is slightly modified to make better use of the Qt built in facilities to format and synchronize cross thread messaging.
84 lines
2.3 KiB
C++
84 lines
2.3 KiB
C++
#ifndef QT_HELPERS_HPP_
|
|
#define QT_HELPERS_HPP_
|
|
|
|
#include <stdexcept>
|
|
|
|
#include <QString>
|
|
#include <QMetaObject>
|
|
#include <QHostAddress>
|
|
#include <QDataStream>
|
|
#include <QMetaType>
|
|
#include <QMetaEnum>
|
|
|
|
#define ENUM_QDATASTREAM_OPS_DECL(CLASS, ENUM) \
|
|
QDataStream& operator << (QDataStream&, CLASS::ENUM const&); \
|
|
QDataStream& operator >> (QDataStream&, CLASS::ENUM&);
|
|
|
|
#define ENUM_QDATASTREAM_OPS_IMPL(CLASS, ENUM) \
|
|
QDataStream& operator << (QDataStream& os, CLASS::ENUM const& v) \
|
|
{ \
|
|
auto const& mo = CLASS::staticMetaObject; \
|
|
return os << mo.enumerator (mo.indexOfEnumerator (#ENUM)).valueToKey (static_cast<int> (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_CONVERSION_OPS_DECL(CLASS, ENUM) \
|
|
QString enum_to_qstring (CLASS::ENUM const&);
|
|
|
|
#define ENUM_CONVERSION_OPS_IMPL(CLASS, ENUM) \
|
|
QString enum_to_qstring (CLASS::ENUM const& m) \
|
|
{ \
|
|
auto const& mo = CLASS::staticMetaObject; \
|
|
return QString {mo.enumerator (mo.indexOfEnumerator (#ENUM)).valueToKey (static_cast<int> (m))}; \
|
|
}
|
|
|
|
inline
|
|
void throw_qstring (QString const& qs)
|
|
{
|
|
throw std::runtime_error {qs.toLocal8Bit ().constData ()};
|
|
}
|
|
|
|
QString font_as_stylesheet (QFont const&);
|
|
|
|
// do what is necessary to change a dynamic property and trigger any
|
|
// conditional style sheet updates
|
|
void update_dynamic_property (QWidget *, char const * property, QVariant const& value);
|
|
|
|
template <class T>
|
|
class VPtr
|
|
{
|
|
public:
|
|
static T * asPtr (QVariant v)
|
|
{
|
|
return reinterpret_cast<T *> (v.value<void *> ());
|
|
}
|
|
|
|
static QVariant asQVariant(T * ptr)
|
|
{
|
|
return qVariantFromValue (reinterpret_cast<void *> (ptr));
|
|
}
|
|
};
|
|
|
|
// Register some useful Qt types with QMetaType
|
|
Q_DECLARE_METATYPE (QHostAddress);
|
|
|
|
#endif
|