|
|
|
@ -32,11 +32,14 @@
|
|
|
|
|
///-- #include "UiGuiHighlighter.h"
|
|
|
|
|
///-- #include "IndentHandler.h"
|
|
|
|
|
|
|
|
|
|
#include <tqpixmap.h>
|
|
|
|
|
#include <tqaction.h>
|
|
|
|
|
#include <tqapplication.h>
|
|
|
|
|
#include <tqcheckbox.h>
|
|
|
|
|
#include <tqlocale.h>
|
|
|
|
|
#include <tqpixmap.h>
|
|
|
|
|
#include <tqpopupmenu.h>
|
|
|
|
|
#include <tqpushbutton.h>
|
|
|
|
|
#include <tqtranslator.h>
|
|
|
|
|
///-- #include <tqwidget.h>
|
|
|
|
|
///-- #include <tqlabel.h>
|
|
|
|
|
///-- #include <tqstring.h>
|
|
|
|
@ -50,8 +53,6 @@
|
|
|
|
|
///-- #include <tqcloseevent.h>
|
|
|
|
|
///-- #include <tqhelpevent.h>
|
|
|
|
|
///-- #include <tqtooltip.h>
|
|
|
|
|
///-- #include <tqtranslator.h>
|
|
|
|
|
///-- #include <tqlocale.h>
|
|
|
|
|
///-- #include <tqtextcodec.h>
|
|
|
|
|
///-- #include <tqdate.h>
|
|
|
|
|
///-- #include <tqurl.h>
|
|
|
|
@ -65,6 +66,7 @@
|
|
|
|
|
|
|
|
|
|
// \defgroup grp_MainWindow All concerning main window functionality.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
\class MainWindow
|
|
|
|
|
\ingroup grp_MainWindow
|
|
|
|
@ -79,24 +81,25 @@
|
|
|
|
|
\brief Constructs the main window.
|
|
|
|
|
*/
|
|
|
|
|
MainWindow::MainWindow(TQString file2OpenOnStart, TQWidget *parent) :
|
|
|
|
|
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)
|
|
|
|
|
MainWindowBase(parent), m_aboutDialog(nullptr), m_qSciSourceCodeEditor(nullptr),
|
|
|
|
|
m_qTranslator(nullptr), m_uiGuiTranslator(nullptr)
|
|
|
|
|
///- _mainWindowForm(nullptr), _settings(nullptr), _saveEncodedActionGroup(nullptr),
|
|
|
|
|
///- _highlighter(nullptr), _textEditVScrollBar(nullptr), _aboutDialogGraphicsView(
|
|
|
|
|
///- nullptr), _settingsDialog(nullptr), _encodingActionGroup(nullptr)
|
|
|
|
|
///- _highlighterActionGroup(nullptr), _toolBarWidget(
|
|
|
|
|
///- nullptr), _indentHandler(nullptr), _textEditLineColumnInfoLabel(nullptr)
|
|
|
|
|
{
|
|
|
|
|
// Init of some variables.
|
|
|
|
|
m_sourceCodeChanged = false;
|
|
|
|
|
|
|
|
|
|
// Create the _settings object, which loads all UiGui settings from a file.
|
|
|
|
|
m_settings = UiGuiSettings::getInstance();
|
|
|
|
|
///--
|
|
|
|
|
///-- // Initialize the language of the application.
|
|
|
|
|
///-- initApplicationLanguage();
|
|
|
|
|
|
|
|
|
|
// Initialize the language of the application.
|
|
|
|
|
initApplicationLanguage();
|
|
|
|
|
|
|
|
|
|
// Creates the main window and initializes it.
|
|
|
|
|
initMainWindow();
|
|
|
|
|
initMainWindow();
|
|
|
|
|
|
|
|
|
|
// Create toolbar and insert it into the main window.
|
|
|
|
|
initToolBar();
|
|
|
|
@ -224,7 +227,6 @@ void MainWindow::initMainWindow()
|
|
|
|
|
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)));
|
|
|
|
|
|
|
|
|
@ -356,76 +358,75 @@ void MainWindow::initToolBar()
|
|
|
|
|
///-- _settings->registerObjectProperty(actionEnableSyntaxHighlighting, "checked",
|
|
|
|
|
///-- "SyntaxHighlightingEnabled");
|
|
|
|
|
///-- }
|
|
|
|
|
///--
|
|
|
|
|
///-- /*
|
|
|
|
|
///-- \brief Initializes the language of UniversalIndentGUI.
|
|
|
|
|
///--
|
|
|
|
|
///-- If the program language is defined in the _settings, the corresponding language
|
|
|
|
|
///-- file will be loaded and set for the application. If not set there, the system
|
|
|
|
|
///-- default language will be set, if a translation file for that language exists.
|
|
|
|
|
///-- Returns true, if the translation file could be loaded. Otherwise it returns
|
|
|
|
|
///-- false and uses the default language, which is English.
|
|
|
|
|
///-- */
|
|
|
|
|
///-- bool MainWindow::initApplicationLanguage()
|
|
|
|
|
///-- {
|
|
|
|
|
///-- TQString languageShort;
|
|
|
|
|
///--
|
|
|
|
|
///-- // Get the language _settings from the _settings object.
|
|
|
|
|
///-- int languageIndex = _settings->getValueByName("language").toInt();
|
|
|
|
|
///--
|
|
|
|
|
///-- // If no language was set, indicated by a negative index, use the system language.
|
|
|
|
|
///-- if (languageIndex < 0)
|
|
|
|
|
///-- {
|
|
|
|
|
///-- languageShort = TQLocale::system().name();
|
|
|
|
|
///--
|
|
|
|
|
///-- // Chinese and Japanese language consist of country and language code.
|
|
|
|
|
///-- // For all others the language code will be cut off.
|
|
|
|
|
///-- if (languageShort.left(2) != "zh" && languageShort.left(2) != "ja")
|
|
|
|
|
///-- {
|
|
|
|
|
///-- languageShort = languageShort.left(2);
|
|
|
|
|
///-- }
|
|
|
|
|
///--
|
|
|
|
|
///-- // If no translation file for the systems local language exist, fall back to English.
|
|
|
|
|
///-- if (_settings->getAvailableTranslations().indexOf(languageShort) < 0)
|
|
|
|
|
///-- {
|
|
|
|
|
///-- languageShort = "en";
|
|
|
|
|
///-- }
|
|
|
|
|
///--
|
|
|
|
|
///-- // Set the language setting to the new language.
|
|
|
|
|
///-- _settings->setValueByName("language",
|
|
|
|
|
///-- _settings->getAvailableTranslations().indexOf(languageShort));
|
|
|
|
|
///-- }
|
|
|
|
|
///-- // If a language was defined in the _settings, get this language mnemonic.
|
|
|
|
|
///-- else
|
|
|
|
|
///-- {
|
|
|
|
|
///-- languageShort = _settings->getAvailableTranslations().at(languageIndex);
|
|
|
|
|
///-- }
|
|
|
|
|
///--
|
|
|
|
|
///-- // Load the TQt own translation file and set it for the application.
|
|
|
|
|
///-- _qTTranslator = new TQTranslator();
|
|
|
|
|
///-- bool translationFileLoaded;
|
|
|
|
|
///-- translationFileLoaded = _qTTranslator->load(
|
|
|
|
|
///-- SettingsPaths::getGlobalFilesPath() + "/translations/qt_" + languageShort);
|
|
|
|
|
///-- if (translationFileLoaded)
|
|
|
|
|
///-- {
|
|
|
|
|
///-- tqApp->installTranslator(_qTTranslator);
|
|
|
|
|
///-- }
|
|
|
|
|
///--
|
|
|
|
|
///-- // Load the uigui translation file and set it for the application.
|
|
|
|
|
///-- _uiGuiTranslator = new TQTranslator();
|
|
|
|
|
///-- translationFileLoaded = _uiGuiTranslator->load(
|
|
|
|
|
///-- SettingsPaths::getGlobalFilesPath() + "/translations/universalindent_" + languageShort);
|
|
|
|
|
///-- if (translationFileLoaded)
|
|
|
|
|
///-- {
|
|
|
|
|
///-- tqApp->installTranslator(_uiGuiTranslator);
|
|
|
|
|
///-- }
|
|
|
|
|
///--
|
|
|
|
|
///-- //connect( _settings, SIGNAL(language(int)), this, SLOT(languageChanged(int)) );
|
|
|
|
|
///-- _settings->registerObjectSlot(this, "languageChanged(int)", "language");
|
|
|
|
|
///--
|
|
|
|
|
///-- return translationFileLoaded;
|
|
|
|
|
///-- }
|
|
|
|
|
///--
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
\brief Initializes the language of UniversalIndentGUI.
|
|
|
|
|
|
|
|
|
|
If the program language is defined in the _settings, the corresponding language
|
|
|
|
|
file will be loaded and set for the application. If not set there, the system
|
|
|
|
|
default language will be set, if a translation file for that language exists.
|
|
|
|
|
Returns true, if the translation file could be loaded. Otherwise it returns
|
|
|
|
|
false and uses the default language, which is English.
|
|
|
|
|
*/
|
|
|
|
|
bool MainWindow::initApplicationLanguage()
|
|
|
|
|
{
|
|
|
|
|
TQString languageShort;
|
|
|
|
|
|
|
|
|
|
// Get the language settings from the settings object.
|
|
|
|
|
int languageIndex = m_settings->getValueByName("Language").toInt();
|
|
|
|
|
|
|
|
|
|
// If no language was set, indicated by a negative index, use the system language.
|
|
|
|
|
if (languageIndex < 0)
|
|
|
|
|
{
|
|
|
|
|
languageShort = TQLocale::system().name();
|
|
|
|
|
|
|
|
|
|
// Chinese and Japanese language consist of country and language code.
|
|
|
|
|
// For all others the language code will be cut off.
|
|
|
|
|
if (languageShort.left(2) != "zh" && languageShort.left(2) != "ja")
|
|
|
|
|
{
|
|
|
|
|
languageShort = languageShort.left(2);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// If no translation file for the systems local language exist, fall back to English.
|
|
|
|
|
if (m_settings->getAvailableTranslations().findIndex(languageShort) < 0)
|
|
|
|
|
{
|
|
|
|
|
languageShort = "en";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Set the language setting to the new language.
|
|
|
|
|
m_settings->setValueByName("Language",
|
|
|
|
|
m_settings->getAvailableTranslations().findIndex(languageShort));
|
|
|
|
|
}
|
|
|
|
|
// If a language was defined in the m_settings, get this language mnemonic.
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
languageShort = m_settings->getAvailableTranslations()[languageIndex];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Load the TQt own translation file and set it for the application.
|
|
|
|
|
m_qTranslator = new TQTranslator();
|
|
|
|
|
bool translationFileLoaded;
|
|
|
|
|
translationFileLoaded = m_qTranslator->load(SettingsPaths::getGlobalFilesPath() +
|
|
|
|
|
"/translations/qt_" + languageShort);
|
|
|
|
|
if (translationFileLoaded)
|
|
|
|
|
{
|
|
|
|
|
tqApp->installTranslator(m_qTranslator);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Load the uigui translation file and set it for the application.
|
|
|
|
|
m_uiGuiTranslator = new TQTranslator();
|
|
|
|
|
translationFileLoaded = m_uiGuiTranslator->load(SettingsPaths::getGlobalFilesPath() +
|
|
|
|
|
"/translations/universalindent_" + languageShort);
|
|
|
|
|
if (translationFileLoaded)
|
|
|
|
|
{
|
|
|
|
|
tqApp->installTranslator(m_uiGuiTranslator);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
connect(m_settings, SIGNAL(language(int)), this, SLOT(languageChanged(int)) );
|
|
|
|
|
|
|
|
|
|
return translationFileLoaded;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
///-- /*
|
|
|
|
|
///-- \brief Creates and initializes the indenter.
|
|
|
|
|
///-- */
|
|
|
|
@ -1166,42 +1167,42 @@ bool MainWindow::maybeSave()
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
///-- /*
|
|
|
|
|
///-- \brief This slot is called whenever a language is selected in the menu. It tries to find the
|
|
|
|
|
///-- corresponding action in the languageInfoList and sets the language.
|
|
|
|
|
///-- */
|
|
|
|
|
///-- void MainWindow::languageChanged(int languageIndex)
|
|
|
|
|
///-- {
|
|
|
|
|
///-- if (languageIndex < _settings->getAvailableTranslations().size())
|
|
|
|
|
///-- {
|
|
|
|
|
///-- // Get the mnemonic of the new selected language.
|
|
|
|
|
///-- TQString languageShort = _settings->getAvailableTranslations().at(languageIndex);
|
|
|
|
|
///--
|
|
|
|
|
///-- // Remove the old qt translation.
|
|
|
|
|
///-- tqApp->removeTranslator(_qTTranslator);
|
|
|
|
|
///--
|
|
|
|
|
///-- // Remove the old uigui translation.
|
|
|
|
|
///-- tqApp->removeTranslator(_uiGuiTranslator);
|
|
|
|
|
///--
|
|
|
|
|
///-- // Load the TQt own translation file and set it for the application.
|
|
|
|
|
///-- bool translationFileLoaded;
|
|
|
|
|
///-- translationFileLoaded = _qTTranslator->load(
|
|
|
|
|
///-- SettingsPaths::getGlobalFilesPath() + "/translations/qt_" + languageShort);
|
|
|
|
|
///-- if (translationFileLoaded)
|
|
|
|
|
///-- {
|
|
|
|
|
///-- tqApp->installTranslator(_qTTranslator);
|
|
|
|
|
///-- }
|
|
|
|
|
///--
|
|
|
|
|
///-- // Load the uigui translation file and set it for the application.
|
|
|
|
|
///-- translationFileLoaded = _uiGuiTranslator->load(
|
|
|
|
|
///-- SettingsPaths::getGlobalFilesPath() + "/translations/universalindent_" + languageShort);
|
|
|
|
|
///-- if (translationFileLoaded)
|
|
|
|
|
///-- {
|
|
|
|
|
///-- tqApp->installTranslator(_uiGuiTranslator);
|
|
|
|
|
///-- }
|
|
|
|
|
///-- }
|
|
|
|
|
///-- }
|
|
|
|
|
///--
|
|
|
|
|
/*
|
|
|
|
|
\brief This slot is called whenever a language is selected in the menu. It tries to find the
|
|
|
|
|
corresponding action in the languageInfoList and sets the language.
|
|
|
|
|
*/
|
|
|
|
|
void MainWindow::languageChanged(int languageIndex)
|
|
|
|
|
{
|
|
|
|
|
if (languageIndex >= 0 && languageIndex < m_settings->getAvailableTranslations().size())
|
|
|
|
|
{
|
|
|
|
|
// Get the mnemonic of the new selected language.
|
|
|
|
|
TQString languageShort = m_settings->getAvailableTranslations()[languageIndex];
|
|
|
|
|
|
|
|
|
|
// Remove the old qt translation.
|
|
|
|
|
tqApp->removeTranslator(m_qTranslator);
|
|
|
|
|
|
|
|
|
|
// Remove the old uigui translation.
|
|
|
|
|
tqApp->removeTranslator(m_uiGuiTranslator);
|
|
|
|
|
|
|
|
|
|
// Load the TQt own translation file and set it for the application.
|
|
|
|
|
bool translationFileLoaded;
|
|
|
|
|
translationFileLoaded = m_qTranslator->load(SettingsPaths::getGlobalFilesPath() +
|
|
|
|
|
"/translations/qt_" + languageShort);
|
|
|
|
|
if (translationFileLoaded)
|
|
|
|
|
{
|
|
|
|
|
tqApp->installTranslator(m_qTranslator);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Load the uigui translation file and set it for the application.
|
|
|
|
|
translationFileLoaded = m_uiGuiTranslator->load(SettingsPaths::getGlobalFilesPath() +
|
|
|
|
|
"/translations/universalindent_" + languageShort);
|
|
|
|
|
if (translationFileLoaded)
|
|
|
|
|
{
|
|
|
|
|
tqApp->installTranslator(m_uiGuiTranslator);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
///-- /*
|
|
|
|
|
///-- \brief Creates a menu entries in the file menu for opening and saving a file with different encodings.
|
|
|
|
|
///-- */
|
|
|
|
|