@ -22,6 +22,8 @@
///-- #include "debugging/TSLogger.h"
///-- #include "debugging/TSLogger.h"
# include "stdlib.h"
# include "AboutDialog.h"
# include "AboutDialog.h"
# include "SettingsPaths.h"
# include "SettingsPaths.h"
# include "UiGuiSettings.h"
# include "UiGuiSettings.h"
@ -35,13 +37,15 @@
# include <tqaction.h>
# include <tqaction.h>
# include <tqapplication.h>
# include <tqapplication.h>
# include <tqcheckbox.h>
# include <tqcheckbox.h>
# include <tqlabel.h>
# include <tqlocale.h>
# include <tqlocale.h>
# include <tqmessagebox.h>
# include <tqpixmap.h>
# include <tqpixmap.h>
# include <tqpopupmenu.h>
# include <tqpopupmenu.h>
# include <tqpushbutton.h>
# include <tqpushbutton.h>
# include <tqstatusbar.h>
# include <tqtranslator.h>
# include <tqtranslator.h>
///-- #include <tqwidget.h>
///-- #include <tqwidget.h>
///-- #include <tqlabel.h>
///-- #include <tqstring.h>
///-- #include <tqstring.h>
///-- #include <tqscrollbar.h>
///-- #include <tqscrollbar.h>
///-- #include <tqtextcursor.h>
///-- #include <tqtextcursor.h>
@ -56,7 +60,6 @@
///-- #include <tqtextcodec.h>
///-- #include <tqtextcodec.h>
///-- #include <tqdate.h>
///-- #include <tqdate.h>
///-- #include <tqurl.h>
///-- #include <tqurl.h>
///-- #include <tqmessagebox.h>
///-- #include <tqtdebug.h>
///-- #include <tqtdebug.h>
///--
///--
# include <tqextscintilla.h>
# include <tqextscintilla.h>
@ -82,17 +85,18 @@
*/
*/
MainWindow : : MainWindow ( TQString file2OpenOnStart , TQWidget * parent ) :
MainWindow : : MainWindow ( TQString file2OpenOnStart , TQWidget * parent ) :
MainWindowBase ( parent ) , m_aboutDialog ( nullptr ) , m_qSciSourceCodeEditor ( nullptr ) ,
MainWindowBase ( parent ) , m_aboutDialog ( nullptr ) , m_qSciSourceCodeEditor ( nullptr ) ,
m_qTranslator ( nullptr ) , m_uiGuiTranslator ( nullptr )
m_qTranslator ( nullptr ) , m_uiGuiTranslator ( nullptr ) , m_textEditLineColumnInfoLabel ( nullptr ) ,
m_oldLinesNumber ( 0 )
///- _mainWindowForm(nullptr), _settings(nullptr), _saveEncodedActionGroup(nullptr),
///- _mainWindowForm(nullptr), _settings(nullptr), _saveEncodedActionGroup(nullptr),
///- _highlighter(nullptr), _ textEditVScrollBar(nullptr), _ aboutDialogGraphicsView(
///- _highlighter(nullptr), _ aboutDialogGraphicsView(
///- nullptr), _settingsDialog(nullptr), _encodingActionGroup(nullptr)
///- nullptr), _settingsDialog(nullptr), _encodingActionGroup(nullptr)
///- _highlighterActionGroup(nullptr), _toolBarWidget(
///- _highlighterActionGroup(nullptr), m_textEditVScrollBar(nullptr), _toolBarWidget(
///- nullptr), _indentHandler(nullptr) , _textEditLineColumnInfoLabel(nullptr)
///- nullptr), _indentHandler(nullptr)
{
{
// Init of some variables.
// Init of some variables.
m_sourceCodeChanged = false ;
m_sourceCodeChanged = false ;
// Create the _ settings object, which loads all UiGui settings from a file.
// Create the settings object, which loads all UiGui settings from a file.
m_settings = UiGuiSettings : : getInstance ( ) ;
m_settings = UiGuiSettings : : getInstance ( ) ;
// Initialize the language of the application.
// Initialize the language of the application.
@ -104,9 +108,9 @@ MainWindow::MainWindow(TQString file2OpenOnStart, TQWidget *parent) :
// Create toolbar and insert it into the main window.
// Create toolbar and insert it into the main window.
initToolBar ( ) ;
initToolBar ( ) ;
///-- // Create the text edit component using the TQScintilla widget.
// Create the text edit component using the TQScintilla widget.
///-- initTextEditor();
initTextEditor ( ) ;
///--
///-- // Create and init the syntax highlighter.
///-- // Create and init the syntax highlighter.
///-- initSyntaxHighlighter();
///-- initSyntaxHighlighter();
///--
///--
@ -184,7 +188,7 @@ void MainWindow::initMainWindow()
actionShowLog - > setIconSet ( TQPixmap ( ICONS_PATH + " document-properties.png " ) ) ;
actionShowLog - > setIconSet ( TQPixmap ( ICONS_PATH + " document-properties.png " ) ) ;
actionAboutUniversalIndentGUITQt - > setIconSet ( TQPixmap ( ICONS_PATH + " info.png " ) ) ;
actionAboutUniversalIndentGUITQt - > setIconSet ( TQPixmap ( ICONS_PATH + " info.png " ) ) ;
// Menu ids
// Menu ids
_actionClearRecentlyOpenedListId = popupMenuRecentlyOpenedFiles - > idAt (
m _actionClearRecentlyOpenedListId = popupMenuRecentlyOpenedFiles - > idAt (
popupMenuRecentlyOpenedFiles - > count ( ) - 1 ) ;
popupMenuRecentlyOpenedFiles - > count ( ) - 1 ) ;
// Handle last opened window size
// Handle last opened window size
@ -282,66 +286,70 @@ void MainWindow::initToolBar()
///-- bool)), m_toolBarWidget->cbLivePreview, SLOT(setChecked(bool)));
///-- bool)), m_toolBarWidget->cbLivePreview, SLOT(setChecked(bool)));
}
}
///-- /*
/*
///-- \brief Create and initialize the text editor component. It uses the TQScintilla widget.
\ brief Create and initialize the text editor component . It uses the TQScintilla widget .
///-- */
*/
///-- void MainWindow::initTextEditor()
void MainWindow : : initTextEditor ( )
///-- {
{
///-- // Create the TQScintilla widget and add it to the layout.
// Create the TQScintilla widget and add it to the layout.
///-- tqDebug() <<
//tqDebug("Trying to load TQScintilla library. If anything fails during loading, it might be "
///-- "Trying to load TQScintilla library. If anything fails during loading, it might be possible that"
// "possible that the debug and release version of TQScintilla are mixed or the library "
///-- <<
// "cannot be found at all.");
///-- " the debug and release version of TQScintilla are mixed or the library cannot be found at all.";
// Try and catch doesn't seem to catch the runtime error when starting UiGUI release with
///-- // Try and catch doesn't seem to catch the runtime error when starting UiGUI release with
// TQScintilla debug lib and the other way around.
///-- // TQScintilla debug lib and the other way around.
try
///-- try
{
///-- {
m_qSciSourceCodeEditor = new TQextScintilla ( this ) ;
///-- m_qSciSourceCodeEditor = new QsciScintilla(this);
}
///-- }
catch ( . . . )
///-- catch (...)
{
///-- {
TQMessageBox : : critical ( this , " Error creating TQScintilla text editor component! " ,
///-- TQMessageBox::critical(this, "Error creating TQScintilla text editor component!",
" While trying to create the text editor component (based on TQScintilla), an error "
///-- "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.");
" occurred. Please make sure that TQScintilla is installed and that release and debug "
///-- exit(1);
" versions are not mixed. " ) ;
///-- }
exit ( 1 ) ;
///-- _mainWindowForm->hboxLayout1->addWidget(m_qSciSourceCodeEditor);
}
///--
setCentralWidget ( m_qSciSourceCodeEditor ) ;
///-- // Make some _settings for the TQScintilla widget.
///-- m_qSciSourceCodeEditor->setUtf8(true);
// Make some _settings for the TQScintilla widget.
///-- m_qSciSourceCodeEditor->setMarginLineNumbers(1, true);
m_qSciSourceCodeEditor - > setUtf8 ( true ) ;
///-- m_qSciSourceCodeEditor->setMarginWidth(1, TQString("10000"));
m_qSciSourceCodeEditor - > setMarginLineNumbers ( 1 , true ) ;
///-- m_qSciSourceCodeEditor->setBraceMatching(m_qSciSourceCodeEditor->SloppyBraceMatch);
m_qSciSourceCodeEditor - > setMarginWidth ( 1 , TQString ( " 10000 " ) ) ;
///-- m_qSciSourceCodeEditor->setMatchedBraceForegroundColor(TQColor("red"));
m_qSciSourceCodeEditor - > setBraceMatching ( m_qSciSourceCodeEditor - > SloppyBraceMatch ) ;
///-- m_qSciSourceCodeEditor->setFolding(QsciScintilla::BoxedTreeFoldStyle);
m_qSciSourceCodeEditor - > setMatchedBraceForegroundColor ( TQColor ( " red " ) ) ;
///-- m_qSciSourceCodeEditor->setAutoCompletionSource(QsciScintilla::AcsAll);
m_qSciSourceCodeEditor - > setFolding ( TQextScintilla : : BoxedTreeFoldStyle ) ;
///-- m_qSciSourceCodeEditor->setAutoCompletionThreshold(3);
m_qSciSourceCodeEditor - > setAutoCompletionSource ( TQextScintilla : : AcsAll ) ;
///--
m_qSciSourceCodeEditor - > setAutoCompletionThreshold ( 3 ) ;
///-- // Handle if white space is set to be visible
///-- bool whiteSpaceIsVisible = _settings->getValueByName("whiteSpaceIsVisible").toBool();
// Handle if white space is set to be visible
///-- setWhiteSpaceVisibility(whiteSpaceIsVisible);
bool whiteSpaceIsVisible = m_settings - > getValueByName ( " WhiteSpaceIsVisible " ) . toBool ( ) ;
///--
setWhiteSpaceVisibility ( whiteSpaceIsVisible ) ;
///-- // Handle the width of tabs in spaces
///-- int tabWidth = _settings->getValueByName("tabWidth").toInt();
// Handle the width of tabs in spaces
///-- m_qSciSourceCodeEditor->setTabWidth(tabWidth);
int tabWidth = m_settings - > getValueByName ( " TabWidth " ) . toInt ( ) ;
///--
m_qSciSourceCodeEditor - > setTabWidth ( tabWidth ) ;
///-- // Remember a pointer to the scrollbar of the TQScintilla widget used to keep
connect ( m_settings , SIGNAL ( tabWidth ( int ) ) , m_qSciSourceCodeEditor , SLOT ( setTabWidth ( int ) ) ) ;
///-- // on the same line as before when turning preview on/off.
///-- _textEditVScrollBar = m_qSciSourceCodeEditor->verticalScrollBar();
// TODO not available in TQScintilla 1.71
///--
// Remember a pointer to the scrollbar of the TQScintilla widget used to keep
///-- // Add a column row indicator to the status bar.
// on the same line as before when turning preview on/off.
///-- _textEditLineColumnInfoLabel = new TQLabel(tr("Line %1, Column %2").arg(1).arg(1));
//m_textEditVScrollBar = m_qSciSourceCodeEditor->verticalScrollBar();
///-- _mainWindowForm->statusbar->addPermanentWidget(_textEditLineColumnInfoLabel);
///-- connect(m_qSciSourceCodeEditor, SIGNAL(cursorPositionChanged(int,int)), this,
// Add a column row indicator to the status bar.
///-- SLOT(setStatusBarCursorPosInfo(int, int)));
m_textEditLineColumnInfoLabel = new TQLabel ( tr ( " Line %1, Column %2 " ) . arg ( 1 ) . arg ( 1 ) , this ) ;
///--
statusBar ( ) - > addWidget ( m_textEditLineColumnInfoLabel , 0 , true ) ;
///-- // Connect the text editor to dependent functions.
connect ( m_qSciSourceCodeEditor , SIGNAL ( cursorPositionChanged ( int , int ) ) ,
///-- connect(m_qSciSourceCodeEditor, SIGNAL(textChanged()), this, SLOT(sourceCodeChangedHelperSlot()));
this , SLOT ( setStatusBarCursorPosInfo ( int , int ) ) ) ;
///-- connect(m_qSciSourceCodeEditor, SIGNAL(linesChanged()), this, SLOT(numberOfLinesChanged()));
///-- //connect( _settings, SIGNAL(tabWidth(int)), m_qSciSourceCodeEditor, SLOT(setTabWidth(int)) );
// Connect the text editor to dependent functions.
///-- _settings->registerObjectSlot(m_qSciSourceCodeEditor, "setTabWidth(int)", "tabWidth");
connect ( m_qSciSourceCodeEditor , SIGNAL ( textChanged ( ) ) , this , SLOT ( sourceCodeChangedHelperSlot ( ) ) ) ;
///-- m_qSciSourceCodeEditor->setTabWidth(_settings->getValueByName("tabWidth").toInt());
// TODO signal 'linesChanged' is not available in TQScintilla 1.71.
///-- }
// Use textChanged for now and check for line number changes in the slot
///--
//connect(m_qSciSourceCodeEditor, SIGNAL(linesChanged()), this, SLOT(numberOfLinesChanged()));
connect ( m_qSciSourceCodeEditor , SIGNAL ( textChanged ( ) ) , this , SLOT ( numberOfLinesChanged ( ) ) ) ;
numberOfLinesChanged ( ) ;
}
///-- /*
///-- /*
///-- \brief Create and init the syntax _highlighter and set it to use the TQScintilla edit component.
///-- \brief Create and init the syntax _highlighter and set it to use the TQScintilla edit component.
///-- */
///-- */
@ -529,7 +537,7 @@ void MainWindow::openSourceFileDialog(TQString fileName)
///-- updateWindowTitle();
///-- updateWindowTitle();
///-- updateRecentlyOpenedList();
///-- updateRecentlyOpenedList();
///-- _textEditLastScrollPos = 0;
///-- _textEditLastScrollPos = 0;
///-- _textEditVScrollBar->setValue(_textEditLastScrollPos);
///-- m _textEditVScrollBar->setValue(_textEditLastScrollPos);
///--
///--
///-- _savedSourceContent = openedSourceFileContent;
///-- _savedSourceContent = openedSourceFileContent;
///-- m_qSciSourceCodeEditor->setModified(false);
///-- m_qSciSourceCodeEditor->setModified(false);
@ -650,7 +658,7 @@ bool MainWindow::saveSourceFile()
///-- */
///-- */
///-- void MainWindow::updateSourceView()
///-- void MainWindow::updateSourceView()
///-- {
///-- {
///-- _textEditLastScrollPos = _textEditVScrollBar->value();
///-- _textEditLastScrollPos = m _textEditVScrollBar->value();
///--
///--
///-- if (m_toolBarWidget->cbLivePreview->isChecked())
///-- if (m_toolBarWidget->cbLivePreview->isChecked())
///-- {
///-- {
@ -673,7 +681,7 @@ bool MainWindow::saveSourceFile()
///-- SLOT(sourceCodeChangedHelperSlot()));
///-- SLOT(sourceCodeChangedHelperSlot()));
///-- }
///-- }
///--
///--
///-- _textEditVScrollBar->setValue(_textEditLastScrollPos);
///-- m _textEditVScrollBar->setValue(_textEditLastScrollPos);
///-- }
///-- }
///--
///--
///-- /*
///-- /*
@ -707,20 +715,20 @@ void MainWindow::turnHighlightOnOff(bool turnOn)
///-- updateSourceView();
///-- updateSourceView();
}
}
///-- /*
/*
///-- \brief Added this slot to avoid multiple calls because of changed text.
\ brief Added this slot to avoid multiple calls because of changed text .
///-- */
*/
///-- void MainWindow::sourceCodeChangedHelperSlot()
void MainWindow : : sourceCodeChangedHelperSlot ( )
///-- {
{
///-- TQTimer::singleShot(0, this, SLOT(sourceCodeChangedSlot()));
TQTimer : : singleShot ( 0 , this , SLOT ( sourceCodeChangedSlot ( ) ) ) ;
///-- }
}
///--
///-- /*
/*
///-- \brief Is emitted whenever the text inside the source view window changes. Calls the indenter
\ brief Is emitted whenever the text inside the source view window changes . Calls the indenter
///-- to format the changed source code.
to format the changed source code .
///-- */
*/
///-- void MainWindow::sourceCodeChangedSlot()
void MainWindow : : sourceCodeChangedSlot ( )
///-- {
{
///-- TQChar enteredCharacter;
///-- TQChar enteredCharacter;
///-- int cursorPos, cursorPosAbsolut, cursorLine;
///-- int cursorPos, cursorPosAbsolut, cursorLine;
///-- TQString text;
///-- TQString text;
@ -863,8 +871,8 @@ void MainWindow::turnHighlightOnOff(bool turnOn)
///-- // Could set cursor this way and use normal linear search in text instead of columns and rows.
///-- // Could set cursor this way and use normal linear search in text instead of columns and rows.
///-- //m_qSciSourceCodeEditor->SendScintilla(QsciScintillaBase::SCI_SETCURRENTPOS, 50);
///-- //m_qSciSourceCodeEditor->SendScintilla(QsciScintillaBase::SCI_SETCURRENTPOS, 50);
///-- //m_qSciSourceCodeEditor->SendScintilla(QsciScintillaBase::SCI_SETANCHOR, 50);
///-- //m_qSciSourceCodeEditor->SendScintilla(QsciScintillaBase::SCI_SETANCHOR, 50);
///-- }
}
///--
///-- /*
///-- /*
///-- \brief This slot is called whenever one of the indenter _settings are changed.
///-- \brief This slot is called whenever one of the indenter _settings are changed.
///--
///--
@ -1348,17 +1356,22 @@ void MainWindow::setWhiteSpaceVisibility(bool visible)
}
}
}
}
///-- /*
/*
///-- \brief This slot is called whenever the number of lines in the editor changes
\ brief This slot is called whenever the number of lines in the editor changes
///-- and adapts the margin for the displayed line numbers.
and adapts the margin for the displayed line numbers .
///-- */
*/
///-- void MainWindow::numberOfLinesChanged()
void MainWindow : : numberOfLinesChanged ( )
///-- {
{
///-- TQString lineNumbers;
int lines = m_qSciSourceCodeEditor - > lines ( ) ;
///-- lineNumbers.setNum(m_qSciSourceCodeEditor->lines() * 10);
if ( lines ! = m_oldLinesNumber )
///-- m_qSciSourceCodeEditor->setMarginWidth(1, lineNumbers);
{
///-- }
m_oldLinesNumber = lines ;
///--
TQString lineNumbers ;
lineNumbers . setNum ( lines * 10 ) ;
m_qSciSourceCodeEditor - > setMarginWidth ( 1 , lineNumbers ) ;
}
}
///-- /*
///-- /*
///-- \brief Catches language change events and retranslates all needed widgets.
///-- \brief Catches language change events and retranslates all needed widgets.
///-- */
///-- */
@ -1547,7 +1560,7 @@ void MainWindow::openFileFromRecentlyOpenedList(int recentlyOpenedActionId)
{
{
// If the selected action from the recently opened list menu is the clear action
// If the selected action from the recently opened list menu is the clear action
// call the slot to clear the list and then leave.
// call the slot to clear the list and then leave.
if ( recentlyOpenedActionId = = _actionClearRecentlyOpenedListId)
if ( recentlyOpenedActionId = = m _actionClearRecentlyOpenedListId)
{
{
clearRecentlyOpenedList ( ) ;
clearRecentlyOpenedList ( ) ;
return ;
return ;
@ -1618,12 +1631,12 @@ void MainWindow::showAboutDialog()
m_aboutDialog - > show ( ) ;
m_aboutDialog - > show ( ) ;
}
}
///-- /*
/*
///-- \brief Sets the label in the status bar to show the \a line and \a column number.
\ brief Sets the label in the status bar to show the \ a line and \ a column number .
///-- */
*/
///-- void MainWindow::setStatusBarCursorPosInfo(int line, int column)
void MainWindow : : setStatusBarCursorPosInfo ( int line , int column )
///-- {
{
///-- _textEditLineColumnInfoLabel->setText(tr("Line %1, Column %2").arg(line + 1).arg(column + 1));
m _textEditLineColumnInfoLabel - > setText ( tr ( " Line %1, Column %2 " ) . arg ( line + 1 ) . arg ( column + 1 ) ) ;
///-- }
}
# include "MainWindow.moc"
# include "MainWindow.moc"