Create encoding menus + some work on highligther menu

Signed-off-by: Michele Calgaro <michele.calgaro@yahoo.it>
master
Michele Calgaro 2 years ago
parent 658a06d1ee
commit 11451cea9d
Signed by: MicheleC
GPG Key ID: 2A75B7CA8ADED5CF

@ -86,12 +86,11 @@
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_textEditLineColumnInfoLabel(nullptr), m_qTranslator(nullptr), m_uiGuiTranslator(nullptr), m_textEditLineColumnInfoLabel(nullptr),
m_oldLinesNumber(0) m_oldLinesNumber(0), m_encodingsList(), m_encodingActionGroup(nullptr),
///- _mainWindowForm(nullptr), _settings(nullptr), _saveEncodedActionGroup(nullptr), m_saveEncodedActionGroup(nullptr), m_highlighterActionGroup(nullptr)
///- _highlighter(nullptr), _aboutDialogGraphicsView( ///- _mainWindowForm(nullptr), _settings(nullptr)
///- nullptr), _settingsDialog(nullptr), _encodingActionGroup(nullptr) ///- m_highlighter(nullptr), _aboutDialogGraphicsView(nullptr), _settingsDialog(nullptr)
///- _highlighterActionGroup(nullptr), m_textEditVScrollBar(nullptr), _toolBarWidget( ///- m_textEditVScrollBar(nullptr), _toolBarWidget(nullptr), _indentHandler(nullptr)
///- nullptr), _indentHandler(nullptr)
{ {
// Init of some variables. // Init of some variables.
m_sourceCodeChanged = false; m_sourceCodeChanged = false;
@ -111,23 +110,23 @@ MainWindow::MainWindow(TQString file2OpenOnStart, TQWidget *parent) :
// 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();
///--
///-- // Create and init the indenter. // Create and init the indenter.
///-- initIndenter(); initIndenter();
///--
///-- // Create some menus. // Create some menus.
///-- createEncodingMenu(); createEncodingMenu();
///-- createHighlighterMenu(); createHighlighterMenu();
///--
///--
// Generate about dialog box // Generate about dialog box
//m_aboutDialog = new AboutDialog(this, WStyle_Splash); //m_aboutDialog = new AboutDialog(this, WStyle_Splash);
m_aboutDialog = new AboutDialog(this); m_aboutDialog = new AboutDialog(this);
///-- _aboutDialogGraphicsView = new AboutDialogGraphicsView(m_aboutDialog, this); ///-- _aboutDialogGraphicsView = new AboutDialogGraphicsView(m_aboutDialog, this);
connect(actionAboutUniversalIndentGUITQt, SIGNAL(activated()), this, SLOT(showAboutDialog())); connect(actionAboutUniversalIndentGUITQt, SIGNAL(activated()), this, SLOT(showAboutDialog()));
///--
///-- // Generate settings dialog box ///-- // Generate settings dialog box
///-- _settingsDialog = new UiGuiSettingsDialog(this, _settings); ///-- _settingsDialog = new UiGuiSettingsDialog(this, _settings);
///-- connect(actionShowSettings, SIGNAL(activated()), _settingsDialog, ///-- connect(actionShowSettings, SIGNAL(activated()), _settingsDialog,
@ -350,22 +349,25 @@ void MainWindow::initTextEditor()
numberOfLinesChanged(); numberOfLinesChanged();
} }
///-- /* /*
///-- \brief Create and init the syntax _highlighter and set it to use the TQScintilla edit component. \brief Create and init the syntax m_highlighter and set it to use the TQScintilla edit component.
///-- */ */
///-- void MainWindow::initSyntaxHighlighter() void MainWindow::initSyntaxHighlighter()
///-- { {
///-- // Create the _highlighter. ///-- // Create the highlighter.
///-- _highlighter = new UiGuiHighlighter(m_qSciSourceCodeEditor); ///-- m_highlighter = new UiGuiHighlighter(qSciSourceCodeEditor);
///--
///-- // Connect the syntax highlighting setting in the menu to the turnHighlightOnOff function.
///-- connect(actionEnableSyntaxHighlighting, SIGNAL(activated(bool)), this,
///-- SLOT(turnHighlightOnOff(bool)));
///-- ///--
///-- // Register the syntax highlighting setting in the menu to the _settings object. ///-- // Handle if syntax highlighting is enabled
///-- _settings->registerObjectProperty(actionEnableSyntaxHighlighting, "checked", ///-- bool syntaxHighlightningEnabled = m_settings->getValueByName("SyntaxHighlightningEnabled").toBool();
///-- "SyntaxHighlightingEnabled"); ///-- if (syntaxHighlightningEnabled)
///-- {
///-- highlighter->turnHighlightOn();
///-- } ///-- }
///-- else
///-- {
///-- highlighter->turnHighlightOff();
///-- }
}
/* /*
\brief Initializes the language of UniversalIndentGUI. \brief Initializes the language of UniversalIndentGUI.
@ -435,11 +437,11 @@ bool MainWindow::initApplicationLanguage()
return translationFileLoaded; return translationFileLoaded;
} }
///-- /* /*
///-- \brief Creates and initializes the indenter. \brief Creates and initializes the indenter.
///-- */ */
///-- void MainWindow::initIndenter() void MainWindow::initIndenter()
///-- { {
///-- // Get Id of last selected indenter. ///-- // Get Id of last selected indenter.
///-- _currentIndenterID = _settings->getValueByName("selectedIndenter").toInt(); ///-- _currentIndenterID = _settings->getValueByName("selectedIndenter").toInt();
///-- ///--
@ -461,8 +463,8 @@ bool MainWindow::initApplicationLanguage()
///-- ///--
///-- // Add the indenters context menu to the mainwindows menu. ///-- // Add the indenters context menu to the mainwindows menu.
///-- _mainWindowForm->menuIndenter->addActions(_indentHandler->getIndenterMenuActions()); ///-- _mainWindowForm->menuIndenter->addActions(_indentHandler->getIndenterMenuActions());
///-- } }
///--
///-- /* ///-- /*
///-- \brief Tries to load the by \a filePath defined file and returns its content as TQString. ///-- \brief Tries to load the by \a filePath defined file and returns its content as TQString.
///-- ///--
@ -490,7 +492,7 @@ bool MainWindow::initApplicationLanguage()
///-- TQFileInfo fileInfo(filePath); ///-- TQFileInfo fileInfo(filePath);
///-- _currentSourceFileExtension = fileInfo.suffix(); ///-- _currentSourceFileExtension = fileInfo.suffix();
///-- int indexOfHighlighter = _highlighter->setLexerForExtension(_currentSourceFileExtension); ///-- int indexOfHighlighter = _highlighter->setLexerForExtension(_currentSourceFileExtension);
///-- _highlighterActionGroup->actions().at(indexOfHighlighter)->setChecked(true); ///-- m_highlighterActionGroup->actions().at(indexOfHighlighter)->setChecked(true);
///-- } ///-- }
///-- return fileContent; ///-- return fileContent;
///-- } ///-- }
@ -580,7 +582,7 @@ bool MainWindow::saveasSourceFileDialog(TQAction *chosenEncodingAction)
///-- } ///-- }
///-- else ///-- else
///-- { ///-- {
///-- encoding = _encodingActionGroup->checkedAction()->text(); ///-- encoding = m_encodingActionGroup->checkedAction()->text();
///-- } ///-- }
///-- TQTextStream outSrcStrm(&outSrcFile); ///-- TQTextStream outSrcStrm(&outSrcFile);
///-- outSrcStrm.setCodec(TQTextCodec::codecForName(encoding.toAscii())); ///-- outSrcStrm.setCodec(TQTextCodec::codecForName(encoding.toAscii()));
@ -616,7 +618,7 @@ bool MainWindow::saveSourceFile()
///-- outSrcFile.open(TQFile::ReadWrite | TQFile::Text); ///-- outSrcFile.open(TQFile::ReadWrite | TQFile::Text);
///-- ///--
///-- // Get current encoding. ///-- // Get current encoding.
///-- TQString m_currentEncoding = _encodingActionGroup->checkedAction()->text(); ///-- TQString m_currentEncoding = m_encodingActionGroup->checkedAction()->text();
///-- TQTextStream outSrcStrm(&outSrcFile); ///-- TQTextStream outSrcStrm(&outSrcFile);
///-- outSrcStrm.setCodec(TQTextCodec::codecForName(m_currentEncoding.toAscii())); ///-- outSrcStrm.setCodec(TQTextCodec::codecForName(m_currentEncoding.toAscii()));
///-- outSrcStrm << _savedSourceContent; ///-- outSrcStrm << _savedSourceContent;
@ -1211,67 +1213,66 @@ void MainWindow::languageChanged(int languageIndex)
} }
} }
///-- /* /*
///-- \brief Creates a menu entries in the file menu for opening and saving a file with different encodings. \brief Creates menu entries in the file menu for opening and saving a file with different encodings.
///-- */ */
///-- void MainWindow::createEncodingMenu() void MainWindow::createEncodingMenu()
///-- { {
///-- TQAction *encodingAction; m_encodingsList << "UTF-8" << "UTF-16" << "UTF-16BE" << "UTF-16LE" <<
///-- TQString encodingName; "Apple Roman" << "Big5" << "Big5-HKSCS" << "EUC-JP" << "EUC-KR" << "GB18030-0" <<
///-- "IBM 850" << "IBM 866" << "IBM 874" << "ISO 2022-JP" << "ISO 8859-1" << "ISO 8859-13" <<
///-- _encodingsList = TQStringList() << "UTF-8" << "UTF-16" << "UTF-16BE" << "UTF-16LE" << "Iscii-Bng" << "JIS X 0201" << "JIS X 0208" << "KOI8-R" << "KOI8-U" << "MuleLao-1" <<
///-- "Apple Roman" << "Big5" << "Big5-HKSCS" << "EUC-JP" << "EUC-KR" << "GB18030-0" << "ROMAN8" << "Shift-JIS" << "TIS-620" << "TSCII" << "Windows-1250" << "WINSAMI2";
///-- "IBM 850" << "IBM 866" << "IBM 874" << "ISO 2022-JP" << "ISO 8859-1" << "ISO 8859-13" <<
///-- "Iscii-Bng" << "JIS X 0201" << "JIS X 0208" << "KOI8-R" << "KOI8-U" << "MuleLao-1" << m_encodingActionGroup = new TQActionGroup(this);
///-- "ROMAN8" << "Shift-JIS" << "TIS-620" << "TSCII" << "Windows-1250" << "WINSAMI2"; m_saveEncodedActionGroup = new TQActionGroup(this);
///--
///-- _encodingActionGroup = new TQActionGroup(this); // Loop for each available encoding
///-- _saveEncodedActionGroup = new TQActionGroup(this); for(const TQString &encodingName : m_encodingsList)
///-- {
///-- // Loop for each available encoding // Create actions for the "reopen" menu
///-- foreach(encodingName, _encodingsList) TQAction *encodingAction = new TQAction(m_encodingActionGroup);
///-- { encodingAction->setText(encodingName);
///-- // Create actions for the "reopen" menu encodingAction->setStatusTip(tr(
///-- encodingAction = new TQAction(encodingName, _encodingActionGroup); "Reopen the currently opened source code file by using the text encoding scheme ") +
///-- encodingAction->setStatusTip(tr( encodingName);
///-- "Reopen the currently opened source code file by using the text encoding scheme ") + encodingAction->setToggleAction(true);
///-- encodingName); if (encodingName == m_currentEncoding)
///-- encodingAction->setCheckable(true); {
///-- if (encodingName == m_currentEncoding) encodingAction->setOn(true);
///-- { }
///-- encodingAction->setChecked(true);
///-- } // Create actions for the "save as encoded" menu
///-- encodingAction = new TQAction(m_saveEncodedActionGroup);
///-- // Create actions for the "save as encoded" menu encodingAction->setText(encodingName);
///-- encodingAction = new TQAction(encodingName, _saveEncodedActionGroup); encodingAction->setStatusTip(tr(
///-- encodingAction->setStatusTip(tr( "Save the currently opened source code file by using the text encoding scheme ") +
///-- "Save the currently opened source code file by using the text encoding scheme ") + encodingName);
///-- encodingName); }
///-- }
///-- m_encodingActionGroup->addTo(popupMenuEncoding);
///-- _mainWindowForm->popupMenuEncoding->addActions(_encodingActionGroup->actions()); connect(m_encodingActionGroup, SIGNAL(selected(TQAction*)),
///-- connect(_encodingActionGroup, SIGNAL(triggered(TQAction*)), this, this, SLOT(encodingChanged(TQAction*)));
///-- SLOT(encodingChanged(TQAction*)));
///-- m_saveEncodedActionGroup->addTo(popupMenuSaveEncoded);
///-- _mainWindowForm->popupMenuSaveEncoded->addActions(_saveEncodedActionGroup->actions()); connect(m_saveEncodedActionGroup, SIGNAL(selected(TQAction*)),
///-- connect(_saveEncodedActionGroup, SIGNAL(triggered(TQAction*)), this, this, SLOT(saveAsOtherEncoding(TQAction*)));
///-- SLOT(saveAsOtherEncoding(TQAction*))); }
///-- }
///-- /*
///-- /* \brief This slot calls the save dialog to save the current source file with another encoding.
///-- \brief This slot calls the save dialog to save the current source file with another encoding.
///-- If the saving is successful and not aborted, the currently used encoding, visible in the
///-- If the saving is successful and not aborted, the currently used encoding, visible in the "reopen" menu, is also changed to the new encoding.
///-- "reopen" menu, is also changed to the new encoding. */
///-- */ void MainWindow::saveAsOtherEncoding(TQAction *chosenEncodingAction)
///-- void MainWindow::saveAsOtherEncoding(TQAction *chosenEncodingAction) {
///-- {
///-- bool fileWasSaved = saveasSourceFileDialog(chosenEncodingAction); ///-- bool fileWasSaved = saveasSourceFileDialog(chosenEncodingAction);
///-- ///--
///-- // If the file was save with another encoding, change the selected encoding in the reopen menu. ///-- // If the file was save with another encoding, change the selected encoding in the reopen menu.
///-- if (fileWasSaved) ///-- if (fileWasSaved)
///-- { ///-- {
///-- foreach(TQAction * action, _encodingActionGroup->actions()) ///-- foreach(TQAction * action, m_encodingActionGroup->actions())
///-- { ///-- {
///-- if (action->text() == chosenEncodingAction->text()) ///-- if (action->text() == chosenEncodingAction->text())
///-- { ///-- {
@ -1280,13 +1281,13 @@ void MainWindow::languageChanged(int languageIndex)
///-- } ///-- }
///-- } ///-- }
///-- } ///-- }
///-- } }
///--
///-- /* /*
///-- \brief This slot is called whenever an encoding is selected in the settings menu. \brief This slot is called whenever an encoding is selected in the settings menu.
///-- */ */
///-- void MainWindow::encodingChanged(TQAction *encodingAction) void MainWindow::encodingChanged(TQAction *encodingAction)
///-- { {
///-- if (maybeSave()) ///-- if (maybeSave())
///-- { ///-- {
///-- TQFile inSrcFile(_currentSourceFile); ///-- TQFile inSrcFile(_currentSourceFile);
@ -1311,32 +1312,31 @@ void MainWindow::languageChanged(int languageIndex)
///-- m_qSciSourceCodeEditor->setModified(false); ///-- m_qSciSourceCodeEditor->setModified(false);
///-- } ///-- }
///-- } ///-- }
///-- } }
///--
///-- /* /*
///-- \brief Creates a menu entry under the settings menu for all available text encodings. \brief Creates a menu entry under the settings menu for all available text encodings.
///-- */ */
///-- void MainWindow::createHighlighterMenu() void MainWindow::createHighlighterMenu()
///-- { {
///-- TQAction *highlighterAction; ///--- m_highlighterActionGroup = new TQActionGroup(this);
///-- TQString highlighterName; ///---
///-- ///--- // Loop for each known highlighter
///-- _highlighterActionGroup = new TQActionGroup(this); ///--- for(const TQString &highlighterName: m_highlighter->getAvailableHighlighters())
///-- ///--- {
///-- // Loop for each known highlighter ///--- TQAction *highlighterAction = new TQAction(m_highlighterActionGroup);
///-- foreach(highlighterName, _highlighter->getAvailableHighlighters()) ///--- highlighterAction->setText(highlighterName);
///-- { ///--- highlighterAction->setStatusTip(tr("Set the syntax highlighting to ") + highlighterName);
///-- highlighterAction = new TQAction(highlighterName, _highlighterActionGroup); ///--- highlighterAction->setToggleAction(true);
///-- highlighterAction->setStatusTip(tr("Set the syntax highlighting to ") + highlighterName); ///--- }
///-- highlighterAction->setCheckable(true); ///---
///-- } ///--- m_highlighterActionGroup ->addTo(popupMenuHighlighter);
///-- _mainWindowForm->popupMenuHighlighter->addActions(_highlighterActionGroup->actions()); ///--- connect(m_highlighterActionGroup , SIGNAL(selected(TQAction*)),
///-- _mainWindowForm->menuSettings->insertMenu(actionIndenterParameterTooltipsEnabled, ///--- m_highlighter, SLOT(setHighlighterByAction(TQAction*)));
///-- _mainWindowForm->popupMenuHighlighter); ///---
///-- ///--- _mainWindowForm->menuSettings->insertMenu(actionIndenterParameterTooltipsEnabled,
///-- connect(_highlighterActionGroup, SIGNAL(triggered(TQAction*)), _highlighter, ///--- _mainWindowForm->popupMenuHighlighter);
///-- SLOT(setHighlighterByAction(TQAction*))); }
///-- }
/* /*
\brief Is called whenever the white space visibility is being changed in the menu. \brief Is called whenever the white space visibility is being changed in the menu.
@ -1394,20 +1394,20 @@ void MainWindow::numberOfLinesChanged()
///-- _indentHandler->retranslateUi(); ///-- _indentHandler->retranslateUi();
///-- ///--
///-- // Translate the load encoding menu. ///-- // Translate the load encoding menu.
///-- TQList<TQAction*> encodingActionList = _encodingActionGroup->actions(); ///-- TQList<TQAction*> encodingActionList = m_encodingActionGroup->actions();
///-- for (i = 0; i < encodingActionList.size(); i++) ///-- for (i = 0; i < encodingActionList.size(); i++)
///-- { ///-- {
///-- encodingActionList.at(i)->setStatusTip(tr( ///-- encodingActionList.at(i)->setStatusTip(tr(
///-- "Reopen the currently opened source code file by using the text encoding scheme ") + _encodingsList.at( ///-- "Reopen the currently opened source code file by using the text encoding scheme ") + m_encodingsList.at(
///-- i)); ///-- i));
///-- } ///-- }
///-- ///--
///-- // Translate the save encoding menu. ///-- // Translate the save encoding menu.
///-- encodingActionList = _saveEncodedActionGroup->actions(); ///-- encodingActionList = m_saveEncodedActionGroup->actions();
///-- for (i = 0; i < encodingActionList.size(); i++) ///-- for (i = 0; i < encodingActionList.size(); i++)
///-- { ///-- {
///-- encodingActionList.at(i)->setStatusTip(tr( ///-- encodingActionList.at(i)->setStatusTip(tr(
///-- "Save the currently opened source code file by using the text encoding scheme ") + _encodingsList.at( ///-- "Save the currently opened source code file by using the text encoding scheme ") + m_encodingsList.at(
///-- i)); ///-- i));
///-- } ///-- }
///-- ///--

@ -56,7 +56,7 @@ class MainWindow : public MainWindowBase
void openSourceFileDialog(TQString fileName = ""); void openSourceFileDialog(TQString fileName = "");
bool saveSourceFile(); bool saveSourceFile();
bool saveasSourceFileDialog(TQAction *chosenEncodingAction = NULL); bool saveasSourceFileDialog(TQAction *chosenEncodingAction = NULL);
///-- void saveAsOtherEncoding(TQAction *chosenEncodingAction); void saveAsOtherEncoding(TQAction *chosenEncodingAction);
///-- void callIndenter(); ///-- void callIndenter();
///-- void updateSourceView(); ///-- void updateSourceView();
void turnHighlightOnOff(bool turnOn); void turnHighlightOnOff(bool turnOn);
@ -68,7 +68,7 @@ class MainWindow : public MainWindowBase
void exportToPDF(); void exportToPDF();
void exportToHTML(); void exportToHTML();
void languageChanged(int languageIndex); void languageChanged(int languageIndex);
///-- void encodingChanged(TQAction *encodingAction); void encodingChanged(TQAction *encodingAction);
void numberOfLinesChanged(); void numberOfLinesChanged();
void updateRecentlyOpenedList(); void updateRecentlyOpenedList();
void openFileFromRecentlyOpenedList(int recentlyOpenedActionId); void openFileFromRecentlyOpenedList(int recentlyOpenedActionId);
@ -83,14 +83,14 @@ class MainWindow : public MainWindowBase
///-- void loadLastOpenedFile(); ///-- void loadLastOpenedFile();
void saveSettings(); void saveSettings();
bool maybeSave(); bool maybeSave();
///-- void createEncodingMenu(); void createEncodingMenu();
///-- void createHighlighterMenu(); void createHighlighterMenu();
bool initApplicationLanguage(); bool initApplicationLanguage();
void initMainWindow(); void initMainWindow();
void initToolBar(); void initToolBar();
void initTextEditor(); void initTextEditor();
///-- void initSyntaxHighlighter(); void initSyntaxHighlighter();
///-- void initIndenter(); void initIndenter();
///-- void changeEvent(TQEvent *event); ///-- void changeEvent(TQEvent *event);
///-- void dragEnterEvent(TQDragEnterEvent *event); ///-- void dragEnterEvent(TQDragEnterEvent *event);
///-- void dropEvent(TQDropEvent *event); ///-- void dropEvent(TQDropEvent *event);
@ -102,7 +102,7 @@ class MainWindow : public MainWindowBase
///-- TQString _sourceFileContent; ///-- TQString _sourceFileContent;
///-- TQString _sourceFormattedContent; ///-- TQString _sourceFormattedContent;
///-- TQString _sourceViewContent; ///-- TQString _sourceViewContent;
///-- UiGuiHighlighter *_highlighter; ///-- UiGuiHighlighter *m_highlighter;
///-- TQScrollBar *m_textEditVScrollBar; ///-- TQScrollBar *m_textEditVScrollBar;
AboutDialog *m_aboutDialog; AboutDialog *m_aboutDialog;
///-- AboutDialogGraphicsView *_aboutDialogGraphicsView; ///-- AboutDialogGraphicsView *_aboutDialogGraphicsView;
@ -115,17 +115,17 @@ class MainWindow : public MainWindowBase
///-- TQString _currentSourceFile; ///-- TQString _currentSourceFile;
///-- TQString _currentSourceFileExtension; ///-- TQString _currentSourceFileExtension;
///-- TQString _savedSourceContent; ///-- TQString _savedSourceContent;
///-- TQActionGroup *_encodingActionGroup; TQActionGroup *m_encodingActionGroup;
///-- TQActionGroup *_saveEncodedActionGroup; TQActionGroup *m_saveEncodedActionGroup;
///-- TQActionGroup *_highlighterActionGroup; TQActionGroup *m_highlighterActionGroup;
TQTranslator *m_uiGuiTranslator; TQTranslator *m_uiGuiTranslator;
TQTranslator *m_qTranslator; TQTranslator *m_qTranslator;
///-- ///--
bool m_sourceCodeChanged; bool m_sourceCodeChanged;
///-- bool _indentSettingsChanged; ///-- bool _indentSettingsChanged;
///-- bool _previewToggled; ///-- bool _previewToggled;
///-- TQStringList _encodingsList; TQStringList m_encodingsList;
///--
ToolBarWidget *m_toolBarWidget; ToolBarWidget *m_toolBarWidget;
///-- IndentHandler *_indentHandler; ///-- IndentHandler *_indentHandler;
TQLabel *m_textEditLineColumnInfoLabel; TQLabel *m_textEditLineColumnInfoLabel;

Loading…
Cancel
Save