# HG changeset patch # User Jacob Dawid # Date 1336351009 -7200 # Node ID c8453a013000e4dc27db517f77206f09f9d2d134 # Parent 772ce0204b3f2cf232fb580f1a1ac0fe90cea0c9 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. diff -r 772ce0204b3f -r c8453a013000 gui/src/FileEditor.cpp --- a/gui/src/FileEditor.cpp Mon May 07 01:37:26 2012 +0200 +++ b/gui/src/FileEditor.cpp Mon May 07 02:36:49 2012 +0200 @@ -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(); + } } } diff -r 772ce0204b3f -r c8453a013000 gui/src/FilesDockWidget.cpp --- a/gui/src/FilesDockWidget.cpp Mon May 07 01:37:26 2012 +0200 +++ b/gui/src/FilesDockWidget.cpp Mon May 07 02:36:49 2012 +0200 @@ -125,7 +125,7 @@ QString editor = settings->value ("customFileEditor").toString (); QStringList arguments; arguments << fileInfo.filePath (); - QProcess::execute (editor, arguments); + QProcess::startDetached (editor, arguments); } else { diff -r 772ce0204b3f -r c8453a013000 gui/src/MainWindow.cpp --- a/gui/src/MainWindow.cpp Mon May 07 01:37:26 2012 +0200 +++ b/gui/src/MainWindow.cpp Mon May 07 02:36:49 2012 +0200 @@ -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; iadd(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; iadd (keywordList.at (i)); // add single strings to the API + } + m_lexerAPI->prepare (); // prepare API info ... this make take some time + readSettings (); updateTerminalFont(); } diff -r 772ce0204b3f -r c8453a013000 gui/src/MainWindow.h --- a/gui/src/MainWindow.h Mon May 07 01:37:26 2012 +0200 +++ b/gui/src/MainWindow.h Mon May 07 02:36:49 2012 +0200 @@ -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