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