Mercurial > octave-nkf
diff 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 |
line wrap: on
line diff
--- a/gui/src/editor/FileEditorInterface.h Thu May 24 12:08:53 2012 +0200 +++ b/gui/src/editor/FileEditorInterface.h Thu May 24 13:20:27 2012 +0200 @@ -18,21 +18,24 @@ #ifndef FILEEDITORINTERFACE_H #define FILEEDITORINTERFACE_H -#include <QWidget> +#include <QDockWidget> class QTerminal; class MainWindow; -class FileEditorInterface : public QWidget +class FileEditorInterface : public QDockWidget { Q_OBJECT public: FileEditorInterface (QTerminal *terminal, MainWindow *mainWindow) - : QWidget () + : QDockWidget ((QWidget*)mainWindow) // QDockWidget constructor is explicit, hence the cast. { + setObjectName ("FileEditor"); m_terminal = terminal; m_mainWindow = mainWindow; + + connect (this, SIGNAL (visibilityChanged (bool)), this, SLOT (handleVisibilityChanged (bool))); } virtual ~FileEditorInterface () { } @@ -41,9 +44,25 @@ virtual void requestOpenFile () = 0; virtual void requestOpenFile (QString fileName) = 0; + signals: + void activeChanged (bool active); + protected: QTerminal* m_terminal; MainWindow* m_mainWindow; + + void closeEvent (QCloseEvent *event) + { + emit activeChanged (false); + QDockWidget::closeEvent (event); + } + + protected slots: + void handleVisibilityChanged (bool visible) + { + if (visible) + emit activeChanged (true); + } }; #endif // FILEEDITORINTERFACE_H