Introduction and implementation of the SidebarAutohide

as discussed in #19.
pull/19/head
Martijn Vogelaar 5 years ago committed by Michail Vourlakos
parent 8b6ae2439a
commit 2e4f7da4c2

@ -926,7 +926,7 @@ void GenericLayout::toggleHiddenState(QString screenName, Plasma::Types::Locatio
if (viewsOnEdge >= 1) { if (viewsOnEdge >= 1) {
for(const auto view : latteViews()) { for(const auto view : latteViews()) {
if (view->positioner()->currentScreenName() == validScreenName && view->location() == edge) { if (view->positioner()->currentScreenName() == validScreenName && view->location() == edge) {
if (viewsOnEdge == 1 || (viewsOnEdge >1 && view->visibility() && view->visibility()->mode() == Latte::Types::SideBar)) { if (viewsOnEdge == 1 || (viewsOnEdge >1 && view->visibility() && view->visibility()->isSidebar())) {
view->visibility()->toggleHiddenState(); view->visibility()->toggleHiddenState();
return; return;
} }

@ -69,7 +69,8 @@ private:
QList<Latte::Types::Visibility> m_ignoreModes{ QList<Latte::Types::Visibility> m_ignoreModes{
Latte::Types::AutoHide, Latte::Types::AutoHide,
Latte::Types::SideBar Latte::Types::SideBar,
Latte::Types::SidebarAutoHide
}; };
QStringList m_lastScreenNames; QStringList m_lastScreenNames;

@ -562,7 +562,7 @@ void GlobalShortcuts::hideViewsTimerSlot()
latteView->visibility()->removeBlockHidingEvent(SHORTCUTBLOCKHIDINGTYPE); latteView->visibility()->removeBlockHidingEvent(SHORTCUTBLOCKHIDINGTYPE);
latteView->extendedInterface()->hideShortcutBadges(); latteView->extendedInterface()->hideShortcutBadges();
if (latteView->visibility()->mode() == Latte::Types::SideBar && !latteView->visibility()->isHidden()) { if (latteView->visibility()->isSidebar() && !latteView->visibility()->isHidden()) {
latteView->visibility()->toggleHiddenState(); latteView->visibility()->toggleHiddenState();
} }
} }

@ -464,7 +464,8 @@ void Positioner::immediateSyncGeometry()
int fixedScreen = m_view->onPrimary() ? latteCorona->screenPool()->primaryScreenId() : m_view->containment()->screen(); int fixedScreen = m_view->onPrimary() ? latteCorona->screenPool()->primaryScreenId() : m_view->containment()->screen();
QList<Types::Visibility> ignoreModes({Latte::Types::AutoHide, QList<Types::Visibility> ignoreModes({Latte::Types::AutoHide,
Latte::Types::SideBar}); Latte::Types::SideBar,
Latte::Types::SidebarAutoHide});
QList<Plasma::Types::Location> ignoreEdges({Plasma::Types::LeftEdge, QList<Plasma::Types::Location> ignoreEdges({Plasma::Types::LeftEdge,
Plasma::Types::RightEdge}); Plasma::Types::RightEdge});

@ -304,10 +304,11 @@ void PrimaryConfigView::instantUpdateAvailableScreenGeometry()
int currentScrId = m_latteView->positioner()->currentScreenId(); int currentScrId = m_latteView->positioner()->currentScreenId();
QList<Latte::Types::Visibility> ignoreModes{Latte::Types::SideBar}; QList<Latte::Types::Visibility> ignoreModes{Latte::Types::SideBar,Latte::Types::SidebarAutoHide};
if (m_latteView->visibility() && m_latteView->visibility()->mode() == Latte::Types::SideBar) { if (m_latteView->visibility() && m_latteView->visibility()->isSidebar()) {
ignoreModes.removeAll(Latte::Types::SideBar); ignoreModes.removeAll(Latte::Types::SideBar);
ignoreModes.removeAll(Latte::Types::SidebarAutoHide);
} }
m_availableScreenGeometry = m_corona->availableScreenRectWithCriteria(currentScrId, m_latteView->layout()->name(), ignoreModes, {}, false, true); m_availableScreenGeometry = m_corona->availableScreenRectWithCriteria(currentScrId, m_latteView->layout()->name(), ignoreModes, {}, false, true);

@ -44,6 +44,7 @@
//! view to be show. For example !compositing+kwin_edges+hide inteval<50ms //! view to be show. For example !compositing+kwin_edges+hide inteval<50ms
const int HIDEMINIMUMINTERVAL = 50; const int HIDEMINIMUMINTERVAL = 50;
namespace Latte { namespace Latte {
namespace ViewPart { namespace ViewPart {
@ -328,6 +329,22 @@ void VisibilityManager::setMode(Latte::Types::Visibility mode)
}); });
toggleHiddenState(); toggleHiddenState();
break;
case Types::SidebarAutoHide:
m_connections[base] = connect(this, &VisibilityManager::containsMouseChanged, this, [&]() {
if(!isHidden()){
raiseView(m_containsMouse);
}
});
m_connections[base] = connect(m_latteView, &Latte::View::inEditModeChanged, this, [&]() {
if (!m_latteView->inEditMode()) {
toggleHiddenState();
}
});
toggleHiddenState();
break;
default: default:
break; break;
@ -592,6 +609,11 @@ void VisibilityManager::setTimerHide(int msec)
emit timerHideChanged(); emit timerHideChanged();
} }
bool VisibilityManager::isSidebar() const
{
return m_mode == Latte::Types::SideBar || m_mode == Latte::Types::SidebarAutoHide;
}
bool VisibilityManager::supportsKWinEdges() const bool VisibilityManager::supportsKWinEdges() const
{ {
return (m_edgeGhostWindow != nullptr); return (m_edgeGhostWindow != nullptr);
@ -693,13 +715,17 @@ bool VisibilityManager::isValidMode() const
void VisibilityManager::toggleHiddenState() void VisibilityManager::toggleHiddenState()
{ {
if (!m_latteView->inEditMode()) { if (!m_latteView->inEditMode()) {
if (m_mode == Latte::Types::SideBar) { if (isSidebar()) {
if (m_blockHidingEvents.contains(Q_FUNC_INFO)) { if (m_blockHidingEvents.contains(Q_FUNC_INFO)) {
removeBlockHidingEvent(Q_FUNC_INFO); removeBlockHidingEvent(Q_FUNC_INFO);
} }
if (m_isHidden) { if (m_isHidden) {
emit mustBeShown(); emit mustBeShown();
if(m_mode == Latte::Types::SidebarAutoHide) {
m_timerHide.start();
}
} else { } else {
emit mustBeHide(); emit mustBeHide();
} }
@ -907,7 +933,7 @@ void VisibilityManager::viewEventManager(QEvent *ev)
case QEvent::DragEnter: case QEvent::DragEnter:
m_dragEnter = true; m_dragEnter = true;
if (m_isHidden && m_mode != Latte::Types::SideBar) { if (m_isHidden && !isSidebar()) {
emit mustBeShown(); emit mustBeShown();
} }

@ -99,6 +99,8 @@ public:
int timerHide() const; int timerHide() const;
void setTimerHide(int msec); void setTimerHide(int msec);
bool isSidebar() const;
//! KWin Edges Support functions //! KWin Edges Support functions
bool enableKWinEdges() const; bool enableKWinEdges() const;
void setEnableKWinEdges(bool enable); void setEnableKWinEdges(bool enable);

@ -189,7 +189,8 @@ private:
Latte::Types::WindowsGoBelow, Latte::Types::WindowsGoBelow,
Latte::Types::WindowsCanCover, Latte::Types::WindowsCanCover,
Latte::Types::WindowsAlwaysCover, Latte::Types::WindowsAlwaysCover,
Latte::Types::SideBar Latte::Types::SideBar,
Latte::Types::SidebarAutoHide
}; };
QMap<WindowId, WindowInfoWrap> m_windows; QMap<WindowId, WindowInfoWrap> m_windows;

@ -32,7 +32,9 @@ Item {
readonly property bool isActive: plasmoid.configuration.autoSizeEnabled readonly property bool isActive: plasmoid.configuration.autoSizeEnabled
&& !root.containsOnlyPlasmaTasks && !root.containsOnlyPlasmaTasks
&& layouter.fillApplets<=0 && layouter.fillApplets<=0
&& latteView && latteView.visibility.mode !== LatteCore.Types.SideBar && latteView
&& latteView.visibility.mode !== LatteCore.Types.SideBar
&& latteView.visibility.mode !== LatteCore.Types.SidebarAutoHide
property int iconSize: -1 //it is not set, this is the default property int iconSize: -1 //it is not set, this is the default
readonly property bool inCalculatedIconSize: ((metrics.iconSize === sizer.iconSize) || (metrics.iconSize === metrics.maxIconSize)) readonly property bool inCalculatedIconSize: ((metrics.iconSize === sizer.iconSize) || (metrics.iconSize === metrics.maxIconSize))

@ -380,6 +380,9 @@ Window{
case LatteCore.Types.SideBar: case LatteCore.Types.SideBar:
return "OnDemand SideBar"; return "OnDemand SideBar";
break; break;
case LatteCore.Types.SidebarAutoHide:
return "AutoHide Sidebar";
break;
case LatteCore.Types.NormalWindow: case LatteCore.Types.NormalWindow:
return "Normal Window"; return "Normal Window";
break; break;

@ -54,6 +54,7 @@ public:
WindowsCanCover, WindowsCanCover,
WindowsAlwaysCover, WindowsAlwaysCover,
SideBar, SideBar,
SidebarAutoHide,
NormalWindow = 20 NormalWindow = 20
}; };
Q_ENUM(Visibility); Q_ENUM(Visibility);

@ -90,7 +90,7 @@ PlasmaComponents.Page {
Layout.fillWidth: true Layout.fillWidth: true
value: plasmoid.configuration.iconSize value: plasmoid.configuration.iconSize
from: 16 from: 16
to: latteView.visibility.mode === LatteCore.Types.SideBar ? 512 : 256 to: (latteView.visibility.mode === LatteCore.Types.SideBar || latteView.visibility.mode === LatteCore.Types.SidebarAutoHide) ? 512 : 256
stepSize: dialog.advancedLevel || (plasmoid.configuration.iconSize % 8 !== 0) || dialog.viewIsPanel ? 1 : 8 stepSize: dialog.advancedLevel || (plasmoid.configuration.iconSize % 8 !== 0) || dialog.viewIsPanel ? 1 : 8
wheelEnabled: false wheelEnabled: false
@ -139,7 +139,7 @@ PlasmaComponents.Page {
Layout.fillWidth: true Layout.fillWidth: true
value: plasmoid.configuration.proportionIconSize value: plasmoid.configuration.proportionIconSize
from: 1.0 from: 1.0
to: latteView.visibility.mode === LatteCore.Types.SideBar ? 25 : 12 to: (latteView.visibility.mode === LatteCore.Types.SideBar || latteView.visibility.mode === LatteCore.Types.SidebarAutoHide) ? 25 : 12
stepSize: 0.5 stepSize: 0.5
wheelEnabled: false wheelEnabled: false

@ -478,6 +478,7 @@ PlasmaComponents.Page {
RowLayout{ RowLayout{
id: showTimerRow id: showTimerRow
anchors.horizontalCenter: parent.horizontalCenter anchors.horizontalCenter: parent.horizontalCenter
enabled: latteView.visibility.mode !== LatteCore.Types.SidebarAutoHide
PlasmaComponents.Label { PlasmaComponents.Label {
Layout.leftMargin: Qt.application.layoutDirection === Qt.RightToLeft ? units.smallSpacing : 0 Layout.leftMargin: Qt.application.layoutDirection === Qt.RightToLeft ? units.smallSpacing : 0
Layout.rightMargin: Qt.application.layoutDirection === Qt.RightToLeft ? 0 : units.smallSpacing Layout.rightMargin: Qt.application.layoutDirection === Qt.RightToLeft ? 0 : units.smallSpacing

@ -140,10 +140,16 @@ LatteComponents.ComboBoxButton{
name: i18n("On Demand SideBar") name: i18n("On Demand SideBar")
} }
var sidebarAutoHide = {
pluginId: '9',
name: i18n("Auto Hide Sidebar")
}
actionsModel.append(windowsGoBelow); actionsModel.append(windowsGoBelow);
actionsModel.append(windowsCanCover); actionsModel.append(windowsCanCover);
actionsModel.append(windowsAlwaysCover); actionsModel.append(windowsAlwaysCover);
actionsModel.append(sideBar); actionsModel.append(sideBar);
actionsModel.append(sidebarAutoHide);
} }
} }

Loading…
Cancel
Save