comparison gui/src/editor/FileEditorInterface.h @ 14681:66ff321cb62e gui

Integrated the editor to be docked with the other widgets. * FilesDockWidget: Some code style corrections. * MainWindow: Added a checkable menu entry for the editor and added file editor as dockable widget. * FileEditor: Moved setting the object name to the interface. * FileEditorInterface: Added routines to correctly handle closing and opening the dock widget.
author Jacob Dawid <jacob.dawid@googlemail.com>
date Thu, 24 May 2012 13:20:27 +0200
parents 35512b788af2
children
comparison
equal deleted inserted replaced
14680:628eeaf879f7 14681:66ff321cb62e
16 */ 16 */
17 17
18 #ifndef FILEEDITORINTERFACE_H 18 #ifndef FILEEDITORINTERFACE_H
19 #define FILEEDITORINTERFACE_H 19 #define FILEEDITORINTERFACE_H
20 20
21 #include <QWidget> 21 #include <QDockWidget>
22 22
23 class QTerminal; 23 class QTerminal;
24 class MainWindow; 24 class MainWindow;
25 25
26 class FileEditorInterface : public QWidget 26 class FileEditorInterface : public QDockWidget
27 { 27 {
28 Q_OBJECT 28 Q_OBJECT
29 29
30 public: 30 public:
31 FileEditorInterface (QTerminal *terminal, MainWindow *mainWindow) 31 FileEditorInterface (QTerminal *terminal, MainWindow *mainWindow)
32 : QWidget () 32 : QDockWidget ((QWidget*)mainWindow) // QDockWidget constructor is explicit, hence the cast.
33 { 33 {
34 setObjectName ("FileEditor");
34 m_terminal = terminal; 35 m_terminal = terminal;
35 m_mainWindow = mainWindow; 36 m_mainWindow = mainWindow;
37
38 connect (this, SIGNAL (visibilityChanged (bool)), this, SLOT (handleVisibilityChanged (bool)));
36 } 39 }
37 40
38 virtual ~FileEditorInterface () { } 41 virtual ~FileEditorInterface () { }
39 public slots: 42 public slots:
40 virtual void requestNewFile () = 0; 43 virtual void requestNewFile () = 0;
41 virtual void requestOpenFile () = 0; 44 virtual void requestOpenFile () = 0;
42 virtual void requestOpenFile (QString fileName) = 0; 45 virtual void requestOpenFile (QString fileName) = 0;
43 46
47 signals:
48 void activeChanged (bool active);
49
44 protected: 50 protected:
45 QTerminal* m_terminal; 51 QTerminal* m_terminal;
46 MainWindow* m_mainWindow; 52 MainWindow* m_mainWindow;
53
54 void closeEvent (QCloseEvent *event)
55 {
56 emit activeChanged (false);
57 QDockWidget::closeEvent (event);
58 }
59
60 protected slots:
61 void handleVisibilityChanged (bool visible)
62 {
63 if (visible)
64 emit activeChanged (true);
65 }
47 }; 66 };
48 67
49 #endif // FILEEDITORINTERFACE_H 68 #endif // FILEEDITORINTERFACE_H