Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Plasma
KScreen
Commits
5245a9f8
Commit
5245a9f8
authored
Apr 11, 2021
by
Xaver Hugl
Browse files
Add support for setting overscan
parent
197de6d2
Changes
7
Hide whitespace changes
Inline
Side-by-side
common/control.cpp
View file @
5245a9f8
...
...
@@ -539,6 +539,74 @@ void ControlConfig::setReplicationSource(const QString &outputId, const QString
// TODO: shall we set this information also as new global value (like with auto-rotate)?
}
uint32_t
ControlConfig
::
getOverscan
(
const
KScreen
::
OutputPtr
&
output
)
const
{
return
getOverscan
(
output
->
hashMd5
(),
output
->
name
());
}
uint32_t
ControlConfig
::
getOverscan
(
const
QString
&
outputId
,
const
QString
&
outputName
)
const
{
const
auto
retention
=
getOutputRetention
(
outputId
,
outputName
);
if
(
retention
==
OutputRetention
::
Individual
)
{
const
QVariantList
outputsInfo
=
getOutputs
();
for
(
const
auto
&
variantInfo
:
outputsInfo
)
{
const
QVariantMap
info
=
variantInfo
.
toMap
();
if
(
!
infoIsOutput
(
info
,
outputId
,
outputName
))
{
continue
;
}
const
auto
val
=
info
[
QStringLiteral
(
"overscan"
)];
if
(
val
.
canConvert
<
uint
>
())
{
return
static_cast
<
uint32_t
>
(
val
.
toUInt
());
}
else
{
return
0
;
}
}
}
// Retention is global or info for output not in config control file.
if
(
auto
*
outputControl
=
getOutputControl
(
outputId
,
outputName
))
{
return
outputControl
->
overscan
();
}
// Info for output not found.
return
0
;
}
void
ControlConfig
::
setOverscan
(
const
KScreen
::
OutputPtr
&
output
,
const
uint32_t
value
)
{
setOverscan
(
output
->
hashMd5
(),
output
->
name
(),
value
);
}
void
ControlConfig
::
setOverscan
(
const
QString
&
outputId
,
const
QString
&
outputName
,
const
uint32_t
value
)
{
QList
<
QVariant
>::
iterator
it
;
QVariantList
outputsInfo
=
getOutputs
();
auto
setOutputOverscan
=
[
&
outputId
,
&
outputName
,
value
,
this
]()
{
if
(
auto
*
control
=
getOutputControl
(
outputId
,
outputName
))
{
control
->
setOverscan
(
value
);
}
};
for
(
it
=
outputsInfo
.
begin
();
it
!=
outputsInfo
.
end
();
++
it
)
{
QVariantMap
outputInfo
=
(
*
it
).
toMap
();
if
(
!
infoIsOutput
(
outputInfo
,
outputId
,
outputName
))
{
continue
;
}
outputInfo
[
QStringLiteral
(
"overscan"
)]
=
value
;
*
it
=
outputInfo
;
setOutputs
(
outputsInfo
);
setOutputOverscan
();
return
;
}
// no entry yet, create one
auto
outputInfo
=
createOutputInfo
(
outputId
,
outputName
);
outputInfo
[
QStringLiteral
(
"overscan"
)]
=
value
;
outputsInfo
<<
outputInfo
;
setOutputs
(
outputsInfo
);
setOutputOverscan
();
}
QVariantList
ControlConfig
::
getOutputs
()
const
{
return
constInfo
()[
QStringLiteral
(
"outputs"
)].
toList
();
...
...
@@ -633,3 +701,21 @@ void ControlOutput::setAutoRotateOnlyInTabletMode(bool value)
}
infoMap
[
QStringLiteral
(
"autorotate-tablet-only"
)]
=
value
;
}
uint32_t
ControlOutput
::
overscan
()
const
{
const
auto
val
=
constInfo
()[
QStringLiteral
(
"overscan"
)];
if
(
val
.
canConvert
<
uint
>
())
{
return
val
.
toUInt
();
}
return
0
;
}
void
ControlOutput
::
setOverscan
(
uint32_t
value
)
{
auto
&
infoMap
=
info
();
if
(
infoMap
.
isEmpty
())
{
infoMap
=
createOutputInfo
(
m_output
->
hashMd5
(),
m_output
->
name
());
}
infoMap
[
QStringLiteral
(
"overscan"
)]
=
static_cast
<
uint
>
(
value
);
}
common/control.h
View file @
5245a9f8
...
...
@@ -96,6 +96,11 @@ public:
void
setReplicationSource
(
const
KScreen
::
OutputPtr
&
output
,
const
KScreen
::
OutputPtr
&
source
);
void
setReplicationSource
(
const
QString
&
outputId
,
const
QString
&
outputName
,
const
KScreen
::
OutputPtr
&
source
);
uint32_t
getOverscan
(
const
KScreen
::
OutputPtr
&
output
)
const
;
uint32_t
getOverscan
(
const
QString
&
outputId
,
const
QString
&
outputName
)
const
;
void
setOverscan
(
const
KScreen
::
OutputPtr
&
output
,
const
uint32_t
value
);
void
setOverscan
(
const
QString
&
outputId
,
const
QString
&
outputName
,
const
uint32_t
value
);
QString
dirPath
()
const
override
;
QString
filePath
()
const
override
;
...
...
@@ -133,6 +138,9 @@ public:
bool
getAutoRotateOnlyInTabletMode
()
const
;
void
setAutoRotateOnlyInTabletMode
(
bool
value
);
uint32_t
overscan
()
const
;
void
setOverscan
(
uint32_t
value
);
QString
dirPath
()
const
override
;
QString
filePath
()
const
override
;
...
...
kcm/config_handler.cpp
View file @
5245a9f8
...
...
@@ -150,7 +150,8 @@ void ConfigHandler::checkNeedsSave()
||
output
->
replicationSource
()
!=
initialOutput
->
replicationSource
()
||
autoRotate
(
output
)
!=
m_initialControl
->
getAutoRotate
(
output
)
||
autoRotateOnlyInTabletMode
(
output
)
!=
m_initialControl
->
getAutoRotateOnlyInTabletMode
(
output
);
!=
m_initialControl
->
getAutoRotateOnlyInTabletMode
(
output
)
||
output
->
overscan
()
!=
initialOutput
->
overscan
();
}
// clang-format on
if
(
needsSave
)
{
...
...
@@ -321,6 +322,16 @@ void ConfigHandler::setAutoRotateOnlyInTabletMode(KScreen::OutputPtr &output, bo
m_control
->
setAutoRotateOnlyInTabletMode
(
output
,
value
);
}
uint32_t
ConfigHandler
::
overscan
(
const
KScreen
::
OutputPtr
&
output
)
const
{
return
m_control
->
getOverscan
(
output
);
}
void
ConfigHandler
::
setOverscan
(
const
KScreen
::
OutputPtr
&
output
,
uint32_t
value
)
{
m_control
->
setOverscan
(
output
,
value
);
}
void
ConfigHandler
::
writeControl
()
{
if
(
!
m_control
)
{
...
...
kcm/config_handler.h
View file @
5245a9f8
...
...
@@ -65,6 +65,9 @@ public:
bool
autoRotateOnlyInTabletMode
(
const
KScreen
::
OutputPtr
&
output
)
const
;
void
setAutoRotateOnlyInTabletMode
(
KScreen
::
OutputPtr
&
output
,
bool
value
);
uint32_t
overscan
(
const
KScreen
::
OutputPtr
&
output
)
const
;
void
setOverscan
(
const
KScreen
::
OutputPtr
&
output
,
uint32_t
value
);
void
writeControl
();
void
checkNeedsSave
();
...
...
kcm/output_model.cpp
View file @
5245a9f8
...
...
@@ -79,13 +79,18 @@ QVariant OutputModel::data(const QModelIndex &index, int role) const
return
replicationSourceIndex
(
index
.
row
());
case
ReplicasModelRole
:
return
replicasModel
(
output
);
case
RefreshRatesRole
:
case
RefreshRatesRole
:
{
QVariantList
ret
;
for
(
const
auto
rate
:
refreshRates
(
output
))
{
ret
<<
i18n
(
"%1 Hz"
,
int
(
rate
+
0.5
));
}
return
ret
;
}
case
CapabilitiesRole
:
return
static_cast
<
uint32_t
>
(
output
->
capabilities
());
case
OverscanRole
:
return
output
->
overscan
();
}
return
QVariant
();
}
...
...
@@ -158,7 +163,7 @@ bool OutputModel::setData(const QModelIndex &index, const QVariant &value, int r
return
setReplicationSourceIndex
(
index
.
row
(),
value
.
toInt
()
-
1
);
}
break
;
case
ScaleRole
:
case
ScaleRole
:
{
bool
ok
;
const
qreal
scale
=
value
.
toReal
(
&
ok
);
if
(
ok
&&
!
qFuzzyCompare
(
output
.
ptr
->
scale
(),
scale
))
{
...
...
@@ -175,6 +180,20 @@ bool OutputModel::setData(const QModelIndex &index, const QVariant &value, int r
}
break
;
}
case
OverscanRole
:
if
(
value
.
canConvert
<
uint32_t
>
())
{
Output
&
output
=
m_outputs
[
index
.
row
()];
const
uint32_t
overscan
=
value
.
toUInt
();
if
(
output
.
ptr
->
overscan
()
==
overscan
)
{
return
false
;
}
output
.
ptr
->
setOverscan
(
overscan
);
m_config
->
setOverscan
(
output
.
ptr
,
overscan
);
Q_EMIT
dataChanged
(
index
,
index
,
{
role
});
return
true
;
}
break
;
}
return
false
;
}
...
...
@@ -198,6 +217,8 @@ QHash<int, QByteArray> OutputModel::roleNames() const
roles
[
ReplicationSourceModelRole
]
=
"replicationSourceModel"
;
roles
[
ReplicationSourceIndexRole
]
=
"replicationSourceIndex"
;
roles
[
ReplicasModelRole
]
=
"replicasModel"
;
roles
[
CapabilitiesRole
]
=
"capabilities"
;
roles
[
OverscanRole
]
=
"overscan"
;
return
roles
;
}
...
...
kcm/output_model.h
View file @
5245a9f8
...
...
@@ -48,6 +48,8 @@ public:
ReplicationSourceModelRole
,
ReplicationSourceIndexRole
,
ReplicasModelRole
,
CapabilitiesRole
,
OverscanRole
,
};
explicit
OutputModel
(
ConfigHandler
*
configHandler
);
...
...
kcm/package/contents/ui/OutputPanel.qml
View file @
5245a9f8
...
...
@@ -20,6 +20,7 @@ import QtQuick.Controls 2.3 as Controls
import
org
.
kde
.
kirigami
2.4
as
Kirigami
import
org
.
kde
.
kcm
1.2
as
KCM
import
org
.
kde
.
private
.
kcm
.
kscreen
1.0
as
KScreen
ColumnLayout
{
id
:
outputPanel
...
...
@@ -104,6 +105,21 @@ ColumnLayout {
onActivated
:
element
.
refreshRateIndex
=
currentIndex
}
Controls.SpinBox
{
Kirigami.FormData.label
:
i18n
(
"
Overscan:
"
)
from
:
0
to
:
100
value
:
element
.
overscan
onValueModified
:
element
.
overscan
=
value
visible
:
element
.
capabilities
&
KScreen
.
Output
.
Capability
.
Overscan
textFromValue
:
function
(
value
,
locale
)
{
return
value
+
'
%
'
;
}
valueFromText
:
function
(
text
,
locale
)
{
return
parseInt
(
text
.
replace
(
"
%
"
,
""
))
}
}
Controls.ComboBox
{
Kirigami.FormData.label
:
i18n
(
"
Replica of:
"
)
model
:
element
.
replicationSourceModel
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a 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