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
Graphics
Gwenview
Commits
e6241375
Commit
e6241375
authored
Jun 12, 2021
by
Noah Davis
🌵
Browse files
Add background color switching widget and use colors based on the color scheme
This also replaces the background color slider
parent
2c829f4e
Changes
19
Hide whitespace changes
Inline
Side-by-side
CMakeLists.txt
View file @
e6241375
...
...
@@ -70,6 +70,7 @@ find_package(KF5 ${KF5_MIN_VERSION} REQUIRED COMPONENTS
Notifications
GuiAddons
WidgetsAddons
GuiAddons
)
find_package
(
KF5
${
KF5_MIN_VERSION
}
OPTIONAL_COMPONENTS
Activities
...
...
app/CMakeLists.txt
View file @
e6241375
...
...
@@ -81,6 +81,7 @@ target_link_libraries(gwenview
KF5::ItemModels
KF5::Notifications
KF5::WidgetsAddons
KF5::GuiAddons
gwenviewlib
)
...
...
app/browsemainpage.cpp
View file @
e6241375
...
...
@@ -352,6 +352,8 @@ BrowseMainPage::BrowseMainPage(QWidget* parent, KActionCollection* actionCollect
connect
(
thumbnailView
(),
&
ThumbnailView
::
selectionChangedSignal
,
this
,
&
BrowseMainPage
::
slotSelectionChanged
);
connect
(
qApp
,
&
QApplication
::
paletteChanged
,
this
,
[
this
](){
d
->
applyPalette
(
window
()
->
isFullScreen
());
});
installEventFilter
(
this
);
}
...
...
app/configdialog.cpp
View file @
e6241375
...
...
@@ -72,11 +72,9 @@ ConfigDialog::ConfigDialog(QWidget* parent)
pageItem
=
addPage
(
widget
,
i18n
(
"General"
));
pageItem
->
setIcon
(
QIcon
::
fromTheme
(
QStringLiteral
(
"gwenview"
)));
connect
(
mGeneralConfigPage
.
kcfg_ViewBackgroundValue
,
&
QAbstractSlider
::
valueChanged
,
this
,
&
ConfigDialog
::
updateViewBackgroundFrame
);
connect
(
mGeneralConfigPage
.
kcfg_JPEGQuality
,
&
QAbstractSlider
::
valueChanged
,
this
,
[
=
]
(
int
value
)
{
mGeneralConfigPage
.
jpegQualitySpinner
->
setValue
(
value
);});
connect
(
mGeneralConfigPage
.
jpegQualitySpinner
,
QOverload
<
int
>::
of
(
&
QSpinBox
::
valueChanged
),
this
,
[
=
]
(
int
value
)
{
mGeneralConfigPage
.
kcfg_JPEGQuality
->
setValue
(
value
);});
mGeneralConfigPage
.
jpegQualitySpinner
->
setValue
(
mGeneralConfigPage
.
kcfg_JPEGQuality
->
value
());
mGeneralConfigPage
.
backgroundValueFrame
->
setMinimumWidth
(
mGeneralConfigPage
.
jpegQualitySpinner
->
width
());
mGeneralConfigPage
.
lossyImageFormatHelpLabel
->
setFont
(
QFontDatabase
::
systemFont
(
QFontDatabase
::
SmallestReadableFont
));
mGeneralConfigPage
.
kcfg_AutoplayVideos
->
setEnabled
(
mGeneralConfigPage
.
kcfg_ListVideos
->
isChecked
());
...
...
@@ -133,24 +131,6 @@ ConfigDialog::ConfigDialog(QWidget* parent)
mAdvancedConfigPage
.
perceptualHelpLabel
->
setFont
(
QFontDatabase
::
systemFont
(
QFontDatabase
::
SmallestReadableFont
));
mAdvancedConfigPage
.
relativeHelpLabel
->
setFont
(
QFontDatabase
::
systemFont
(
QFontDatabase
::
SmallestReadableFont
));
mAdvancedConfigPage
.
colorProfileHelpLabel
->
setFont
(
QFontDatabase
::
systemFont
(
QFontDatabase
::
SmallestReadableFont
));
updateViewBackgroundFrame
();
}
void
ConfigDialog
::
updateViewBackgroundFrame
()
{
const
QColor
color
=
QColor
::
fromHsv
(
0
,
0
,
mGeneralConfigPage
.
kcfg_ViewBackgroundValue
->
value
());
const
QString
css
=
QStringLiteral
(
"background-color: %1;"
"border-radius: 5px;"
"border: 1px solid %1;"
)
.
arg
(
color
.
name
());
// When using Oxygen, setting the background color via palette causes the
// pixels outside the frame to be painted with the new background color as
// well. Using CSS works more like expected.
mGeneralConfigPage
.
backgroundValueFrame
->
setStyleSheet
(
css
);
}
}
// namespace
app/configdialog.h
View file @
e6241375
...
...
@@ -41,9 +41,6 @@ class ConfigDialog : public KConfigDialog
public:
ConfigDialog
(
QWidget
*
parent
);
private
Q_SLOTS
:
void
updateViewBackgroundFrame
();
private:
InvisibleButtonGroup
*
mWrapNavigationBehaviorGroup
=
nullptr
;
InvisibleButtonGroup
*
mAlphaBackgroundModeGroup
=
nullptr
;
...
...
app/generalconfigpage.ui
View file @
e6241375
...
...
@@ -83,90 +83,6 @@
</spacer>
</item>
<item
row=
"6"
column=
"0"
>
<widget
class=
"QLabel"
name=
"label_2"
>
<property
name=
"text"
>
<string>
Background color:
</string>
</property>
<property
name=
"buddy"
>
<cstring>
kcfg_ViewBackgroundValue
</cstring>
</property>
</widget>
</item>
<item
row=
"6"
column=
"1"
>
<layout
class=
"QHBoxLayout"
>
<item>
<widget
class=
"QSlider"
name=
"kcfg_ViewBackgroundValue"
>
<property
name=
"minimumSize"
>
<size>
<width>
256
</width>
<height>
0
</height>
</size>
</property>
<property
name=
"maximum"
>
<number>
255
</number>
</property>
<property
name=
"orientation"
>
<enum>
Qt::Horizontal
</enum>
</property>
</widget>
</item>
<item>
<widget
class=
"QFrame"
name=
"backgroundValueFrame"
>
<property
name=
"sizePolicy"
>
<sizepolicy
hsizetype=
"Fixed"
vsizetype=
"Preferred"
>
<horstretch>
0
</horstretch>
<verstretch>
0
</verstretch>
</sizepolicy>
</property>
<property
name=
"minimumSize"
>
<size>
<width>
70
</width>
<height>
0
</height>
</size>
</property>
<property
name=
"autoFillBackground"
>
<bool>
true
</bool>
</property>
<property
name=
"frameShape"
>
<enum>
QFrame::StyledPanel
</enum>
</property>
<property
name=
"frameShadow"
>
<enum>
QFrame::Sunken
</enum>
</property>
</widget>
</item>
<item>
<spacer>
<property
name=
"orientation"
>
<enum>
Qt::Horizontal
</enum>
</property>
<property
name=
"sizeHint"
stdset=
"0"
>
<size>
<width>
40
</width>
<height>
20
</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
<item
row=
"7"
column=
"1"
>
<spacer
name=
"verticalSpacer_2"
>
<property
name=
"orientation"
>
<enum>
Qt::Vertical
</enum>
</property>
<property
name=
"sizeType"
>
<enum>
QSizePolicy::Fixed
</enum>
</property>
<property
name=
"sizeHint"
stdset=
"0"
>
<size>
<width>
20
</width>
<height>
20
</height>
</size>
</property>
</spacer>
</item>
<item
row=
"8"
column=
"0"
>
<widget
class=
"QLabel"
name=
"label_3"
>
<property
name=
"text"
>
<string>
Fullscreen background:
</string>
...
...
@@ -176,21 +92,21 @@
</property>
</widget>
</item>
<item
row=
"
8
"
column=
"1"
>
<item
row=
"
6
"
column=
"1"
>
<widget
class=
"QRadioButton"
name=
"fullscreenBackgroundImageRadioButton"
>
<property
name=
"text"
>
<string>
Dark gray texture
</string>
</property>
</widget>
</item>
<item
row=
"
9
"
column=
"1"
>
<item
row=
"
7
"
column=
"1"
>
<widget
class=
"QRadioButton"
name=
"fullscreenBackgroundBlackRadioButton"
>
<property
name=
"text"
>
<string>
Black
</string>
</property>
</widget>
</item>
<item
row=
"
10
"
column=
"1"
>
<item
row=
"
8
"
column=
"1"
>
<spacer
name=
"verticalSpacer_3"
>
<property
name=
"orientation"
>
<enum>
Qt::Vertical
</enum>
...
...
@@ -206,7 +122,7 @@
</property>
</spacer>
</item>
<item
row=
"
11
"
column=
"0"
>
<item
row=
"
9
"
column=
"0"
>
<widget
class=
"QLabel"
name=
"label_4"
>
<property
name=
"text"
>
<string>
Lossy image save quality:
</string>
...
...
@@ -216,7 +132,7 @@
</property>
</widget>
</item>
<item
row=
"
11
"
column=
"1"
>
<item
row=
"
9
"
column=
"1"
>
<layout
class=
"QHBoxLayout"
name=
"horizontalLayout"
>
<item>
<widget
class=
"QSlider"
name=
"kcfg_JPEGQuality"
>
...
...
@@ -274,7 +190,7 @@
</item>
</layout>
</item>
<item
row=
"1
2
"
column=
"1"
>
<item
row=
"1
0
"
column=
"1"
>
<widget
class=
"QLabel"
name=
"lossyImageFormatHelpLabel"
>
<property
name=
"text"
>
<string>
The quality level when saving images using lossy image formats such as JPEG, WEBP, AVIF, HEIF, and HEIC. Higher quality increases the file size.
</string>
...
...
@@ -284,8 +200,8 @@
</property>
</widget>
</item>
<item
row=
"1
3
"
column=
"1"
>
<spacer
name=
"verticalSpacer_
4
"
>
<item
row=
"1
1
"
column=
"1"
>
<spacer
name=
"verticalSpacer_
3
"
>
<property
name=
"orientation"
>
<enum>
Qt::Vertical
</enum>
</property>
...
...
@@ -300,28 +216,28 @@
</property>
</spacer>
</item>
<item
row=
"1
4
"
column=
"0"
>
<item
row=
"1
2
"
column=
"0"
>
<widget
class=
"QLabel"
name=
"label_5"
>
<property
name=
"text"
>
<string>
Thumbnail actions:
</string>
</property>
</widget>
</item>
<item
row=
"1
5
"
column=
"1"
>
<item
row=
"1
3
"
column=
"1"
>
<widget
class=
"QRadioButton"
name=
"allButtonsThumbnailActionsRadioButton"
>
<property
name=
"text"
>
<string>
All buttons
</string>
</property>
</widget>
</item>
<item
row=
"1
6
"
column=
"1"
>
<item
row=
"1
4
"
column=
"1"
>
<widget
class=
"QRadioButton"
name=
"selectionOnlyThumbnailActionsRadioButton"
>
<property
name=
"text"
>
<string>
Show selection button only
</string>
</property>
</widget>
</item>
<item
row=
"1
7
"
column=
"1"
>
<item
row=
"1
5
"
column=
"1"
>
<widget
class=
"QRadioButton"
name=
"noneThumbnailActionsRadioButton"
>
<property
name=
"text"
>
<string>
None
</string>
...
...
app/gvcore.cpp
View file @
e6241375
...
...
@@ -33,6 +33,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Cambridge, MA 02110-1301, USA
// KF
#include <KColorScheme>
#include <KColorUtils>
#include <KFileCustomDialog>
#include <KFileWidget>
#include <KLocalizedString>
...
...
@@ -41,6 +42,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Cambridge, MA 02110-1301, USA
// Local
#include "gwenview_app_debug.h"
#include "dialogguard.h"
#include <lib/backgroundcolorwidget/backgroundcolorwidget.h>
#include <lib/binder.h>
#include <lib/document/documentfactory.h>
#include <lib/document/documentjob.h>
...
...
@@ -166,18 +168,44 @@ struct GvCorePrivate
void
setupPalettes
()
{
QPalette
pal
;
int
value
=
GwenviewConfig
::
viewBackgroundValue
();
QColor
fgColor
=
value
>
128
?
Qt
::
black
:
Qt
::
white
;
// Normal
KSharedConfigPtr
config
=
KSharedConfig
::
openConfig
();
mPalettes
[
GvCore
::
NormalPalette
]
=
KColorScheme
::
createApplicationPalette
(
config
);
QPalette
viewPalette
=
mPalettes
[
GvCore
::
NormalPalette
];
BackgroundColorWidget
::
ColorMode
colorMode
=
GwenviewConfig
::
backgroundColorMode
();
bool
usingLightTheme
=
BackgroundColorWidget
::
usingLightTheme
();
if
((
usingLightTheme
&&
colorMode
==
BackgroundColorWidget
::
Dark
)
||
(
!
usingLightTheme
&&
colorMode
==
BackgroundColorWidget
::
Light
))
{
viewPalette
.
setColor
(
QPalette
::
Base
,
mPalettes
[
GvCore
::
NormalPalette
].
color
(
QPalette
::
Text
));
viewPalette
.
setColor
(
QPalette
::
Text
,
mPalettes
[
GvCore
::
NormalPalette
].
color
(
QPalette
::
Base
));
viewPalette
.
setColor
(
QPalette
::
Window
,
mPalettes
[
GvCore
::
NormalPalette
].
color
(
QPalette
::
WindowText
));
viewPalette
.
setColor
(
QPalette
::
WindowText
,
mPalettes
[
GvCore
::
NormalPalette
].
color
(
QPalette
::
Window
));
viewPalette
.
setColor
(
QPalette
::
Button
,
mPalettes
[
GvCore
::
NormalPalette
].
color
(
QPalette
::
ButtonText
));
viewPalette
.
setColor
(
QPalette
::
ButtonText
,
mPalettes
[
GvCore
::
NormalPalette
].
color
(
QPalette
::
Button
));
viewPalette
.
setColor
(
QPalette
::
ToolTipBase
,
mPalettes
[
GvCore
::
NormalPalette
].
color
(
QPalette
::
ToolTipText
));
viewPalette
.
setColor
(
QPalette
::
ToolTipText
,
mPalettes
[
GvCore
::
NormalPalette
].
color
(
QPalette
::
ToolTipBase
));
}
else
if
(
colorMode
==
BackgroundColorWidget
::
Neutral
)
{
QColor
base
=
KColorUtils
::
mix
(
mPalettes
[
GvCore
::
NormalPalette
].
color
(
QPalette
::
Base
),
mPalettes
[
GvCore
::
NormalPalette
].
color
(
QPalette
::
Text
),
0.5
);
QColor
window
=
KColorUtils
::
mix
(
mPalettes
[
GvCore
::
NormalPalette
].
color
(
QPalette
::
Window
),
mPalettes
[
GvCore
::
NormalPalette
].
color
(
QPalette
::
WindowText
),
0.5
);
QColor
button
=
KColorUtils
::
mix
(
mPalettes
[
GvCore
::
NormalPalette
].
color
(
QPalette
::
Button
),
mPalettes
[
GvCore
::
NormalPalette
].
color
(
QPalette
::
ButtonText
),
0.5
);
QColor
toolTipBase
=
KColorUtils
::
mix
(
mPalettes
[
GvCore
::
NormalPalette
].
color
(
QPalette
::
ToolTipBase
),
mPalettes
[
GvCore
::
NormalPalette
].
color
(
QPalette
::
ToolTipText
),
0.5
);
viewPalette
.
setColor
(
QPalette
::
Base
,
base
);
viewPalette
.
setColor
(
QPalette
::
Text
,
base
.
lightnessF
()
>
0.5
?
Qt
::
black
:
Qt
::
white
);
viewPalette
.
setColor
(
QPalette
::
Window
,
window
);
viewPalette
.
setColor
(
QPalette
::
WindowText
,
base
.
lightnessF
()
>
0.5
?
Qt
::
black
:
Qt
::
white
);
viewPalette
.
setColor
(
QPalette
::
Button
,
button
);
viewPalette
.
setColor
(
QPalette
::
ButtonText
,
base
.
lightnessF
()
>
0.5
?
Qt
::
black
:
Qt
::
white
);
viewPalette
.
setColor
(
QPalette
::
ToolTipBase
,
toolTipBase
);
viewPalette
.
setColor
(
QPalette
::
ToolTipText
,
base
.
lightnessF
()
>
0.5
?
Qt
::
black
:
Qt
::
white
);
}
pal
=
mPalettes
[
GvCore
::
NormalPalette
];
pal
.
setColor
(
QPalette
::
Base
,
QColor
::
fromHsv
(
0
,
0
,
value
));
pal
.
setColor
(
QPalette
::
Text
,
fgColor
);
mPalettes
[
GvCore
::
NormalViewPalette
]
=
pal
;
mPalettes
[
GvCore
::
NormalViewPalette
]
=
viewPalette
;
// Fullscreen
QString
name
=
GwenviewConfig
::
fullScreenColorScheme
();
...
...
@@ -202,7 +230,7 @@ struct GvCorePrivate
}
// FullScreenView has either a solid black color or a textured background
pal
=
mPalettes
[
GvCore
::
FullScreenPalette
];
viewPalette
=
mPalettes
[
GvCore
::
FullScreenPalette
];
QPixmap
bgTexture
(
256
,
256
);
if
(
Gwenview
::
GwenviewConfig
::
fullScreenBackground
()
==
Gwenview
::
FullScreenBackground
::
Black
)
{
bgTexture
.
fill
(
Qt
::
black
);
...
...
@@ -210,8 +238,8 @@ struct GvCorePrivate
QString
path
=
QStandardPaths
::
locate
(
QStandardPaths
::
AppDataLocation
,
"images/background.png"
);
bgTexture
=
path
;
}
pal
.
setBrush
(
QPalette
::
Base
,
bgTexture
);
mPalettes
[
GvCore
::
FullScreenViewPalette
]
=
pal
;
viewPalette
.
setBrush
(
QPalette
::
Base
,
bgTexture
);
mPalettes
[
GvCore
::
FullScreenViewPalette
]
=
viewPalette
;
}
void
adjustDefaultFullScreenPalette
()
...
...
@@ -318,6 +346,7 @@ GvCore::GvCore(MainWindow* mainWindow, SortedDirModel* dirModel)
connect
(
GwenviewConfig
::
self
(),
SIGNAL
(
configChanged
()),
SLOT
(
slotConfigChanged
()));
connect
(
qApp
,
&
QApplication
::
paletteChanged
,
this
,
[
this
](){
d
->
setupPalettes
();
});
}
GvCore
::~
GvCore
()
...
...
app/gwenviewui.rc
View file @
e6241375
...
...
@@ -30,6 +30,11 @@
<Action
name=
"view_zoom_out"
/>
<Action
name=
"view_toggle_birdeyeview"
/>
<Separator/>
<Action
name=
"view_background_colormode_auto"
/>
<Action
name=
"view_background_colormode_light"
/>
<Action
name=
"view_background_colormode_neutral"
/>
<Action
name=
"view_background_colormode_dark"
/>
<Separator/>
<Action
name=
"sort_by"
/>
<Action
name=
"thumbnail_details"
/>
<Separator/>
...
...
app/startmainpage.cpp
View file @
e6241375
...
...
@@ -189,6 +189,8 @@ StartMainPage::StartMainPage(QWidget* parent, GvCore* gvCore)
d
->
updateHistoryTab
();
connect
(
GwenviewConfig
::
self
(),
&
GwenviewConfig
::
configChanged
,
this
,
&
StartMainPage
::
loadConfig
);
connect
(
qApp
,
&
QApplication
::
paletteChanged
,
this
,
[
this
](){
applyPalette
(
d
->
mGvCore
->
palette
(
GvCore
::
NormalViewPalette
));
});
d
->
mRecentFoldersView
->
setFocus
();
ScrollerUtils
::
setQScroller
(
d
->
mBookmarksView
->
viewport
());
...
...
app/viewmainpage.cpp
View file @
e6241375
...
...
@@ -45,6 +45,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#include "fileoperations.h"
#include <gvcore.h>
#include "splitter.h"
#include <lib/backgroundcolorwidget/backgroundcolorwidget.h>
#include <lib/documentview/abstractdocumentviewadapter.h>
#include <lib/documentview/abstractrasterimageviewtool.h>
#include <lib/documentview/documentview.h>
...
...
@@ -121,6 +122,7 @@ struct ViewMainPagePrivate
DocumentViewSynchronizer
*
mSynchronizer
;
QToolButton
*
mToggleSideBarButton
;
QToolButton
*
mToggleThumbnailBarButton
;
BackgroundColorWidget
*
mBackgroundColorWidget
;
ZoomWidget
*
mZoomWidget
;
DocumentViewContainer
*
mDocumentViewContainer
;
SlideContainer
*
mToolContainer
;
...
...
@@ -151,6 +153,7 @@ struct ViewMainPagePrivate
mStatusBarContainer
->
setSizePolicy
(
QSizePolicy
::
Expanding
,
QSizePolicy
::
Fixed
);
mToggleSideBarButton
=
new
StatusBarToolButton
;
mToggleThumbnailBarButton
=
new
StatusBarToolButton
;
mBackgroundColorWidget
=
new
BackgroundColorWidget
;
mZoomWidget
=
new
ZoomWidget
;
mSynchronizeCheckBox
=
new
QCheckBox
(
i18n
(
"Synchronize"
));
mSynchronizeCheckBox
->
hide
();
...
...
@@ -176,6 +179,7 @@ struct ViewMainPagePrivate
// so its autohide feature works properly (stretch factor = 1)
statusBarContainerLayout
->
addWidget
(
mDocumentCountLabel
,
1
);
statusBarContainerLayout
->
addStretch
();
statusBarContainerLayout
->
addWidget
(
mBackgroundColorWidget
);
statusBarContainerLayout
->
addWidget
(
mZoomWidget
);
//--
mAdapterContainer
=
new
QWidget
;
...
...
@@ -214,6 +218,7 @@ struct ViewMainPagePrivate
viewMainPageLayout
->
addWidget
(
mStatusBarContainer
);
//--
mDocumentViewController
=
new
DocumentViewController
(
mActionCollection
,
q
);
mDocumentViewController
->
setBackgroundColorWidget
(
mBackgroundColorWidget
);
mDocumentViewController
->
setZoomWidget
(
mZoomWidget
);
mDocumentViewController
->
setToolContainer
(
mToolContainer
);
mSynchronizer
=
new
DocumentViewSynchronizer
(
&
mDocumentViews
,
q
);
...
...
@@ -448,6 +453,8 @@ ViewMainPage::ViewMainPage(QWidget* parent, SlideShow* slideShow, KActionCollect
connect
(
d
->
mThumbnailBar
,
&
ThumbnailBarView
::
rowsRemovedSignal
,
this
,
&
ViewMainPage
::
slotDirModelItemsAddedOrRemoved
);
connect
(
qApp
,
&
QApplication
::
paletteChanged
,
this
,
[
this
](){
d
->
applyPalette
(
window
()
->
isFullScreen
());
});
installEventFilter
(
this
);
}
...
...
@@ -555,6 +562,14 @@ void ViewMainPage::showContextMenu()
addActionToMenu
(
&
menu
,
d
->
mActionCollection
,
"view_zoom_out"
);
addActionToMenu
(
&
menu
,
d
->
mActionCollection
,
"view_toggle_birdeyeview"
);
}
menu
.
addSeparator
();
QMenu
backgroundColorModeMenu
(
i18nc
(
"@item:inmenu"
,
"Background Color Mode"
),
this
);
addActionToMenu
(
&
backgroundColorModeMenu
,
d
->
mActionCollection
,
"view_background_colormode_auto"
);
addActionToMenu
(
&
backgroundColorModeMenu
,
d
->
mActionCollection
,
"view_background_colormode_light"
);
addActionToMenu
(
&
backgroundColorModeMenu
,
d
->
mActionCollection
,
"view_background_colormode_neutral"
);
addActionToMenu
(
&
backgroundColorModeMenu
,
d
->
mActionCollection
,
"view_background_colormode_dark"
);
backgroundColorModeMenu
.
setIcon
(
backgroundColorModeMenu
.
actions
().
at
(
0
)
->
icon
());
menu
.
addMenu
(
&
backgroundColorModeMenu
);
if
(
d
->
mCompareMode
)
{
menu
.
addSeparator
();
addActionToMenu
(
&
menu
,
d
->
mActionCollection
,
"synchronize_views"
);
...
...
@@ -568,7 +583,7 @@ void ViewMainPage::showContextMenu()
menu
.
addSeparator
();
addActionToMenu
(
&
menu
,
d
->
mActionCollection
,
"file_open_with"
);
addActionToMenu
(
&
menu
,
d
->
mActionCollection
,
"file_open_containing_folder"
);
menu
.
exec
(
QCursor
::
pos
());
}
...
...
importer/thumbnailpage.cpp
View file @
e6241375
...
...
@@ -175,17 +175,6 @@ struct ThumbnailPagePrivate : public Ui_ThumbnailPage
delegate
->
setContextBarActions
(
actions
);
mThumbnailView
->
setItemDelegate
(
delegate
);
// Colors
int
value
=
GwenviewConfig
::
viewBackgroundValue
();
QColor
bgColor
=
QColor
::
fromHsv
(
0
,
0
,
value
);
QColor
fgColor
=
value
>
128
?
Qt
::
black
:
Qt
::
white
;
QPalette
pal
=
mThumbnailView
->
palette
();
pal
.
setColor
(
QPalette
::
Base
,
bgColor
);
pal
.
setColor
(
QPalette
::
Text
,
fgColor
);
mThumbnailView
->
setPalette
(
pal
);
QObject
::
connect
(
mSlider
,
&
ZoomSlider
::
valueChanged
,
mThumbnailView
,
&
ThumbnailView
::
setThumbnailWidth
);
QObject
::
connect
(
mThumbnailView
,
&
ThumbnailView
::
thumbnailWidthChanged
,
...
...
lib/CMakeLists.txt
View file @
e6241375
...
...
@@ -41,6 +41,7 @@ include_directories(
)
set
(
gwenviewlib_SRCS
backgroundcolorwidget/backgroundcolorwidget.cpp
cms/iccjpeg.c
cms/cmsprofile.cpp
cms/cmsprofile_png.cpp
...
...
lib/backgroundcolorwidget/backgroundcolorwidget.cpp
0 → 100644
View file @
e6241375
/* SPDX-FileCopyrightText: 2021 Noah Davis <noahadvs@gmail.com>
* SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
*/
#include "backgroundcolorwidget.h"
#include <lib/gwenviewconfig.h>
#include <lib/statusbartoolbutton.h>
#include <KColorUtils>
#include <KLocalizedString>
#include <KSqueezedTextLabel>
#include <QAction>
#include <QApplication>
#include <QButtonGroup>
#include <QHBoxLayout>
#include <QPainter>
#include <QStyle>
#include <QStyleOptionToolButton>
using
namespace
Gwenview
;
class
Gwenview
::
BackgroundColorWidgetPrivate
{
Q_DECLARE_PUBLIC
(
BackgroundColorWidget
)
public:
BackgroundColorWidgetPrivate
(
BackgroundColorWidget
*
q
);
BackgroundColorWidget
*
const
q_ptr
;
void
initChildWidgets
();
void
initPixmaps
();
void
paintPixmap
(
QPixmap
&
pixmap
,
const
QColor
&
color
);
void
paintAutoPixmap
(
QPixmap
&
pixmap
,
const
QColor
&
lightColor
,
const
QColor
&
darkColor
);
void
setIcons
(
const
QIcon
&
autoIcon
,
const
QIcon
&
lightIcon
,
const
QIcon
&
neutralIcon
,
const
QIcon
&
darkIcon
);
BackgroundColorWidget
::
ColorMode
colorMode
;
bool
mirrored
;
bool
usingLightTheme
;
QHBoxLayout
*
hBoxLayout
=
nullptr
;
KSqueezedTextLabel
*
label
=
nullptr
;
QButtonGroup
*
buttonGroup
=
nullptr
;
StatusBarToolButton
*
autoButton
=
nullptr
;
StatusBarToolButton
*
lightButton
=
nullptr
;
StatusBarToolButton
*
neutralButton
=
nullptr
;
StatusBarToolButton
*
darkButton
=
nullptr
;
QAction
*
autoMode
=
nullptr
;
QAction
*
lightMode
=
nullptr
;
QAction
*
neutralMode
=
nullptr
;
QAction
*
darkMode
=
nullptr
;
};
BackgroundColorWidgetPrivate
::
BackgroundColorWidgetPrivate
(
BackgroundColorWidget
*
q
)
:
q_ptr
(
q
)
,
colorMode
(
GwenviewConfig
::
backgroundColorMode
())
,
mirrored
(
qApp
->
isRightToLeft
())
,
usingLightTheme
(
q
->
usingLightTheme
())
,
hBoxLayout
(
new
QHBoxLayout
(
q
))
,
label
(
new
KSqueezedTextLabel
(
q
))
,
buttonGroup
(
new
QButtonGroup
(
q
))
,
autoButton
(
new
StatusBarToolButton
(
q
))
,
lightButton
(
new
StatusBarToolButton
(
q
))
,
neutralButton
(
new
StatusBarToolButton
(
q
))
,
darkButton
(
new
StatusBarToolButton
(
q
))
{
initChildWidgets
();
};
void
BackgroundColorWidgetPrivate
::
initChildWidgets
()
{
Q_Q
(
BackgroundColorWidget
);
hBoxLayout
->
setContentsMargins
(
0
,
0
,
0
,
0
);
hBoxLayout
->
setSpacing
(
0
);
label
->
setText
(
i18nc
(
"@label:chooser Describes what a row of buttons control"
,
"Background color:"
));
// 4 is the same as the hardcoded spacing between icons and labels defined in
// QToolButton::sizeHint() when toolButtonStyle == ToolButtonTextBesideIcon.
label
->
setContentsMargins
(
4
,
0
,
4
,
0
);
label
->
setAlignment
(
Qt
::
AlignRight
|
Qt
::
AlignVCenter
);
label
->
setTextElideMode
(
Qt
::
ElideRight
);
hBoxLayout
->
addWidget
(
label
);
buttonGroup
->
setExclusive
(
true
);
for
(
auto
button
:
{
autoButton
,
lightButton
,
neutralButton
,
darkButton
})
{
button
->
setToolButtonStyle
(
Qt
::
ToolButtonIconOnly
);
button
->
setCheckable
(
true
);
buttonGroup
->
addButton
(
button
);
hBoxLayout
->
addWidget
(
button
);
}
autoButton
->
setGroupPosition
(
mirrored
?
StatusBarToolButton
::
GroupRight
:
StatusBarToolButton
::
GroupLeft
);
autoButton
->
setChecked
(
colorMode
==
BackgroundColorWidget
::
Auto
);
lightButton
->
setGroupPosition
(
StatusBarToolButton
::
GroupCenter
);
lightButton
->
setChecked
(
colorMode
==
BackgroundColorWidget
::
Light
);
neutralButton
->
setGroupPosition
(
StatusBarToolButton
::
GroupCenter
);
neutralButton
->
setChecked
(
colorMode
==
BackgroundColorWidget
::
Neutral
);
darkButton
->
setGroupPosition
(
mirrored
?
StatusBarToolButton
::
GroupLeft
:
StatusBarToolButton
::
GroupRight
);
darkButton
->
setChecked
(
colorMode
==
BackgroundColorWidget
::
Dark
);
initPixmaps
();
}
void
BackgroundColorWidgetPrivate
::
initPixmaps
()
{
QPixmap
lightPixmap
(
lightButton
->
iconSize
()
*
qApp
->
devicePixelRatio
());
QPixmap
neutralPixmap
(
neutralButton
->
iconSize
()
*
qApp
->
devicePixelRatio
());
QPixmap
darkPixmap
(
darkButton
->
iconSize
()
*
qApp
->
devicePixelRatio
());
QPixmap
autoPixmap
(
/*autoButton*/
darkButton
->
iconSize
()
*
qApp
->
devicePixelRatio
());
// Wipe them clean. If we don't do this, the background will have all sorts of weird artifacts.
lightPixmap
.
fill
(
Qt
::
transparent
);
neutralPixmap
.
fill
(
Qt
::
transparent
);
darkPixmap
.
fill
(
Qt
::
transparent
);
autoPixmap
.
fill
(
Qt
::
transparent
);
const
QColor
&
lightColor
=
usingLightTheme
?
qApp
->
palette
().
base
().
color
()
:
qApp
->
palette
().
text
().
color
();
const
QColor
&
darkColor
=
usingLightTheme
?
qApp
->
palette
().
text
().
color
()
:
qApp
->
palette
().
base
().
color
();
QColor
neutralColor
=
KColorUtils
::
mix
(
lightColor
,
darkColor
,
0.5
);
paintPixmap
(
lightPixmap
,
lightColor
);
paintPixmap
(
neutralPixmap
,
neutralColor
);
paintPixmap
(
darkPixmap
,
darkColor
);
paintAutoPixmap
(
autoPixmap
,
lightColor
,
darkColor
);