Mercurial > hg > octave-lyh
changeset 14602:c8453a013000 gui
Cleaned up code. Fixed bug that causes the GUI to freeze when launching another editor.
* FileEditor: Now the call of another process returns immediately. Adjusted text when closing a file.
* MainWindow: Moved creating a lexer into the constructor.
author | Jacob Dawid <jacob.dawid@googlemail.com> |
---|---|
date | Mon, 07 May 2012 02:36:49 +0200 |
parents | 772ce0204b3f |
children | fa6809bbc3a6 |
files | gui/src/FileEditor.cpp gui/src/FilesDockWidget.cpp gui/src/MainWindow.cpp gui/src/MainWindow.h |
diffstat | 4 files changed, 49 insertions(+), 43 deletions(-) [+] |
line wrap: on
line diff
--- a/gui/src/FileEditor.cpp +++ b/gui/src/FileEditor.cpp @@ -38,18 +38,23 @@ void FileEditor::closeEvent(QCloseEvent *event) { - if ( m_mainWindow->isCloseApplication() ) + if ( m_mainWindow->closing () ) { // close wohle application: save file or not if modified - checkFileModified ("Close Octave GUI",0); // no cancel possible + checkFileModified ("Closing Octave", 0); // no cancel possible + event->accept (); } else { // ignore close event if file is not saved and user cancels closing this window - if (checkFileModified ("Close File",QMessageBox::Cancel)==QMessageBox::Cancel) - event->ignore(); + if (checkFileModified ("Close File",QMessageBox::Cancel) == QMessageBox::Cancel) + { + event->ignore (); + } else - event->accept(); + { + event->accept(); + } } }
--- a/gui/src/FilesDockWidget.cpp +++ b/gui/src/FilesDockWidget.cpp @@ -125,7 +125,7 @@ QString editor = settings->value ("customFileEditor").toString (); QStringList arguments; arguments << fileInfo.filePath (); - QProcess::execute (editor, arguments); + QProcess::startDetached (editor, arguments); } else {
--- a/gui/src/MainWindow.cpp +++ b/gui/src/MainWindow.cpp @@ -55,40 +55,9 @@ { FileEditor *fileEditor = new FileEditor (); fileEditor->setAttribute (Qt::WA_DeleteOnClose); - // check whether lexer is already prepared and prepare it if not - if ( m_lexer == NULL ) - { - // this has to be done only once, not for each editor - m_lexer = new LexerOctaveGui(); - // 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 () ) ); - // TODO: Autoindent not working as it should - m_lexer->setAutoIndentStyle(QsciScintilla::AiMaintain || - QsciScintilla::AiOpening || - QsciScintilla::AiClosing); - // The API info that is used for auto completion - // TODO: Where to store a file with API info (raw or prepared?)? - // 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); - 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 - } fileEditor->initEditor(m_terminalView, m_lexer, this); // init necessary informations for editor - if ( fileName.isEmpty() ) + if (fileName.isEmpty ()) fileEditor->newFile (); else fileEditor->loadFile (fileName); @@ -205,7 +174,7 @@ { reportStatusMessage (tr ("Saving data and shutting down.")); writeSettings (); - m_closeApplication = true; // inform editor window that whole application is closed + m_closing = true; // inform editor window that whole application is closed OctaveLink::instance ()->terminateOctave(); QMainWindow::closeEvent (closeEvent); @@ -232,7 +201,7 @@ MainWindow::construct () { // TODO: Check this. - m_closeApplication = false; // flag for editor files when closed + m_closing = false; // flag for editor files when closed setWindowIcon (ResourceManager::instance ()->icon (ResourceManager::Octave)); // Setup dockable widgets and the status bar. @@ -315,6 +284,38 @@ addDockWidget (Qt::RightDockWidgetArea, m_filesDockWidget); setStatusBar (m_statusBar); + // this has to be done only once, not for each editor + m_lexer = new LexerOctaveGui (); + + // 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 ())); + + // TODO: Autoindent not working as it should + m_lexer->setAutoIndentStyle (QsciScintilla::AiMaintain || + QsciScintilla::AiOpening || + QsciScintilla::AiClosing); + + // The API info that is used for auto completion + // TODO: Where to store a file with API info (raw or prepared?)? + // 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); + + 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 @@ -67,9 +67,9 @@ { return m_filesDockWidget; } - bool isCloseApplication () + bool closing () { - return m_closeApplication; + return m_closing; } signals: @@ -115,7 +115,7 @@ QStatusBar *m_statusBar; // Flag for closing whole application - bool m_closeApplication; + bool m_closing; }; #endif // MAINWINDOW_H