1 /*
2  * Copyright (C) 2020 Damir Porobic <damir.porobic@gmx.com>
3  *
4  * This program is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU Lesser General Public License as published by
6  * the Free Software Foundation; either version 2 of the License, or
7  * (at your option) any later version.
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU Lesser General Public License
15  * along with this program; if not, write to the Free Software
16  * Foundation, Inc., 51 Franklin Street, Fifth Floor,
17  * Boston, MA 02110-1301, USA.
18  */
19 
20 #ifndef KIMAGEANNOTATOR_ANNOTATIONTABCONTEXTMENU_H
21 #define KIMAGEANNOTATOR_ANNOTATIONTABCONTEXTMENU_H
22 
23 #include <QMenu>
24 
25 namespace kImageAnnotator {
26 
27 class AnnotationTabContextMenu : public QMenu
28 {
29 	Q_OBJECT
30 public:
31 	explicit AnnotationTabContextMenu(QWidget *parent);
32 	~AnnotationTabContextMenu() override;
33 	void show(int tabIndex, const QPoint &pos);
34 	void addCustomActions(const QList<QAction*> & customActions);
35 
36 signals:
37 	void closeTab(int index) const;
38 	void closeOtherTabs(int index) const;
39 	void closeAllTabs() const;
40 	void closeAllTabsToLeft(int index) const;
41 	void closeAllTabsToRight(int index) const;
42 
43 private:
44 	int mTabIndex;
45 	QAction *mCloseTab;
46 	QAction *mClosedOtherTabs;
47 	QAction *mCloseAllTabs;
48 	QAction *mCloseAllTabsToLeft;
49 	QAction *mCloseAllTabsToRight;
50 	QHash<QAction*, QAction*> mCustomActionMap;
51 
52 	void closeTabTriggered() const;
53 	void closeOtherTabsTriggered() const;
54 	void closeAllTabsTriggered() const;
55 	void closeAllTabsToLeftTriggered() const;
56 	void closeAllTabsToRightTriggered() const;
57 
58 private slots:
59     void customActionTriggered();
60     void customActionChanged();
61 	void addCustomAction(QAction *innerAction);
62 };
63 
64 } // namespace kImageAnnotator
65 
66 #endif //KIMAGEANNOTATOR_ANNOTATIONTABCONTEXTMENU_H
67