File indexing completed on 2024-05-12 04:58:27
0001 /* ============================================================ 0002 * Falkon - Qt web browser 0003 * Copyright (C) 2010-2014 David Rosca <nowrep@gmail.com> 0004 * 0005 * This program is free software: you can redistribute it and/or modify 0006 * it under the terms of the GNU General Public License as published by 0007 * the Free Software Foundation, either version 3 of the License, or 0008 * (at your option) any later version. 0009 * 0010 * This program is distributed in the hope that it will be useful, 0011 * but WITHOUT ANY WARRANTY; without even the implied warranty of 0012 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 0013 * GNU General Public License for more details. 0014 * 0015 * You should have received a copy of the GNU General Public License 0016 * along with this program. If not, see <http://www.gnu.org/licenses/>. 0017 * ============================================================ */ 0018 #ifndef ENHANCEDMENU_H 0019 #define ENHANCEDMENU_H 0020 0021 #include <QMenu> 0022 0023 #include "qzcommon.h" 0024 0025 0026 class Action; 0027 0028 class FALKON_EXPORT Menu : public QMenu 0029 { 0030 Q_OBJECT 0031 public: 0032 explicit Menu(QWidget* parent = nullptr); 0033 explicit Menu(const QString &title, QWidget* parent = nullptr); 0034 0035 // Default is false, menu will NOT be closed on middle click 0036 bool closeOnMiddleClick() const; 0037 void setCloseOnMiddleClick(bool close); 0038 0039 Q_SIGNALS: 0040 void menuMiddleClicked(Menu*); 0041 0042 public Q_SLOTS: 0043 0044 private: 0045 void mouseReleaseEvent(QMouseEvent* e) override; 0046 void keyPressEvent(QKeyEvent* e) override; 0047 0048 void closeAllMenus(); 0049 0050 bool m_closeOnMiddleClick = false; 0051 }; 0052 0053 class FALKON_EXPORT Action : public QAction 0054 { 0055 Q_OBJECT 0056 public: 0057 explicit Action(QObject* parent = nullptr); 0058 explicit Action(const QString &text, QObject* parent = nullptr); 0059 explicit Action(const QIcon &icon, const QString &text, QObject* parent = nullptr); 0060 0061 Q_SIGNALS: 0062 void ctrlTriggered(); 0063 void shiftTriggered(); 0064 0065 public Q_SLOTS: 0066 void emitCtrlTriggered(); 0067 void emitShiftTriggered(); 0068 0069 }; 0070 0071 #endif // ENHANCEDMENU_H