Qt Utilities 6.22.0
Common Qt related C++ classes and routines used by my applications such as dialogs, widgets and models
Loading...
Searching...
No Matches
desktoputils.h
Go to the documentation of this file.
1#ifndef DESKTOP_UTILS_DESKTOPSERVICES_H
2#define DESKTOP_UTILS_DESKTOPSERVICES_H
3
4#include "../global.h"
5
6#include <QMetaObject>
7#include <QPalette>
8
9#include <functional>
10#include <optional>
11
12QT_FORWARD_DECLARE_CLASS(QObject)
13QT_FORWARD_DECLARE_CLASS(QString)
14
15#ifdef Q_OS_ANDROID
16#define QT_UTILITIES_DARK_MODE_FROM_COLOR_SCHEME
17#endif
18#ifdef QT_UTILITIES_DARK_MODE_FROM_COLOR_SCHEME
19#define QT_UTILITIES_IS_PALETTE_DARK(palette) false
20#else
21#define QT_UTILITIES_IS_PALETTE_DARK(palette) QtUtilities::isPaletteDark(palette)
22#endif
23
24namespace QtUtilities {
25
26enum class ToastDuration { Short, Long };
27
28QT_UTILITIES_EXPORT bool openLocalFileOrDir(const QString &path);
29QT_UTILITIES_EXPORT bool showToast(const QString &message, ToastDuration duration = ToastDuration::Long);
31QT_UTILITIES_EXPORT bool isPaletteDark(const QPalette &palette = QPalette());
32QT_UTILITIES_EXPORT std::optional<bool> isDarkModeEnabled();
33QT_UTILITIES_EXPORT QMetaObject::Connection onDarkModeChanged(
34 std::function<void(bool)> &&darkModeChangedCallback, QObject *context = nullptr, bool invokeImmediately = true);
35
36} // namespace QtUtilities
37
38#endif // DESKTOP_UTILS_DESKTOPSERVICES_H
#define QT_UTILITIES_EXPORT
Marks the symbol to be exported by the qtutilities library.
Definition global.h:14
QT_UTILITIES_EXPORT bool performHapticFeedback()
QT_UTILITIES_EXPORT QMetaObject::Connection onDarkModeChanged(std::function< void(bool)> &&darkModeChangedCallback, QObject *context=nullptr, bool invokeImmediately=true)
Invokes the specified callback when the color scheme changed.
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)
\macro QT_UTILITIES_DARK_MODE_FROM_COLOR_SCHEME
QT_UTILITIES_EXPORT bool showToast(const QString &message, ToastDuration duration=ToastDuration::Long)