Mercurial > hg > octave-terminal
changeset 13564:d04622d694fd
Merge.
author | Jacob Dawid <jacob.dawid@googlemail.com> |
---|---|
date | Sun, 31 Jul 2011 23:13:36 +0200 |
parents | 93dc3b05a30c (current diff) a89aa9e05e19 (diff) |
children | da49b128a4d3 |
files | |
diffstat | 4 files changed, 71 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- a/gui/src/FileEditorMdiSubWindow.cpp +++ b/gui/src/FileEditorMdiSubWindow.cpp @@ -17,6 +17,7 @@ */ #include "FileEditorMdiSubWindow.h" +#include "MainWindow.h" #include <QVBoxLayout> #include <QApplication> #include <QFile> @@ -211,10 +212,24 @@ saveFile(saveFileName); } +// handle the run command void -FileEditorMdiSubWindow::setEditorLexer (LexerOctaveGui* lexer) +FileEditorMdiSubWindow::runFile () +{ + if (m_editor->isModified ()) + saveFile(m_fileName); + m_octave->sendText (QString ("run \'%1\'\n").arg (m_fileName)); + m_octave->setFocus (); +} + +// function for setting the already existing lexer from MainWindow +void +FileEditorMdiSubWindow::initEditor (OctaveTerminal* terminal, + LexerOctaveGui* lexer) { m_editor->setLexer(lexer); + m_octave = terminal; // for sending commands to octave + // TODO: make a global commandOctave function? } // TODO: Do we still need tool tips in the status bar? Tool tips are now @@ -266,6 +281,7 @@ { QStyle *style = QApplication::style (); setWidget (new QWidget ()); + m_menuBar = new QMenuBar (this); m_toolBar = new QToolBar (this); m_statusBar = new QStatusBar (this); m_editor = new QsciScintilla (this); @@ -287,8 +303,9 @@ m_editor->setAutoCompletionSource(QsciScintilla::AcsAPIs); m_editor->setAutoCompletionThreshold (3); + // The Actions + // Theme icons with QStyle icons as fallback - m_toolBar->setIconSize(QSize(20,20)); // smaller icons (make configurable in user settings?) QAction *closeAction = new QAction ( QIcon::fromTheme("window-close",style->standardIcon (QStyle::SP_DialogCloseButton)), tr("&Close File"), m_toolBar); @@ -310,6 +327,12 @@ QAction *redoAction = new QAction ( QIcon::fromTheme("edit-redo",style->standardIcon (QStyle::SP_ArrowRight)), tr("&Redo"), m_toolBar); + QAction *copyAction = new QAction (QIcon::fromTheme("edit-copy"),tr("&Copy"),m_toolBar); + QAction *cutAction = new QAction (QIcon::fromTheme("edit-cut"),tr("Cu&t"),m_toolBar); + QAction *pasteAction = new QAction (QIcon::fromTheme("edit-paste"),tr("&Paste"),m_toolBar); + QAction *runAction = new QAction ( + QIcon::fromTheme("media-play",style->standardIcon (QStyle::SP_MediaPlay)), + tr("&Run File"), m_toolBar); // short cuts newAction->setShortcut(QKeySequence::New); @@ -318,16 +341,50 @@ saveAsAction->setShortcut(QKeySequence::SaveAs); undoAction->setShortcut(QKeySequence::Undo); redoAction->setShortcut(QKeySequence::Redo); + copyAction->setShortcut(QKeySequence::Copy); + cutAction->setShortcut(QKeySequence::Cut); + pasteAction->setShortcut(QKeySequence::Paste); + runAction->setShortcut(Qt::Key_F5); + // toolbar + m_toolBar->setIconSize(QSize(20,20)); // smaller icons (make configurable in user settings?) m_toolBar->addAction (closeAction); m_toolBar->addAction (newAction); m_toolBar->addAction (openAction); m_toolBar->addAction (saveAction); m_toolBar->addAction (saveAsAction); + m_toolBar->addSeparator(); m_toolBar->addAction (undoAction); m_toolBar->addAction (redoAction); + m_toolBar->addAction (copyAction); + m_toolBar->addAction (cutAction); + m_toolBar->addAction (pasteAction); + m_toolBar->addSeparator(); + m_toolBar->addAction (runAction); + + // menu bar + QMenu *fileMenu = new QMenu(tr("&File"),m_menuBar); + fileMenu->addAction(newAction); + fileMenu->addAction(openAction); + fileMenu->addAction(saveAction); + fileMenu->addAction(saveAsAction); + fileMenu->addSeparator(); + fileMenu->addAction (closeAction); + m_menuBar->addMenu(fileMenu); + QMenu *editMenu = new QMenu(tr("&Edit"),m_menuBar); + editMenu->addAction(undoAction); + editMenu->addAction(redoAction); + fileMenu->addSeparator(); + editMenu->addAction(copyAction); + editMenu->addAction(cutAction); + editMenu->addAction(pasteAction); + m_menuBar->addMenu(editMenu); + QMenu *runMenu = new QMenu(tr("&Run"),m_menuBar); + runMenu->addAction(runAction); + m_menuBar->addMenu(runMenu); QVBoxLayout *layout = new QVBoxLayout (); + layout->addWidget (m_menuBar); layout->addWidget (m_toolBar); layout->addWidget (m_editor); layout->addWidget (m_statusBar); @@ -339,8 +396,12 @@ connect (openAction, SIGNAL (triggered ()), this, SLOT (openFile ())); connect (undoAction, SIGNAL (triggered ()), m_editor, SLOT (undo ())); connect (redoAction, SIGNAL (triggered ()), m_editor, SLOT (redo ())); + connect (copyAction, SIGNAL (triggered ()), m_editor, SLOT (copy ())); + connect (cutAction, SIGNAL (triggered ()), m_editor, SLOT (cut ())); + connect (pasteAction, SIGNAL (triggered ()), m_editor, SLOT (paste ())); connect (saveAction, SIGNAL (triggered ()), this, SLOT (saveFile ())); connect (saveAsAction, SIGNAL (triggered ()), this, SLOT (saveFileAs ())); + connect (runAction, SIGNAL (triggered ()), this, SLOT (runFile ())); // TODO: Do we still need tool tips in the status bar? Tool tips are now // shown directly at the theme icons
--- a/gui/src/FileEditorMdiSubWindow.h +++ b/gui/src/FileEditorMdiSubWindow.h @@ -19,8 +19,10 @@ #ifndef FILEEDITORMDISUBWINDOW_H #define FILEEDITORMDISUBWINDOW_H +#include "OctaveTerminal.h" #include <QMdiSubWindow> #include <QToolBar> +#include <QMenuBar> #include <QStatusBar> #include <QCloseEvent> #include <Qsci/qsciscintilla.h> @@ -37,7 +39,7 @@ FileEditorMdiSubWindow (QWidget * parent = 0); ~FileEditorMdiSubWindow (); void loadFile (QString fileName); - void setEditorLexer (LexerOctaveGui *lexer); + void initEditor (OctaveTerminal *terminal, LexerOctaveGui *lexer); public slots: @@ -61,14 +63,17 @@ private: int checkFileModified (QString msg); void construct (); + QMenuBar *m_menuBar; QToolBar *m_toolBar; QsciScintilla *m_editor; QStatusBar *m_statusBar; QString m_fileName; + OctaveTerminal* m_octave; bool m_modified; private slots: void handleModificationChanged(bool modified); + void runFile(); };
--- a/gui/src/MainWindow.cpp +++ b/gui/src/MainWindow.cpp @@ -95,7 +95,7 @@ } m_lexerAPI->prepare(); // prepare API info ... this make take some time } - subWindow->setEditorLexer(m_lexer); // set the already prepared lexer + subWindow->initEditor(m_octaveTerminal,m_lexer); // init necessary informations for editor if ( fileName.isEmpty() ) subWindow->newFile ();