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
System
Dolphin
Commits
0dac70d0
Commit
0dac70d0
authored
Jan 28, 2022
by
Kai Uwe Broulik
🍇
Browse files
Hide "Places" section header when panels are unlocked
Avoids showing "Places" twice.
parent
f645e6b4
Pipeline
#133742
passed with stage
in 4 minutes and 4 seconds
Changes
3
Pipelines
3
Hide whitespace changes
Inline
Side-by-side
src/dolphinmainwindow.cpp
View file @
0dac70d0
...
...
@@ -912,6 +912,8 @@ void DolphinMainWindow::togglePanelLockState()
}
}
DolphinPlacesModelSingleton
::
instance
().
placesModel
()
->
setPanelsLocked
(
newLockState
);
GeneralSettings
::
setLockPanels
(
newLockState
);
}
...
...
@@ -1814,6 +1816,8 @@ void DolphinMainWindow::setupDockWidgets()
{
const
bool
lock
=
GeneralSettings
::
lockPanels
();
DolphinPlacesModelSingleton
::
instance
().
placesModel
()
->
setPanelsLocked
(
lock
);
KDualAction
*
lockLayoutAction
=
actionCollection
()
->
add
<
KDualAction
>
(
QStringLiteral
(
"lock_panels"
));
lockLayoutAction
->
setActiveText
(
i18nc
(
"@action:inmenu Panels"
,
"Unlock Panels"
));
lockLayoutAction
->
setActiveIcon
(
QIcon
::
fromTheme
(
QStringLiteral
(
"object-unlocked"
)));
...
...
src/dolphinplacesmodelsingleton.cpp
View file @
0dac70d0
...
...
@@ -20,9 +20,37 @@ DolphinPlacesModel::DolphinPlacesModel(const QString &alternativeApplicationName
DolphinPlacesModel
::~
DolphinPlacesModel
()
=
default
;
bool
DolphinPlacesModel
::
panelsLocked
()
const
{
return
m_panelsLocked
;
}
void
DolphinPlacesModel
::
setPanelsLocked
(
bool
locked
)
{
if
(
m_panelsLocked
==
locked
)
{
return
;
}
m_panelsLocked
=
locked
;
if
(
rowCount
()
>
0
)
{
int
lastPlace
=
rowCount
()
-
1
;
for
(
int
i
=
0
;
i
<
rowCount
();
++
i
)
{
if
(
KFilePlacesModel
::
groupType
(
index
(
i
,
0
))
!=
KFilePlacesModel
::
PlacesType
)
{
lastPlace
=
i
-
1
;
break
;
}
}
Q_EMIT
dataChanged
(
index
(
0
,
0
),
index
(
lastPlace
,
0
),
{
KFilePlacesModel
::
GroupRole
});
}
}
QVariant
DolphinPlacesModel
::
data
(
const
QModelIndex
&
index
,
int
role
)
const
{
if
(
role
==
Qt
::
DecorationRole
)
{
switch
(
role
)
{
case
Qt
::
DecorationRole
:
if
(
isTrash
(
index
))
{
if
(
m_isEmpty
)
{
return
QIcon
::
fromTheme
(
QStringLiteral
(
"user-trash"
));
...
...
@@ -30,6 +58,18 @@ QVariant DolphinPlacesModel::data(const QModelIndex &index, int role) const
return
QIcon
::
fromTheme
(
QStringLiteral
(
"user-trash-full"
));
}
}
break
;
case
KFilePlacesModel
::
GroupRole
:
{
// When panels are unlocked, avoid a double "Places" heading,
// one from the panel title bar, one from the places view section.
if
(
!
m_panelsLocked
)
{
const
auto
groupType
=
KFilePlacesModel
::
groupType
(
index
);
if
(
groupType
==
KFilePlacesModel
::
PlacesType
)
{
return
QString
();
}
}
break
;
}
}
return
KFilePlacesModel
::
data
(
index
,
role
);
...
...
src/dolphinplacesmodelsingleton.h
View file @
0dac70d0
...
...
@@ -26,6 +26,9 @@ public:
explicit
DolphinPlacesModel
(
const
QString
&
alternativeApplicationName
,
QObject
*
parent
=
nullptr
);
~
DolphinPlacesModel
()
override
;
bool
panelsLocked
()
const
;
void
setPanelsLocked
(
bool
locked
);
protected:
QVariant
data
(
const
QModelIndex
&
index
,
int
role
=
Qt
::
DisplayRole
)
const
override
;
...
...
@@ -36,6 +39,7 @@ private:
bool
isTrash
(
const
QModelIndex
&
index
)
const
;
bool
m_isEmpty
=
false
;
bool
m_panelsLocked
=
true
;
// common-case, panels are locked
};
/**
...
...
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