Mercurial > hg > octave-terminal
changeset 13371:c6e7dc1c2925
Added variable list view and status bar to octave terminal.
author | Jacob Dawid <jacob.dawid@googlemail.com> |
---|---|
date | Thu, 07 Apr 2011 22:01:14 +0200 |
parents | 3b089411a59d |
children | 45e5447ef292 |
files | gui//src/MainWindow.cpp gui//src/QTerminalWidget.cpp gui//src/QTerminalWidget.h gui//src/TerminalMdiSubWindow.cpp gui//src/TerminalMdiSubWindow.h |
diffstat | 5 files changed, 51 insertions(+), 31 deletions(-) [+] |
line wrap: on
line diff
--- a/gui//src/MainWindow.cpp +++ b/gui//src/MainWindow.cpp @@ -26,15 +26,9 @@ MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent) { - m_mdiArea = new QMdiArea(); - setWindowTitle("Quint"); - setCentralWidget(m_mdiArea); - constructWindow(); loadWebPage("Online Manual", "http://www.gnu.org/software/octave/doc/interpreter/"); - //addTerminalWindow(); - m_mdiArea->setViewMode(QMdiArea::SubWindowView); } MainWindow::~MainWindow() { @@ -42,7 +36,7 @@ } void MainWindow::addTerminalWindow() { - TerminalMdiSubWindow *terminal = new TerminalMdiSubWindow; + TerminalMdiSubWindow *terminal = new TerminalMdiSubWindow(this); m_mdiArea->addSubWindow(terminal); terminal->show(); } @@ -56,8 +50,14 @@ } void MainWindow::constructWindow() { + m_mdiArea = new QMdiArea(); + setWindowTitle("Quint"); + setCentralWidget(m_mdiArea); + QMenu *viewsMenu = menuBar()->addMenu("Views"); QAction *addOctaveTerminalAction = viewsMenu->addAction("Add Octave Terminal"); + m_mdiArea->setViewMode(QMdiArea::SubWindowView); + connect(addOctaveTerminalAction, SIGNAL(triggered()), this, SLOT(addTerminalWindow())); }
--- a/gui//src/QTerminalWidget.cpp +++ b/gui//src/QTerminalWidget.cpp @@ -48,7 +48,7 @@ session->setFlowControlEnabled(true); session->setHistoryType(HistoryTypeBuffer(1000)); session->setDarkBackground(true); - session->setKeyBindings(""); + session->setKeyBindings(""); return session; } @@ -97,8 +97,8 @@ font.setPointSize(10); font.setStyleHint(QFont::TypeWriter); setTerminalFont(font); - setScrollBarPosition(NoScrollBar); - + setScrollBarPosition(NoScrollBar); + m_impl->m_session->addView(m_impl->m_terminalDisplay); connect(m_impl->m_session, SIGNAL(finished()), this, SLOT(sessionFinished())); @@ -116,7 +116,7 @@ m_impl->m_terminalDisplay->setVTFont(font); } -void QTerminalWidget::setShellProgram(QString &progname) +void QTerminalWidget::setShellProgram(QString progname) { if (!m_impl->m_session) return; @@ -182,10 +182,9 @@ void QTerminalWidget::resizeEvent(QResizeEvent*) { m_impl->m_terminalDisplay->resize(this->size()); + m_impl->m_terminalDisplay->update(); } - - void QTerminalWidget::sessionFinished() { emit finished();
--- a/gui//src/QTerminalWidget.h +++ b/gui//src/QTerminalWidget.h @@ -60,7 +60,7 @@ void setTerminalFont(QFont &font); /** Shell program, default is /bin/bash. */ - void setShellProgram(QString &progname); + void setShellProgram(QString progname); /** Shell program args, default is none. */ void setArgs(QStringList &args);
--- a/gui//src/TerminalMdiSubWindow.cpp +++ b/gui//src/TerminalMdiSubWindow.cpp @@ -1,23 +1,40 @@ #include "TerminalMdiSubWindow.h" +#include <QHBoxLayout> +#include <QVBoxLayout> -TerminalMdiSubWindow::TerminalMdiSubWindow() - : QMdiSubWindow(), +TerminalMdiSubWindow::TerminalMdiSubWindow(QWidget *parent) + : QMdiSubWindow(parent), m_terminalWidget(0) { - setWindowTitle("Terminal Session"); - resize(800, 400); - launchTerminal(); + constructWindow(); } -void TerminalMdiSubWindow::launchTerminal() { - delete m_terminalWidget; - m_terminalWidget = new QTerminalWidget(0, this); - m_terminalWidget->setScrollBarPosition(QTerminalWidget::ScrollBarRight); - setWidget(m_terminalWidget); +void TerminalMdiSubWindow::constructWindow() { + setWindowTitle("Octave Session"); + resize(800, 400); + setWidget(new QWidget(this)); + + QVBoxLayout *vBoxLayout = new QVBoxLayout(); + + QWidget *hWidget = new QWidget(); + QHBoxLayout *hBoxLayout = new QHBoxLayout(); - QString programName = "octave"; - m_terminalWidget->setShellProgram(programName); - m_terminalWidget->startShellProgram(); - setFocus(); + m_terminalWidget = new QTerminalWidget(0, hWidget); + m_terminalWidget->setScrollBarPosition(QTerminalWidget::ScrollBarRight); + m_terminalWidget->setShellProgram("octave"); + m_terminalWidget->startShellProgram(); + m_terminalWidget->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); + m_variableView = new QTreeView(hWidget); + m_variableView->setMaximumWidth(200); - connect(m_terminalWidget, SIGNAL(finished()), this, SLOT(launchTerminal())); + hBoxLayout->addWidget(m_terminalWidget); + hBoxLayout->addWidget(m_variableView); + hWidget->setLayout(hBoxLayout); + + m_statusBar = new QStatusBar(); + + vBoxLayout->addWidget(hWidget); + vBoxLayout->addWidget(m_statusBar); + widget()->setLayout(vBoxLayout); + + m_statusBar->showMessage("Ready."); }
--- a/gui//src/TerminalMdiSubWindow.h +++ b/gui//src/TerminalMdiSubWindow.h @@ -2,18 +2,22 @@ #define TERMINALMDISUBWINDOW_H #include <QMdiSubWindow> +#include <QTreeView> +#include <QStatusBar> #include "QTerminalWidget.h" class TerminalMdiSubWindow : public QMdiSubWindow { Q_OBJECT public: - TerminalMdiSubWindow(); + TerminalMdiSubWindow(QWidget *parent = 0); private slots: - void launchTerminal(); private: + void constructWindow(); QTerminalWidget *m_terminalWidget; + QTreeView *m_variableView; + QStatusBar *m_statusBar; }; #endif // TERMINALMDISUBWINDOW_H