3#include <QDesktopServices>
5#if (QT_VERSION >= QT_VERSION_CHECK(6, 5, 0))
6#include <QGuiApplication>
27 QUrl url(QStringLiteral(
"file://"));
32 tmp.replace(QChar(
'\\'), QChar(
'/'));
35 if (QFileInfo(path).isAbsolute()) {
36 tmp = QStringLiteral(
"/") + tmp;
38 url.setPath(tmp, QUrl::DecodedMode);
41 url.setPath(path, QUrl::DecodedMode);
43 return QDesktopServices::openUrl(url);
51 return palette.color(QPalette::WindowText).lightness() > palette.color(QPalette::Window).lightness();
61#if (QT_VERSION >= QT_VERSION_CHECK(6, 5, 0))
62 if (
const auto *
const styleHints = QGuiApplication::styleHints()) {
63 const auto colorScheme = styleHints->colorScheme();
64 if (colorScheme != Qt::ColorScheme::Unknown) {
65 return colorScheme == Qt::ColorScheme::Dark;
QT_UTILITIES_EXPORT std::optional< bool > isDarkModeEnabled()
Returns whether dark mode is enabled.
QT_UTILITIES_EXPORT bool isPaletteDark(const QPalette &palette=QPalette())
Returns whether palette is dark.
QT_UTILITIES_EXPORT bool openLocalFileOrDir(const QString &path)
Shows the specified file or directory using the default file browser.