changeset 14692:d6d250812c01 gui

Made the terminal window dockable, too. Now the whole interface is fully dockable. * TerminalDockWidget: Subclassed QDockWidget to add some additional functionality. * MainWindow: Added TerminalDockWidget and removed central widget. * src.pro: Added new file to project file.
author Jacob Dawid <jacob.dawid@googlemail.com>
date Sun, 27 May 2012 13:54:03 +0200
parents ca733a66be7a
children c952f1e35e50
files gui/src/MainWindow.cpp gui/src/MainWindow.h gui/src/TerminalDockWidget.cpp gui/src/TerminalDockWidget.h gui/src/src.pro
diffstat 5 files changed, 98 insertions(+), 18 deletions(-) [+]
line wrap: on
line diff
--- a/gui/src/MainWindow.cpp	Fri May 25 23:56:31 2012 +0200
+++ b/gui/src/MainWindow.cpp	Sun May 27 13:54:03 2012 +0200
@@ -66,8 +66,8 @@
   QString selectedFile =
       QFileDialog::getSaveFileName (this, tr ("Save Workspace"),
                                     ResourceManager::instance ()->homePath ());
-  m_terminalView->sendText (QString ("save \'%1\'\n").arg (selectedFile));
-  m_terminalView->setFocus ();
+  m_terminal->sendText (QString ("save \'%1\'\n").arg (selectedFile));
+  m_terminal->setFocus ();
 }
 
 void
@@ -78,23 +78,23 @@
                                     ResourceManager::instance ()->homePath ());
   if (!selectedFile.isEmpty ())
     {
-      m_terminalView->sendText (QString ("load \'%1\'\n").arg (selectedFile));
-      m_terminalView->setFocus ();
+      m_terminal->sendText (QString ("load \'%1\'\n").arg (selectedFile));
+      m_terminal->setFocus ();
     }
 }
 
 void
 MainWindow::handleClearWorkspaceRequest ()
 {
-  m_terminalView->sendText ("clear\n");
-  m_terminalView->setFocus ();
+  m_terminal->sendText ("clear\n");
+  m_terminal->setFocus ();
 }
 
 void
 MainWindow::handleCommandDoubleClicked (QString command)
 {
-  m_terminalView->sendText(command);
-  m_terminalView->setFocus ();
+  m_terminal->sendText(command);
+  m_terminal->setFocus ();
 }
 
 void
@@ -134,7 +134,7 @@
   //font.setStyleHint(QFont::TypeWriter);
   font.setFamily(settings->value("terminal/fontName").toString());
   font.setPointSize(settings->value("terminal/fontSize").toInt ());
-  m_terminalView->setTerminalFont(font);
+  m_terminal->setTerminalFont(font);
 }
 
 void
@@ -217,10 +217,12 @@
   m_currentDirectoryUpToolButton->setIcon (style->standardIcon (QStyle::SP_FileDialogToParent));
 
   // Octave Terminal subwindow.
-  m_terminalView = new QTerminal(this);
-  setCentralWidget (m_terminalView);
+  m_terminal = new QTerminal(this);
+  m_terminalDockWidget = new TerminalDockWidget (m_terminal, this);
 
-  m_fileEditor = new FileEditor (m_terminalView, this);
+  //setCentralWidget (new QWidget (this));
+
+  m_fileEditor = new FileEditor (m_terminal, this);
 
   QMenu *fileMenu = menuBar ()->addMenu (tr ("&File"));
   QAction *newFileAction
@@ -271,6 +273,8 @@
 
   // Window menu
   QMenu *windowMenu = menuBar ()->addMenu (tr ("&Window"));
+  QAction *showCommandWindowAction = windowMenu->addAction (tr ("Command Window"));
+  showCommandWindowAction->setCheckable (true);
   QAction *showWorkspaceAction = windowMenu->addAction (tr ("Workspace"));
   showWorkspaceAction->setCheckable (true);
   QAction *showHistoryAction = windowMenu->addAction (tr ("History"));
@@ -313,6 +317,8 @@
   connect (octaveForgeAction, SIGNAL (triggered ()), this, SLOT (openOctaveForgePage ()));
   connect (aboutOctaveAction, SIGNAL (triggered ()), this, SLOT (showAboutOctave ()));
 
+  connect (showCommandWindowAction, SIGNAL (toggled (bool)), m_terminalDockWidget, SLOT (setShown (bool)));
+  connect (m_terminalDockWidget, SIGNAL (activeChanged (bool)), showCommandWindowAction, SLOT (setChecked (bool)));
   connect (showWorkspaceAction, SIGNAL (toggled (bool)), m_workspaceView, SLOT (setShown (bool)));
   connect (m_workspaceView, SIGNAL (activeChanged (bool)), showWorkspaceAction, SLOT (setChecked (bool)));
   connect (showHistoryAction, SIGNAL (toggled (bool)), m_historyDockWidget, SLOT (setShown (bool)));
@@ -333,8 +339,8 @@
   connect (loadWorkspaceAction, SIGNAL (triggered ()), this, SLOT (handleLoadWorkspaceRequest ()));
   connect (clearWorkspaceAction, SIGNAL (triggered ()), this, SLOT (handleClearWorkspaceRequest ()));
 
-  connect (copyAction, SIGNAL (triggered()), m_terminalView, SLOT(copyClipboard ()));
-  connect (pasteAction, SIGNAL (triggered()), m_terminalView, SLOT(pasteClipboard ()));
+  connect (copyAction, SIGNAL (triggered()), m_terminal, SLOT(copyClipboard ()));
+  connect (pasteAction, SIGNAL (triggered()), m_terminal, SLOT(pasteClipboard ()));
   setWindowTitle ("Octave");
 
   setDockOptions(QMainWindow::AnimatedDocks | QMainWindow::AllowNestedDocks | QMainWindow::AllowTabbedDocks);
@@ -343,6 +349,7 @@
   addDockWidget (Qt::LeftDockWidgetArea, m_historyDockWidget);
   addDockWidget (Qt::RightDockWidgetArea, m_filesDockWidget);
   addDockWidget (Qt::BottomDockWidgetArea, m_fileEditor);
+  addDockWidget (Qt::BottomDockWidgetArea, m_terminalDockWidget);
   setStatusBar (m_statusBar);
 
   readSettings ();
--- a/gui/src/MainWindow.h	Fri May 25 23:56:31 2012 +0200
+++ b/gui/src/MainWindow.h	Sun May 27 13:54:03 2012 +0200
@@ -42,6 +42,7 @@
 #include "WorkspaceView.h"
 #include "HistoryDockWidget.h"
 #include "FilesDockWidget.h"
+#include "TerminalDockWidget.h"
 
 /**
   * \class MainWindow
@@ -56,7 +57,7 @@
 
   QTerminal *terminalView ()
   {
-    return m_terminalView;
+    return m_terminal;
   }
 
   HistoryDockWidget *historyDockWidget ()
@@ -99,13 +100,14 @@
   void construct ();
   void establishOctaveLink ();
 
-  QTerminal *m_terminalView;
+  QTerminal *m_terminal;
   FileEditorInterface *m_fileEditor;
 
   // Dock widgets.
   WorkspaceView *m_workspaceView;
   HistoryDockWidget *m_historyDockWidget;
   FilesDockWidget *m_filesDockWidget;
+  TerminalDockWidget *m_terminalDockWidget;
 
   // Toolbars.
   QStatusBar *m_statusBar;
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/gui/src/TerminalDockWidget.cpp	Sun May 27 13:54:03 2012 +0200
@@ -0,0 +1,28 @@
+/* OctaveGUI - A graphical user interface for Octave
+ * Copyright (C) 2011 Jacob Dawid (jacob.dawid@googlemail.com)
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include "TerminalDockWidget.h"
+
+TerminalDockWidget::TerminalDockWidget (QTerminal *terminal, QWidget *parent)
+  : QDockWidget (parent)
+{
+  setObjectName ("TerminalDockWidget");
+  setWindowTitle (tr ("Command Window"));
+  setWidget (terminal);
+
+  connect (this, SIGNAL (visibilityChanged (bool)), this, SLOT (handleVisibilityChanged (bool)));
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/gui/src/TerminalDockWidget.h	Sun May 27 13:54:03 2012 +0200
@@ -0,0 +1,41 @@
+/* OctaveGUI - A graphical user interface for Octave
+ * Copyright (C) 2011 Jacob Dawid (jacob.dawid@googlemail.com)
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef TERMINALDOCKWIDGET_H
+#define TERMINALDOCKWIDGET_H
+
+#include <QDockWidget>
+#include "QTerminal.h"
+
+class TerminalDockWidget : public QDockWidget
+{
+  Q_OBJECT
+public:
+  TerminalDockWidget (QTerminal *terminal, QWidget *parent = 0);
+
+signals:
+    void activeChanged (bool active);
+
+public slots:
+    void handleVisibilityChanged (bool visible)
+    {
+      if (visible)
+        emit activeChanged (true);
+    }
+};
+
+#endif // TERMINALDOCKWIDGET_H
--- a/gui/src/src.pro	Fri May 25 23:56:31 2012 +0200
+++ b/gui/src/src.pro	Sun May 27 13:54:03 2012 +0200
@@ -87,7 +87,8 @@
     WelcomeWizard.cpp \
     editor/FileEditor.cpp \
     WorkspaceModel.cpp \
-    editor/FileEditorTab.cpp
+    editor/FileEditorTab.cpp \
+    TerminalDockWidget.cpp
 
 HEADERS += \
     editor/lexeroctavegui.h \
@@ -103,7 +104,8 @@
     editor/FileEditor.h \
     WorkspaceModel.h \
     editor/FileEditorInterface.h \
-    editor/FileEditorTab.h
+    editor/FileEditorTab.h \
+    TerminalDockWidget.h
 
 FORMS += \
     SettingsDialog.ui \