11#include <QGuiApplication>
13#include <QInputDevice>
16#include <QStandardPaths>
19#include <QtGui/private/qguiapplication_p.h>
20#include <QtGui/qpa/qplatformmenu.h>
21#include <QtGui/qpa/qplatformtheme.h>
23#include "kirigamiplatform_version.h"
24#include "tabletmodewatcher.h"
31class SettingsSingleton
37Settings::Settings(
QObject *parent)
39 , m_hasTouchScreen(false)
40 , m_hasTransientTouchInput(false)
42 m_tabletModeAvailable = TabletModeWatcher::self()->isTabletModeAvailable();
43 connect(TabletModeWatcher::self(), &TabletModeWatcher::tabletModeAvailableChanged,
this, [
this](
bool tabletModeAvailable) {
44 setTabletModeAvailable(tabletModeAvailable);
47 m_tabletMode = TabletModeWatcher::self()->isTabletMode();
48 connect(TabletModeWatcher::self(), &TabletModeWatcher::tabletModeChanged,
this, [
this](
bool tabletMode) {
49 setTabletMode(tabletMode);
52#if defined(Q_OS_ANDROID) || defined(Q_OS_IOS) || defined(UBUNTU_TOUCH)
54 m_hasTouchScreen =
true;
58 if (qEnvironmentVariableIsSet(
"QT_QUICK_CONTROLS_MOBILE")) {
65 const auto touchDeviceType = QInputDevice::DeviceType::TouchScreen;
66 for (
const auto &device : touchDevices) {
67 if (device->type() == touchDeviceType) {
68 m_hasTouchScreen =
true;
72 if (m_hasTouchScreen) {
81 auto bar = QGuiApplicationPrivate::platformTheme()->createPlatformMenuBar();
82 m_hasPlatformMenuBar = bar !=
nullptr;
90 globals.beginGroup(QStringLiteral(
"KDE"));
91 m_scrollLines = qMax(1, globals.value(QStringLiteral(
"WheelScrollLines"), 3).toInt());
104 switch (
event->type()) {
106 setTransientTouchInput(
true);
112 setTransientTouchInput(
false);
117 setTransientTouchInput(
false);
125void Settings::setTabletModeAvailable(
bool mobileAvailable)
127 if (mobileAvailable == m_tabletModeAvailable) {
131 m_tabletModeAvailable = mobileAvailable;
132 Q_EMIT tabletModeAvailableChanged();
135bool Settings::isTabletModeAvailable()
const
137 return m_tabletModeAvailable;
140void Settings::setIsMobile(
bool mobile)
142 if (mobile == m_mobile) {
147 Q_EMIT isMobileChanged();
150bool Settings::isMobile()
const
155void Settings::setTabletMode(
bool tablet)
157 if (tablet == m_tabletMode) {
161 m_tabletMode = tablet;
162 Q_EMIT tabletModeChanged();
165bool Settings::tabletMode()
const
170void Settings::setTransientTouchInput(
bool touch)
172 if (touch == m_hasTransientTouchInput) {
176 m_hasTransientTouchInput = touch;
178 Q_EMIT hasTransientTouchInputChanged();
182bool Settings::hasTransientTouchInput()
const
184 return m_hasTransientTouchInput || m_tabletMode;
192void Settings::setStyle(
const QString &style)
197int Settings::mouseWheelScrollLines()
const
199 return m_scrollLines;
205#ifndef KIRIGAMI_BUILD_TYPE_STATIC
206 tr(
"KDE Frameworks %1").arg(QStringLiteral(KIRIGAMIPLATFORM_VERSION_STRING)),
212QVariant Settings::applicationWindowIcon()
const
214 const QIcon &windowIcon = qApp->windowIcon();
215 if (windowIcon.
isNull()) {
221bool Settings::hasPlatformMenuBar()
const
223 return m_hasPlatformMenuBar;
229#include "moc_settings.cpp"
AKONADI_CALENDAR_EXPORT KCalendarCore::Event::Ptr event(const Akonadi::Item &item)
bool exists() const const
void focusWindowChanged(QWindow *focusWindow)
bool isNull() const const
bool contains(const AT &value) const const
Qt::MouseEventSource source() const const
void installEventFilter(QObject *filterObj)
QString locate(StandardLocation type, const QString &fileName, LocateOptions options)
QString fromLocal8Bit(QByteArrayView str)
QFuture< ArgsType< Signal > > connect(Sender *sender, Signal signal)