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
2a360ba3
Commit
2a360ba3
authored
Sep 06, 2022
by
Liu Bodong
😘
Committed by
Tomaz Canabrava
Sep 08, 2022
Browse files
Feature: Allow wallpaper flip(both horizontal and vertical)
parent
5547abc7
Changes
7
Hide whitespace changes
Inline
Side-by-side
src/colorscheme/ColorScheme.cpp
View file @
2a360ba3
...
...
@@ -188,7 +188,7 @@ ColorScheme::ColorScheme()
,
_colorRandomization
(
false
)
,
_wallpaper
(
nullptr
)
{
setWallpaper
(
QString
(),
ColorSchemeWallpaper
::
Tile
,
QPointF
(
0.5
,
0.5
),
1.0
);
setWallpaper
(
QString
(),
ColorSchemeWallpaper
::
Tile
,
QPointF
(
0.5
,
0.5
),
1.0
,
false
,
false
);
}
ColorScheme
::
ColorScheme
(
const
ColorScheme
&
other
)
...
...
@@ -469,7 +469,9 @@ void ColorScheme::read(const KConfig &config)
setWallpaper
(
configGroup
.
readEntry
(
"Wallpaper"
,
QString
()),
configGroup
.
readEntry
(
"FillStyle"
,
QString
::
fromLatin1
(
"Tile"
)),
configGroup
.
readEntry
(
"Anchor"
,
QPointF
(
0.5
,
0.5
)),
configGroup
.
readEntry
(
"WallpaperOpacity"
,
1.0
));
configGroup
.
readEntry
(
"WallpaperOpacity"
,
1.0
),
configGroup
.
readEntry
(
"wallpaperFlipHorizontal"
,
false
),
configGroup
.
readEntry
(
"wallpaperFlipVertical"
,
false
));
_colorRandomization
=
configGroup
.
readEntry
(
EnableColorRandomizationKey
,
false
);
for
(
int
i
=
0
;
i
<
TABLE_COLORS
;
i
++
)
{
...
...
@@ -531,6 +533,8 @@ void ColorScheme::write(KConfig &config) const
configGroup
.
writeEntry
(
"Blur"
,
_blur
);
configGroup
.
writeEntry
(
"Wallpaper"
,
_wallpaper
->
path
());
configGroup
.
writeEntry
(
"FillStyle"
,
QMetaEnum
::
fromType
<
ColorSchemeWallpaper
::
FillStyle
>
().
valueToKey
(
_wallpaper
->
style
()));
configGroup
.
writeEntry
(
"wallpaperFlipHorizontal"
,
_wallpaper
->
flipHorizontal
());
configGroup
.
writeEntry
(
"wallpaperFlipVertical"
,
_wallpaper
->
flipVertical
());
configGroup
.
writeEntry
(
"Anchor"
,
_wallpaper
->
anchor
());
configGroup
.
writeEntry
(
"WallpaperOpacity"
,
_wallpaper
->
opacity
());
configGroup
.
writeEntry
(
EnableColorRandomizationKey
,
_colorRandomization
);
...
...
@@ -580,19 +584,29 @@ void ColorScheme::writeColorEntry(KConfig &config, int index) const
checkAndMaybeSaveValue
(
RandomLightnessRangeKey
,
random
.
lightness
);
}
void
ColorScheme
::
setWallpaper
(
const
QString
&
path
,
const
ColorSchemeWallpaper
::
FillStyle
style
,
const
QPointF
&
anchor
,
const
qreal
&
opacity
)
void
ColorScheme
::
setWallpaper
(
const
QString
&
path
,
const
ColorSchemeWallpaper
::
FillStyle
style
,
const
QPointF
&
anchor
,
const
qreal
&
opacity
,
const
bool
&
flipHorizontal
,
const
bool
&
flipVertical
)
{
_wallpaper
=
new
ColorSchemeWallpaper
(
path
,
style
,
anchor
,
opacity
);
_wallpaper
=
new
ColorSchemeWallpaper
(
path
,
style
,
anchor
,
opacity
,
flipHorizontal
,
flipVertical
);
}
void
ColorScheme
::
setWallpaper
(
const
QString
&
path
,
const
QString
&
style
,
const
QPointF
&
anchor
,
const
qreal
&
opacity
)
void
ColorScheme
::
setWallpaper
(
const
QString
&
path
,
const
QString
&
style
,
const
QPointF
&
anchor
,
const
qreal
&
opacity
,
const
bool
&
flipHorizontal
,
const
bool
&
flipVertical
)
{
ColorSchemeWallpaper
::
FillStyle
fstyle
;
fstyle
=
static_cast
<
ColorSchemeWallpaper
::
FillStyle
>
(
std
::
max
(
// keyToValue returns -1 if key was not found, but we should default to 0
QMetaEnum
::
fromType
<
ColorSchemeWallpaper
::
FillStyle
>
().
keyToValue
(
style
.
toStdString
().
c_str
()),
0
));
setWallpaper
(
path
,
fstyle
,
anchor
,
opacity
);
setWallpaper
(
path
,
fstyle
,
anchor
,
opacity
,
flipHorizontal
,
flipVertical
);
}
ColorSchemeWallpaper
::
Ptr
ColorScheme
::
wallpaper
()
const
...
...
src/colorscheme/ColorScheme.h
View file @
2a360ba3
...
...
@@ -133,8 +133,14 @@ public:
*/
bool
blur
()
const
;
void
setWallpaper
(
const
QString
&
path
,
const
ColorSchemeWallpaper
::
FillStyle
style
,
const
QPointF
&
anchor
,
const
qreal
&
opacity
);
void
setWallpaper
(
const
QString
&
path
,
const
QString
&
style
,
const
QPointF
&
anchor
,
const
qreal
&
opacity
);
void
setWallpaper
(
const
QString
&
path
,
const
ColorSchemeWallpaper
::
FillStyle
style
,
const
QPointF
&
anchor
,
const
qreal
&
opacity
,
const
bool
&
flipHorizontal
,
const
bool
&
flipVertical
);
void
setWallpaper
(
const
QString
&
path
,
const
QString
&
style
,
const
QPointF
&
anchor
,
const
qreal
&
opacity
,
const
bool
&
flipHorizontal
,
const
bool
&
flipVertical
);
ColorSchemeWallpaper
::
Ptr
wallpaper
()
const
;
...
...
src/colorscheme/ColorSchemeEditor.cpp
View file @
2a360ba3
...
...
@@ -99,6 +99,9 @@ ColorSchemeEditor::ColorSchemeEditor(QWidget *parent)
connect
(
_ui
->
wallpaperHorizontalAnchorSlider
,
&
QSlider
::
valueChanged
,
this
,
&
Konsole
::
ColorSchemeEditor
::
horizontalAnchorChanged
);
connect
(
_ui
->
wallpaperVerticalAnchorSlider
,
&
QSlider
::
valueChanged
,
this
,
&
Konsole
::
ColorSchemeEditor
::
verticalAnchorChanged
);
connect
(
_ui
->
wallpaperFlipHorizontalCheckBox
,
&
QCheckBox
::
toggled
,
this
,
&
Konsole
::
ColorSchemeEditor
::
wallpaperFlipHorizontalChanged
);
connect
(
_ui
->
wallpaperFlipVerticalCheckBox
,
&
QCheckBox
::
toggled
,
this
,
&
Konsole
::
ColorSchemeEditor
::
wallpaperFlipVerticalChanged
);
// color table
_ui
->
colorTable
->
setColumnCount
(
4
);
_ui
->
colorTable
->
setRowCount
(
COLOR_TABLE_ROW_LENGTH
);
...
...
@@ -196,19 +199,34 @@ void ColorSchemeEditor::setWallpaperOpacity(int percent)
_ui
->
wallpaperTransparencyPercentLabel
->
setText
(
QStringLiteral
(
"%1%"
).
arg
(
percent
));
const
qreal
opacity
=
(
100.0
-
percent
)
/
100.0
;
_colors
->
setWallpaper
(
_colors
->
wallpaper
()
->
path
(),
_colors
->
wallpaper
()
->
style
(),
_colors
->
wallpaper
()
->
anchor
(),
opacity
);
_colors
->
setWallpaper
(
_colors
->
wallpaper
()
->
path
(),
_colors
->
wallpaper
()
->
style
(),
_colors
->
wallpaper
()
->
anchor
(),
opacity
,
_colors
->
wallpaper
()
->
flipHorizontal
(),
_colors
->
wallpaper
()
->
flipVertical
());
}
void
ColorSchemeEditor
::
wallpaperPathChanged
(
const
QString
&
path
)
{
if
(
path
.
isEmpty
())
{
_colors
->
setWallpaper
(
path
,
_colors
->
wallpaper
()
->
style
(),
_colors
->
wallpaper
()
->
anchor
(),
_colors
->
wallpaper
()
->
opacity
());
_colors
->
setWallpaper
(
path
,
_colors
->
wallpaper
()
->
style
(),
_colors
->
wallpaper
()
->
anchor
(),
_colors
->
wallpaper
()
->
opacity
(),
_colors
->
wallpaper
()
->
flipHorizontal
(),
_colors
->
wallpaper
()
->
flipVertical
());
enableWallpaperSettings
(
false
);
}
else
{
QFileInfo
i
(
path
);
if
(
i
.
exists
()
&&
i
.
isFile
()
&&
i
.
isReadable
())
{
_colors
->
setWallpaper
(
path
,
_colors
->
wallpaper
()
->
style
(),
_colors
->
wallpaper
()
->
anchor
(),
_colors
->
wallpaper
()
->
opacity
());
_colors
->
setWallpaper
(
path
,
_colors
->
wallpaper
()
->
style
(),
_colors
->
wallpaper
()
->
anchor
(),
_colors
->
wallpaper
()
->
opacity
(),
_colors
->
wallpaper
()
->
flipHorizontal
(),
_colors
->
wallpaper
()
->
flipVertical
());
enableWallpaperSettings
(
true
);
}
}
...
...
@@ -217,13 +235,43 @@ void ColorSchemeEditor::wallpaperPathChanged(const QString &path)
void
ColorSchemeEditor
::
scalingTypeChanged
(
int
styleIndex
)
{
const
char
*
style
=
QMetaEnum
::
fromType
<
ColorSchemeWallpaper
::
FillStyle
>
().
valueToKey
(
styleIndex
);
_colors
->
setWallpaper
(
_colors
->
wallpaper
()
->
path
(),
QString
::
fromLatin1
(
style
),
_colors
->
wallpaper
()
->
anchor
(),
_colors
->
wallpaper
()
->
opacity
());
_colors
->
setWallpaper
(
_colors
->
wallpaper
()
->
path
(),
QString
::
fromLatin1
(
style
),
_colors
->
wallpaper
()
->
anchor
(),
_colors
->
wallpaper
()
->
opacity
(),
_colors
->
wallpaper
()
->
flipHorizontal
(),
_colors
->
wallpaper
()
->
flipVertical
());
}
void
ColorSchemeEditor
::
wallpaperFlipHorizontalChanged
(
bool
horizontal
)
{
_colors
->
setWallpaper
(
_colors
->
wallpaper
()
->
path
(),
_colors
->
wallpaper
()
->
style
(),
_colors
->
wallpaper
()
->
anchor
(),
_colors
->
wallpaper
()
->
opacity
(),
horizontal
,
_colors
->
wallpaper
()
->
flipVertical
());
}
void
ColorSchemeEditor
::
wallpaperFlipVerticalChanged
(
bool
vertical
)
{
_colors
->
setWallpaper
(
_colors
->
wallpaper
()
->
path
(),
_colors
->
wallpaper
()
->
style
(),
_colors
->
wallpaper
()
->
anchor
(),
_colors
->
wallpaper
()
->
opacity
(),
_colors
->
wallpaper
()
->
flipHorizontal
(),
vertical
);
}
void
ColorSchemeEditor
::
horizontalAnchorChanged
(
int
pos
)
{
QPointF
anch
=
_colors
->
wallpaper
()
->
anchor
();
_colors
->
setWallpaper
(
_colors
->
wallpaper
()
->
path
(),
_colors
->
wallpaper
()
->
style
(),
QPointF
(
pos
/
2.0
,
anch
.
y
()),
_colors
->
wallpaper
()
->
opacity
());
_colors
->
setWallpaper
(
_colors
->
wallpaper
()
->
path
(),
_colors
->
wallpaper
()
->
style
(),
QPointF
(
pos
/
2.0
,
anch
.
y
()),
_colors
->
wallpaper
()
->
opacity
(),
_colors
->
wallpaper
()
->
flipHorizontal
(),
_colors
->
wallpaper
()
->
flipVertical
());
switch
(
pos
)
{
case
2
:
_ui
->
wallpaperHorizontalAnchorPosition
->
setText
(
QString
::
fromLatin1
(
"Right"
));
...
...
@@ -241,7 +289,12 @@ void ColorSchemeEditor::horizontalAnchorChanged(int pos)
void
ColorSchemeEditor
::
verticalAnchorChanged
(
int
pos
)
{
QPointF
anch
=
_colors
->
wallpaper
()
->
anchor
();
_colors
->
setWallpaper
(
_colors
->
wallpaper
()
->
path
(),
_colors
->
wallpaper
()
->
style
(),
QPointF
(
anch
.
x
(),
pos
/
2.0
),
_colors
->
wallpaper
()
->
opacity
());
_colors
->
setWallpaper
(
_colors
->
wallpaper
()
->
path
(),
_colors
->
wallpaper
()
->
style
(),
QPointF
(
anch
.
x
(),
pos
/
2.0
),
_colors
->
wallpaper
()
->
opacity
(),
_colors
->
wallpaper
()
->
flipHorizontal
(),
_colors
->
wallpaper
()
->
flipVertical
());
switch
(
pos
)
{
case
2
:
_ui
->
wallpaperVerticalAnchorPosition
->
setText
(
QString
::
fromLatin1
(
"Bottom"
));
...
...
@@ -323,6 +376,8 @@ void ColorSchemeEditor::setup(const std::shared_ptr<const ColorScheme> &scheme,
int
ay
=
qRound
(
scheme
->
wallpaper
()
->
anchor
().
y
()
*
2.0
);
_ui
->
wallpaperPath
->
setText
(
scheme
->
wallpaper
()
->
path
());
_ui
->
wallpaperScalingType
->
setCurrentIndex
(
scheme
->
wallpaper
()
->
style
());
_ui
->
wallpaperFlipHorizontalCheckBox
->
setChecked
(
scheme
->
wallpaper
()
->
flipHorizontal
());
_ui
->
wallpaperFlipVerticalCheckBox
->
setChecked
(
scheme
->
wallpaper
()
->
flipVertical
());
_ui
->
wallpaperHorizontalAnchorSlider
->
setValue
(
ax
);
_ui
->
wallpaperVerticalAnchorSlider
->
setValue
(
ay
);
enableWallpaperSettings
(
!
scheme
->
wallpaper
()
->
isNull
());
...
...
@@ -382,4 +437,6 @@ void ColorSchemeEditor::enableWallpaperSettings(bool enable)
_ui
->
wallpaperVerticalAnchorSlider
->
setEnabled
(
enable
);
_ui
->
wallpaperTransparencySlider
->
setEnabled
(
enable
);
_ui
->
wallpaperScalingType
->
setEnabled
(
enable
);
_ui
->
wallpaperFlipHorizontalCheckBox
->
setEnabled
(
enable
);
_ui
->
wallpaperFlipVerticalCheckBox
->
setEnabled
(
enable
);
}
src/colorscheme/ColorSchemeEditor.h
View file @
2a360ba3
...
...
@@ -71,6 +71,8 @@ private Q_SLOTS:
void
setWallpaperOpacity
(
int
percent
);
void
wallpaperPathChanged
(
const
QString
&
path
);
void
scalingTypeChanged
(
int
styleIndex
);
void
wallpaperFlipHorizontalChanged
(
bool
horizontal
);
void
wallpaperFlipVerticalChanged
(
bool
vertical
);
void
horizontalAnchorChanged
(
int
pos
);
void
verticalAnchorChanged
(
int
pos
);
void
selectWallpaper
();
...
...
src/colorscheme/ColorSchemeEditor.ui
View file @
2a360ba3
...
...
@@ -7,7 +7,7 @@
<x>
0
</x>
<y>
0
</y>
<width>
364
</width>
<height>
4
60
</height>
<height>
4
74
</height>
</rect>
</property>
<layout
class=
"QVBoxLayout"
>
...
...
@@ -197,6 +197,31 @@ To see any effect, set colors with saturation value greater than 0.</string>
</item>
</layout>
</item>
<item>
<layout
class=
"QHBoxLayout"
>
<item>
<widget
class=
"QLabel"
name=
"wallpaperFlipLabel"
>
<property
name=
"text"
>
<string>
Wallpaper flip:
</string>
</property>
</widget>
</item>
<item>
<widget
class=
"QCheckBox"
name=
"wallpaperFlipHorizontalCheckBox"
>
<property
name=
"text"
>
<string>
Horizontal
</string>
</property>
</widget>
</item>
<item>
<widget
class=
"QCheckBox"
name=
"wallpaperFlipVerticalCheckBox"
>
<property
name=
"text"
>
<string>
Vertical
</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout
class=
"QHBoxLayout"
>
<item>
...
...
src/colorscheme/ColorSchemeWallpaper.cpp
View file @
2a360ba3
...
...
@@ -17,12 +17,19 @@
using
namespace
Konsole
;
ColorSchemeWallpaper
::
ColorSchemeWallpaper
(
const
QString
&
path
,
const
ColorSchemeWallpaper
::
FillStyle
style
,
const
QPointF
&
anchor
,
const
qreal
&
opacity
)
ColorSchemeWallpaper
::
ColorSchemeWallpaper
(
const
QString
&
path
,
const
ColorSchemeWallpaper
::
FillStyle
style
,
const
QPointF
&
anchor
,
const
qreal
&
opacity
,
const
bool
&
flipHorizontal
,
const
bool
&
flipVertical
)
:
_path
(
path
)
,
_picture
(
nullptr
)
,
_style
(
style
)
,
_anchor
(
anchor
)
,
_opacity
(
opacity
)
,
_flipHorizontal
(
flipHorizontal
)
,
_flipVertical
(
flipVertical
)
{
float
x
=
_anchor
.
x
(),
y
=
_anchor
.
y
();
...
...
@@ -44,7 +51,9 @@ void ColorSchemeWallpaper::load()
}
if
(
_picture
->
isNull
())
{
_picture
->
load
(
_path
);
QImage
image
(
_path
);
QImage
transformed
=
image
.
mirrored
(
flipHorizontal
(),
flipVertical
());
_picture
->
convertFromImage
(
transformed
);
}
}
...
...
@@ -87,6 +96,16 @@ ColorSchemeWallpaper::FillStyle ColorSchemeWallpaper::style() const
return
_style
;
}
bool
ColorSchemeWallpaper
::
flipHorizontal
()
const
{
return
_flipHorizontal
;
}
bool
ColorSchemeWallpaper
::
flipVertical
()
const
{
return
_flipVertical
;
}
QPointF
ColorSchemeWallpaper
::
anchor
()
const
{
return
_anchor
;
...
...
src/colorscheme/ColorSchemeWallpaper.h
View file @
2a360ba3
...
...
@@ -42,7 +42,12 @@ public:
typedef
QExplicitlySharedDataPointer
<
ColorSchemeWallpaper
>
Ptr
;
explicit
ColorSchemeWallpaper
(
const
QString
&
path
,
const
ColorSchemeWallpaper
::
FillStyle
style
,
const
QPointF
&
anchor
,
const
qreal
&
opacity
);
explicit
ColorSchemeWallpaper
(
const
QString
&
path
,
const
ColorSchemeWallpaper
::
FillStyle
style
,
const
QPointF
&
anchor
,
const
qreal
&
opacity
,
const
bool
&
flipHorizontal
,
const
bool
&
flipVertical
);
~
ColorSchemeWallpaper
();
void
load
();
...
...
@@ -60,6 +65,10 @@ public:
qreal
opacity
()
const
;
bool
flipHorizontal
()
const
;
bool
flipVertical
()
const
;
private:
Q_GADGET
Q_DISABLE_COPY
(
ColorSchemeWallpaper
)
...
...
@@ -69,6 +78,8 @@ private:
FillStyle
_style
;
QPointF
_anchor
;
qreal
_opacity
;
bool
_flipHorizontal
;
bool
_flipVertical
;
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