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 3 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 ANNOTATIONTABWIDGET_H
21 #define ANNOTATIONTABWIDGET_H
22 
23 #include <QTabWidget>
24 #include <QPixmap>
25 
26 #include "AnnotationTabContent.h"
27 #include "AnnotationTabContextMenu.h"
28 #include "AnnotationTabCloser.h"
29 
30 namespace kImageAnnotator {
31 
32 class AnnotationTabWidget : public QTabWidget
33 {
34 	Q_OBJECT
35 public:
36 	AnnotationTabWidget(Config *config, AbstractSettingsProvider *settingsProvider);
37 	~AnnotationTabWidget() override = default;
38 	int addTab(const QPixmap &image, const QString &title, const QString &toolTip);
39 	AnnotationArea* currentAnnotationArea() const;
40 	AnnotationArea *annotationAreaAt(int index) const;
41 	ZoomValueProvider* currentZoomValueProvider() const;
42 	QAction* undoAction() const;
43 	QAction* redoAction() const;
44 	void updateTabInfo(int index, const QString &title, const QString &toolTip);
45 	void setUndoRedoEnabled(bool enabled);
46     void addContextMenuActions(const QList<QAction*> & actions);
47 
48 signals:
49 	void imageChanged() const;
50 	void tabMoved(int fromIndex, int toIndex) const;
51 	void tabContextMenuOpened(int index) const;
52 
53 protected:
54 	void tabInserted(int index) override;
55 	void tabRemoved(int index) override;
56 
57 private:
58 	Config *mConfig;
59 	QTabBar *mTabBar;
60 	AbstractSettingsProvider *mSettingsProvider;
61 	QAction *mUndoAction;
62 	QAction *mRedoAction;
63 	AnnotationTabContextMenu *mTabContextMenu;
64 	AnnotationTabCloser *mTabCloser;
65 
66 private slots:
67 	void undoTriggered() const;
68 	void redoTriggered() const;
69 	void updateCurrentWidget(int index);
70 	void showTabContextMenu(const QPoint &pos);
71 	void tabChanged();
72 };
73 
74 } // namespace kImageAnnotator
75 
76 #endif //ANNOTATIONTABWIDGET_H
77