mirror of
https://github.com/KDE/latte-dock.git
synced 2025-01-08 13:18:09 +03:00
support new visibility mode for SideBars
--SideBar views are shown/hide ONLY WHEN the user has requested to DO SHOW from external applets, shortcuts and scripts
This commit is contained in:
parent
eb2d9a0190
commit
90df4f4f61
@ -32,5 +32,10 @@
|
||||
<arg name="screenName" type="s" direction="in"/>
|
||||
<arg name="enabled" type="b" direction="in"/>
|
||||
</method>
|
||||
<method name="toggleHiddenState">
|
||||
<arg name="layoutName" type="s" direction="in"/>
|
||||
<arg name="screenName" type="s" direction="in"/>
|
||||
<arg name="screenEdge" type="i" direction="in"/>
|
||||
</method>
|
||||
</interface>
|
||||
</node>
|
||||
|
@ -506,6 +506,23 @@ CentralLayout *Corona::centralLayout(QString name) const
|
||||
return result;
|
||||
}
|
||||
|
||||
Layout::GenericLayout *Corona::layout(QString name) const
|
||||
{
|
||||
Layout::GenericLayout *result{nullptr};
|
||||
|
||||
if (name.isEmpty()) {
|
||||
result = m_layoutsManager->currentLayout();
|
||||
} else {
|
||||
result = m_layoutsManager->synchronizer()->layout(name);
|
||||
|
||||
if (!result) {
|
||||
result = m_layoutsManager->currentLayout();
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
QRegion Corona::availableScreenRegion(int id) const
|
||||
{
|
||||
return availableScreenRegionWithCriteria(id);
|
||||
@ -1169,6 +1186,15 @@ void Corona::setBroadcastedBackgroundsEnabled(QString activity, QString screenNa
|
||||
Q_ARG(QVariant, enabled));
|
||||
}
|
||||
|
||||
void Corona::toggleHiddenState(QString layoutName, QString screenName, int screenEdge)
|
||||
{
|
||||
Layout::GenericLayout *gLayout = layout(layoutName);
|
||||
|
||||
if (gLayout) {
|
||||
gLayout->toggleHiddenState(screenName, (Plasma::Types::Location)screenEdge);
|
||||
}
|
||||
}
|
||||
|
||||
inline void Corona::qmlRegisterTypes() const
|
||||
{
|
||||
#if QT_VERSION < QT_VERSION_CHECK(5, 14, 0)
|
||||
|
@ -159,6 +159,8 @@ public slots:
|
||||
void setBackgroundFromBroadcast(QString activity, QString screenName, QString filename);
|
||||
void setBroadcastedBackgroundsEnabled(QString activity, QString screenName, bool enabled);
|
||||
void showAlternativesForApplet(Plasma::Applet *applet);
|
||||
void toggleHiddenState(QString layoutName, QString screenName, int screenEdge);
|
||||
|
||||
//! values are separated with a "-" character
|
||||
void windowColorScheme(QString windowIdAndScheme);
|
||||
void updateDockItemBadge(QString identifier, QString value);
|
||||
@ -195,6 +197,7 @@ private:
|
||||
QStringList containmentsIds();
|
||||
QStringList appletsIds();
|
||||
|
||||
Layout::GenericLayout *layout(QString name) const;
|
||||
CentralLayout *centralLayout(QString name) const;
|
||||
|
||||
private:
|
||||
|
@ -886,6 +886,24 @@ void GenericLayout::addView(Plasma::Containment *containment, bool forceOnPrimar
|
||||
emit viewsCountChanged();
|
||||
}
|
||||
|
||||
void GenericLayout::toggleHiddenState(QString screenName, Plasma::Types::Location edge)
|
||||
{
|
||||
if (!m_corona) {
|
||||
return;
|
||||
}
|
||||
|
||||
QString validScreenName = qGuiApp->primaryScreen()->name();
|
||||
if (!screenName.isEmpty()) {
|
||||
validScreenName = screenName;
|
||||
}
|
||||
|
||||
for(const auto view : latteViews()) {
|
||||
if (view->positioner()->currentScreenName() == validScreenName && view->location() == edge) {
|
||||
view->visibility()->toggleHiddenState();
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool GenericLayout::initToCorona(Latte::Corona *corona)
|
||||
{
|
||||
|
@ -149,6 +149,8 @@ public slots:
|
||||
Q_INVOKABLE int viewsWithTasks() const;
|
||||
virtual Q_INVOKABLE QList<int> qmlFreeEdges(int screen) const; //change <Plasma::Types::Location> to <int> types
|
||||
|
||||
void toggleHiddenState(QString screenName, Plasma::Types::Location edge);
|
||||
|
||||
signals:
|
||||
void activitiesChanged(); // to move at an interface
|
||||
void viewsCountChanged();
|
||||
|
@ -280,6 +280,19 @@ void VisibilityManager::setMode(Latte::Types::Visibility mode)
|
||||
case Types::WindowsAlwaysCover:
|
||||
break;
|
||||
|
||||
case Types::SideBar:
|
||||
m_connections[base] = connect(m_latteView, &Latte::View::inEditModeChanged, this, [&]() {
|
||||
if (!m_latteView->inEditMode()) {
|
||||
//! Give the time to View to change from !behaveAsPlasmaPanel to behaveAsPlasmaPanel
|
||||
//! if this is needed when changing to !inEditMode
|
||||
QTimer::singleShot(100, [this]() {
|
||||
toggleHiddenState();
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
toggleHiddenState();
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
@ -428,7 +441,7 @@ void VisibilityManager::setBlockHiding(bool blockHiding)
|
||||
}
|
||||
|
||||
m_blockHiding = blockHiding;
|
||||
// qDebug() << "blockHiding:" << blockHiding;
|
||||
//qDebug() << "blockHiding:" << blockHiding;
|
||||
|
||||
if (m_blockHiding) {
|
||||
m_timerHide.stop();
|
||||
@ -519,7 +532,7 @@ void VisibilityManager::show()
|
||||
|
||||
void VisibilityManager::raiseView(bool raise)
|
||||
{
|
||||
if (m_blockHiding)
|
||||
if (m_blockHiding || m_mode == Latte::Types::SideBar)
|
||||
return;
|
||||
|
||||
if (raise) {
|
||||
@ -559,6 +572,21 @@ void VisibilityManager::raiseViewTemporarily()
|
||||
});
|
||||
}
|
||||
|
||||
void VisibilityManager::toggleHiddenState()
|
||||
{
|
||||
if (!m_latteView->inEditMode()) {
|
||||
if (m_mode == Latte::Types::SideBar) {
|
||||
if (m_isHidden) {
|
||||
emit mustBeShown();
|
||||
} else {
|
||||
emit mustBeHide();
|
||||
}
|
||||
} else {
|
||||
setBlockHiding(!m_blockHiding);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void VisibilityManager::updateHiddenState()
|
||||
{
|
||||
if (m_dragEnter)
|
||||
@ -753,7 +781,7 @@ void VisibilityManager::viewEventManager(QEvent *ev)
|
||||
case QEvent::DragEnter:
|
||||
m_dragEnter = true;
|
||||
|
||||
if (m_isHidden) {
|
||||
if (m_isHidden && m_mode != Latte::Types::SideBar) {
|
||||
emit mustBeShown();
|
||||
}
|
||||
|
||||
|
@ -105,6 +105,9 @@ public:
|
||||
|
||||
bool supportsKWinEdges() const;
|
||||
|
||||
//! Used mostly to show / hide SideBars
|
||||
void toggleHiddenState();
|
||||
|
||||
public slots:
|
||||
Q_INVOKABLE void hide();
|
||||
Q_INVOKABLE void show();
|
||||
|
@ -29,7 +29,9 @@ Item {
|
||||
|
||||
// when there are only plasma style task managers OR any applets that fill width or height
|
||||
// the automatic icon size algorithm should better be disabled
|
||||
readonly property bool isActive: !root.containsOnlyPlasmaTasks && layoutsContainer.fillApplets<=0
|
||||
readonly property bool isActive: !root.containsOnlyPlasmaTasks
|
||||
&& layoutsContainer.fillApplets<=0
|
||||
&& latteView && latteView.visibility.mode !== Latte.Types.SideBar
|
||||
|
||||
property bool automaticSizeAnimation: false
|
||||
|
||||
|
@ -75,8 +75,8 @@ Item{
|
||||
|
||||
property int thicknessNormalOriginalValue: root.screenEdgeMargin + root.maxIconSize + (root.maxThickMargin * 2) + extraThickMask + 1
|
||||
property int thicknessZoomOriginal:root.screenEdgeMargin + Math.max( ((root.maxIconSize+(root.maxThickMargin * 2)) * root.maxZoomFactor) + extraThickMask + 2,
|
||||
root.realPanelSize + root.panelShadow,
|
||||
(Latte.WindowSystem.compositingActive ? thicknessEditMode + root.editShadow : thicknessEditMode))
|
||||
root.realPanelSize + root.panelShadow,
|
||||
(Latte.WindowSystem.compositingActive ? thicknessEditMode + root.editShadow : thicknessEditMode))
|
||||
|
||||
//! is used from Panel in edit mode in order to provide correct masking
|
||||
property int thicknessEditMode: thicknessNormalOriginalValue + editModeVisual.settingsThickness
|
||||
@ -356,10 +356,10 @@ Item{
|
||||
|
||||
onThicknessZoomOriginalChanged: {
|
||||
updateMaskArea();
|
||||
}
|
||||
}
|
||||
|
||||
function slotContainsMouseChanged() {
|
||||
if(latteView.visibility.containsMouse) {
|
||||
if(latteView.visibility.containsMouse && latteView.visibility.mode !== Latte.Types.SideBar) {
|
||||
updateMaskArea();
|
||||
|
||||
if (slidingAnimationAutoHiddenOut.running && !inTempHiding && !inForceHiding) {
|
||||
@ -393,8 +393,10 @@ Item{
|
||||
}
|
||||
|
||||
//! Normal Dodge/AutoHide case
|
||||
if((!slidingAnimationAutoHiddenOut.running && !latteView.visibility.blockHiding
|
||||
&& !latteView.visibility.containsMouse) || inForceHiding) {
|
||||
if((!slidingAnimationAutoHiddenOut.running
|
||||
&& !latteView.visibility.blockHiding
|
||||
&& (!latteView.visibility.containsMouse || latteView.visibility.mode === Latte.Types.SideBar))
|
||||
|| inForceHiding) {
|
||||
slidingAnimationAutoHiddenOut.init();
|
||||
}
|
||||
}
|
||||
@ -565,6 +567,14 @@ Item{
|
||||
localY = latteView.height - layoutsContainer.mainLayout.height - space - root.offset;
|
||||
}
|
||||
}
|
||||
|
||||
if (latteView.visibility.isHidden && latteView && latteView.visibility.mode === Latte.Types.SideBar) {
|
||||
//!hide completely
|
||||
localX = -1;
|
||||
localY = -1;
|
||||
tempThickness = 1;
|
||||
tempLength = 1;
|
||||
}
|
||||
} else {
|
||||
// !inNormalState
|
||||
|
||||
@ -661,6 +671,8 @@ Item{
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
// console.log("Not updating mask...");
|
||||
if( maskArea.x !== localX || maskArea.y !== localY
|
||||
|| maskLength !== tempLength || maskThickness !== tempThickness) {
|
||||
@ -886,7 +898,7 @@ Item{
|
||||
}
|
||||
|
||||
//! Slides Animations for FLOATING+BEHAVEASPLASMAPANEL
|
||||
/* DISABLED because they dont create a smooth transition
|
||||
/* DISABLED because they dont create a smooth transition
|
||||
|
||||
SequentialAnimation{
|
||||
id: slidingInRealFloating
|
||||
|
@ -54,6 +54,7 @@ public:
|
||||
WindowsGoBelow,
|
||||
WindowsCanCover,
|
||||
WindowsAlwaysCover,
|
||||
SideBar,
|
||||
NormalWindow = 20
|
||||
};
|
||||
Q_ENUM(Visibility);
|
||||
|
@ -173,7 +173,7 @@ PlasmaComponents.Page {
|
||||
Layout.fillWidth: true
|
||||
value: plasmoid.configuration.iconSize
|
||||
from: 16
|
||||
to: 256
|
||||
to: latteView.visibility.mode === Latte.Types.SideBar ? 512 : 256
|
||||
stepSize: dialog.highLevel || (plasmoid.configuration.iconSize % 8 !== 0) || dialog.viewIsPanel ? 1 : 8
|
||||
wheelEnabled: false
|
||||
|
||||
@ -222,7 +222,7 @@ PlasmaComponents.Page {
|
||||
Layout.fillWidth: true
|
||||
value: plasmoid.configuration.proportionIconSize
|
||||
from: 1.0
|
||||
to: 12
|
||||
to: latteView.visibility.mode === Latte.Types.SideBar ? 25 : 12
|
||||
stepSize: 0.5
|
||||
wheelEnabled: false
|
||||
|
||||
|
@ -482,7 +482,8 @@ PlasmaComponents.Page {
|
||||
|
||||
enabled: !(latteView.visibility.mode === Latte.Types.AlwaysVisible
|
||||
|| latteView.visibility.mode === Latte.Types.WindowsGoBelow
|
||||
|| latteView.visibility.mode === Latte.Types.WindowsAlwaysCover)
|
||||
|| latteView.visibility.mode === Latte.Types.WindowsAlwaysCover
|
||||
|| latteView.visibility.mode === Latte.Types.SideBar)
|
||||
|
||||
LatteComponents.Header {
|
||||
text: i18n("Delay")
|
||||
@ -827,7 +828,7 @@ PlasmaComponents.Page {
|
||||
text: i18n("Activate KWin edge after hiding")
|
||||
checked: latteView.visibility.enableKWinEdges
|
||||
tooltip: i18n("After the view becomes hidden, KWin is informed to track user feedback. For example an edge visual hint is shown whenever the mouse approaches the hidden view")
|
||||
enabled: !latteView.byPassWM
|
||||
enabled: !latteView.byPassWM && latteView.visibility.mode !== Latte.Types.SideBar
|
||||
|
||||
onClicked: {
|
||||
latteView.visibility.enableKWinEdges = checked;
|
||||
|
@ -29,8 +29,8 @@ LatteComponents.ComboBoxButton{
|
||||
id: custom
|
||||
checkable: true
|
||||
|
||||
// buttonToolTip: checked ? i18n("Use %0 style for your indicators").arg(buttonText) :
|
||||
// i18n("Download indicator styles from the internet")
|
||||
buttonToolTip: mode === Latte.Types.SideBar ? i18n("SideBar can be shown only when the user has explicitly requested it. For example through an external applet, shortcut or script") : ""
|
||||
|
||||
comboBoxTextRole: "name"
|
||||
comboBoxBlankSpaceForEmptyIcons: false
|
||||
comboBoxForcePressed: latteView.visibility.mode === mode
|
||||
@ -135,9 +135,15 @@ LatteComponents.ComboBoxButton{
|
||||
name: i18n("Windows Always Cover"),
|
||||
}
|
||||
|
||||
var sideBar = {
|
||||
pluginId: '8',
|
||||
name: i18n("On Demand SideBar")
|
||||
}
|
||||
|
||||
actionsModel.append(windowsGoBelow);
|
||||
actionsModel.append(windowsCanCover);
|
||||
actionsModel.append(windowsAlwaysCover);
|
||||
actionsModel.append(sideBar);
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user