Qt Utilities: misc/desktoputils.h Source File

Qt Utilities 6.22.1 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
26 enum class ToastDuration { Short, Long };
27
28 QT_UTILITIES_EXPORT bool openLocalFileOrDir(const QString &path);
29 QT_UTILITIES_EXPORT bool showToast(const QString &message, ToastDuration duration = ToastDuration::Long);
30 QT_UTILITIES_EXPORT bool performHapticFeedback();
31 QT_UTILITIES_EXPORT bool isPaletteDark(const QPalette &palette = QPalette());
32 QT_UTILITIES_EXPORT std::optional<bool> isDarkModeEnabled();
33 QT_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
global.h
QT_UTILITIES_EXPORT
#define QT_UTILITIES_EXPORT
Marks the symbol to be exported by the qtutilities library.
Definition global.h:14
QtUtilities
!
Definition trylocker.h:8
QtUtilities::ToastDuration
ToastDuration
Definition desktoputils.h:26
QtUtilities::ToastDuration::Short
@ Short
Definition desktoputils.h:26
QtUtilities::ToastDuration::Long
@ Long
Definition desktoputils.h:26
QtUtilities::performHapticFeedback
QT_UTILITIES_EXPORT bool performHapticFeedback()
Definition desktoputils.cpp:113
QtUtilities::onDarkModeChanged
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.
Definition desktoputils.cpp:161
QtUtilities::isDarkModeEnabled
QT_UTILITIES_EXPORT std::optional< bool > isDarkModeEnabled()
Returns whether dark mode is enabled.
Definition desktoputils.cpp:139
QtUtilities::isPaletteDark
QT_UTILITIES_EXPORT bool isPaletteDark(const QPalette &palette=QPalette())
Returns whether palette is dark.
Definition desktoputils.cpp:129
QtUtilities::openLocalFileOrDir
QT_UTILITIES_EXPORT bool openLocalFileOrDir(const QString &path)
\macro QT_UTILITIES_DARK_MODE_FROM_COLOR_SCHEME
Definition desktoputils.cpp:67
QtUtilities::showToast
QT_UTILITIES_EXPORT bool showToast(const QString &message, ToastDuration duration=ToastDuration::Long)
Definition desktoputils.cpp:97