mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-07-23 06:09:50 -06:00
DolphinQt: Remove another usage of QFontMetrics::width
QFontMetrics::width breaks building with CMake on Windows, due to a deprecation warning which gets promoted to an error.
This commit is contained in:
20
Source/Core/DolphinQt/QtUtils/FontMetricsHelper.h
Normal file
20
Source/Core/DolphinQt/QtUtils/FontMetricsHelper.h
Normal file
@ -0,0 +1,20 @@
|
||||
// Copyright 2020 Dolphin Emulator Project
|
||||
// Licensed under GPLv2+
|
||||
// Refer to the license.txt file included.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <utility>
|
||||
|
||||
#include <QFontMetrics>
|
||||
|
||||
// This exists purely to get rid of deprecation warnings while still supporting older Qt versions
|
||||
template <typename... Args>
|
||||
int FontMetricsWidth(const QFontMetrics& fm, Args&&... args)
|
||||
{
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(5, 11, 0)
|
||||
return fm.horizontalAdvance(std::forward<Args>(args)...);
|
||||
#else
|
||||
return fm.width(std::forward<Args>(args)...);
|
||||
#endif
|
||||
}
|
Reference in New Issue
Block a user