mirror of
https://github.com/saitohirga/WSJT-X.git
synced 2024-11-16 09:01:59 -05:00
127c633a97
Colours behave like other configuration items and changes are only applied when the Settings UI is dismissed via the "OK" button. Simplified font settings and use style sheets consistently to set the application and decoded text fonts. This is necessary because any UI widget that has a style sheet applied does not honor a font set by QWidget::setFont() even if there is no font setting in the style sheet, this is broken behaviour IMHO but that is the way Qt currently works. Use a style sheet to style the frequency display and clock. This is necessary to allow fonts to be cascaded through parent style sheets and still be overridden on these widgets. Simplify the decoded text widgets, there is no need to use the QTextBrowser as a super class since the simpler QTextEdit set as read-only is sufficient. Also removed colour setting via a background brush as it doesn't work and the HTML 'bgcolor' attribute works correctly. Change to UI properties of the decoded text widgets to allow horizontal scrolling if required, this allows larger fonts to be used without truncating decoded messages. git-svn-id: svn+ssh://svn.code.sf.net/p/wsjt/wsjt/branches/wsjtx@4957 ab8295b8-cf94-4d9e-aec4-7959e3be5d79
72 lines
2.0 KiB
C++
72 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 ());
|
|
}
|
|
|
|
QString font_as_stylesheet (QFont const&);
|
|
|
|
#endif
|