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
Utilities
Konsole
Commits
7ecaf93b
Commit
7ecaf93b
authored
Dec 07, 2021
by
Riccardo Degli Esposti
🍌
Committed by
Tomaz Canabrava
Dec 29, 2021
Browse files
Added anchor and no scaling
parent
e123d8b4
Changes
5
Hide whitespace changes
Inline
Side-by-side
src/colorscheme/ColorScheme.cpp
View file @
7ecaf93b
...
...
@@ -187,7 +187,7 @@ ColorScheme::ColorScheme()
,
_colorRandomization
(
false
)
,
_wallpaper
(
nullptr
)
{
setWallpaper
(
QString
(),
ColorSchemeWallpaper
::
Tile
);
setWallpaper
(
QString
(),
ColorSchemeWallpaper
::
Tile
,
QPointF
(
0.5
f
,
0.5
f
)
);
}
ColorScheme
::
ColorScheme
(
const
ColorScheme
&
other
)
...
...
@@ -464,8 +464,10 @@ void ColorScheme::read(const KConfig &config)
_description
=
i18n
(
schemeDescription
.
toUtf8
().
constData
());
setOpacity
(
configGroup
.
readEntry
(
"Opacity"
,
1.0
));
_blur
=
configGroup
.
readEntry
(
"Blur"
,
false
);
setWallpaper
(
configGroup
.
readEntry
(
"Wallpaper"
,
QString
()),
static_cast
<
ColorSchemeWallpaper
::
FillStyle
>
(
configGroup
.
readEntry
(
"FillStyle"
,
0
)));
setWallpaper
(
configGroup
.
readEntry
(
"Wallpaper"
,
QString
()),
static_cast
<
ColorSchemeWallpaper
::
FillStyle
>
(
configGroup
.
readEntry
(
"FillStyle"
,
0
)),
configGroup
.
readEntry
(
"Anchor"
,
QPointF
(
0.5
f
,
0.5
f
)));
_colorRandomization
=
configGroup
.
readEntry
(
EnableColorRandomizationKey
,
false
);
for
(
int
i
=
0
;
i
<
TABLE_COLORS
;
i
++
)
{
...
...
@@ -527,6 +529,7 @@ void ColorScheme::write(KConfig &config) const
configGroup
.
writeEntry
(
"Blur"
,
_blur
);
configGroup
.
writeEntry
(
"Wallpaper"
,
_wallpaper
->
path
());
configGroup
.
writeEntry
(
"FillStyle"
,
static_cast
<
int
>
(
_wallpaper
->
style
()));
configGroup
.
writeEntry
(
"Anchor"
,
_wallpaper
->
anchor
());
configGroup
.
writeEntry
(
EnableColorRandomizationKey
,
_colorRandomization
);
for
(
int
i
=
0
;
i
<
TABLE_COLORS
;
i
++
)
{
...
...
@@ -574,9 +577,9 @@ void ColorScheme::writeColorEntry(KConfig &config, int index) const
checkAndMaybeSaveValue
(
RandomLightnessRangeKey
,
random
.
lightness
);
}
void
ColorScheme
::
setWallpaper
(
const
QString
&
path
,
ColorSchemeWallpaper
::
FillStyle
style
)
void
ColorScheme
::
setWallpaper
(
const
QString
&
path
,
const
ColorSchemeWallpaper
::
FillStyle
style
,
const
QPointF
&
anchor
)
{
_wallpaper
=
new
ColorSchemeWallpaper
(
path
,
style
);
_wallpaper
=
new
ColorSchemeWallpaper
(
path
,
style
,
anchor
);
}
ColorSchemeWallpaper
::
Ptr
ColorScheme
::
wallpaper
()
const
...
...
src/colorscheme/ColorScheme.h
View file @
7ecaf93b
...
...
@@ -133,7 +133,7 @@ public:
*/
bool
blur
()
const
;
void
setWallpaper
(
const
QString
&
path
,
ColorSchemeWallpaper
::
FillStyle
style
);
void
setWallpaper
(
const
QString
&
path
,
const
ColorSchemeWallpaper
::
FillStyle
style
,
const
QPointF
&
anchor
);
ColorSchemeWallpaper
::
Ptr
wallpaper
()
const
;
...
...
src/colorscheme/ColorSchemeEditor.cpp
View file @
7ecaf93b
...
...
@@ -187,12 +187,12 @@ void ColorSchemeEditor::selectWallpaper()
void
ColorSchemeEditor
::
wallpaperPathChanged
(
const
QString
&
path
)
{
if
(
path
.
isEmpty
())
{
_colors
->
setWallpaper
(
path
,
_colors
->
wallpaper
()
->
style
());
_colors
->
setWallpaper
(
path
,
_colors
->
wallpaper
()
->
style
()
,
_colors
->
wallpaper
()
->
anchor
()
);
}
else
{
QFileInfo
i
(
path
);
if
(
i
.
exists
()
&&
i
.
isFile
()
&&
i
.
isReadable
())
{
_colors
->
setWallpaper
(
path
,
_colors
->
wallpaper
()
->
style
());
_colors
->
setWallpaper
(
path
,
_colors
->
wallpaper
()
->
style
()
,
_colors
->
wallpaper
()
->
anchor
()
);
}
}
}
...
...
src/colorscheme/ColorSchemeWallpaper.cpp
View file @
7ecaf93b
...
...
@@ -17,11 +17,16 @@
using
namespace
Konsole
;
ColorSchemeWallpaper
::
ColorSchemeWallpaper
(
const
QString
&
path
,
ColorSchemeWallpaper
::
FillStyle
style
)
ColorSchemeWallpaper
::
ColorSchemeWallpaper
(
const
QString
&
path
,
const
ColorSchemeWallpaper
::
FillStyle
style
,
const
QPointF
&
anchor
)
:
_path
(
path
)
,
_picture
(
nullptr
)
,
_style
(
style
)
,
_anchor
(
anchor
)
{
float
x
=
_anchor
.
x
(),
y
=
_anchor
.
y
();
if
(
x
<
0
||
x
>
1.0
f
||
y
<
0
||
y
>
1.0
f
)
_anchor
=
QPointF
(
0.5
f
,
0.5
f
);
}
ColorSchemeWallpaper
::~
ColorSchemeWallpaper
()
=
default
;
...
...
@@ -90,16 +95,21 @@ ColorSchemeWallpaper::FillStyle ColorSchemeWallpaper::style() const
return
_style
;
}
QPointF
ColorSchemeWallpaper
::
anchor
()
const
{
return
_anchor
;
}
QRectF
ColorSchemeWallpaper
::
ScaledRect
(
const
QSize
viewportSize
,
const
QSize
pictureSize
,
const
QRect
rect
)
{
QRectF
scaledRect
=
QRectF
();
QSize
scaledSize
=
pictureSize
.
scaled
(
viewportSize
,
RatioMode
());
QSize
scaledSize
=
_style
==
NoResize
?
pictureSize
:
pictureSize
.
scaled
(
viewportSize
,
RatioMode
());
double
scaleX
=
pictureSize
.
width
()
/
static_cast
<
double
>
(
scaledSize
.
width
());
double
scaleY
=
pictureSize
.
height
()
/
static_cast
<
double
>
(
scaledSize
.
height
());
double
offsetX
=
(
scaledSize
.
width
()
-
viewportSize
.
width
())
/
2.0
;
double
offsetY
=
(
scaledSize
.
height
()
-
viewportSize
.
height
())
/
2.0
;
double
offsetX
=
(
scaledSize
.
width
()
-
viewportSize
.
width
())
*
_anchor
.
x
()
;
double
offsetY
=
(
scaledSize
.
height
()
-
viewportSize
.
height
())
*
_anchor
.
y
()
;
scaledRect
.
setX
((
rect
.
x
()
+
offsetX
)
*
scaleX
);
scaledRect
.
setY
((
rect
.
y
()
+
offsetY
)
*
scaleY
);
...
...
@@ -113,7 +123,7 @@ QRectF ColorSchemeWallpaper::ScaledRect(const QSize viewportSize, const QSize pi
Qt
::
AspectRatioMode
ColorSchemeWallpaper
::
RatioMode
()
{
switch
(
_style
)
{
case
C
enter
:
case
C
rop
:
return
Qt
::
KeepAspectRatioByExpanding
;
case
Adapt
:
return
Qt
::
KeepAspectRatio
;
...
...
src/colorscheme/ColorSchemeWallpaper.h
View file @
7ecaf93b
...
...
@@ -14,6 +14,7 @@
// Qt
#include
<QMetaType>
#include
<QSharedData>
#include
<QPointF>
// Konsole
#include
"../characters/CharacterColor.h"
...
...
@@ -34,13 +35,14 @@ public:
{
Tile
=
0
,
Stretch
,
Center
,
Adapt
Crop
,
Adapt
,
NoResize
};
typedef
QExplicitlySharedDataPointer
<
ColorSchemeWallpaper
>
Ptr
;
explicit
ColorSchemeWallpaper
(
const
QString
&
path
,
FillStyle
style
);
explicit
ColorSchemeWallpaper
(
const
QString
&
path
,
const
ColorSchemeWallpaper
::
FillStyle
style
,
const
QPointF
&
anchor
);
~
ColorSchemeWallpaper
();
void
load
();
...
...
@@ -54,12 +56,15 @@ public:
FillStyle
style
()
const
;
QPointF
anchor
()
const
;
private:
Q_DISABLE_COPY
(
ColorSchemeWallpaper
)
QString
_path
;
std
::
unique_ptr
<
QPixmap
>
_picture
;
FillStyle
_style
;
QPointF
_anchor
;
QRectF
ScaledRect
(
const
QSize
viewportSize
,
const
QSize
pictureSize
,
const
QRect
rect
);
Qt
::
AspectRatioMode
RatioMode
();
...
...
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