Krita Source Code Documentation
Loading...
Searching...
No Matches
KisPortingUtils.h
Go to the documentation of this file.
1
/*
2
* SPDX-FileCopyrightText: 2024 Halla Rempt <halla@valdyas.org>
3
*
4
* SPDX-License-Identifier: GPL-2.0-or-later
5
*/
6
#ifndef KISPORTINGUTILS_H
7
#define KISPORTINGUTILS_H
8
9
#include <QIODevice>
10
#include <QTextStream>
11
#include <QWidget>
12
#include <QScreen>
13
#include <QGuiApplication>
14
15
namespace
KisPortingUtils
16
{
17
18
inline
void
setUtf8OnStream
(QTextStream &stream)
19
{
20
#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0))
21
stream.setCodec(
"UTF-8"
);
22
#else
23
stream.setEncoding(QStringConverter::Utf8);
24
#endif
25
}
26
27
inline
int
getScreenNumberForWidget
(
const
QWidget *w)
28
{
29
QList<QScreen *>
screens = QGuiApplication::screens();
30
if
(w) {
31
if
(screens.contains(w->screen())) {
32
return
screens.indexOf(w->screen());
33
}
34
}
35
36
return
screens.indexOf(QGuiApplication::primaryScreen());
37
}
38
39
inline
void
stringRemoveLast
(QString &str)
40
{
41
#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0))
42
str.remove(str.size() - 1, 1);
43
#else
44
str.removeLast();
45
#endif
46
}
47
48
inline
void
stringRemoveFirst
(QString &str)
49
{
50
#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0))
51
str.remove(0, 1);
52
#else
53
str.removeFirst();
54
#endif
55
}
56
57
}
58
59
#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0))
60
#define Q_UNREACHABLE_RETURN(...) Q_UNREACHABLE(); return __VA_ARGS__
61
#endif
62
63
64
#endif
// KISPORTINGUTILS_H
QList
Definition
KisQStringListFwd.h:16
KisPortingUtils
Definition
KisPortingUtils.h:16
KisPortingUtils::stringRemoveFirst
void stringRemoveFirst(QString &str)
Definition
KisPortingUtils.h:48
KisPortingUtils::stringRemoveLast
void stringRemoveLast(QString &str)
Definition
KisPortingUtils.h:39
KisPortingUtils::getScreenNumberForWidget
int getScreenNumberForWidget(const QWidget *w)
Definition
KisPortingUtils.h:27
KisPortingUtils::setUtf8OnStream
void setUtf8OnStream(QTextStream &stream)
Definition
KisPortingUtils.h:18
libs
global
KisPortingUtils.h
Generated at
2025-11-04 02:30:02+01:00
from
Krita
branch
master
, commit
c9dde2e79561a8aea4a7e8d9ac99c98a7bac9e52