Add function to determine whether palette is dark
This commit is contained in:
parent
6e5a9419be
commit
0f7a4eb059
|
@ -38,4 +38,14 @@ bool openLocalFileOrDir(const QString &path)
|
||||||
#endif
|
#endif
|
||||||
return QDesktopServices::openUrl(url);
|
return QDesktopServices::openUrl(url);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief Returns whether \a palette is dark.
|
||||||
|
* \remarks Just call with no argument to check for the default palette to see whether "dark mode" is enabled.
|
||||||
|
*/
|
||||||
|
bool isPaletteDark(const QPalette &palette)
|
||||||
|
{
|
||||||
|
return palette.color(QPalette::WindowText).lightness() > palette.color(QPalette::Window).lightness();
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace QtUtilities
|
} // namespace QtUtilities
|
||||||
|
|
|
@ -3,13 +3,15 @@
|
||||||
|
|
||||||
#include "../global.h"
|
#include "../global.h"
|
||||||
|
|
||||||
#include <QtGlobal>
|
#include <QPalette>
|
||||||
|
|
||||||
QT_FORWARD_DECLARE_CLASS(QString)
|
QT_FORWARD_DECLARE_CLASS(QString)
|
||||||
|
|
||||||
namespace QtUtilities {
|
namespace QtUtilities {
|
||||||
|
|
||||||
QT_UTILITIES_EXPORT bool openLocalFileOrDir(const QString &path);
|
QT_UTILITIES_EXPORT bool openLocalFileOrDir(const QString &path);
|
||||||
}
|
QT_UTILITIES_EXPORT bool isPaletteDark(const QPalette &palette = QPalette());
|
||||||
|
|
||||||
|
} // namespace QtUtilities
|
||||||
|
|
||||||
#endif // DESKTOP_UTILS_DESKTOPSERVICES_H
|
#endif // DESKTOP_UTILS_DESKTOPSERVICES_H
|
||||||
|
|
Loading…
Reference in New Issue