Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Accessibility
Kontrast
Commits
314b2750
Commit
314b2750
authored
Sep 12, 2022
by
Carl Schwan
🚴
Committed by
Vlad Rakhmanin
Sep 12, 2022
Browse files
Added suggestions
Implemented suggested changes made by Carl Schwan on the Merge Request.
parent
605e1544
Changes
3
Hide whitespace changes
Inline
Side-by-side
src/contents/ui/MainPage.qml
View file @
314b2750
/**
* SPDX-FileCopyrightText: (C) 2020 Carl Schwan <carl@carlschwan.eu>
*
* SPDX-License
Ref
: GPL-3.0-or-later
* SPDX-License
-Identifier
: GPL-3.0-or-later
*/
import
QtQuick
2.1
...
...
@@ -45,7 +45,6 @@ Kirigami.ScrollablePage {
Layout.fillWidth
:
true
}
Kirigami.Heading
{
level
:
1
font.bold
:
true
text
:
i18n
(
"
%1
"
,
Kontrast
.
fontSizeLabel
)
...
...
src/kontrast.cpp
View file @
314b2750
/*
* SPDX-FileCopyrightText: (C) 2020 Carl Schwan <carl@carlschwan.eu>
*
* SPDX-License
Ref
: GPL-3.0-or-later
* SPDX-License
-Identifier
: GPL-3.0-or-later
*/
#include
"kontrast.h"
...
...
@@ -9,7 +9,6 @@
#include
<QDebug>
#include
<QRandomGenerator>
#include
<QtMath>
#include
<iostream>
#ifdef QT_DBUS_LIB
#include
<KLocalizedString>
...
...
@@ -322,7 +321,7 @@ void Kontrast::gotColorResponse(uint response, const QVariantMap &results)
Kontrast
::
ContrastQualities
Kontrast
::
getContrastQualities
()
{
qreal
contrast
=
Kontrast
::
contrast
();
const
qreal
contrast
=
Kontrast
::
contrast
();
if
(
contrast
>
7.0
)
{
return
ContrastQualities
{
Perfect
,
Perfect
,
Perfect
};
...
...
@@ -337,18 +336,36 @@ Kontrast::ContrastQualities Kontrast::getContrastQualities()
QString
Kontrast
::
getFontSizeQualityLabel
()
{
auto
currentQualities
=
getContrastQualities
();
const
auto
currentQualities
=
getContrastQualities
();
Quality
currentQuality
;
if
(
m_fontSize
>=
18
)
{
return
i18n
(
"Font size %1px is %2 with the current contrast"
,
m_fontSize
,
getStringFromEnum
(
currentQualities
.
large
).
toLower
())
;
currentQuality
=
currentQualities
.
large
;
}
else
if
(
m_fontSize
>
13
)
{
return
i18n
(
"Font size %1px is %2 with the current contrast"
,
m_fontSize
,
getStringFromEnum
(
currentQualities
.
medium
).
toLower
())
;
currentQuality
=
currentQualities
.
medium
;
}
else
{
return
i18n
(
"Font size %1px is %2 with the current contrast"
,
m_fontSize
,
getStringFromEnum
(
currentQualities
.
small
).
toLower
());
currentQuality
=
currentQualities
.
small
;
}
switch
(
currentQuality
)
{
case
Bad
:
return
i18n
(
"Font size %1px is bad with the current contrast"
,
m_fontSize
);
case
Good
:
return
i18n
(
"Font size %1px is good with the current contrast"
,
m_fontSize
);
case
Perfect
:
return
i18n
(
"Font size %1px is perfect with the current contrast"
,
m_fontSize
);
}
}
}
QString
Kontrast
::
getStringFromEnum
(
Quality
quality
)
{
return
i18n
(
QMetaEnum
::
fromType
<
Quality
>
().
valueToKey
(
quality
));
switch
(
quality
)
{
case
Bad
:
return
i18nc
(
"A bad quality"
,
"bad"
);
case
Good
:
return
i18nc
(
"A good quality"
,
"good"
);
case
Perfect
:
return
i18nc
(
"A perfect quality"
,
"perfect"
);
}
}
src/kontrast.h
View file @
314b2750
/*
* SPDX-FileCopyrightText: (C) 2020 Carl Schwan <carl@carlschwan.eu>
*
* SPDX-License
Ref
: GPL-3.0-or-later
* SPDX-License
-Identifier
: GPL-3.0-or-later
*/
#pragma once
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment