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
f8fe5a57
Commit
f8fe5a57
authored
Dec 07, 2021
by
Riccardo Degli Esposti
🍌
Committed by
Tomaz Canabrava
Dec 29, 2021
Browse files
Added settings
parent
7ecaf93b
Changes
7
Hide whitespace changes
Inline
Side-by-side
src/colorscheme/ColorScheme.cpp
View file @
f8fe5a57
...
...
@@ -13,6 +13,7 @@
// Qt
#include
<QPainter>
#include
<QMetaEnum>
// KDE
#include
<KConfig>
...
...
@@ -466,7 +467,7 @@ void ColorScheme::read(const KConfig &config)
_blur
=
configGroup
.
readEntry
(
"Blur"
,
false
);
setWallpaper
(
configGroup
.
readEntry
(
"Wallpaper"
,
QString
()),
static_cast
<
ColorSchemeWallpaper
::
FillStyle
>
(
configGroup
.
readEntry
(
"FillStyle"
,
0
)),
configGroup
.
readEntry
(
"FillStyle"
,
QString
::
fromLatin1
(
"Tile"
)),
configGroup
.
readEntry
(
"Anchor"
,
QPointF
(
0.5
f
,
0.5
f
)));
_colorRandomization
=
configGroup
.
readEntry
(
EnableColorRandomizationKey
,
false
);
...
...
@@ -528,7 +529,9 @@ void ColorScheme::write(KConfig &config) const
configGroup
.
writeEntry
(
"Opacity"
,
_opacity
);
configGroup
.
writeEntry
(
"Blur"
,
_blur
);
configGroup
.
writeEntry
(
"Wallpaper"
,
_wallpaper
->
path
());
configGroup
.
writeEntry
(
"FillStyle"
,
static_cast
<
int
>
(
_wallpaper
->
style
()));
configGroup
.
writeEntry
(
"FillStyle"
,
QMetaEnum
::
fromType
<
ColorSchemeWallpaper
::
FillStyle
>
()
.
valueToKey
(
_wallpaper
->
style
()));
configGroup
.
writeEntry
(
"Anchor"
,
_wallpaper
->
anchor
());
configGroup
.
writeEntry
(
EnableColorRandomizationKey
,
_colorRandomization
);
...
...
@@ -582,7 +585,19 @@ void ColorScheme::setWallpaper(const QString &path, const ColorSchemeWallpaper::
_wallpaper
=
new
ColorSchemeWallpaper
(
path
,
style
,
anchor
);
}
void
ColorScheme
::
setWallpaper
(
const
QString
&
path
,
const
QString
style
,
const
QPointF
&
anchor
)
{
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
);
}
ColorSchemeWallpaper
::
Ptr
ColorScheme
::
wallpaper
()
const
{
return
_wallpaper
;
}
}
\ No newline at end of file
src/colorscheme/ColorScheme.h
View file @
f8fe5a57
...
...
@@ -134,6 +134,7 @@ public:
bool
blur
()
const
;
void
setWallpaper
(
const
QString
&
path
,
const
ColorSchemeWallpaper
::
FillStyle
style
,
const
QPointF
&
anchor
);
void
setWallpaper
(
const
QString
&
path
,
const
QString
style
,
const
QPointF
&
anchor
);
ColorSchemeWallpaper
::
Ptr
wallpaper
()
const
;
...
...
src/colorscheme/ColorSchemeEditor.cpp
View file @
f8fe5a57
...
...
@@ -92,6 +92,10 @@ ColorSchemeEditor::ColorSchemeEditor(QWidget *parent)
connect
(
_ui
->
wallpaperSelectButton
,
&
QToolButton
::
clicked
,
this
,
&
Konsole
::
ColorSchemeEditor
::
selectWallpaper
);
connect
(
_ui
->
wallpaperPath
,
&
QLineEdit
::
textChanged
,
this
,
&
Konsole
::
ColorSchemeEditor
::
wallpaperPathChanged
);
connect
(
_ui
->
wallpaperScalingType
,
&
QComboBox
::
currentTextChanged
,
this
,
&
Konsole
::
ColorSchemeEditor
::
scalingTypeChanged
);
connect
(
_ui
->
wallpaperHorizontalAnchorSlider
,
&
QSlider
::
valueChanged
,
this
,
&
Konsole
::
ColorSchemeEditor
::
horizontalAnchorChanged
);
connect
(
_ui
->
wallpaperVerticalAnchorSlider
,
&
QSlider
::
valueChanged
,
this
,
&
Konsole
::
ColorSchemeEditor
::
verticalAnchorChanged
);
// color table
_ui
->
colorTable
->
setColumnCount
(
4
);
_ui
->
colorTable
->
setRowCount
(
COLOR_TABLE_ROW_LENGTH
);
...
...
@@ -197,6 +201,47 @@ void ColorSchemeEditor::wallpaperPathChanged(const QString &path)
}
}
void
ColorSchemeEditor
::
scalingTypeChanged
(
QString
style
)
{
_colors
->
setWallpaper
(
_colors
->
wallpaper
()
->
path
(),
style
,
_colors
->
wallpaper
()
->
anchor
());
}
void
ColorSchemeEditor
::
horizontalAnchorChanged
(
int
pos
)
{
QPointF
anch
=
_colors
->
wallpaper
()
->
anchor
();
_colors
->
setWallpaper
(
_colors
->
wallpaper
()
->
path
(),
_colors
->
wallpaper
()
->
style
(),
QPointF
(
pos
/
2.0
,
anch
.
y
()));
switch
(
pos
)
{
case
2
:
_ui
->
wallpaperHorizontalAnchorPosition
->
setText
(
QString
::
fromLatin1
(
"Right"
));
break
;
case
1
:
_ui
->
wallpaperHorizontalAnchorPosition
->
setText
(
QString
::
fromLatin1
(
"Center"
));
break
;
case
0
:
default:
_ui
->
wallpaperHorizontalAnchorPosition
->
setText
(
QString
::
fromLatin1
(
"Left"
));
break
;
}
}
void
ColorSchemeEditor
::
verticalAnchorChanged
(
int
pos
)
{
QPointF
anch
=
_colors
->
wallpaper
()
->
anchor
();
_colors
->
setWallpaper
(
_colors
->
wallpaper
()
->
path
(),
_colors
->
wallpaper
()
->
style
(),
QPointF
(
anch
.
x
(),
pos
/
2.0
));
switch
(
pos
)
{
case
2
:
_ui
->
wallpaperVerticalAnchorPosition
->
setText
(
QString
::
fromLatin1
(
"Bottom"
));
break
;
case
1
:
_ui
->
wallpaperVerticalAnchorPosition
->
setText
(
QString
::
fromLatin1
(
"Middle"
));
break
;
case
0
:
default:
_ui
->
wallpaperVerticalAnchorPosition
->
setText
(
QString
::
fromLatin1
(
"Top"
));
break
;
}
}
void
ColorSchemeEditor
::
setDescription
(
const
QString
&
description
)
{
if
(
_colors
!=
nullptr
)
{
...
...
@@ -257,7 +302,12 @@ void ColorSchemeEditor::setup(const std::shared_ptr<const ColorScheme> &scheme,
_ui
->
randomizedBackgroundCheck
->
setChecked
(
scheme
->
isColorRandomizationEnabled
());
// wallpaper stuff
int
ax
=
qRound
(
scheme
->
wallpaper
()
->
anchor
().
x
()
*
2.0
);
int
ay
=
qRound
(
scheme
->
wallpaper
()
->
anchor
().
y
()
*
2.0
);
_ui
->
wallpaperPath
->
setText
(
scheme
->
wallpaper
()
->
path
());
_ui
->
wallpaperScalingType
->
setCurrentIndex
(
scheme
->
wallpaper
()
->
style
());
_ui
->
wallpaperHorizontalAnchorSlider
->
setValue
(
ax
);
_ui
->
wallpaperVerticalAnchorSlider
->
setValue
(
ay
);
}
void
ColorSchemeEditor
::
setupColorTable
(
const
std
::
shared_ptr
<
ColorScheme
>
&
colors
)
...
...
src/colorscheme/ColorSchemeEditor.h
View file @
f8fe5a57
...
...
@@ -69,6 +69,9 @@ private Q_SLOTS:
void
setRandomizedBackgroundColor
(
bool
randomized
);
void
editColorItem
(
QTableWidgetItem
*
item
);
void
wallpaperPathChanged
(
const
QString
&
path
);
void
scalingTypeChanged
(
QString
style
);
void
horizontalAnchorChanged
(
int
pos
);
void
verticalAnchorChanged
(
int
pos
);
void
selectWallpaper
();
/** Triggered by apply/ok buttons */
void
saveColorScheme
();
...
...
src/colorscheme/ColorSchemeEditor.ui
View file @
f8fe5a57
...
...
@@ -7,7 +7,7 @@
<x>
0
</x>
<y>
0
</y>
<width>
364
</width>
<height>
376
</height>
<height>
460
</height>
</rect>
</property>
<layout
class=
"QVBoxLayout"
>
...
...
@@ -123,6 +123,120 @@ 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=
"wallpaperScalingLabel"
>
<property
name=
"text"
>
<string>
Wallpaper scaling:
</string>
</property>
</widget>
</item>
<item>
<widget
class=
"QComboBox"
name=
"wallpaperScalingType"
>
<item>
<property
name=
"text"
>
<string>
Tile
</string>
</property>
</item>
<item>
<property
name=
"text"
>
<string>
Stretch
</string>
</property>
</item>
<item>
<property
name=
"text"
>
<string>
Crop
</string>
</property>
</item>
<item>
<property
name=
"text"
>
<string>
Adapt
</string>
</property>
</item>
<item>
<property
name=
"text"
>
<string>
NoScaling
</string>
</property>
</item>
</widget>
</item>
</layout>
</item>
<item>
<layout
class=
"QHBoxLayout"
>
<item>
<widget
class=
"QLabel"
name=
"wallpaperHorizontalAnchorLabel"
>
<property
name=
"text"
>
<string>
Horizontal Anchor:
</string>
</property>
</widget>
</item>
<item>
<widget
class=
"QSlider"
name=
"wallpaperHorizontalAnchorSlider"
>
<property
name=
"maximum"
>
<number>
2
</number>
</property>
<property
name=
"singleStep"
>
<number>
1
</number>
</property>
<property
name=
"orientation"
>
<enum>
Qt::Horizontal
</enum>
</property>
<property
name=
"tickPosition"
>
<enum>
QSlider::TicksBelow
</enum>
</property>
<property
name=
"tickInterval"
>
<number>
1
</number>
</property>
</widget>
</item>
<item>
<widget
class=
"QLabel"
name=
"wallpaperHorizontalAnchorPosition"
>
<property
name=
"text"
>
<string>
Left
</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout
class=
"QHBoxLayout"
>
<item>
<widget
class=
"QLabel"
name=
"wallpaperVerticalAnchorLabel"
>
<property
name=
"text"
>
<string>
Vertical Anchor:
</string>
</property>
</widget>
</item>
<item>
<widget
class=
"QSlider"
name=
"wallpaperVerticalAnchorSlider"
>
<property
name=
"maximum"
>
<number>
2
</number>
</property>
<property
name=
"singleStep"
>
<number>
1
</number>
</property>
<property
name=
"orientation"
>
<enum>
Qt::Horizontal
</enum>
</property>
<property
name=
"tickPosition"
>
<enum>
QSlider::TicksBelow
</enum>
</property>
<property
name=
"tickInterval"
>
<number>
1
</number>
</property>
</widget>
</item>
<item>
<widget
class=
"QLabel"
name=
"wallpaperVerticalAnchorPosition"
>
<property
name=
"text"
>
<string>
Top
</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<spacer>
<property
name=
"orientation"
>
...
...
src/colorscheme/ColorSchemeWallpaper.cpp
View file @
f8fe5a57
...
...
@@ -103,7 +103,7 @@ QPointF ColorSchemeWallpaper::anchor() const
QRectF
ColorSchemeWallpaper
::
ScaledRect
(
const
QSize
viewportSize
,
const
QSize
pictureSize
,
const
QRect
rect
)
{
QRectF
scaledRect
=
QRectF
();
QSize
scaledSize
=
_style
==
No
Resize
?
pictureSize
:
pictureSize
.
scaled
(
viewportSize
,
RatioMode
());
QSize
scaledSize
=
_style
==
No
Scaling
?
pictureSize
:
pictureSize
.
scaled
(
viewportSize
,
RatioMode
());
double
scaleX
=
pictureSize
.
width
()
/
static_cast
<
double
>
(
scaledSize
.
width
());
double
scaleY
=
pictureSize
.
height
()
/
static_cast
<
double
>
(
scaledSize
.
height
());
...
...
src/colorscheme/ColorSchemeWallpaper.h
View file @
f8fe5a57
...
...
@@ -37,8 +37,9 @@ public:
Stretch
,
Crop
,
Adapt
,
No
Resize
No
Scaling
};
Q_ENUM
(
FillStyle
)
typedef
QExplicitlySharedDataPointer
<
ColorSchemeWallpaper
>
Ptr
;
...
...
@@ -59,6 +60,7 @@ public:
QPointF
anchor
()
const
;
private:
Q_GADGET
Q_DISABLE_COPY
(
ColorSchemeWallpaper
)
QString
_path
;
...
...
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