Mercurial > hg > octave-nkf
changeset 14670:7fbea449737d gui
Restructured menus, added toolbar and current directory line edit.
* MainWindow (construct): Restructured menus, added toolbar and current working directory line edit.
author | Jacob Dawid <jacob.dawid@googlemail.com> |
---|---|
date | Tue, 22 May 2012 13:04:24 +0200 |
parents | 7605e7136b50 |
children | f346343654a4 |
files | gui/src/MainWindow.cpp gui/src/MainWindow.h gui/src/backend/OctaveLink.cpp |
diffstat | 3 files changed, 106 insertions(+), 43 deletions(-) [+] |
line wrap: on
line diff
--- a/gui/src/MainWindow.cpp +++ b/gui/src/MainWindow.cpp @@ -19,9 +19,13 @@ #include <QMenu> #include <QAction> #include <QSettings> +#include <QStyle> +#include <QToolBar> #include <QDesktopServices> #include <QFileDialog> #include <QMessageBox> +#include <QIcon> + #include "MainWindow.h" #include "FileEditor.h" #include "SettingsDialog.h" @@ -35,6 +39,7 @@ MainWindow::~MainWindow () { + OctaveLink::instance ()->terminateOctave(); } void @@ -73,8 +78,8 @@ MainWindow::handleSaveWorkspaceRequest () { QString selectedFile = - QFileDialog::getSaveFileName (this, tr ("Save Workspace"), - ResourceManager::instance ()->homePath ()); + QFileDialog::getSaveFileName (this, tr ("Save Workspace"), + ResourceManager::instance ()->homePath ()); m_terminalView->sendText (QString ("save \'%1\'\n").arg (selectedFile)); m_terminalView->setFocus (); } @@ -83,8 +88,8 @@ MainWindow::handleLoadWorkspaceRequest () { QString selectedFile = - QFileDialog::getOpenFileName (this, tr ("Load Workspace"), - ResourceManager::instance ()->homePath ()); + QFileDialog::getOpenFileName (this, tr ("Load Workspace"), + ResourceManager::instance ()->homePath ()); m_terminalView->sendText (QString ("load \'%1\'\n").arg (selectedFile)); m_terminalView->setFocus (); } @@ -199,6 +204,7 @@ void MainWindow::construct () { + QStyle *style = QApplication::style (); // TODO: Check this. m_closing = false; // flag for editor files when closed setWindowIcon (ResourceManager::instance ()->icon (ResourceManager::Octave)); @@ -212,47 +218,100 @@ m_filesDockWidget->setStatusTip (tr ("Browse your files.")); m_statusBar = new QStatusBar (this); + m_currentDirectoryLineEdit = new QLineEdit (QDir::currentPath (), this); + m_currentDirectoryLineEdit->setFixedWidth (300); + + m_currentDirectoryToolButton = new QToolButton (this); + m_currentDirectoryToolButton->setIcon (style->standardIcon (QStyle::SP_DirOpenIcon)); + + m_currentDirectoryUpToolButton = new QToolButton (this); + m_currentDirectoryUpToolButton->setIcon (style->standardIcon (QStyle::SP_FileDialogToParent)); + // Octave Terminal subwindow. m_terminalView = new QTerminal(this); setCentralWidget (m_terminalView); m_lexer = NULL; // initialise the empty lexer for the edtiors - QMenu *controlMenu = menuBar ()->addMenu (tr ("Octave")); - QAction *settingsAction = controlMenu->addAction (tr ("Settings")); - controlMenu->addSeparator (); - QAction *exitAction = controlMenu->addAction (tr ("Exit")); + QMenu *fileMenu = menuBar ()->addMenu (tr ("&File")); + QAction *newFileAction + = fileMenu->addAction (QIcon::fromTheme ("document-new", + style->standardIcon (QStyle::SP_FileIcon)), tr ("New File")); + + QAction *openFileAction + = fileMenu->addAction (QIcon::fromTheme ("document-open", + style->standardIcon (QStyle::SP_FileIcon)), tr ("Open File")); - QMenu *interfaceMenu = menuBar ()->addMenu (tr ("Interface")); + QAction *settingsAction = fileMenu->addAction (tr ("Settings")); + fileMenu->addSeparator (); + QAction *exitAction = fileMenu->addAction (tr ("Exit")); + + QMenu *editMenu = menuBar ()->addMenu (tr ("&Edit")); + QAction *cutAction + = editMenu->addAction (QIcon::fromTheme ("edit-cut", + style->standardIcon (QStyle::SP_FileIcon)), tr ("Cut")); + + QAction *copyAction + = editMenu->addAction (QIcon::fromTheme ("edit-copy", + style->standardIcon (QStyle::SP_FileIcon)), tr ("Copy")); - QAction *showWorkspaceAction = interfaceMenu->addAction (tr ("Workspace")); - showWorkspaceAction->setCheckable (true); + QAction *pasteAction + = editMenu->addAction (QIcon::fromTheme ("edit-paste", + style->standardIcon (QStyle::SP_FileIcon)), tr ("Paste")); + + QAction *undoAction + = editMenu->addAction (QIcon::fromTheme ("edit-undo", + style->standardIcon (QStyle::SP_FileIcon)), tr ("Undo")); + + QAction *redoAction + = editMenu->addAction (QIcon::fromTheme ("edit-redo", + style->standardIcon (QStyle::SP_FileIcon)), tr ("Redo")); - QAction *showHistoryAction = interfaceMenu->addAction (tr ("History")); + //QMenu *debugMenu = menuBar ()->addMenu (tr ("De&bug")); + //QMenu *parallelMenu = menuBar ()->addMenu (tr ("&Parallel")); + + QMenu *desktopMenu = menuBar ()->addMenu (tr ("&Desktop")); + QAction *loadWorkspaceAction = desktopMenu->addAction (tr ("Load workspace")); + QAction *saveWorkspaceAction = desktopMenu->addAction (tr ("Save workspace")); + QAction *clearWorkspaceAction = desktopMenu->addAction (tr ("Clear workspace")); + + // Window menu + QMenu *windowMenu = menuBar ()->addMenu (tr ("&Window")); + QAction *showWorkspaceAction = windowMenu->addAction (tr ("Workspace")); + showWorkspaceAction->setCheckable (true); + QAction *showHistoryAction = windowMenu->addAction (tr ("History")); showHistoryAction->setCheckable (true); - - QAction *showFileBrowserAction = interfaceMenu->addAction (tr ("File Browser")); + QAction *showFileBrowserAction = windowMenu->addAction (tr ("File Browser")); showFileBrowserAction->setCheckable (true); - interfaceMenu->addSeparator (); - QAction *openEditorAction = interfaceMenu->addAction (tr ("Open New Editor Window")); + // Help menu + QMenu *helpMenu = menuBar ()->addMenu (tr ("&Help")); + QAction *reportBugAction = helpMenu->addAction (tr ("Report Bug")); + QAction *agoraAction = helpMenu->addAction (tr ("Visit Agora")); + QAction *octaveForgeAction = helpMenu->addAction (tr ("Visit Octave Forge")); + helpMenu->addSeparator (); + QAction *aboutOctaveAction = helpMenu->addAction (tr ("About Octave")); + + // Toolbars - QMenu *workspaceMenu = menuBar ()->addMenu (tr ("Workspace")); - QAction *loadWorkspaceAction = workspaceMenu->addAction (tr ("Load")); - QAction *saveWorkspaceAction = workspaceMenu->addAction (tr ("Save")); - workspaceMenu->addSeparator (); - QAction *clearWorkspaceAction = workspaceMenu->addAction (tr ("Clear")); - - QMenu *communityMenu = menuBar ()->addMenu (tr ("Community")); - 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")); + QToolBar *mainToolBar = addToolBar ("Main"); + mainToolBar->addAction (newFileAction); + mainToolBar->addAction (openFileAction); + mainToolBar->addSeparator (); + mainToolBar->addAction (cutAction); + mainToolBar->addAction (copyAction); + mainToolBar->addAction (pasteAction); + mainToolBar->addAction (undoAction); + mainToolBar->addAction (redoAction); + mainToolBar->addSeparator (); + mainToolBar->addWidget (new QLabel (tr ("Current Directory:"))); + mainToolBar->addWidget (m_currentDirectoryLineEdit); + mainToolBar->addWidget (m_currentDirectoryToolButton); + mainToolBar->addWidget (m_currentDirectoryUpToolButton); connect (settingsAction, SIGNAL (triggered ()), this, SLOT (processSettingsDialogRequest ())); connect (exitAction, SIGNAL (triggered ()), this, SLOT (close ())); - connect (openEditorAction, SIGNAL (triggered ()), this, SLOT (newFile ())); + connect (newFileAction, 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 ())); @@ -289,8 +348,8 @@ // Editor font (default or from settings) QSettings *settings = ResourceManager::instance ()->settings (); m_lexer->setDefaultFont (QFont ( - settings->value ("editor/fontName","Courier").toString (), - settings->value ("editor/fontSize",10).toInt ())); + settings->value ("editor/fontName","Courier").toString (), + settings->value ("editor/fontSize",10).toInt ())); // TODO: Autoindent not working as it should m_lexer->setAutoIndentStyle (QsciScintilla::AiMaintain || @@ -302,18 +361,18 @@ // TODO: Also provide infos on octave-forge functions? // TODO: Also provide infos on function parameters? // By now, use the keywords-list from syntax highlighting - m_lexerAPI = new QsciAPIs (m_lexer); + m_lexerAPI = new QsciAPIs (m_lexer); - QString keyword; - QStringList keywordList; - keyword = m_lexer->keywords (1); // get whole string with all keywords - keywordList = keyword.split (QRegExp ("\\s+")); // split into single strings - int i; - for (i=0; i<keywordList.size(); i++) - { - m_lexerAPI->add (keywordList.at (i)); // add single strings to the API - } - m_lexerAPI->prepare (); // prepare API info ... this make take some time + QString keyword; + QStringList keywordList; + keyword = m_lexer->keywords (1); // get whole string with all keywords + keywordList = keyword.split (QRegExp ("\\s+")); // split into single strings + int i; + for (i=0; i<keywordList.size(); i++) + { + m_lexerAPI->add (keywordList.at (i)); // add single strings to the API + } + m_lexerAPI->prepare (); // prepare API info ... this make take some time readSettings (); updateTerminalFont();
--- a/gui/src/MainWindow.h +++ b/gui/src/MainWindow.h @@ -28,6 +28,7 @@ #include <QQueue> #include <QMdiSubWindow> #include <QCloseEvent> +#include <QToolButton> // QScintilla includes #include <Qsci/qsciapis.h> @@ -114,6 +115,10 @@ // Toolbars. QStatusBar *m_statusBar; + QLineEdit *m_currentDirectoryLineEdit; + QToolButton *m_currentDirectoryToolButton; + QToolButton *m_currentDirectoryUpToolButton; + // Flag for closing whole application bool m_closing; };