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 "smoothscrollwatcher.h"
25#include "tabletmodewatcher.h"
32class SettingsSingleton
38Settings::Settings(
QObject *parent)
40 , m_hasTouchScreen(false)
41 , m_hasTransientTouchInput(false)
43 m_tabletModeAvailable = TabletModeWatcher::self()->isTabletModeAvailable();
44 connect(TabletModeWatcher::self(), &TabletModeWatcher::tabletModeAvailableChanged,
this, [
this](
bool tabletModeAvailable) {
45 setTabletModeAvailable(tabletModeAvailable);
48 m_tabletMode = TabletModeWatcher::self()->isTabletMode();
49 connect(TabletModeWatcher::self(), &TabletModeWatcher::tabletModeChanged,
this, [
this](
bool tabletMode) {
50 setTabletMode(tabletMode);
53#if defined(Q_OS_ANDROID) || defined(Q_OS_IOS) || defined(UBUNTU_TOUCH)
55 m_hasTouchScreen =
true;
59 if (qEnvironmentVariableIsSet(
"QT_QUICK_CONTROLS_MOBILE")) {
66 const auto touchDeviceType = QInputDevice::DeviceType::TouchScreen;
67 for (
const auto &device : touchDevices) {
68 if (device->type() == touchDeviceType) {
69 m_hasTouchScreen =
true;
73 if (m_hasTouchScreen) {
82 auto bar = QGuiApplicationPrivate::platformTheme()->createPlatformMenuBar();
83 m_hasPlatformMenuBar = bar !=
nullptr;
91 globals.beginGroup(QStringLiteral(
"KDE"));
92 m_scrollLines = qMax(1, globals.value(QStringLiteral(
"WheelScrollLines"), 3).toInt());
93 m_smoothScroll = globals.value(QStringLiteral(
"SmoothScroll"),
true).toBool();
96 m_smoothScroll =
true;
99 connect(SmoothScrollWatcher::self(), &SmoothScrollWatcher::enabledChanged,
this, [
this](
bool enabled) {
100 m_smoothScroll = enabled;
101 Q_EMIT smoothScrollChanged();
112 switch (
event->type()) {
114 setTransientTouchInput(
true);
120 setTransientTouchInput(
false);
125 setTransientTouchInput(
false);
133void Settings::setTabletModeAvailable(
bool mobileAvailable)
135 if (mobileAvailable == m_tabletModeAvailable) {
139 m_tabletModeAvailable = mobileAvailable;
140 Q_EMIT tabletModeAvailableChanged();
143bool Settings::isTabletModeAvailable()
const
145 return m_tabletModeAvailable;
148void Settings::setIsMobile(
bool mobile)
150 if (mobile == m_mobile) {
155 Q_EMIT isMobileChanged();
158bool Settings::isMobile()
const
163void Settings::setTabletMode(
bool tablet)
165 if (tablet == m_tabletMode) {
169 m_tabletMode = tablet;
170 Q_EMIT tabletModeChanged();
173bool Settings::tabletMode()
const
178void Settings::setTransientTouchInput(
bool touch)
180 if (touch == m_hasTransientTouchInput) {
184 m_hasTransientTouchInput = touch;
186 Q_EMIT hasTransientTouchInputChanged();
190bool Settings::hasTransientTouchInput()
const
192 return m_hasTransientTouchInput || m_tabletMode;
200void Settings::setStyle(
const QString &style)
205int Settings::mouseWheelScrollLines()
const
207 return m_scrollLines;
210bool Settings::smoothScroll()
const
212 return m_smoothScroll;
218#ifndef KIRIGAMI_BUILD_TYPE_STATIC
219 tr(
"KDE Frameworks %1").arg(QStringLiteral(KIRIGAMIPLATFORM_VERSION_STRING)),
225QVariant Settings::applicationWindowIcon()
const
227 const QIcon &windowIcon = qApp->windowIcon();
228 if (windowIcon.
isNull()) {
234bool Settings::hasPlatformMenuBar()
const
236 return m_hasPlatformMenuBar;
242#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)