Mercurial > hg > octave-lyh
changeset 14599:97cb9286919c gui
Cleaned up code.
* .hgsub: Removed IRC Widget.
* gui.pro: Removed dependency on IRC Widget and removed files.
* class FileEditorMdiSubWindow: Renamed to FileEditor. File editor windows are now independent windows, thus removed the extra close button.
* MainWindow: Removed MDI Area and replaced it with the terminal instead.
* BrowserWidget: Removed browser widget.
* SettingsDialog: Rearranged settings for the editor, removed tab for shortcuts.
* OctaveCallbackThread: Raised update intervals from 0,5s to 1s.
* OctaveLink: Replaced signals names for triggering updates on the symbol table.
* WorkspaceView: Adjusted connect statements to fit the new signal names.
author | Jacob Dawid <jacob.dawid@googlemail.com> |
---|---|
date | Mon, 07 May 2012 00:53:54 +0200 |
parents | fa52c6e84ae0 |
children | 32e53ccdf0ca |
files | .hgsub .hgsubstate gui/gui.pro gui/src/BrowserWidget.cpp gui/src/BrowserWidget.h gui/src/FileEditor.cpp gui/src/FileEditor.h gui/src/FileEditorMdiSubWindow.cpp gui/src/FileEditorMdiSubWindow.h gui/src/MainWindow.cpp gui/src/MainWindow.h gui/src/SettingsDialog.cpp gui/src/SettingsDialog.ui gui/src/WorkspaceView.cpp gui/src/backend/OctaveCallbackThread.cpp gui/src/backend/OctaveLink.cpp gui/src/backend/OctaveLink.h gui/src/src.pro |
diffstat | 16 files changed, 181 insertions(+), 580 deletions(-) [+] |
line wrap: on
line diff
--- a/.hgsub +++ b/.hgsub @@ -1,3 +1,2 @@ gnulib = [git]git://git.sv.gnu.org/gnulib gui/qterminal = [git]https://code.google.com/p/qterminal/ -gui/qirc = [git]https://code.google.com/p/qirc
--- a/.hgsubstate +++ b/.hgsubstate @@ -1,3 +1,2 @@ f9813bce2c06a6130a68db4478d1b16ddadaf276 gnulib -34c2a274a1b607d2616d9903099a0905237c8f80 gui/qirc a81f99b9b77d9a402b92463b41c5fdb82324349a gui/qterminal
--- a/gui/gui.pro +++ b/gui/gui.pro @@ -1,2 +1,2 @@ TEMPLATE = subdirs -SUBDIRS = qterminal qirc src +SUBDIRS = qterminal src
deleted file mode 100644 --- a/gui/src/BrowserWidget.cpp +++ /dev/null @@ -1,105 +0,0 @@ -/* 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 "BrowserWidget.h" -#include <QVBoxLayout> -#include <QAction> -#include <QStyle> -#include <QApplication> - -BrowserWidget::BrowserWidget (QWidget * parent):QWidget (parent) -{ - construct (); -} - -void -BrowserWidget::construct () -{ - QStyle *style = QApplication::style (); - m_navigationToolBar = new QToolBar (this); - m_webView = new QWebView (this); - m_urlLineEdit = new QLineEdit (this); - m_statusBar = new QStatusBar (this); - m_progressBar = new QProgressBar (this); - m_progressBar->setMaximumWidth (150); - - m_webView->setSizePolicy (QSizePolicy::Expanding, QSizePolicy::Expanding); - QAction *backAction = - new QAction (style->standardIcon (QStyle::SP_ArrowLeft), - "", m_navigationToolBar); - QAction *forwardAction = - new QAction (style->standardIcon (QStyle::SP_ArrowRight), - "", m_navigationToolBar); - - m_navigationToolBar->addAction (backAction); - m_navigationToolBar->addAction (forwardAction); - m_navigationToolBar->addWidget (m_urlLineEdit); - - QVBoxLayout *layout = new QVBoxLayout (); - layout->addWidget (m_navigationToolBar); - layout->addWidget (m_webView); - - QWidget *bottomWidget = new QWidget (this); - QHBoxLayout *bottomLineLayout = new QHBoxLayout (); - bottomLineLayout->addWidget (m_progressBar); - bottomLineLayout->addWidget (m_statusBar); - bottomLineLayout->setMargin (0); - bottomWidget->setLayout (bottomLineLayout); - - layout->addWidget (bottomWidget); - layout->setMargin (2); - setLayout (layout); - - connect (backAction, SIGNAL (triggered ()), m_webView, SLOT (back ())); - connect (forwardAction, SIGNAL (triggered ()), m_webView, - SLOT (forward ())); - connect (m_webView, SIGNAL (urlChanged (QUrl)), this, SLOT (setUrl (QUrl))); - connect (m_urlLineEdit, SIGNAL (returnPressed ()), this, - SLOT (jumpToWebsite ())); - - connect (m_webView, SIGNAL (statusBarMessage(QString)), - m_statusBar, SLOT (showMessage(QString))); - connect (m_webView, SIGNAL (loadProgress(int)), - m_progressBar, SLOT (setValue(int))); -} - -void -BrowserWidget::setUrl (QUrl url) -{ - m_urlLineEdit->setText (url.toString ()); -} - -void -BrowserWidget::jumpToWebsite () -{ - QString url = m_urlLineEdit->text (); - if (!url.startsWith ("http://") && !url.startsWith ("https://")) - url = "http://" + url; - load (url); -} - -void -BrowserWidget::showStatusMessage (QString message) -{ - m_statusBar->showMessage (message, 1000); -} - -void -BrowserWidget::load (QUrl url) -{ - m_webView->load (url); -}
deleted file mode 100644 --- a/gui/src/BrowserWidget.h +++ /dev/null @@ -1,50 +0,0 @@ -/* 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 BROWSERMDISUBWINDOW_H -#define BROWSERMDISUBWINDOW_H - -#include <QWidget> -#include <QToolBar> -#include <QLineEdit> -#include <QtWebKit/QWebView> -#include <QStatusBar> -#include <QProgressBar> - -class BrowserWidget:public QWidget -{ - Q_OBJECT -public: - BrowserWidget (QWidget * parent = 0); - void load (QUrl url); - -public slots: - void setUrl (QUrl url); - void jumpToWebsite (); - void showStatusMessage (QString message); - -private: - void construct (); - - QLineEdit *m_urlLineEdit; - QToolBar *m_navigationToolBar; - QWebView *m_webView; - QStatusBar *m_statusBar; - QProgressBar *m_progressBar; -}; - -#endif // BROWSERMDISUBWINDOW_H
rename from gui/src/FileEditorMdiSubWindow.cpp rename to gui/src/FileEditor.cpp --- a/gui/src/FileEditorMdiSubWindow.cpp +++ b/gui/src/FileEditor.cpp @@ -15,7 +15,7 @@ * along with this program. If not, see <http://www.gnu.org/licenses/>. */ -#include "FileEditorMdiSubWindow.h" +#include "FileEditor.h" #include <QVBoxLayout> #include <QApplication> #include <QFile> @@ -25,18 +25,18 @@ #include <QStyle> #include <QTextStream> -FileEditorMdiSubWindow::FileEditorMdiSubWindow (QWidget * parent):QMdiSubWindow - (parent) +FileEditor::FileEditor (QWidget * parent) + : QWidget (parent) { construct (); } -FileEditorMdiSubWindow::~FileEditorMdiSubWindow () +FileEditor::~FileEditor () { } void -FileEditorMdiSubWindow::closeEvent(QCloseEvent *event) +FileEditor::closeEvent(QCloseEvent *event) { if ( m_mainWindow->isCloseApplication() ) { @@ -54,7 +54,7 @@ } void -FileEditorMdiSubWindow::handleMarginClicked(int margin, int line, Qt::KeyboardModifiers state) +FileEditor::handleMarginClicked(int margin, int line, Qt::KeyboardModifiers state) { Q_UNUSED (state); if ( margin == 1 ) // marker margin @@ -68,7 +68,7 @@ } void -FileEditorMdiSubWindow::newWindowTitle(bool modified) +FileEditor::newWindowTitle(bool modified) { QString title(m_fileName); if ( !m_longTitle ) @@ -85,7 +85,7 @@ } void -FileEditorMdiSubWindow::handleCopyAvailable(bool enableCopy) +FileEditor::handleCopyAvailable(bool enableCopy) { m_copyAction->setEnabled(enableCopy); m_cutAction->setEnabled(enableCopy); @@ -93,7 +93,7 @@ void -FileEditorMdiSubWindow::openFile () +FileEditor::openFile () { if (checkFileModified ("Open File",QMessageBox::Cancel)==QMessageBox::Cancel) { @@ -114,14 +114,14 @@ } void -FileEditorMdiSubWindow::loadFile (QString fileName) +FileEditor::loadFile (QString fileName) { QFile file (fileName); if (!file.open (QFile::ReadOnly)) { QMessageBox::warning (this, tr ("File Editor"), - tr ("Cannot read file %1:\n%2.").arg (fileName). - arg (file.errorString ())); + tr ("Cannot read file %1:\n%2.").arg (fileName). + arg (file.errorString ())); return; } @@ -137,12 +137,13 @@ } void -FileEditorMdiSubWindow::newFile () +FileEditor::newFile () { if (checkFileModified ("Create New File",QMessageBox::Cancel)==QMessageBox::Cancel) { return; // existing file not saved and creating new file canceled by user } + m_fileName = UNNAMED_FILE; newWindowTitle (false); // window title (no modification) m_editor->setText (""); @@ -150,7 +151,7 @@ } int -FileEditorMdiSubWindow::checkFileModified (QString msg, int cancelButton) +FileEditor::checkFileModified (QString msg, int cancelButton) { int decision = QMessageBox::Yes; if (m_editor->isModified ()) @@ -182,13 +183,13 @@ } void -FileEditorMdiSubWindow::saveFile () +FileEditor::saveFile () { saveFile(m_fileName); } void -FileEditorMdiSubWindow::saveFile (QString saveFileName) +FileEditor::saveFile (QString saveFileName) { // it is a new file with the name "<unnamed>" -> call saveFielAs if (saveFileName==UNNAMED_FILE || saveFileName.isEmpty ()) @@ -219,7 +220,7 @@ } void -FileEditorMdiSubWindow::saveFileAs () +FileEditor::saveFileAs () { QString saveFileName(m_fileName); QFileDialog dlg(this); @@ -247,7 +248,7 @@ // handle the run command void -FileEditorMdiSubWindow::runFile () +FileEditor::runFile () { if (m_editor->isModified ()) saveFile(m_fileName); @@ -258,17 +259,17 @@ // (un)comment selected text void -FileEditorMdiSubWindow::commentSelectedText () +FileEditor::commentSelectedText () { doCommentSelectedText (true); } void -FileEditorMdiSubWindow::uncommentSelectedText () +FileEditor::uncommentSelectedText () { doCommentSelectedText (false); } void -FileEditorMdiSubWindow::doCommentSelectedText (bool comment) +FileEditor::doCommentSelectedText (bool comment) { if ( m_editor->hasSelectedText() ) { @@ -298,13 +299,13 @@ // remove bookmarks void -FileEditorMdiSubWindow::removeBookmark () +FileEditor::removeBookmark () { m_editor->markerDeleteAll(MARKER_BOOKMARK); } // toggle bookmark void -FileEditorMdiSubWindow::toggleBookmark () +FileEditor::toggleBookmark () { int line,cur; m_editor->getCursorPosition(&line,&cur); @@ -315,7 +316,7 @@ } // goto next bookmark void -FileEditorMdiSubWindow::nextBookmark () +FileEditor::nextBookmark () { int line,cur,nextline; m_editor->getCursorPosition(&line,&cur); @@ -326,7 +327,7 @@ } // goto previous bookmark void -FileEditorMdiSubWindow::prevBookmark () +FileEditor::prevBookmark () { int line,cur,prevline; m_editor->getCursorPosition(&line,&cur); @@ -338,7 +339,7 @@ // function for setting the already existing lexer from MainWindow void -FileEditorMdiSubWindow::initEditor (QTerminal* terminalView, +FileEditor::initEditor (QTerminal* terminalView, LexerOctaveGui* lexer, MainWindow* mainWindow) { @@ -348,56 +349,17 @@ m_mainWindow = mainWindow; // get the MainWindow for chekcing state at subwindow close } -// TODO: Do we still need tool tips in the status bar? Tool tips are now -// shown directly at the theme icons void -FileEditorMdiSubWindow::showToolTipNew () -{ - m_statusBar->showMessage ("Create a new file", 2000); -} - -void -FileEditorMdiSubWindow::showToolTipOpen () -{ - m_statusBar->showMessage ("Open a file", 2000); -} - -void -FileEditorMdiSubWindow::showToolTipSave () -{ - m_statusBar->showMessage ("Save the file", 2000); -} - -void -FileEditorMdiSubWindow::showToolTipSaveAs () -{ - m_statusBar->showMessage ("Save the file as", 2000); -} - -void -FileEditorMdiSubWindow::showToolTipUndo () -{ - m_statusBar->showMessage ("Revert previous changes", 2000); -} - -void -FileEditorMdiSubWindow::showToolTipRedo () -{ - m_statusBar->showMessage ("Append previous changes", 2000); -} - -void -FileEditorMdiSubWindow::registerModified (bool modified) +FileEditor::setModified (bool modified) { m_modified = modified; } void -FileEditorMdiSubWindow::construct () +FileEditor::construct () { QSettings *settings = ResourceManager::instance ()->settings (); QStyle *style = QApplication::style (); - setWidget (new QWidget ()); m_menuBar = new QMenuBar (this); m_toolBar = new QToolBar (this); @@ -449,9 +411,6 @@ // The Actions // Theme icons with QStyle icons as fallback - QAction *closeAction = new QAction ( - QIcon::fromTheme("window-close",style->standardIcon (QStyle::SP_DialogCloseButton)), - tr("&Close File"), m_toolBar); QAction *newAction = new QAction ( QIcon::fromTheme("document-new",style->standardIcon (QStyle::SP_FileIcon)), tr("&New File"), m_toolBar); @@ -506,8 +465,6 @@ uncommentSelectedAction->setShortcut(Qt::CTRL + Qt::Key_T); // toolbar - m_toolBar->setIconSize(QSize(16,16)); // smaller icons (make configurable in user settings?) - m_toolBar->addAction (closeAction); m_toolBar->addAction (newAction); m_toolBar->addAction (openAction); m_toolBar->addAction (saveAction); @@ -528,7 +485,6 @@ 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); @@ -557,9 +513,8 @@ layout->addWidget (m_editor); layout->addWidget (m_statusBar); layout->setMargin (2); - widget ()->setLayout (layout); + setLayout (layout); - connect (closeAction, SIGNAL (triggered()), this, SLOT (close())); connect (newAction, SIGNAL (triggered ()), this, SLOT (newFile ())); connect (openAction, SIGNAL (triggered ()), this, SLOT (openFile ())); connect (undoAction, SIGNAL (triggered ()), m_editor, SLOT (undo ())); @@ -577,14 +532,6 @@ connect (commentSelectedAction, SIGNAL (triggered ()), this, SLOT (commentSelectedText ())); connect (uncommentSelectedAction, SIGNAL (triggered ()), this, SLOT (uncommentSelectedText ())); - // TODO: Do we still need tool tips in the status bar? Tool tips are now - // shown directly at the theme icons - connect (newAction, SIGNAL (hovered ()), this, SLOT (showToolTipNew ())); - connect (openAction, SIGNAL (hovered ()), this, SLOT (showToolTipOpen ())); - connect (undoAction, SIGNAL (hovered ()), this, SLOT (showToolTipUndo ())); - connect (redoAction, SIGNAL (hovered ()), this, SLOT (showToolTipRedo ())); - connect (saveAction, SIGNAL (hovered ()), this, SLOT (showToolTipSave ())); - connect (saveAsAction, SIGNAL (hovered ()), this,SLOT (showToolTipSaveAs ())); // connect modified signal connect (m_editor, SIGNAL (modificationChanged(bool)), this, SLOT (newWindowTitle(bool)) );
rename from gui/src/FileEditorMdiSubWindow.h rename to gui/src/FileEditor.h --- a/gui/src/FileEditorMdiSubWindow.h +++ b/gui/src/FileEditor.h @@ -20,7 +20,7 @@ #include "MainWindow.h" -#include <QMdiSubWindow> +#include <QWidget> #include <QToolBar> #include <QAction> #include <QMenuBar> @@ -39,13 +39,13 @@ MARKER_BREAKPOINT }; -class FileEditorMdiSubWindow:public QMdiSubWindow +class FileEditor : public QWidget { Q_OBJECT public: - FileEditorMdiSubWindow (QWidget * parent = 0); - ~FileEditorMdiSubWindow (); + FileEditor (QWidget * parent = 0); + ~FileEditor (); void loadFile (QString fileName); void initEditor (QTerminal *terminalView, LexerOctaveGui *lexer, @@ -59,13 +59,7 @@ void saveFile (QString fileName); void saveFileAs (); - void showToolTipNew (); - void showToolTipOpen (); - void showToolTipSave (); - void showToolTipSaveAs (); - void showToolTipUndo (); - void showToolTipRedo (); - void registerModified (bool modified); + void setModified (bool modified); protected: void closeEvent(QCloseEvent *event);
--- a/gui/src/MainWindow.cpp +++ b/gui/src/MainWindow.cpp @@ -23,13 +23,14 @@ #include <QFileDialog> #include <QMessageBox> #include "MainWindow.h" -#include "FileEditorMdiSubWindow.h" +#include "FileEditor.h" #include "SettingsDialog.h" #define VERSION_STRING "Octave GUI (0.8.8)" MainWindow::MainWindow (QWidget * parent):QMainWindow (parent) { + // We have to set up all our windows, before we finally launch octave. construct (); OctaveLink::instance ()->launchOctave(); } @@ -39,33 +40,23 @@ } void -MainWindow::handleOpenFileRequest (QString fileName) +MainWindow::openExistingFile (QString fileName) { - reportStatusMessage (tr ("Opening file.")); - QPixmap pixmap; - if (pixmap.load (fileName)) - { -// ImageViewerMdiSubWindow *subWindow = new ImageViewerMdiSubWindow(pixmap, this); -// subWindow->setAttribute(Qt::WA_DeleteOnClose); -// m_centralMdiArea->addSubWindow(subWindow); -// subWindow->setWindowTitle(fileName); - } - else - { - openEditorFile(fileName); - } + reportStatusMessage (tr ("Opening file..")); + newEditorWindow(fileName); } void -MainWindow::openEditor () +MainWindow::newFile () { - openEditorFile(QString()); + newEditorWindow(QString()); } + void -MainWindow::openEditorFile (QString fileName) +MainWindow::newEditorWindow (QString fileName) { - FileEditorMdiSubWindow *subWindow = new FileEditorMdiSubWindow (m_centralMdiArea); - subWindow->setAttribute (Qt::WA_DeleteOnClose); + FileEditor *fileEditor = new FileEditor (); + fileEditor->setAttribute (Qt::WA_DeleteOnClose); // check whether lexer is already prepared and prepare it if not if ( m_lexer == NULL ) { @@ -97,12 +88,12 @@ } m_lexerAPI->prepare(); // prepare API info ... this make take some time } - subWindow->initEditor(m_terminalView, m_lexer, this); // init necessary informations for editor + fileEditor->initEditor(m_terminalView, m_lexer, this); // init necessary informations for editor if ( fileName.isEmpty() ) - subWindow->newFile (); + fileEditor->newFile (); else - subWindow->loadFile (fileName); + fileEditor->loadFile (fileName); } @@ -113,29 +104,6 @@ } void -MainWindow::openWebPage (QString url) -{ - m_documentationWidget->load (QUrl (url)); -} - -void -MainWindow::openChat () -{ - if (!m_ircWidget) - { - m_ircWidget = new QIRCWidget (); - m_ircWidget->setWindowTitle ("Chat"); - m_ircWidget->connectToServer ("irc.freenode.net", "Octave-GUI-User", "#octave"); - } - - if (!m_ircWidget->isVisible ()) - { - m_ircWidget->setVisible (true); - m_ircWidget->raise (); - } -} - -void MainWindow::handleSaveWorkspaceRequest () { QString selectedFile = @@ -170,12 +138,6 @@ } void -MainWindow::alignMdiWindows () -{ - m_centralMdiArea->tileSubWindows (); -} - -void MainWindow::openBugTrackerPage () { QDesktopServices::openUrl (QUrl ("http://savannah.gnu.org/bugs/?group=octave")); @@ -241,20 +203,13 @@ } void -MainWindow::showAboutQt () -{ - QMessageBox::aboutQt (this); -} - -void MainWindow::closeEvent (QCloseEvent * closeEvent) { reportStatusMessage (tr ("Saving data and shutting down.")); writeSettings (); m_closeApplication = true; // inform editor window that whole application is closed OctaveLink::instance ()->terminateOctave(); - m_centralMdiArea->closeAllSubWindows(); // send close events to subwindows - // (editor files can be saved!) + QMainWindow::closeEvent (closeEvent); } @@ -264,7 +219,6 @@ QSettings *settings = ResourceManager::instance ()->settings (); restoreGeometry (settings->value ("MainWindow/geometry").toByteArray ()); restoreState (settings->value ("MainWindow/windowState").toByteArray ()); - m_centralMdiArea->restoreGeometry (settings->value ("MdiArea/geometry").toByteArray ()); emit settingsChanged (); } @@ -274,22 +228,15 @@ QSettings *settings = ResourceManager::instance ()->settings (); settings->setValue ("MainWindow/geometry", saveGeometry ()); settings->setValue ("MainWindow/windowState", saveState ()); - settings->setValue ("MdiArea/geometry", m_centralMdiArea->saveGeometry ()); } void MainWindow::construct () { + // TODO: Check this. m_closeApplication = false; // flag for editor files when closed setWindowIcon (ResourceManager::instance ()->icon (ResourceManager::Octave)); - m_ircWidget = 0; - - // Initialize MDI area. - m_centralMdiArea = new QMdiArea (this); - m_centralMdiArea->setObjectName ("CentralMdiArea"); - m_centralMdiArea->setViewMode (QMdiArea::TabbedView); - // Setup dockable widgets and the status bar. m_workspaceView = new WorkspaceView (this); m_workspaceView->setStatusTip (tr ("View the variables in the active workspace.")); @@ -299,33 +246,9 @@ m_filesDockWidget->setStatusTip (tr ("Browse your files.")); m_statusBar = new QStatusBar (this); - // Documentation subwindow. - m_documentationWidget = new BrowserWidget (this); - m_documentationWidgetSubWindow = new NonClosableMdiSubWindow (this); - m_documentationWidgetSubWindow->setWidget (m_documentationWidget); - m_centralMdiArea->addSubWindow (m_documentationWidgetSubWindow, Qt::WindowTitleHint | Qt::WindowMinMaxButtonsHint); - - m_documentationWidgetSubWindow->setObjectName ("DocumentationWidgetSubWindow"); - m_documentationWidgetSubWindow->setWindowTitle (tr ("Documentation")); - m_documentationWidgetSubWindow - ->setWindowIcon (ResourceManager::instance ()->icon (ResourceManager::Documentation)); - m_documentationWidgetSubWindow->setFocusProxy (m_documentationWidget); - m_documentationWidgetSubWindow->setStatusTip (tr ("Browse the Octave documentation for help.")); - m_documentationWidgetSubWindow->setMinimumSize (300, 300); - // Octave Terminal subwindow. m_terminalView = new QTerminal(this); - m_terminalViewSubWindow = new NonClosableMdiSubWindow (this); - m_terminalViewSubWindow->setWidget (m_terminalView); - m_centralMdiArea->addSubWindow (m_terminalViewSubWindow, Qt::WindowTitleHint | Qt::WindowMinMaxButtonsHint); - - m_terminalViewSubWindow->setObjectName ("OctaveTerminalSubWindow"); - m_terminalViewSubWindow->setWindowTitle (tr ("Terminal")); - m_terminalViewSubWindow - ->setWindowIcon (ResourceManager::instance ()->icon (ResourceManager::Terminal)); - m_terminalViewSubWindow->setFocusProxy (m_terminalView); - m_terminalViewSubWindow->setStatusTip (tr ("Enter your commands into the Octave terminal.")); - m_terminalViewSubWindow->setMinimumSize (300, 300); + setCentralWidget (m_terminalView); m_lexer = NULL; // initialise the empty lexer for the edtiors @@ -336,8 +259,6 @@ QMenu *interfaceMenu = menuBar ()->addMenu (tr ("Interface")); - QAction *alignWindowsAction = interfaceMenu->addAction (tr ("Align Windows")); - interfaceMenu->addSeparator (); QAction *showWorkspaceAction = interfaceMenu->addAction (tr ("Workspace")); showWorkspaceAction->setCheckable (true); @@ -357,25 +278,19 @@ QAction *clearWorkspaceAction = workspaceMenu->addAction (tr ("Clear")); QMenu *communityMenu = menuBar ()->addMenu (tr ("Community")); - QAction *openChatAction = communityMenu->addAction (tr ("Chat")); - communityMenu->addSeparator(); QAction *reportBugAction = communityMenu->addAction (tr ("Report Bug")); QAction *agoraAction = communityMenu->addAction (tr ("Agora")); QAction *octaveForgeAction = communityMenu->addAction (tr ("Octave Forge")); communityMenu->addSeparator (); QAction *aboutOctaveAction = communityMenu->addAction (tr ("About Octave")); - QAction *aboutQt = communityMenu->addAction (tr ("About Qt")); connect (settingsAction, SIGNAL (triggered ()), this, SLOT (processSettingsDialogRequest ())); connect (exitAction, SIGNAL (triggered ()), this, SLOT (close ())); - connect (alignWindowsAction, SIGNAL (triggered ()), this, SLOT (alignMdiWindows ())); - connect (openEditorAction, SIGNAL (triggered ()), this, SLOT (openEditor ())); - connect (openChatAction, SIGNAL (triggered ()), this, SLOT (openChat ())); + connect (openEditorAction, SIGNAL (triggered ()), this, SLOT (newFile ())); connect (reportBugAction, SIGNAL (triggered ()), this, SLOT (openBugTrackerPage ())); connect (agoraAction, SIGNAL (triggered ()), this, SLOT (openAgoraPage ())); connect (octaveForgeAction, SIGNAL (triggered ()), this, SLOT (openOctaveForgePage ())); connect (aboutOctaveAction, SIGNAL (triggered ()), this, SLOT (showAboutOctave ())); - connect (aboutQt, SIGNAL (triggered ()), this, SLOT (showAboutQt ())); connect (showWorkspaceAction, SIGNAL (toggled (bool)), m_workspaceView, SLOT (setShown (bool))); connect (m_workspaceView, SIGNAL (activeChanged (bool)), showWorkspaceAction, SLOT (setChecked (bool))); @@ -388,7 +303,7 @@ //connect (this, SIGNAL (settingsChanged ()), m_historyDockWidget, SLOT (noticeSettings ())); connect (this, SIGNAL (settingsChanged ()), m_filesDockWidget, SLOT (noticeSettings ())); - connect (m_filesDockWidget, SIGNAL (openFile (QString)), this, SLOT (handleOpenFileRequest (QString))); + connect (m_filesDockWidget, SIGNAL (openFile (QString)), this, SLOT (openExistingFile (QString))); connect (m_historyDockWidget, SIGNAL (information (QString)), this, SLOT (reportStatusMessage (QString))); connect (m_historyDockWidget, SIGNAL (commandDoubleClicked (QString)), this, SLOT (handleCommandDoubleClicked (QString))); connect (saveWorkspaceAction, SIGNAL (triggered ()), this, SLOT (handleSaveWorkspaceRequest ())); @@ -397,7 +312,6 @@ setWindowTitle (QString (VERSION_STRING)); - setCentralWidget (m_centralMdiArea); addDockWidget (Qt::LeftDockWidgetArea, m_workspaceView); addDockWidget (Qt::LeftDockWidgetArea, m_historyDockWidget); addDockWidget (Qt::RightDockWidgetArea, m_filesDockWidget); @@ -405,6 +319,5 @@ readSettings (); updateTerminalFont(); - openWebPage ("http://www.gnu.org/software/octave/doc/interpreter/"); }
--- a/gui/src/MainWindow.h +++ b/gui/src/MainWindow.h @@ -18,6 +18,7 @@ #ifndef MAINWINDOW_H #define MAINWINDOW_H +// Qt includes #include <QtGui/QMainWindow> #include <QThread> #include <QTabWidget> @@ -25,32 +26,22 @@ #include <QStatusBar> #include <QToolBar> #include <QQueue> -#include <Qsci/qsciapis.h> #include <QMdiSubWindow> #include <QCloseEvent> + +// QScintilla includes +#include <Qsci/qsciapis.h> +#include "lexer/lexeroctavegui.h" + +// QTerminal includes +#include "QTerminal.h" + +// Own includes #include "ResourceManager.h" #include "OctaveLink.h" #include "WorkspaceView.h" #include "HistoryDockWidget.h" #include "FilesDockWidget.h" -#include "BrowserWidget.h" -#include "lexer/lexeroctavegui.h" -#include "QTerminal.h" -#include "QIRCWidget.h" - -class NonClosableMdiSubWindow : public QMdiSubWindow -{ - Q_OBJECT -public: - explicit NonClosableMdiSubWindow (QWidget *parent = 0) - : QMdiSubWindow (parent) { } - virtual ~NonClosableMdiSubWindow () { } -protected: - void closeEvent (QCloseEvent *closeEvent) - { - closeEvent->ignore (); - } -}; /** * \class MainWindow @@ -85,23 +76,19 @@ void settingsChanged (); public slots: - void handleOpenFileRequest (QString fileName); + void openExistingFile (QString fileName); void reportStatusMessage (QString statusMessage); - void openWebPage (QString url); - void openChat (); void handleSaveWorkspaceRequest (); void handleLoadWorkspaceRequest (); void handleClearWorkspaceRequest (); void handleCommandDoubleClicked (QString command); - void alignMdiWindows (); - void openEditor (); - void openEditorFile (QString fileName); + void newFile (); + void newEditorWindow (QString fileName); void openBugTrackerPage (); void openAgoraPage (); void openOctaveForgePage (); void processSettingsDialogRequest (); void showAboutOctave (); - void showAboutQt (); void updateTerminalFont (); protected: @@ -112,15 +99,8 @@ private: void construct (); void establishOctaveLink (); - QMdiArea *m_centralMdiArea; - // Mdi sub windows. QTerminal *m_terminalView; - BrowserWidget *m_documentationWidget; - QIRCWidget *m_ircWidget; - - NonClosableMdiSubWindow *m_terminalViewSubWindow; - NonClosableMdiSubWindow *m_documentationWidgetSubWindow; // Dock widgets. WorkspaceView *m_workspaceView;
--- a/gui/src/SettingsDialog.cpp +++ b/gui/src/SettingsDialog.cpp @@ -56,33 +56,6 @@ ui->proxyPort->setText (settings->value ("proxyPort").toString ()); ui->proxyUserName->setText (settings->value ("proxyUserName").toString ()); ui->proxyPassword->setText (settings->value ("proxyPassword").toString ()); - - // Short cuts - QStringList headerLabels; - headerLabels << "Modifier" << "Key" << "Action"; - ui->shortcutTableWidget->setColumnCount (3); - ui->shortcutTableWidget->setRowCount (10); - ui->shortcutTableWidget->horizontalHeader ()->setStretchLastSection (true); - ui->shortcutTableWidget->setHorizontalHeaderLabels (headerLabels); - ui->shortcutTableWidget->setSelectionBehavior(QAbstractItemView::SelectRows); - ui->shortcutTableWidget->setSelectionMode(QAbstractItemView::SingleSelection); - - /* - newAction->setShortcut(QKeySequence::New); - openAction->setShortcut(QKeySequence::Open); - saveAction->setShortcut(QKeySequence::Save); - saveAsAction->setShortcut(QKeySequence::SaveAs); - undoAction->setShortcut(QKeySequence::Undo); - redoAction->setShortcut(QKeySequence::Redo); - m_copyAction->setShortcut(QKeySequence::Copy); - m_cutAction->setShortcut(QKeySequence::Cut); - pasteAction->setShortcut(QKeySequence::Paste); - runAction->setShortcut(Qt::Key_F5); - nextBookmarkAction->setShortcut(Qt::Key_F2); - prevBookmarkAction->setShortcut(Qt::SHIFT + Qt::Key_F2); - toggleBookmarkAction->setShortcut(Qt::Key_F7); - commentSelectedAction->setShortcut(Qt::CTRL + Qt::Key_R); - uncommentSelectedAction->setShortcut(Qt::CTRL + Qt::Key_T);*/ } SettingsDialog::~SettingsDialog ()
--- a/gui/src/SettingsDialog.ui +++ b/gui/src/SettingsDialog.ui @@ -34,93 +34,62 @@ <property name="currentIndex"> <number>0</number> </property> - <widget class="QWidget" name="tab_4"> - <attribute name="title"> - <string>Interface</string> - </attribute> - <layout class="QVBoxLayout" name="verticalLayout_6"> - <item> - <widget class="QLabel" name="label_10"> - <property name="text"> - <string>Shortcuts:</string> - </property> - </widget> - </item> - <item> - <widget class="QTableWidget" name="shortcutTableWidget"> - <property name="enabled"> - <bool>false</bool> - </property> - </widget> - </item> - <item> - <layout class="QHBoxLayout" name="horizontalLayout_2"> - <item> - <widget class="QPushButton" name="addShortcutButton"> - <property name="enabled"> - <bool>false</bool> - </property> - <property name="text"> - <string>Add</string> - </property> - </widget> - </item> - <item> - <widget class="QPushButton" name="removeShortCutButton"> - <property name="enabled"> - <bool>false</bool> - </property> - <property name="text"> - <string>Remove</string> - </property> - </widget> - </item> - <item> - <spacer name="horizontalSpacer_2"> - <property name="orientation"> - <enum>Qt::Horizontal</enum> - </property> - <property name="sizeHint" stdset="0"> - <size> - <width>40</width> - <height>20</height> - </size> - </property> - </spacer> - </item> - </layout> - </item> - </layout> - </widget> <widget class="QWidget" name="tab"> <attribute name="title"> <string>Editor</string> </attribute> - <layout class="QVBoxLayout" name="verticalLayout_5"> + <layout class="QVBoxLayout" name="verticalLayout_6"> <item> - <layout class="QVBoxLayout" name="verticalLayout_7"> + <layout class="QVBoxLayout" name="verticalLayout_5"> <item> - <layout class="QHBoxLayout" name="horizontalLayout_3"> + <layout class="QHBoxLayout" name="horizontalLayout_4"> <item> - <widget class="QCheckBox" name="useCustomFileEditor"> - <property name="enabled"> - <bool>true</bool> + <widget class="QLabel" name="label_8"> + <property name="text"> + <string>Font</string> </property> - <property name="text"> - <string>Use custom file editor:</string> + </widget> + </item> + <item> + <widget class="QFontComboBox" name="editor_fontName"> + <property name="editable"> + <bool>false</bool> </property> </widget> </item> <item> - <widget class="QLineEdit" name="customFileEditor"> - <property name="enabled"> - <bool>false</bool> - </property> + <widget class="QLabel" name="label_9"> <property name="text"> - <string>emacs</string> + <string>Font Size</string> </property> </widget> </item> + <item> + <widget class="QSpinBox" name="editor_fontSize"> + <property name="minimum"> + <number>2</number> + </property> + <property name="maximum"> + <number>96</number> + </property> + <property name="value"> + <number>10</number> + </property> + </widget> + </item> + <item> + <spacer name="horizontalSpacer_4"> + <property name="orientation"> + <enum>Qt::Horizontal</enum> + </property> + <property name="sizeHint" stdset="0"> + <size> + <width>40</width> + <height>20</height> + </size> + </property> + </spacer> + </item> </layout> </item> <item> @@ -172,30 +141,74 @@ </layout> </item> <item> - <layout class="QHBoxLayout" name="horizontalLayout_4"> + <spacer name="verticalSpacer"> + <property name="orientation"> + <enum>Qt::Vertical</enum> + </property> + <property name="sizeHint" stdset="0"> + <size> + <width>20</width> + <height>40</height> + </size> + </property> + </spacer> + </item> + <item> + <layout class="QHBoxLayout" name="horizontalLayout"> <item> - <widget class="QLabel" name="label_8"> + <widget class="QCheckBox" name="useCustomFileEditor"> + <property name="enabled"> + <bool>true</bool> + </property> + <property name="text"> + <string>Use custom file editor:</string> + </property> + </widget> + </item> + <item> + <widget class="QLineEdit" name="customFileEditor"> + <property name="enabled"> + <bool>false</bool> + </property> + <property name="text"> + <string>emacs</string> + </property> + </widget> + </item> + </layout> + </item> + </layout> + </widget> + <widget class="QWidget" name="tab_5"> + <attribute name="title"> + <string>Terminal</string> + </attribute> + <layout class="QVBoxLayout" name="verticalLayout"> + <item> + <layout class="QHBoxLayout" name="horizontalLayout_5"> + <item> + <widget class="QLabel" name="label_11"> <property name="text"> <string>Font</string> </property> </widget> </item> <item> - <widget class="QFontComboBox" name="editor_fontName"> + <widget class="QFontComboBox" name="terminal_fontName"> <property name="editable"> <bool>false</bool> </property> </widget> </item> <item> - <widget class="QLabel" name="label_9"> + <widget class="QLabel" name="label_12"> <property name="text"> <string>Font Size</string> </property> </widget> </item> <item> - <widget class="QSpinBox" name="editor_fontSize"> + <widget class="QSpinBox" name="terminal_fontSize"> <property name="minimum"> <number>2</number> </property> @@ -208,7 +221,7 @@ </widget> </item> <item> - <spacer name="horizontalSpacer_4"> + <spacer name="horizontalSpacer_5"> <property name="orientation"> <enum>Qt::Horizontal</enum> </property> @@ -223,84 +236,20 @@ </layout> </item> <item> - <spacer name="verticalSpacer"> + <spacer name="verticalSpacer_3"> <property name="orientation"> <enum>Qt::Vertical</enum> </property> <property name="sizeHint" stdset="0"> <size> <width>20</width> - <height>40</height> + <height>321</height> </size> </property> </spacer> </item> </layout> </widget> - <widget class="QWidget" name="tab_5"> - <attribute name="title"> - <string>Terminal</string> - </attribute> - <widget class="QWidget" name="layoutWidget"> - <property name="geometry"> - <rect> - <x>10</x> - <y>10</y> - <width>436</width> - <height>22</height> - </rect> - </property> - <layout class="QHBoxLayout" name="horizontalLayout_5"> - <item> - <widget class="QLabel" name="label_11"> - <property name="text"> - <string>Font</string> - </property> - </widget> - </item> - <item> - <widget class="QFontComboBox" name="terminal_fontName"> - <property name="editable"> - <bool>false</bool> - </property> - </widget> - </item> - <item> - <widget class="QLabel" name="label_12"> - <property name="text"> - <string>Font Size</string> - </property> - </widget> - </item> - <item> - <widget class="QSpinBox" name="terminal_fontSize"> - <property name="minimum"> - <number>2</number> - </property> - <property name="maximum"> - <number>96</number> - </property> - <property name="value"> - <number>10</number> - </property> - </widget> - </item> - <item> - <spacer name="horizontalSpacer_5"> - <property name="orientation"> - <enum>Qt::Horizontal</enum> - </property> - <property name="sizeHint" stdset="0"> - <size> - <width>40</width> - <height>20</height> - </size> - </property> - </spacer> - </item> - </layout> - </widget> - </widget> <widget class="QWidget" name="tab_2"> <attribute name="title"> <string>File Browser</string>
--- a/gui/src/WorkspaceView.cpp +++ b/gui/src/WorkspaceView.cpp @@ -59,8 +59,10 @@ m_variablesTreeWidget->setAlternatingRowColors (true); m_variablesTreeWidget->setAnimated (true); - connect (this, SIGNAL (visibilityChanged(bool)), this, SLOT(handleVisibilityChanged(bool))); - connect (OctaveLink::instance(), SIGNAL (symbolTableChanged()), this, SLOT (fetchSymbolTable())); + connect (this, SIGNAL (visibilityChanged (bool)), + this, SLOT(handleVisibilityChanged (bool))); + connect (OctaveLink::instance(), SIGNAL (updateSymbolTable ()), + this, SLOT (fetchSymbolTable ())); } void @@ -68,7 +70,7 @@ { treeItem->setData (0, 0, QString (symbolRecord.name ().c_str ())); treeItem->setData (1, 0, - QString (symbolRecord.varval ().type_name ().c_str ())); + QString (symbolRecord.varval ().type_name ().c_str ())); treeItem->setData (2, 0, OctaveLink::octaveValueAsQString (symbolRecord. varval ()));
--- a/gui/src/backend/OctaveCallbackThread.cpp +++ b/gui/src/backend/OctaveCallbackThread.cpp @@ -39,9 +39,9 @@ bool running = true; while (running) { - OctaveLink::instance ()->emitSymbolTableChanged(); - OctaveLink::instance ()->updateHistoryModel (); - usleep (500000); + OctaveLink::instance ()->triggerUpdateSymbolTable (); + OctaveLink::instance ()->triggerUpdateHistoryModel (); + usleep (1000000); m_runningSemaphore->acquire (); running = m_running;
--- a/gui/src/backend/OctaveLink.cpp +++ b/gui/src/backend/OctaveLink.cpp @@ -121,12 +121,15 @@ std::list < SymbolRecord >::iterator iterator; for (iterator = allVariables.begin (); iterator != allVariables.end (); iterator++) - m_symbolTableBuffer.append (iterator->dup()); + { + SymbolRecord s = iterator->dup (); + m_symbolTableBuffer.append (s); + } return m_symbolTableBuffer; } void -OctaveLink::updateHistoryModel () +OctaveLink::triggerUpdateHistoryModel () { // Determine the client's (our) history length and the one of the server. int clientHistoryLength = m_historyModel->rowCount ();
--- a/gui/src/backend/OctaveLink.h +++ b/gui/src/backend/OctaveLink.h @@ -111,12 +111,12 @@ */ QList < SymbolRecord > copyCurrentSymbolTable (); - void updateHistoryModel (); + void triggerUpdateHistoryModel (); QStringListModel *historyModel (); - void emitSymbolTableChanged() { emit symbolTableChanged(); } + void triggerUpdateSymbolTable() { emit updateSymbolTable(); } signals: - void symbolTableChanged (); + void updateSymbolTable (); private: OctaveLink ();
--- a/gui/src/src.pro +++ b/gui/src/src.pro @@ -31,7 +31,6 @@ win32-msvc*: include(msvc.pri) LIBS += -lqscintilla2 \ - -L../qirc/libqirc/$$LIBDIR_SUFFIX -lqirc \ -L../qterminal/libqterminal/$$LIBDIR_SUFFIX -lqterminal \ $$system(mkoctfile -p LIBS) \ $$system(mkoctfile -p OCTAVE_LIBS) @@ -41,7 +40,7 @@ } # Includepaths and libraries to link against: -INCLUDEPATH += . backend ../qterminal/libqterminal ../qirc/libqirc \ +INCLUDEPATH += . backend ../qterminal/libqterminal \ $$system(mkoctfile -p INCFLAGS) INCFLAGS += $$system(mkoctfile -p INCFLAGS) mac { @@ -80,8 +79,6 @@ WorkspaceView.cpp \ HistoryDockWidget.cpp \ FilesDockWidget.cpp \ - FileEditorMdiSubWindow.cpp \ - BrowserWidget.cpp \ SettingsDialog.cpp \ OctaveGUI.cpp \ ResourceManager.cpp \ @@ -90,7 +87,8 @@ backend/OctaveLink.cpp \ backend/OctaveMainThread.cpp \ backend/ReadlineAdapter.cpp \ - WelcomeWizard.cpp + WelcomeWizard.cpp \ + FileEditor.cpp HEADERS += \ lexer/lexeroctavegui.h \ @@ -98,8 +96,6 @@ WorkspaceView.h \ HistoryDockWidget.h \ FilesDockWidget.h \ - FileEditorMdiSubWindow.h \ - BrowserWidget.h \ SettingsDialog.h \ ResourceManager.h \ CommandLineParser.h \ @@ -107,7 +103,8 @@ backend/OctaveLink.h \ backend/OctaveMainThread.h \ backend/ReadlineAdapter.h \ - WelcomeWizard.h + WelcomeWizard.h \ + FileEditor.h FORMS += \ SettingsDialog.ui \