File indexing completed on 2024-04-28 09:25:36

0001 /*
0002     SPDX-FileCopyrightText: 2019 Michail Vourlakos <mvourlakos@gmail.com>
0003     SPDX-License-Identifier: GPL-2.0-or-later
0004 */
0005 
0006 #include "persistentmenu.h"
0007 
0008 namespace Latte {
0009 namespace Settings {
0010 namespace Layout {
0011 namespace Delegate {
0012 
0013 PersistentMenu::PersistentMenu(QWidget *parent)
0014     : QMenu (parent),
0015       m_blockHide(false)
0016 {
0017 }
0018 
0019 void PersistentMenu::setVisible (bool visible)
0020 {
0021   if (m_blockHide) {
0022       m_blockHide = false;
0023       return;
0024   }
0025 
0026   QMenu::setVisible(visible);
0027 }
0028 
0029 int PersistentMenu::masterIndex() const
0030 {
0031     return m_masterIndex;
0032 }
0033 
0034 void PersistentMenu::setMasterIndex(const int &index)
0035 {
0036     if (m_masterIndex == index) {
0037         return;
0038     }
0039 
0040     m_masterIndex = index;
0041     emit masterIndexChanged(index);
0042 }
0043 
0044 void PersistentMenu::mouseReleaseEvent (QMouseEvent *e)
0045 {
0046   const QAction *action = actionAt(e->pos());
0047   if (action) {
0048       m_blockHide = true;
0049   }
0050 
0051   QMenu::mouseReleaseEvent (e);
0052 }
0053 
0054 }
0055 }
0056 }
0057 }