made formal QtUtils class

This commit is contained in:
itsmattkc
2020-11-17 09:42:36 +11:00
parent 97a15f2c54
commit e2010dde83
19 changed files with 48 additions and 33 deletions
+9 -1
View File
@@ -22,7 +22,7 @@
OLIVE_NAMESPACE_ENTER
int QFontMetricsWidth(QFontMetrics fm, const QString& s) {
int QtUtils::QFontMetricsWidth(QFontMetrics fm, const QString& s) {
#if QT_VERSION < QT_VERSION_CHECK(5, 11, 0)
return fm.width(s);
#else
@@ -30,4 +30,12 @@ int QFontMetricsWidth(QFontMetrics fm, const QString& s) {
#endif
}
QFrame *QtUtils::CreateHorizontalLine()
{
QFrame* horizontal_line = new QFrame();
horizontal_line->setFrameShape(QFrame::HLine);
horizontal_line->setFrameShadow(QFrame::Sunken);
return horizontal_line;
}
OLIVE_NAMESPACE_EXIT
+15 -8
View File
@@ -28,19 +28,26 @@
*/
#include <QFontMetrics>
#include <QFrame>
#include "common/define.h"
OLIVE_NAMESPACE_ENTER
/**
* @brief Retrieves the width of a string according to certain QFontMetrics
*
* QFontMetrics::width() has been deprecatd in favor of QFontMetrics::horizontalAdvance(), but the
* latter was only introduced in 5.11+. This function wraps the latter for 5.11+ and the former for
* earlier.
*/
int QFontMetricsWidth(QFontMetrics fm, const QString& s);
class QtUtils {
public:
/**
* @brief Retrieves the width of a string according to certain QFontMetrics
*
* QFontMetrics::width() has been deprecatd in favor of QFontMetrics::horizontalAdvance(), but the
* latter was only introduced in 5.11+. This function wraps the latter for 5.11+ and the former for
* earlier.
*/
static int QFontMetricsWidth(QFontMetrics fm, const QString& s);
static QFrame* CreateHorizontalLine();
};
OLIVE_NAMESPACE_EXIT