28#include <QOperatingSystemVersion>
29#include <QStandardPaths>
33#include "platforms/platform.h"
35#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
36#include <QTouchDevice>
38#include <QInputDevice>
42#include <QGuiApplication>
44#include <QApplication>
47#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
48#include <MauiMan3/formfactormanager.h>
49#include <MauiMan3/accessibilitymanager.h>
51#include <MauiMan4/formfactormanager.h>
52#include <MauiMan4/accessibilitymanager.h>
55Q_GLOBAL_STATIC(
Handy, handyInstance)
59 ,m_formFactor(new
MauiMan::FormFactorManager(this))
60 ,m_accessibility(new
MauiMan::AccessibilityManager(this))
61 ,m_hasTransientTouchInput(false)
63 qDebug() <<
"CREATING INSTANCE OF MAUI HANDY";
65 connect(m_accessibility, &MauiMan::AccessibilityManager::singleClickChanged, [&](
bool value)
67 m_singleClick = value;
68 Q_EMIT singleClickChanged();
71 m_singleClick = m_accessibility->singleClick();
75connect(m_formFactor, &MauiMan::FormFactorManager::preferredModeChanged, [
this](uint value)
77 m_ffactor =
static_cast<FFactor
>(value);
78 m_mobile = m_ffactor == FFactor::Phone || m_ffactor == FFactor::Tablet;
79 Q_EMIT formFactorChanged();
80 Q_EMIT isMobileChanged();
83connect(m_formFactor, &MauiMan::FormFactorManager::hasTouchscreenChanged, [
this](
bool value)
85 m_isTouch = value || m_formFactor->forceTouchScreen();
86 Q_EMIT isTouchChanged();
89m_ffactor =
static_cast<FFactor
>(m_formFactor->preferredMode());
90m_mobile = m_ffactor == FFactor::Phone || m_ffactor == FFactor::Tablet;
91m_isTouch = m_formFactor->hasTouchscreen() || m_formFactor->forceTouchScreen();
102Handy *Handy::instance()
104 return handyInstance();
119 return m_hasTransientTouchInput;
122void Handy::setTransientTouchInput(
bool touch)
124 if (touch == m_hasTransientTouchInput) {
128 m_hasTransientTouchInput = touch;
129 Q_EMIT hasTransientTouchInputChanged();
135 switch (
event->type())
138 setTransientTouchInput(
true);
145 setTransientTouchInput(
false);
150 setTransientTouchInput(
false);
159static inline struct {
178 QString name = qgetenv(
"USER");
180 name = qgetenv(
"USERNAME");
193 auto mime = clipboard->mimeData();
195 return clipboard->text();
204 if (_clipboard.hasUrls())
207 if (_clipboard.hasText())
208 res.insert(
"text", _clipboard.text);
210 res.insert(
"cut", _clipboard.cut);
214 auto mime = clipboard->mimeData();
223 res.insert(
"text", mime->text());
226 res.insert(
"image", mime->imageData());
228 const QByteArray a = mime->
data(QStringLiteral(
"application/x-kde-cutselection"));
230 res.insert(
"cut", !a.
isEmpty() && a.
at(0) ==
'1');
238 if (value.contains(
"urls"))
241 if (value.contains(
"text"))
242 _clipboard.text = value[
"text"].toString();
244 _clipboard.cut = cut;
251 if (value.contains(
"urls"))
254 if (value.contains(
"text"))
255 mimeData->
setText(value[
"text"].toString());
257 mimeData->
setData(QStringLiteral(
"application/x-kde-cutselection"), cut ?
"1" :
"0");
258 clipboard->setMimeData(mimeData);
335 QTime time((value / 3600) % 60, (value / 60) % 60, value % 60, (value * 1000) % 1000);
344 return tStr.
isEmpty() ?
"00:00" : tStr;
FFactor formFactor
The current preferred from factor the user has selected.
bool isTouch
Whether the target device has a touch screen.
static int version()
Returns the major version of the current OS.
QML_SINGLETONbool isMobile
Whether the host platform is set as mobile.
static QVariantMap getClipboard()
Retrieves the data in the clipboard into a key-value map.
static QString formatTime(const qint64 &value)
Format a milliseconds value to a readable format.
FFactor
The different form factor options.
bool isLinux
Whether the host platform is a GNU/Linux distribution.
bool isMac
Whether the host platform is running MacOS.
bool hasMouse
Whether the target device has a physical mouse attached.
bool isWindows
Whether the host platform is running Windows OS.
static QString getClipboardText()
Returns the text contained in the clipboard.
bool hasKeyboard
Whether the target device has a physical keyboard attached.
static bool copyToClipboard(const QVariantMap &value, const bool &cut=false)
Adds a key-value map to the clipboard.
bool isIOS
Whether the host platform is running IOS.
static QString formatDate(const QString &dateStr, const QString &format=QString("dd/MM/yyyy"), const QString &initFormat=QString())
Given a date string, its original format and an intended format, return a readable string.
static QVariantMap userInfo()
Returns a key-value map containing basic information about the current user.
bool hasTransientTouchInput
Whether the current press input has been received from a touch screen.
bool isAndroid
Whether the host platform is an Android device.
static bool copyTextToClipboard(const QString &text)
Copies a text string to the clipboard.
static QString formatSize(quint64 size)
Format a size value to the a readable locale size format.
bool isLinux()
Whether the platform running is GNU/Linux.
bool isIOS()
Whether the platform running is IOS.
static const QHash< MODEL_KEY, QString > MODEL_NAME
The mapping of the FMH::MODEL_KEY enum values to its string representation.
bool isWindows()
Whether the platform running is Window.
bool isMac()
Whether the platform running is Mac.
bool isAndroid()
Whether the platform running is Android.
const QList< QKeySequence > & cut()
char at(qsizetype i) const const
bool isEmpty() const const
void setText(const QString &text, Mode mode)
QDateTime fromString(QStringView string, QStringView format, QCalendar cal)
QString toString(QStringView format, QCalendar cal) const const
void focusWindowChanged(QWindow *focusWindow)
bool isEmpty() const const
void setData(const QString &mimeType, const QByteArray &data)
void setText(const QString &text)
void setUrls(const QList< QUrl > &urls)
Qt::MouseEventSource source() const const
virtual bool event(QEvent *e)
void installEventFilter(QObject *filterObj)
QOperatingSystemVersion current()
int majorVersion() const const
bool isEmpty() const const
QFuture< ArgsType< Signal > > connect(Sender *sender, Signal signal)
QString toString(QStringView format) const const
QList< QUrl > fromStringList(const QStringList &urls, ParsingMode mode)
QStringList toStringList(const QList< QUrl > &urls, FormattingOptions options)