summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/MainWindow.cpp286
-rw-r--r--src/MainWindow.h15
-rwxr-xr-xsrc/MainWindowBase.ui4
-rwxr-xr-xsrc/ToolBarWidget.ui2
-rw-r--r--src/UiGuiSettings.cpp49
-rw-r--r--src/UiGuiSettings.h11
-rw-r--r--src/__TODO/UiGuiHighlighter.cpp8
-rw-r--r--src/__TODO/UiGuiHighlighter.h2
8 files changed, 216 insertions, 161 deletions
diff --git a/src/MainWindow.cpp b/src/MainWindow.cpp
index 38e893b..496636d 100644
--- a/src/MainWindow.cpp
+++ b/src/MainWindow.cpp
@@ -58,7 +58,7 @@
///-- #include <tqmessagebox.h>
///-- #include <tqtdebug.h>
///--
-///-- #include <Qsci/qsciscintilla.h>
+#include <tqextscintilla.h>
///-- #include <Qsci/qsciprinter.h>
///--
///-- using namespace tschweitzer;
@@ -79,16 +79,15 @@
\brief Constructs the main window.
*/
MainWindow::MainWindow(TQString file2OpenOnStart, TQWidget *parent) :
- MainWindowBase(parent), m_aboutDialog(NULL)
-///- _mainWindowForm(NULL), _qSciSourceCodeEditor(NULL), _settings(NULL),
+ MainWindowBase(parent), m_aboutDialog(NULL), m_qSciSourceCodeEditor(NULL)
+///- _mainWindowForm(NULL), _settings(NULL),
///- _highlighter(NULL), _textEditVScrollBar(NULL), _aboutDialogGraphicsView(
///- NULL), _settingsDialog(NULL), _encodingActionGroup(NULL), _saveEncodedActionGroup(NULL),
///- _highlighterActionGroup(NULL), _uiGuiTranslator(NULL), _qTTranslator(NULL), _toolBarWidget(
///- NULL), _indentHandler(NULL), _textEditLineColumnInfoLabel(NULL)
{
-///-- // Init of some variables.
-///-- _sourceCodeChanged = false;
-///-- _scrollPositionChanged = false;
+ // Init of some variables.
+ m_sourceCodeChanged = false;
// Create the _settings object, which loads all UiGui settings from a file.
m_settings = UiGuiSettings::getInstance();
@@ -197,22 +196,39 @@ void MainWindow::initMainWindow()
showMaximized();
}
-///-- // Get last selected file encoding
-///-- // -------------------------------
-///-- _currentEncoding = _settings->getValueByName("encoding").toString();
-///--
-///-- // Register the load last file setting in the menu to the _settings object.
-///-- _settings->registerObjectProperty(actionLoadLastOpenedFileOnStartup, "checked",
-///-- "loadLastSourceCodeFileOnStartup");
-///--
-///-- // Tell the TQScintilla editor if it has to show white space.
-///-- connect(_mainWindowForm->actionWhiteSpaceIsVisible, SIGNAL(acivated(bool)), this,
-///-- SLOT(setWhiteSpaceVisibility(bool)));
-///-- // Register the white space setting in the menu to the _settings object.
-///-- _settings->registerObjectProperty(actionWhiteSpaceIsVisible, "checked",
-///-- "whiteSpaceIsVisible");
-///--
-///-- // Connect the remaining menu items.
+ // Get last selected file encoding
+ // -------------------------------
+ m_currentEncoding = m_settings->getValueByName("FileEncoding").toString();
+
+ // Register the syntax highlighting setting in the menu to the settings object.
+ connect(actionEnableSyntaxHighlighting, SIGNAL(toggled(bool)),
+ m_settings, SLOT(handleValueChangeFromExtern(bool)));
+ connect(m_settings, SIGNAL(syntaxHighlightingEnabled(bool)),
+ actionEnableSyntaxHighlighting, SLOT(setOn(bool)));
+ actionEnableSyntaxHighlighting->setOn(
+ m_settings->getValueByName("SyntaxHighlightingEnabled").toBool());
+ // Tell the highlighter if it has to be enabled or disabled.
+ connect(m_settings, SIGNAL(syntaxHighlightingEnabled(bool)), this, SLOT(turnHighlightOnOff(bool)));
+
+ // Register the load last file setting in the menu to the settings object
+ connect(actionLoadLastOpenedFileOnStartup, SIGNAL(toggled(bool)),
+ m_settings, SLOT(handleValueChangeFromExtern(bool)));
+ connect(m_settings, SIGNAL(loadLastOpenedFileOnStartup(bool)),
+ actionLoadLastOpenedFileOnStartup, SLOT(setOn(bool)));
+ actionLoadLastOpenedFileOnStartup->setOn(
+ m_settings->getValueByName("LoadLastOpenedFileOnStartup").toBool());
+
+ // Register the white space setting in the menu to the settings object.
+ connect(actionWhiteSpaceIsVisible, SIGNAL(toggled(bool)),
+ m_settings, SLOT(handleValueChangeFromExtern(bool)));
+ connect(m_settings, SIGNAL(whiteSpaceIsVisible(bool)),
+ actionWhiteSpaceIsVisible, SLOT(setOn(bool)));
+ actionWhiteSpaceIsVisible->setOn(m_settings->getValueByName("WhiteSpaceIsVisible").toBool());
+
+ // Tell the TQScintilla editor if it has to show white space.
+ connect(m_settings, SIGNAL(whiteSpaceIsVisible(bool)), this, SLOT(setWhiteSpaceVisibility(bool)));
+
+ // Connect the remaining menu items.
connect(actionOpenSourceFile, SIGNAL(activated()), this, SLOT(openSourceFileDialog()));
connect(actionSaveSourceFile, SIGNAL(activated()), this, SLOT(saveSourceFile()));
connect(actionSaveSourceFileAs, SIGNAL(activated()), this, SLOT(saveasSourceFileDialog()));
@@ -278,7 +294,7 @@ void MainWindow::initToolBar()
///-- // TQScintilla debug lib and the other way around.
///-- try
///-- {
-///-- _qSciSourceCodeEditor = new QsciScintilla(this);
+///-- m_qSciSourceCodeEditor = new QsciScintilla(this);
///-- }
///-- catch (...)
///-- {
@@ -286,17 +302,17 @@ void MainWindow::initToolBar()
///-- "During trying to create the text editor component, that is based on TQScintilla, an error occurred. Please make sure that you have installed TQScintilla and not mixed release and debug versions.");
///-- exit(1);
///-- }
-///-- _mainWindowForm->hboxLayout1->addWidget(_qSciSourceCodeEditor);
+///-- _mainWindowForm->hboxLayout1->addWidget(m_qSciSourceCodeEditor);
///--
///-- // Make some _settings for the TQScintilla widget.
-///-- _qSciSourceCodeEditor->setUtf8(true);
-///-- _qSciSourceCodeEditor->setMarginLineNumbers(1, true);
-///-- _qSciSourceCodeEditor->setMarginWidth(1, TQString("10000"));
-///-- _qSciSourceCodeEditor->setBraceMatching(_qSciSourceCodeEditor->SloppyBraceMatch);
-///-- _qSciSourceCodeEditor->setMatchedBraceForegroundColor(TQColor("red"));
-///-- _qSciSourceCodeEditor->setFolding(QsciScintilla::BoxedTreeFoldStyle);
-///-- _qSciSourceCodeEditor->setAutoCompletionSource(QsciScintilla::AcsAll);
-///-- _qSciSourceCodeEditor->setAutoCompletionThreshold(3);
+///-- m_qSciSourceCodeEditor->setUtf8(true);
+///-- m_qSciSourceCodeEditor->setMarginLineNumbers(1, true);
+///-- m_qSciSourceCodeEditor->setMarginWidth(1, TQString("10000"));
+///-- m_qSciSourceCodeEditor->setBraceMatching(m_qSciSourceCodeEditor->SloppyBraceMatch);
+///-- m_qSciSourceCodeEditor->setMatchedBraceForegroundColor(TQColor("red"));
+///-- m_qSciSourceCodeEditor->setFolding(QsciScintilla::BoxedTreeFoldStyle);
+///-- m_qSciSourceCodeEditor->setAutoCompletionSource(QsciScintilla::AcsAll);
+///-- m_qSciSourceCodeEditor->setAutoCompletionThreshold(3);
///--
///-- // Handle if white space is set to be visible
///-- bool whiteSpaceIsVisible = _settings->getValueByName("whiteSpaceIsVisible").toBool();
@@ -304,24 +320,24 @@ void MainWindow::initToolBar()
///--
///-- // Handle the width of tabs in spaces
///-- int tabWidth = _settings->getValueByName("tabWidth").toInt();
-///-- _qSciSourceCodeEditor->setTabWidth(tabWidth);
+///-- m_qSciSourceCodeEditor->setTabWidth(tabWidth);
///--
///-- // Remember a pointer to the scrollbar of the TQScintilla widget used to keep
///-- // on the same line as before when turning preview on/off.
-///-- _textEditVScrollBar = _qSciSourceCodeEditor->verticalScrollBar();
+///-- _textEditVScrollBar = m_qSciSourceCodeEditor->verticalScrollBar();
///--
///-- // Add a column row indicator to the status bar.
///-- _textEditLineColumnInfoLabel = new TQLabel(tr("Line %1, Column %2").arg(1).arg(1));
///-- _mainWindowForm->statusbar->addPermanentWidget(_textEditLineColumnInfoLabel);
-///-- connect(_qSciSourceCodeEditor, SIGNAL(cursorPositionChanged(int,int)), this,
+///-- connect(m_qSciSourceCodeEditor, SIGNAL(cursorPositionChanged(int,int)), this,
///-- SLOT(setStatusBarCursorPosInfo(int, int)));
///--
///-- // Connect the text editor to dependent functions.
-///-- connect(_qSciSourceCodeEditor, SIGNAL(textChanged()), this, SLOT(sourceCodeChangedHelperSlot()));
-///-- connect(_qSciSourceCodeEditor, SIGNAL(linesChanged()), this, SLOT(numberOfLinesChanged()));
-///-- //connect( _settings, SIGNAL(tabWidth(int)), _qSciSourceCodeEditor, SLOT(setTabWidth(int)) );
-///-- _settings->registerObjectSlot(_qSciSourceCodeEditor, "setTabWidth(int)", "tabWidth");
-///-- _qSciSourceCodeEditor->setTabWidth(_settings->getValueByName("tabWidth").toInt());
+///-- connect(m_qSciSourceCodeEditor, SIGNAL(textChanged()), this, SLOT(sourceCodeChangedHelperSlot()));
+///-- connect(m_qSciSourceCodeEditor, SIGNAL(linesChanged()), this, SLOT(numberOfLinesChanged()));
+///-- //connect( _settings, SIGNAL(tabWidth(int)), m_qSciSourceCodeEditor, SLOT(setTabWidth(int)) );
+///-- _settings->registerObjectSlot(m_qSciSourceCodeEditor, "setTabWidth(int)", "tabWidth");
+///-- m_qSciSourceCodeEditor->setTabWidth(_settings->getValueByName("tabWidth").toInt());
///-- }
///--
///-- /*
@@ -330,7 +346,7 @@ void MainWindow::initToolBar()
///-- void MainWindow::initSyntaxHighlighter()
///-- {
///-- // Create the _highlighter.
-///-- _highlighter = new UiGuiHighlighter(_qSciSourceCodeEditor);
+///-- _highlighter = new UiGuiHighlighter(m_qSciSourceCodeEditor);
///--
///-- // Connect the syntax highlighting setting in the menu to the turnHighlightOnOff function.
///-- connect(actionEnableSyntaxHighlighting, SIGNAL(activated(bool)), this,
@@ -457,7 +473,7 @@ void MainWindow::initToolBar()
///-- {
///-- TQTextStream inSrcStrm(&inSrcFile);
///-- TQApplication::setOverrideCursor(TQt::WaitCursor);
-///-- inSrcStrm.setCodec(TQTextCodec::codecForName(_currentEncoding.toAscii()));
+///-- inSrcStrm.setCodec(TQTextCodec::codecForName(m_currentEncoding.toAscii()));
///-- fileContent = inSrcStrm.readAll();
///-- TQApplication::restoreOverrideCursor();
///-- inSrcFile.close();
@@ -506,7 +522,7 @@ void MainWindow::openSourceFileDialog(TQString fileName)
///-- {
///-- callIndenter();
///-- }
-///-- _sourceCodeChanged = true;
+///-- m_sourceCodeChanged = true;
///-- _previewToggled = true;
///-- updateSourceView();
///-- updateWindowTitle();
@@ -515,7 +531,7 @@ void MainWindow::openSourceFileDialog(TQString fileName)
///-- _textEditVScrollBar->setValue(_textEditLastScrollPos);
///--
///-- _savedSourceContent = openedSourceFileContent;
-///-- _qSciSourceCodeEditor->setModified(false);
+///-- m_qSciSourceCodeEditor->setModified(false);
///-- setWindowModified(false);
///-- }
}
@@ -541,7 +557,7 @@ bool MainWindow::saveasSourceFileDialog(TQAction *chosenEncodingAction)
///-- return false;
///-- }
///--
-///-- _savedSourceContent = _qSciSourceCodeEditor->text();
+///-- _savedSourceContent = m_qSciSourceCodeEditor->text();
///--
///-- _currentSourceFile = fileName;
///-- TQFile::remove(fileName);
@@ -565,7 +581,7 @@ bool MainWindow::saveasSourceFileDialog(TQAction *chosenEncodingAction)
///-- TQFileInfo fileInfo(fileName);
///-- _currentSourceFileExtension = fileInfo.suffix();
///--
-///-- _qSciSourceCodeEditor->setModified(false);
+///-- m_qSciSourceCodeEditor->setModified(false);
///-- setWindowModified(false);
///--
///-- updateWindowTitle();
@@ -587,17 +603,17 @@ bool MainWindow::saveSourceFile()
///-- {
///-- TQFile::remove(_currentSourceFile);
///-- TQFile outSrcFile(_currentSourceFile);
-///-- _savedSourceContent = _qSciSourceCodeEditor->text();
+///-- _savedSourceContent = m_qSciSourceCodeEditor->text();
///-- outSrcFile.open(TQFile::ReadWrite | TQFile::Text);
///--
///-- // Get current encoding.
-///-- TQString _currentEncoding = _encodingActionGroup->checkedAction()->text();
+///-- TQString m_currentEncoding = _encodingActionGroup->checkedAction()->text();
///-- TQTextStream outSrcStrm(&outSrcFile);
-///-- outSrcStrm.setCodec(TQTextCodec::codecForName(_currentEncoding.toAscii()));
+///-- outSrcStrm.setCodec(TQTextCodec::codecForName(m_currentEncoding.toAscii()));
///-- outSrcStrm << _savedSourceContent;
///-- outSrcFile.close();
///--
-///-- _qSciSourceCodeEditor->setModified(false);
+///-- m_qSciSourceCodeEditor->setModified(false);
///-- setWindowModified(false);
///-- }
return true;
@@ -646,13 +662,13 @@ bool MainWindow::saveSourceFile()
///--
///-- if (_previewToggled)
///-- {
-///-- disconnect(_qSciSourceCodeEditor, SIGNAL(textChanged()), this,
+///-- disconnect(m_qSciSourceCodeEditor, SIGNAL(textChanged()), this,
///-- SLOT(sourceCodeChangedHelperSlot()));
///-- bool textIsModified = isWindowModified();
-///-- _qSciSourceCodeEditor->setText(_sourceViewContent);
+///-- m_qSciSourceCodeEditor->setText(_sourceViewContent);
///-- setWindowModified(textIsModified);
///-- _previewToggled = false;
-///-- connect(_qSciSourceCodeEditor, SIGNAL(textChanged()), this,
+///-- connect(m_qSciSourceCodeEditor, SIGNAL(textChanged()), this,
///-- SLOT(sourceCodeChangedHelperSlot()));
///-- }
///--
@@ -672,12 +688,12 @@ bool MainWindow::saveSourceFile()
///-- //updateSourceView();
///-- TQApplication::restoreOverrideCursor();
///-- }
-///--
-///-- /*
-///-- \brief Switches the syntax highlighting corresponding to the value \a turnOn either on or off.
-///-- */
-///-- void MainWindow::turnHighlightOnOff(bool turnOn)
-///-- {
+
+/*
+ \brief Switches the syntax highlighting corresponding to the value \a turnOn either on or off.
+ */
+void MainWindow::turnHighlightOnOff(bool turnOn)
+{
///-- if (turnOn)
///-- {
///-- _highlighter->turnHighlightOn();
@@ -688,8 +704,8 @@ bool MainWindow::saveSourceFile()
///-- }
///-- _previewToggled = true;
///-- updateSourceView();
-///-- }
-///--
+}
+
///-- /*
///-- \brief Added this slot to avoid multiple calls because of changed text.
///-- */
@@ -708,14 +724,10 @@ bool MainWindow::saveSourceFile()
///-- int cursorPos, cursorPosAbsolut, cursorLine;
///-- TQString text;
///--
-///-- _sourceCodeChanged = true;
-///-- if (_scrollPositionChanged)
-///-- {
-///-- _scrollPositionChanged = false;
-///-- }
+///-- m_sourceCodeChanged = true;
///--
///-- // Get the content text of the text editor.
-///-- _sourceFileContent = _qSciSourceCodeEditor->text();
+///-- _sourceFileContent = m_qSciSourceCodeEditor->text();
///--
///-- // Get the position of the cursor in the unindented text.
///-- if (_sourceFileContent.isEmpty())
@@ -729,9 +741,9 @@ bool MainWindow::saveSourceFile()
///-- }
///-- else
///-- {
-///-- _qSciSourceCodeEditor->getCursorPosition(&cursorLine, &cursorPos);
-///-- cursorPosAbsolut = _qSciSourceCodeEditor->SendScintilla(QsciScintillaBase::SCI_GETCURRENTPOS);
-///-- text = _qSciSourceCodeEditor->text(cursorLine);
+///-- m_qSciSourceCodeEditor->getCursorPosition(&cursorLine, &cursorPos);
+///-- cursorPosAbsolut = m_qSciSourceCodeEditor->SendScintilla(QsciScintillaBase::SCI_GETCURRENTPOS);
+///-- text = m_qSciSourceCodeEditor->text(cursorLine);
///-- if (cursorPosAbsolut > 0)
///-- {
///-- cursorPosAbsolut--;
@@ -765,10 +777,10 @@ bool MainWindow::saveSourceFile()
///--
///-- // Search forward
///-- for (cursorLine = saveCursorLine;
-///-- cursorLine - saveCursorLine < 6 && cursorLine < _qSciSourceCodeEditor->lines();
+///-- cursorLine - saveCursorLine < 6 && cursorLine < m_qSciSourceCodeEditor->lines();
///-- cursorLine++)
///-- {
-///-- text = _qSciSourceCodeEditor->text(cursorLine);
+///-- text = m_qSciSourceCodeEditor->text(cursorLine);
///-- while (cursorPos < text.count() && enteredCharacter != text.at(cursorPos))
///-- {
///-- cursorPos++;
@@ -787,7 +799,7 @@ bool MainWindow::saveSourceFile()
///-- // If foward search did not find the character, search backward
///-- if (!charFound)
///-- {
-///-- text = _qSciSourceCodeEditor->text(saveCursorLine);
+///-- text = m_qSciSourceCodeEditor->text(saveCursorLine);
///-- cursorPos = saveCursorPos;
///-- if (cursorPos >= text.count())
///-- {
@@ -797,14 +809,14 @@ bool MainWindow::saveSourceFile()
///-- for (cursorLine = saveCursorLine; saveCursorLine - cursorLine < 6 && cursorLine >= 0;
///-- cursorLine--)
///-- {
-///-- text = _qSciSourceCodeEditor->text(cursorLine);
+///-- text = m_qSciSourceCodeEditor->text(cursorLine);
///-- while (cursorPos >= 0 && enteredCharacter != text.at(cursorPos))
///-- {
///-- cursorPos--;
///-- }
///-- if (cursorPos < 0)
///-- {
-///-- cursorPos = _qSciSourceCodeEditor->lineLength(cursorLine - 1) - 1;
+///-- cursorPos = m_qSciSourceCodeEditor->lineLength(cursorLine - 1) - 1;
///-- }
///-- else
///-- {
@@ -817,39 +829,39 @@ bool MainWindow::saveSourceFile()
///-- // If the character was found set its new cursor position...
///-- if (charFound)
///-- {
-///-- _qSciSourceCodeEditor->setCursorPosition(cursorLine, cursorPos + 1);
+///-- m_qSciSourceCodeEditor->setCursorPosition(cursorLine, cursorPos + 1);
///-- }
///-- // ...if it was not found, set the previous cursor position.
///-- else
///-- {
-///-- _qSciSourceCodeEditor->setCursorPosition(saveCursorLine, saveCursorPos + 1);
+///-- m_qSciSourceCodeEditor->setCursorPosition(saveCursorLine, saveCursorPos + 1);
///-- }
///-- }
///-- // set the previous cursor position.
///-- else if (enteredCharacter == 10)
///-- {
-///-- _qSciSourceCodeEditor->setCursorPosition(cursorLine, cursorPos);
+///-- m_qSciSourceCodeEditor->setCursorPosition(cursorLine, cursorPos);
///-- }
///--
///-- if (m_toolBarWidget->cbLivePreview->isChecked())
///-- {
-///-- _sourceCodeChanged = false;
+///-- m_sourceCodeChanged = false;
///-- }
///--
-///-- if (_savedSourceContent == _qSciSourceCodeEditor->text())
+///-- if (_savedSourceContent == m_qSciSourceCodeEditor->text())
///-- {
-///-- _qSciSourceCodeEditor->setModified(false);
+///-- m_qSciSourceCodeEditor->setModified(false);
///-- setWindowModified(false);
///-- }
///-- else
///-- {
-///-- _qSciSourceCodeEditor->setModified(true); // Has no effect according to TQScintilla docs.
+///-- m_qSciSourceCodeEditor->setModified(true); // Has no effect according to TQScintilla docs.
///-- setWindowModified(true);
///-- }
///--
///-- // Could set cursor this way and use normal linear search in text instead of columns and rows.
-///-- //_qSciSourceCodeEditor->SendScintilla(QsciScintillaBase::SCI_SETCURRENTPOS, 50);
-///-- //_qSciSourceCodeEditor->SendScintilla(QsciScintillaBase::SCI_SETANCHOR, 50);
+///-- //m_qSciSourceCodeEditor->SendScintilla(QsciScintillaBase::SCI_SETCURRENTPOS, 50);
+///-- //m_qSciSourceCodeEditor->SendScintilla(QsciScintillaBase::SCI_SETANCHOR, 50);
///-- }
///--
///-- /*
@@ -863,7 +875,7 @@ bool MainWindow::saveSourceFile()
///-- _indentSettingsChanged = true;
///--
///-- int cursorLine, cursorPos;
-///-- _qSciSourceCodeEditor->getCursorPosition(&cursorLine, &cursorPos);
+///-- m_qSciSourceCodeEditor->getCursorPosition(&cursorLine, &cursorPos);
///--
///-- if (m_toolBarWidget->cbLivePreview->isChecked())
///-- {
@@ -871,16 +883,16 @@ bool MainWindow::saveSourceFile()
///-- _previewToggled = true;
///--
///-- updateSourceView();
-///-- if (_sourceCodeChanged)
+///-- if (m_sourceCodeChanged)
///-- {
-///-- /* savedCursor = _qSciSourceCodeEditor->textCursor();
-///-- if ( cursorPos >= _qSciSourceCodeEditor->text().count() ) {
-///-- cursorPos = _qSciSourceCodeEditor->text().count() - 1;
+///-- /* savedCursor = m_qSciSourceCodeEditor->textCursor();
+///-- if ( cursorPos >= m_qSciSourceCodeEditor->text().count() ) {
+///-- cursorPos = m_qSciSourceCodeEditor->text().count() - 1;
///-- }
///-- savedCursor.setPosition( cursorPos );
-///-- _qSciSourceCodeEditor->setTextCursor( savedCursor );
+///-- m_qSciSourceCodeEditor->setTextCursor( savedCursor );
///-- */
-///-- _sourceCodeChanged = false;
+///-- m_sourceCodeChanged = false;
///-- }
///-- _indentSettingsChanged = false;
///-- }
@@ -889,14 +901,14 @@ bool MainWindow::saveSourceFile()
///-- updateSourceView();
///-- }
///--
-///-- if (_savedSourceContent == _qSciSourceCodeEditor->text())
+///-- if (_savedSourceContent == m_qSciSourceCodeEditor->text())
///-- {
-///-- _qSciSourceCodeEditor->setModified(false);
+///-- m_qSciSourceCodeEditor->setModified(false);
///-- setWindowModified(false);
///-- }
///-- else
///-- {
-///-- _qSciSourceCodeEditor->setModified(true); // Has no effect according to TQScintilla docs.
+///-- m_qSciSourceCodeEditor->setModified(true); // Has no effect according to TQScintilla docs.
///-- setWindowModified(true);
///-- }
///-- }
@@ -912,34 +924,34 @@ void MainWindow::previewTurnedOnOff(bool turnOn)
///-- _previewToggled = true;
///--
///-- int cursorLine, cursorPos;
-///-- _qSciSourceCodeEditor->getCursorPosition(&cursorLine, &cursorPos);
+///-- m_qSciSourceCodeEditor->getCursorPosition(&cursorLine, &cursorPos);
///--
-///-- if (turnOn && (_indentSettingsChanged || _sourceCodeChanged))
+///-- if (turnOn && (_indentSettingsChanged || m_sourceCodeChanged))
///-- {
///-- callIndenter();
///-- }
///-- updateSourceView();
-///-- if (_sourceCodeChanged)
+///-- if (m_sourceCodeChanged)
///-- {
-///-- /* savedCursor = _qSciSourceCodeEditor->textCursor();
-///-- if ( cursorPos >= _qSciSourceCodeEditor->text().count() ) {
-///-- cursorPos = _qSciSourceCodeEditor->text().count() - 1;
+///-- /* savedCursor = m_qSciSourceCodeEditor->textCursor();
+///-- if ( cursorPos >= m_qSciSourceCodeEditor->text().count() ) {
+///-- cursorPos = m_qSciSourceCodeEditor->text().count() - 1;
///-- }
///-- savedCursor.setPosition( cursorPos );
-///-- _qSciSourceCodeEditor->setTextCursor( savedCursor );
+///-- m_qSciSourceCodeEditor->setTextCursor( savedCursor );
///-- */
-///-- _sourceCodeChanged = false;
+///-- m_sourceCodeChanged = false;
///-- }
///-- _indentSettingsChanged = false;
///--
-///-- if (_savedSourceContent == _qSciSourceCodeEditor->text())
+///-- if (_savedSourceContent == m_qSciSourceCodeEditor->text())
///-- {
-///-- _qSciSourceCodeEditor->setModified(false);
+///-- m_qSciSourceCodeEditor->setModified(false);
///-- setWindowModified(false);
///-- }
///-- else
///-- {
-///-- _qSciSourceCodeEditor->setModified(true);
+///-- m_qSciSourceCodeEditor->setModified(true);
///-- setWindowModified(true);
///-- }
///-- }
@@ -974,7 +986,7 @@ void MainWindow::exportToPDF()
///-- QsciPrinter printer(TQPrinter::HighResolution);
///-- printer.setOutputFormat(TQPrinter::PdfFormat);
///-- printer.setOutputFileName(fileName);
-///-- printer.printRange(_qSciSourceCodeEditor);
+///-- printer.printRange(m_qSciSourceCodeEditor);
///-- }
}
@@ -996,7 +1008,7 @@ void MainWindow::exportToHTML()
///-- if (!fileName.isEmpty())
///-- {
///-- // Create a document from which HTML code can be generated.
-///-- TQTextDocument sourceCodeDocument(_qSciSourceCodeEditor->text());
+///-- TQTextDocument sourceCodeDocument(m_qSciSourceCodeEditor->text());
///-- sourceCodeDocument.setDefaultFont(TQFont("Courier", 12, TQFont::Normal));
///-- TQString sourceCodeAsHTML = sourceCodeDocument.toHtml();
///-- // To ensure that empty lines are kept in the HTML code make this replacement.
@@ -1073,14 +1085,14 @@ void MainWindow::exportToHTML()
*/
void MainWindow::saveSettings()
{
-///-- m_settings->setValueByName("encoding", _currentEncoding);
-///-- m_settings->setValueByName("version", PROGRAM_VERSION_STRING);
+ m_settings->setValueByName("VersionInSettingsFile", PROGRAM_VERSION_STRING);
m_settings->setValueByName("WindowIsMaximized", isMaximized());
if (!isMaximized())
{
m_settings->setValueByName("WindowPosition", pos());
m_settings->setValueByName("WindowSize", size());
}
+ m_settings->setValueByName("FileEncoding", m_currentEncoding);
///-- m_settings->setValueByName("MainWindowState", saveState());
///--
///-- // Also save the syntax highlight style for all lexers.
@@ -1216,7 +1228,7 @@ bool MainWindow::maybeSave()
///-- "Reopen the currently opened source code file by using the text encoding scheme ") +
///-- encodingName);
///-- encodingAction->setCheckable(true);
-///-- if (encodingName == _currentEncoding)
+///-- if (encodingName == m_currentEncoding)
///-- {
///-- encodingAction->setChecked(true);
///-- }
@@ -1281,13 +1293,13 @@ bool MainWindow::maybeSave()
///-- TQTextStream inSrcStrm(&inSrcFile);
///-- TQApplication::setOverrideCursor(TQt::WaitCursor);
///-- TQString encodingName = encodingAction->text();
-///-- _currentEncoding = encodingName;
+///-- m_currentEncoding = encodingName;
///-- inSrcStrm.setCodec(TQTextCodec::codecForName(encodingName.toAscii()));
///-- fileContent = inSrcStrm.readAll();
///-- TQApplication::restoreOverrideCursor();
///-- inSrcFile.close();
-///-- _qSciSourceCodeEditor->setText(fileContent);
-///-- _qSciSourceCodeEditor->setModified(false);
+///-- m_qSciSourceCodeEditor->setText(fileContent);
+///-- m_qSciSourceCodeEditor->setModified(false);
///-- }
///-- }
///-- }
@@ -1306,7 +1318,7 @@ bool MainWindow::maybeSave()
///-- foreach(highlighterName, _highlighter->getAvailableHighlighters())
///-- {
///-- highlighterAction = new TQAction(highlighterName, _highlighterActionGroup);
-///-- highlighterAction->setStatusTip(tr("Set the syntax highlightning to ") + highlighterName);
+///-- highlighterAction->setStatusTip(tr("Set the syntax highlighting to ") + highlighterName);
///-- highlighterAction->setCheckable(true);
///-- }
///-- _mainWindowForm->popupMenuHighlighter->addActions(_highlighterActionGroup->actions());
@@ -1316,25 +1328,25 @@ bool MainWindow::maybeSave()
///-- connect(_highlighterActionGroup, SIGNAL(triggered(TQAction*)), _highlighter,
///-- SLOT(setHighlighterByAction(TQAction*)));
///-- }
-///--
-///-- /*
-///-- \brief Is called whenever the white space visibility is being changed in the menu.
-///-- */
-///-- void MainWindow::setWhiteSpaceVisibility(bool visible)
-///-- {
-///-- if (_qSciSourceCodeEditor != NULL)
-///-- {
-///-- if (visible)
-///-- {
-///-- _qSciSourceCodeEditor->setWhitespaceVisibility(QsciScintilla::WsVisible);
-///-- }
-///-- else
-///-- {
-///-- _qSciSourceCodeEditor->setWhitespaceVisibility(QsciScintilla::WsInvisible);
-///-- }
-///-- }
-///-- }
-///--
+
+/*
+ \brief Is called whenever the white space visibility is being changed in the menu.
+ */
+void MainWindow::setWhiteSpaceVisibility(bool visible)
+{
+ if (m_qSciSourceCodeEditor)
+ {
+ if (visible)
+ {
+ m_qSciSourceCodeEditor->setWhitespaceVisibility(TQextScintilla::WsVisible);
+ }
+ else
+ {
+ m_qSciSourceCodeEditor->setWhitespaceVisibility(TQextScintilla::WsInvisible);
+ }
+ }
+}
+
///-- /*
///-- \brief This slot is called whenever the number of lines in the editor changes
///-- and adapts the margin for the displayed line numbers.
@@ -1342,8 +1354,8 @@ bool MainWindow::maybeSave()
///-- void MainWindow::numberOfLinesChanged()
///-- {
///-- TQString lineNumbers;
-///-- lineNumbers.setNum(_qSciSourceCodeEditor->lines() * 10);
-///-- _qSciSourceCodeEditor->setMarginWidth(1, lineNumbers);
+///-- lineNumbers.setNum(m_qSciSourceCodeEditor->lines() * 10);
+///-- m_qSciSourceCodeEditor->setMarginWidth(1, lineNumbers);
///-- }
///--
///-- /*
@@ -1391,13 +1403,13 @@ bool MainWindow::maybeSave()
///-- foreach(TQString highlighterName, _highlighter->getAvailableHighlighters())
///-- {
///-- TQAction *highlighterAction = actionList.at(i);
-///-- highlighterAction->setStatusTip(tr("Set the syntax highlightning to ") + highlighterName);
+///-- highlighterAction->setStatusTip(tr("Set the syntax highlighting to ") + highlighterName);
///-- i++;
///-- }
///--
///-- // Translate the line and column indicators in the statusbar.
///-- int line, column;
-///-- _qSciSourceCodeEditor->getCursorPosition(&line, &column);
+///-- m_qSciSourceCodeEditor->getCursorPosition(&line, &column);
///-- setStatusBarCursorPosInfo(line, column);
///-- }
///-- else
diff --git a/src/MainWindow.h b/src/MainWindow.h
index 7326c5c..8453399 100644
--- a/src/MainWindow.h
+++ b/src/MainWindow.h
@@ -37,7 +37,7 @@ class ToolBarWidget;
/// class TQActionGroup;
/// class TQTranslator;
///
-/// class QsciScintilla;
+class TQextScintilla;
class MainWindow : public MainWindowBase
@@ -60,8 +60,8 @@ class MainWindow : public MainWindowBase
///-- void saveAsOtherEncoding(TQAction *chosenEncodingAction);
///-- void callIndenter();
///-- void updateSourceView();
-///-- void turnHighlightOnOff(bool turnOn);
-///-- void setWhiteSpaceVisibility(bool visible);
+ void turnHighlightOnOff(bool turnOn);
+ void setWhiteSpaceVisibility(bool visible);
///-- void sourceCodeChangedHelperSlot();
///-- void sourceCodeChangedSlot();
///-- void indentSettingsChangedSlot();
@@ -96,10 +96,10 @@ class MainWindow : public MainWindowBase
///-- void dragEnterEvent(TQDragEnterEvent *event);
///-- void dropEvent(TQDropEvent *event);
///--
-///-- QsciScintilla *_qSciSourceCodeEditor;
- UiGuiSettings *m_settings;
+ TQextScintilla *m_qSciSourceCodeEditor;
+ UiGuiSettings *m_settings;
///--
-///-- TQString _currentEncoding;
+ TQString m_currentEncoding;
///-- TQString _sourceFileContent;
///-- TQString _sourceFormattedContent;
///-- TQString _sourceViewContent;
@@ -121,8 +121,7 @@ class MainWindow : public MainWindowBase
///-- TQTranslator *_uiGuiTranslator;
///-- TQTranslator *_qTTranslator;
///--
-///-- bool _sourceCodeChanged;
-///-- bool _scrollPositionChanged;
+ bool m_sourceCodeChanged;
///-- bool _indentSettingsChanged;
///-- bool _previewToggled;
///-- TQStringList _encodingsList;
diff --git a/src/MainWindowBase.ui b/src/MainWindowBase.ui
index 9d478b4..676b6f1 100755
--- a/src/MainWindowBase.ui
+++ b/src/MainWindowBase.ui
@@ -289,7 +289,7 @@
<string>Enables or disables diplaying of white space characters in the editor.</string>
</property>
<property name="visible">
- <bool>false</bool>
+ <bool>true</bool>
</property>
</action>
<action>
@@ -340,7 +340,7 @@
<string>If selected opens last source code file on startup.</string>
</property>
<property name="visible">
- <bool>false</bool>
+ <bool>true</bool>
</property>
</action>
<action>
diff --git a/src/ToolBarWidget.ui b/src/ToolBarWidget.ui
index 19f3259..25663c2 100755
--- a/src/ToolBarWidget.ui
+++ b/src/ToolBarWidget.ui
@@ -58,7 +58,7 @@
<string>Syntax Highlight</string>
</property>
<property name="whatsThis" stdset="0">
- <string>Enables and disables the highlightning of the source</string>
+ <string>Enables and disables the highlighting of the source</string>
</property>
<property name="accel">
<string>Ctrl+H</string>
diff --git a/src/UiGuiSettings.cpp b/src/UiGuiSettings.cpp
index baea1d9..e4ab510 100644
--- a/src/UiGuiSettings.cpp
+++ b/src/UiGuiSettings.cpp
@@ -53,6 +53,11 @@ UiGuiSettings::UiGuiSettings() : TQObject()
m_qsettings->beginGroup("universalindentgui/UniversalIndentGUI");
m_indenterDirectoryStr = SettingsPaths::getGlobalFilesPath() + "/indenters";
+
+ m_actionSettings["actionEnableSyntaxHighlighting"] = "SyntaxHighlightingEnabled";
+ m_actionSettings["actionLoadLastOpenedFileOnStartup"] = "LoadLastOpenedFileOnStartup";
+ m_actionSettings["actionWhiteSpaceIsVisible"] = "WhiteSpaceIsVisible";
+
readAvailableTranslations();
loadSettings();
}
@@ -229,8 +234,8 @@ void UiGuiSettings::loadSettings()
m_settings["SelectedIndenter"] = selectedIndenter;
// Read if syntax highlighting is enabled.
- m_settings["SyntaxHighlightningEnabled"] = m_qsettings->readBoolEntry(
- "SyntaxHighlightningEnabled", true);
+ m_settings["SyntaxHighlightingEnabled"] = m_qsettings->readBoolEntry(
+ "SyntaxHighlightingEnabled", true);
// Read if white space characters should be displayed.
m_settings["WhiteSpaceIsVisible"] = m_qsettings->readBoolEntry("whiteSpaceIsVisible", false);
@@ -297,8 +302,8 @@ void UiGuiSettings::saveSettings()
m_qsettings->writeEntry("selectedIndenter", m_settings["SelectedIndenter"].toInt());
// Write if syntax highlighting is enabled.
- m_qsettings->writeEntry("SyntaxHighlightningEnabled",
- m_settings["SyntaxHighlightningEnabled"].toBool());
+ m_qsettings->writeEntry("SyntaxHighlightingEnabled",
+ m_settings["SyntaxHighlightingEnabled"].toBool());
// Write if white space characters should be displayed.
m_qsettings->writeEntry("whiteSpaceIsVisible", m_settings["WhiteSpaceIsVisible"].toBool());
@@ -318,8 +323,44 @@ void UiGuiSettings::saveSettings()
//m_qsettings->writeEntry("MainWindowState", m_settings["MainWindowState"].toByteArray());
}
+/*
+ \brief Extern widgets can connect to this slot to change settings.
+
+ According to the objects property "connectedSettingName" the corresponding
+ setting is known and set.
+ */
+void UiGuiSettings::handleValueChangeFromExtern(bool value)
+{
+ if (sender())
+ {
+ // Get the corresponding setting name from the sender objects property
+ TQString senderName = TQString(sender()->name());
+ if (m_actionSettings.contains(senderName))
+ {
+ TQString settingName = m_actionSettings[senderName];
+
+ // Set the value of the setting to the objects value.
+ setValueByName(settingName, value);
+ tqWarning("MIKE set="+settingName);
+ }
+ }
+}
+
void UiGuiSettings::emitSignalForSetting(TQString settingName)
{
+ // Emit the signal for the changed value.
+ if (settingName == "LoadLastOpenedFileOnStartup")
+ {
+ emit loadLastOpenedFileOnStartup(m_settings[settingName].toBool());
+ }
+ else if (settingName == "SyntaxHighlightingEnabled")
+ {
+ emit syntaxHighlightingEnabled(m_settings[settingName].toBool());
+ }
+ else if (settingName == "WhiteSpaceIsVisible")
+ {
+ emit whiteSpaceIsVisible(m_settings[settingName].toBool());
+ }
}
/*
diff --git a/src/UiGuiSettings.h b/src/UiGuiSettings.h
index de5ddad..6fd6428 100644
--- a/src/UiGuiSettings.h
+++ b/src/UiGuiSettings.h
@@ -74,7 +74,7 @@ class UiGuiSettings : public TQObject
// [--] private slots:
// [--] void handleObjectPropertyChange();
// [++] void handleValueChangeFromExtern(int value);
-// [++] void handleValueChangeFromExtern(bool value);
+ void handleValueChangeFromExtern(bool value);
// [++] void handleValueChangeFromExtern(TQDate value);
// [++] void handleValueChangeFromExtern(TQByteArray value);
@@ -87,11 +87,11 @@ class UiGuiSettings : public TQObject
// [++] void windowSize(TQSize value);
// [++] void fileEncoding(TQString value);
// [++] void recentlyOpenedListSize(int value);
-// [++] void loadLastOpenedFileOnStartup(bool value);
+ void loadLastOpenedFileOnStartup(bool value);
// [++] void lastOpenedFiles(TQString value);
// [++] void selectedIndenter(int value);
-// [++] void syntaxHighlightningEnabled(bool value);
-// [++] void whiteSpaceIsVisible(bool value);
+ void syntaxHighlightingEnabled(bool value);
+ void whiteSpaceIsVisible(bool value);
// [++] void indenterParameterTooltipsEnabled(bool value);
// [++] void tabWidth(int value);
// [++] void language(int value);
@@ -111,6 +111,9 @@ class UiGuiSettings : public TQObject
// This map holds all possible settings defined by their name as TQString.
TQMap<TQString, TQVariant> m_settings;
+ // This map holds the relationship between action widgets and settings entries
+ TQMap<TQString, TQString> m_actionSettings;
+
// The path where the indenters are located
TQString m_indenterDirectoryStr;
};
diff --git a/src/__TODO/UiGuiHighlighter.cpp b/src/__TODO/UiGuiHighlighter.cpp
index cfbf299..cfb99c9 100644
--- a/src/__TODO/UiGuiHighlighter.cpp
+++ b/src/__TODO/UiGuiHighlighter.cpp
@@ -95,7 +95,7 @@ UiGuiHighlighter::UiGuiHighlighter(QsciScintilla *parent) :
SettingsPaths::getSettingsPath() + "/UiGuiSyntaxHighlightConfig.ini", TQSettings::IniFormat,
this);
- _highlightningIsOn = true;
+ _highlightingIsOn = true;
_mapHighlighternameToExtension["Bash"] = TQStringList() << "sh";
_mapHighlighternameToExtension["Batch"] = TQStringList() << "bat";
@@ -187,7 +187,7 @@ void UiGuiHighlighter::setHighlighterByAction(TQAction *highlighterAction)
*/
void UiGuiHighlighter::turnHighlightOn()
{
- _highlightningIsOn = true;
+ _highlightingIsOn = true;
_qsciEditorParent->setLexer(_lexer);
readCurrentSettings("");
}
@@ -197,7 +197,7 @@ void UiGuiHighlighter::turnHighlightOn()
*/
void UiGuiHighlighter::turnHighlightOff()
{
- _highlightningIsOn = false;
+ _highlightingIsOn = false;
_qsciEditorParent->setLexer();
_qsciEditorParent->setFont(TQFont("Monospace", 10, TQFont::Normal));
_qsciEditorParent->setMarginsFont(TQFont("Monospace", 10, TQFont::Normal));
@@ -583,7 +583,7 @@ int UiGuiHighlighter::setLexerForExtension(TQString extension)
}
// Set the _lexer for the TQScintilla widget.
- if (_highlightningIsOn)
+ if (_highlightingIsOn)
{
_qsciEditorParent->setLexer(_lexer);
}
diff --git a/src/__TODO/UiGuiHighlighter.h b/src/__TODO/UiGuiHighlighter.h
index 025219e..3dd8200 100644
--- a/src/__TODO/UiGuiHighlighter.h
+++ b/src/__TODO/UiGuiHighlighter.h
@@ -63,7 +63,7 @@ class UiGuiHighlighter : public TQObject
void setHighlighterByAction(TQAction *highlighterAction);
private:
- bool _highlightningIsOn;
+ bool _highlightingIsOn;
QsciScintilla *_qsciEditorParent;
TQMap<int, TQFont> _fontForStyles;
TQMap<int, TQColor> _colorForStyles;