From dd4c8a461d88cbbba745f4de76eed75a9a8e4cfe Mon Sep 17 00:00:00 2001 From: Michele Calgaro Date: Mon, 7 Aug 2023 12:47:45 +0900 Subject: [PATCH] Added UiGuiSettingsDialog Signed-off-by: Michele Calgaro --- icons/CMakeLists.txt | 13 +- icons/__TODO/language-zh_CN.png | Bin 472 -> 0 bytes .../{__TODO => }/accessories-text-editor.png | Bin icons/{__TODO => }/applications-system.png | Bin icons/{__TODO => }/language-de.png | Bin icons/{__TODO => }/language-en.png | Bin icons/{__TODO => }/language-fr.png | Bin icons/{__TODO => }/language-ja.png | Bin icons/{__TODO => }/language-ru.png | Bin icons/{__TODO => }/language-uk.png | Bin icons/{__TODO => }/language-zh_TW.png | Bin src/AboutDialogBase.ui | 218 ++++----- src/CMakeLists.txt | 4 +- src/MainWindow.cpp | 124 ++--- src/MainWindow.h | 9 +- src/MainWindowBase.ui | 42 +- src/ToolBarWidget.ui | 228 ++++----- src/UiGuiSettings.cpp | 12 +- src/UiGuiSettings.h | 7 +- src/UiGuiSettingsDialog.cpp | 218 +++++++++ src/{__TODO => }/UiGuiSettingsDialog.h | 25 +- src/UiGuiSettingsDialogBase.ui | 338 +++++++++++++ src/__TODO/UiGuiSettingsDialog.cpp | 205 -------- src/__TODO/UiGuiSettingsDialog.ui | 460 ------------------ 24 files changed, 876 insertions(+), 1027 deletions(-) delete mode 100755 icons/__TODO/language-zh_CN.png rename icons/{__TODO => }/accessories-text-editor.png (100%) rename icons/{__TODO => }/applications-system.png (100%) rename icons/{__TODO => }/language-de.png (100%) rename icons/{__TODO => }/language-en.png (100%) rename icons/{__TODO => }/language-fr.png (100%) rename icons/{__TODO => }/language-ja.png (100%) rename icons/{__TODO => }/language-ru.png (100%) rename icons/{__TODO => }/language-uk.png (100%) rename icons/{__TODO => }/language-zh_TW.png (100%) create mode 100644 src/UiGuiSettingsDialog.cpp rename src/{__TODO => }/UiGuiSettingsDialog.h (79%) create mode 100755 src/UiGuiSettingsDialogBase.ui delete mode 100644 src/__TODO/UiGuiSettingsDialog.cpp delete mode 100755 src/__TODO/UiGuiSettingsDialog.ui diff --git a/icons/CMakeLists.txt b/icons/CMakeLists.txt index 9e83cf4..08b954e 100644 --- a/icons/CMakeLists.txt +++ b/icons/CMakeLists.txt @@ -1,5 +1,7 @@ install( FILES + accessories-text-editor.png + applications-system.png banner.png document-open.png document-properties.png @@ -8,10 +10,17 @@ install( edit-clear.png exporthtml.png exportpdf.png - help.png + help.png info.png + language-de.png + language-en.png + language-fr.png + language-ja.png + language-ru.png + language-uk.png + language-zh_TW.png live-preview.png - load_indent_cfg.png + load_indent_cfg.png preferences-system.png save_indent_cfg.png shell.png diff --git a/icons/__TODO/language-zh_CN.png b/icons/__TODO/language-zh_CN.png deleted file mode 100755 index 89144146219e6fbec7eaa89e1bf4b073d299569e..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 472 zcmV;}0Vn>6P)$bmtfBa_T{rmsVufH!rO2O)W0!b+P{TrwO zAb?mv&i(NBbu;G`sX*)cv$d*%>MiL-(QdhpkjakVmyu%k;sfcNRj;yhJaxT5MTg0u5&QfH8#Bf O0000 - AboutDialogBase - + AboutDialogBase + AboutDialogBase - - - 0 - 0 - 588 - 512 - - - - - 0 - 5 - 0 - 0 - - - - - 588 - 333 - - - - About UniversalIndentGUI - - - - 0 - - - - frame - - - StyledPanel - - - - - bannerLabel - - - - 0 - 0 - 0 - 0 - - - - - 570 - 87 - - - - - 570 - 87 - - - - - - - - - - spacer1 - - - TQt::Horizontal - - - - 40 - 20 - - - - - - okButton - - - OK - - - - - spacer2 - - - TQt::Horizontal - - - - 40 - 20 - - - - - - - - + + + 0 + 0 + 588 + 512 + + + + + 0 + 5 + 0 + 0 + + + + + 588 + 333 + + + + About UniversalIndentGUI + + + + 0 + + + + frame + + + StyledPanel + + + + + bannerLabel + + + + 0 + 0 + 0 + 0 + + + + + 570 + 87 + + + + + 570 + 87 + + + + + + + + + + spacer1 + + + TQt::Horizontal + + + + 40 + 20 + + + + + + okButton + + + OK + + + + + spacer2 + + + TQt::Horizontal + + + + 40 + 20 + + + + + + + + diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 7d5f6b4..901feca 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -30,6 +30,7 @@ set( ${target}_SRCS MainWindowBase.ui ToolBarWidget.ui + IndentHandler.cpp SettingsPaths.cpp TemplateBatchScript.cpp UiGuiErrorMessage.cpp @@ -38,12 +39,13 @@ set( ${target}_SRCS # ongoing AboutDialogBase.ui + UiGuiSettingsDialogBase.ui AboutDialog.cpp - IndentHandler.cpp MainWindow.cpp main.cpp UiGuiSettings.cpp + UiGuiSettingsDialog.cpp ) tde_add_executable( ${target} AUTOMOC diff --git a/src/MainWindow.cpp b/src/MainWindow.cpp index c945da4..899a029 100644 --- a/src/MainWindow.cpp +++ b/src/MainWindow.cpp @@ -28,10 +28,10 @@ #include "IndentHandler.h" #include "SettingsPaths.h" #include "UiGuiSettings.h" +#include "UiGuiSettingsDialog.h" #include "UiGuiVersion.h" #include "ToolBarWidget.h" ///-- #include "AboutDialogGraphicsView.h" -///-- #include "UiGuiSettingsDialog.h" ///-- #include "UiGuiHighlighter.h" #include @@ -50,22 +50,10 @@ #include #include #include +#include #include #include -///-- #include -///-- #include -///-- #include -///-- #include -///-- #include -///-- #include -///-- #include -///-- #include -///-- #include -///-- #include -///-- #include -///-- #include -///-- #include -///-- + #include ///-- #include ///-- @@ -89,13 +77,12 @@ */ MainWindow::MainWindow(TQString file2OpenOnStart, TQWidget *parent) : MainWindowBase(parent), m_aboutDialog(nullptr), m_qSciSourceCodeEditor(nullptr), - m_qTranslator(nullptr), m_uiGuiTranslator(nullptr), m_textEditLineColumnInfoLabel(nullptr), + m_uiGuiTranslator(nullptr), m_textEditLineColumnInfoLabel(nullptr), m_oldLinesNumber(0), m_openEncodingActions(), m_saveEncodingActions(), m_encodingActionGroup(nullptr), m_saveEncodedActionGroup(nullptr), m_highlighterActionGroup(nullptr), m_documentModified(false), m_previewToggled(true), - m_indentHandler(nullptr), m_centralSplitter(nullptr) -///- _mainWindowForm(nullptr), _settings(nullptr) -///- m_highlighter(nullptr), _aboutDialogGraphicsView(nullptr), _settingsDialog(nullptr) + m_indentHandler(nullptr), m_centralSplitter(nullptr), m_settingsDialog(nullptr) +///- m_highlighter(nullptr), _aboutDialogGraphicsView(nullptr) ///- m_textEditVScrollBar(nullptr), _toolBarWidget(nullptr) { // Init of some variables. @@ -133,10 +120,9 @@ MainWindow::MainWindow(TQString file2OpenOnStart, TQWidget *parent) : ///-- _aboutDialogGraphicsView = new AboutDialogGraphicsView(m_aboutDialog, this); connect(actionAboutUniversalIndentGUITQt, SIGNAL(activated()), this, SLOT(showAboutDialog())); -///-- // Generate settings dialog box -///-- _settingsDialog = new UiGuiSettingsDialog(this, _settings); -///-- connect(actionShowSettings, SIGNAL(activated()), _settingsDialog, -///-- SLOT(showDialog())); + // Generate settings dialog box + m_settingsDialog = new UiGuiSettingsDialog(this, m_settings); + connect(actionShowSettings, SIGNAL(activated()), m_settingsDialog, SLOT(showDialog())); if (TQFile::exists(file2OpenOnStart)) { @@ -157,6 +143,7 @@ MainWindow::MainWindow(TQString file2OpenOnStart, TQWidget *parent) : MainWindow::~MainWindow() { + delete m_settingsDialog; delete m_aboutDialog; UiGuiSettings::deleteInstance(); } @@ -254,6 +241,8 @@ void MainWindow::initMainWindow() connect(actionSaveSourceFileAs, SIGNAL(activated()), this, SLOT(saveasSourceFileDialog())); connect(actionExportPDF, SIGNAL(activated()), this, SLOT(exportToPDF())); connect(actionExportHTML, SIGNAL(activated()), this, SLOT(exportToHTML())); + connect(m_settings, SIGNAL(indenterParameterTooltipsEnabled(bool)), + this, SLOT(setIndenterParameterTooltips(bool))); ///-- connect(actionShowLog, SIGNAL(activated()), ///-- debugging::TSLogger::getInstance(), SLOT(show())); @@ -265,9 +254,7 @@ void MainWindow::initMainWindow() this, SLOT(recentlyOpenedFileHighlighted(int))); connect(popupMenuRecentlyOpenedFiles, SIGNAL(activated(int)), this, SLOT(openFileFromRecentlyOpenedList(int))); -///-- //connect( _settings, SIGNAL(recentlyOpenedListSize(int)), this, SLOT(updateRecentlyOpenedList()) -///-- // ); -///-- _settings->registerObjectSlot(this, "updateRecentlyOpenedList()", "recentlyOpenedListSize"); + connect(m_settings, SIGNAL(recentlyOpenedListSize(int)), this, SLOT(updateRecentlyOpenedList())); updateWindowTitle(); } @@ -387,7 +374,7 @@ void MainWindow::initSyntaxHighlighter() /* \brief Initializes the language of UniversalIndentGUI. - If the program language is defined in the _settings, the corresponding language + If the program language is defined in the m_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 @@ -429,19 +416,10 @@ bool MainWindow::initApplicationLanguage() } // 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); + bool translationFileLoaded = m_uiGuiTranslator->load(SettingsPaths::getGlobalFilesPath() + + "/translations/universalindent_" + languageShort + ".qm"); if (translationFileLoaded) { tqApp->installTranslator(m_uiGuiTranslator); @@ -1102,34 +1080,6 @@ void MainWindow::closeEvent(TQCloseEvent *event) } } -///-- /* -///-- \brief This function is setup to capture tooltip events. -///-- -///-- All widgets that are created by the m_indentHandler object and are responsible -///-- for indenter parameters are connected with this event filter. -///-- So depending on the _settings the tooltips can be enabled and disabled for these widgets. -///-- */ -///-- bool MainWindow::eventFilter(TQObject *obj, TQEvent *event) -///-- { -///-- if (event->type() == TQEvent::ToolTip) -///-- { -///-- if (actionIndenterParameterTooltipsEnabled->isOn()) -///-- { -///-- return TQMainWindow::eventFilter(obj, event); -///-- } -///-- else -///-- { -///-- //TQToolTip::showText( TQPoint(100,100) , "Test1"); -///-- return true; -///-- } -///-- } -///-- else -///-- { -///-- // pass the event on to the parent class -///-- return TQMainWindow::eventFilter(obj, event); -///-- } -///-- } - /* \brief Is called at application exit and asks whether to save the source code file, if it has been changed. @@ -1164,24 +1114,12 @@ void MainWindow::languageChanged(int languageIndex) // 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); + bool translationFileLoaded = m_uiGuiTranslator->load(SettingsPaths::getGlobalFilesPath() + + "/translations/universalindent_" + languageShort + ".qm"); if (translationFileLoaded) { tqApp->installTranslator(m_uiGuiTranslator); @@ -1336,6 +1274,14 @@ void MainWindow::setWhiteSpaceVisibility(bool visible) } } +/* + \brief Is called whenever the tooltip visibility is being changed in the settings. + */ +void MainWindow::setIndenterParameterTooltips(bool enabled) +{ + TQToolTip::setGloballyEnabled(enabled); +} + /* \brief This slot is called whenever the number of lines in the editor changes and adapts the margin for the displayed line numbers. @@ -1453,6 +1399,9 @@ void MainWindow::initRecentlyOpenedList() */ void MainWindow::updateRecentlyOpenedList() { + // Make sure to read the currnt max size settings + m_recentlyOpenedListMaxSize = m_settings->getValueByName("RecentlyOpenedListSize").toInt(); + TQString fileName; TQString filePath; @@ -1472,22 +1421,23 @@ void MainWindow::updateRecentlyOpenedList() -1, 0); popupMenuRecentlyOpenedFiles->setWhatsThis(id, m_currentSourceFile); } - // Put the current file at the first position if it not already is and is not empty. + // Put the current file at the first position if it was not in the list else if (currentFileIndex == -1) { m_recentlyOpenedList.prepend(m_currentSourceFile); int id = popupMenuRecentlyOpenedFiles->insertItem(TQFileInfo(m_currentSourceFile).fileName(), -1, 0); popupMenuRecentlyOpenedFiles->setWhatsThis(id, m_currentSourceFile); - // Trim the last element if we have reached the max allowed size - if (m_recentlyOpenedList.size() > m_recentlyOpenedListMaxSize) - { - m_recentlyOpenedList.pop_back(); - popupMenuRecentlyOpenedFiles->removeItemAt(m_recentlyOpenedListMaxSize); - } } } + // Trim excessive elements if the size has shrinked + while (m_recentlyOpenedList.size() > m_recentlyOpenedListMaxSize) + { + m_recentlyOpenedList.pop_back(); + popupMenuRecentlyOpenedFiles->removeItemAt(m_recentlyOpenedListMaxSize); + } + // Enable or disable "actionClearRecentlyOpenedList" actionClearRecentlyOpenedList->setEnabled(!m_recentlyOpenedList.isEmpty()); } diff --git a/src/MainWindow.h b/src/MainWindow.h index 4b500af..2236c5b 100644 --- a/src/MainWindow.h +++ b/src/MainWindow.h @@ -25,14 +25,14 @@ #include "tqvaluelist.h" -/// class UiGuiSettingsDialog; class AboutDialog; /// class AboutDialogGraphicsView; /// class UiGuiHighlighter; class IndentHandler; class UiGuiSettings; +class UiGuiSettingsDialog; class ToolBarWidget; -/// + /// class TQActionGroup; class TQextScintilla; class TQSplitter; @@ -52,7 +52,6 @@ class MainWindow : public MainWindowBase protected: void closeEvent(TQCloseEvent *event); -///-- bool eventFilter(TQObject *obj, TQEvent *event); private slots: void openSourceFileDialog(const TQString &fileName = TQString::null); @@ -63,6 +62,7 @@ class MainWindow : public MainWindowBase void updateSourceView(); void turnHighlightOnOff(bool turnOn); void setWhiteSpaceVisibility(bool visible); + void setIndenterParameterTooltips(bool enabled); void sourceCodeChangedHelperSlot(); void sourceCodeChangedSlot(); void indentSettingsChangedSlot(); @@ -110,7 +110,7 @@ class MainWindow : public MainWindowBase ///-- TQScrollBar *m_textEditVScrollBar; AboutDialog *m_aboutDialog; ///-- AboutDialogGraphicsView *_aboutDialogGraphicsView; -///-- UiGuiSettingsDialog *_settingsDialog; + UiGuiSettingsDialog *m_settingsDialog; int m_actionClearRecentlyOpenedListId; int m_recentlyOpenedListMaxSize; ///-- int _textEditLastScrollPos; @@ -126,7 +126,6 @@ class MainWindow : public MainWindowBase TQValueList m_openEncodingActions; TQValueList m_saveEncodingActions; TQTranslator *m_uiGuiTranslator; - TQTranslator *m_qTranslator; bool m_sourceCodeChanged; bool m_indentSettingsChanged; diff --git a/src/MainWindowBase.ui b/src/MainWindowBase.ui index 48679d6..720e8aa 100755 --- a/src/MainWindowBase.ui +++ b/src/MainWindowBase.ui @@ -70,27 +70,27 @@ - - - - toolBar - - - Tools - - - TQt::Horizontal - - - - 5 - 5 - 1 - 1 - - - - + + + + toolBar + + + Tools + + + TQt::Horizontal + + + + 5 + 5 + 1 + 1 + + + + diff --git a/src/ToolBarWidget.ui b/src/ToolBarWidget.ui index 25663c2..14ebc8c 100755 --- a/src/ToolBarWidget.ui +++ b/src/ToolBarWidget.ui @@ -1,116 +1,116 @@ - ToolBarWidget - - - ToolBarWidget - - - - 0 - 0 - 773 - 34 - - - - Form - - - - unnamed - - - 6 - - - 0 - - - - pbOpenSourceFile - - - Open Source File - - - Opens a dialog for selecting a source code file - - - - - cbLivePreview - - - Live Indent Preview - - - Turns the preview of the reformatted source code on and off - - - Ctrl+L - - - - - cbEnableSyntaxHL - - - Syntax Highlight - - - Enables and disables the highlighting of the source - - - Ctrl+H - - - true - - - - - spacer1 - - - TQt::Horizontal - - - - 2000 - 20 - - - - - 5 - 5 - 1 - 1 - - - - - - pbAbout - - - About - - - Shows info about UniversalIndentGUI - - - - - pbExit - - - Exit - - - Quits UniversalIndentGUI - - - - + ToolBarWidget + + + ToolBarWidget + + + + 0 + 0 + 773 + 34 + + + + Form + + + + unnamed + + + 6 + + + 0 + + + + pbOpenSourceFile + + + Open Source File + + + Opens a dialog for selecting a source code file + + + + + cbLivePreview + + + Live Indent Preview + + + Turns the preview of the reformatted source code on and off + + + Ctrl+L + + + + + cbEnableSyntaxHL + + + Syntax Highlight + + + Enables and disables the highlighting of the source + + + Ctrl+H + + + true + + + + + spacer1 + + + TQt::Horizontal + + + + 2000 + 20 + + + + + 5 + 5 + 1 + 1 + + + + + + pbAbout + + + About + + + Shows info about UniversalIndentGUI + + + + + pbExit + + + Exit + + + Quits UniversalIndentGUI + + + + diff --git a/src/UiGuiSettings.cpp b/src/UiGuiSettings.cpp index 0f4ae72..c3fccbb 100644 --- a/src/UiGuiSettings.cpp +++ b/src/UiGuiSettings.cpp @@ -112,7 +112,7 @@ void UiGuiSettings::readAvailableTranslations() // Find all translation files in the "translations" directory. TQDir translationDirectory = TQDir(SettingsPaths::getGlobalFilesPath() + "/translations"); - for (TQString &file : translationDirectory.entryList(TQString("universalindent_*.qm"))) + for (const TQString &file : translationDirectory.entryList(TQString("universalindent_*.qm"))) { languageFileList << file; } @@ -348,7 +348,11 @@ void UiGuiSettings::handleValueChangeFromExtern(bool value) void UiGuiSettings::emitSignalForSetting(TQString settingName) { // Emit the signal for the changed value. - if (settingName == "LoadLastOpenedFileOnStartup") + if (settingName == "RecentlyOpenedListSize") + { + emit recentlyOpenedListSize(m_settings[settingName].toInt()); + } + else if (settingName == "LoadLastOpenedFileOnStartup") { emit loadLastOpenedFileOnStartup(m_settings[settingName].toBool()); } @@ -360,6 +364,10 @@ void UiGuiSettings::emitSignalForSetting(TQString settingName) { emit whiteSpaceIsVisible(m_settings[settingName].toBool()); } + else if (settingName == "IndenterParameterTooltipsEnabled") + { + emit indenterParameterTooltipsEnabled(m_settings[settingName].toBool()); + } else if (settingName == "TabWidth") { emit tabWidth(m_settings[settingName].toInt()); diff --git a/src/UiGuiSettings.h b/src/UiGuiSettings.h index df9d04f..99137b5 100644 --- a/src/UiGuiSettings.h +++ b/src/UiGuiSettings.h @@ -71,9 +71,8 @@ class UiGuiSettings : public TQObject // [--] bool (UiGuiSettings::*callBackFunc)(TQObject *obj, const TQString &propertyName, // [--] const TQString &settingName)); // [--] -// [--] private slots: + private slots: // [--] void handleObjectPropertyChange(); -// [++] void handleValueChangeFromExtern(int value); void handleValueChangeFromExtern(bool value); // [++] void handleValueChangeFromExtern(TQDate value); // [++] void handleValueChangeFromExtern(TQByteArray value); @@ -86,13 +85,13 @@ class UiGuiSettings : public TQObject // [++] void windowPosition(TQPoint value); // [++] void windowSize(TQSize value); // [++] void fileEncoding(TQString value); -// [++] void recentlyOpenedListSize(int value); + void recentlyOpenedListSize(int value); void loadLastOpenedFileOnStartup(bool value); // [++] void lastOpenedFiles(TQString value); // [++] void selectedIndenter(int value); void syntaxHighlightingEnabled(bool value); void whiteSpaceIsVisible(bool value); -// [++] void indenterParameterTooltipsEnabled(bool value); + void indenterParameterTooltipsEnabled(bool value); void tabWidth(int value); void language(int value); // [++] void lastUpdateCheck(TQDate value); diff --git a/src/UiGuiSettingsDialog.cpp b/src/UiGuiSettingsDialog.cpp new file mode 100644 index 0000000..8eb5783 --- /dev/null +++ b/src/UiGuiSettingsDialog.cpp @@ -0,0 +1,218 @@ +/*************************************************************************** +* Copyright (C) 2006-2012 by Thomas Schweitzer * +* thomas-schweitzer(at)arcor.de * +* * +* This program is free software; you can redistribute it and/or modify * +* it under the terms of the GNU General Public License version 2.0 as * +* published by the Free Software Foundation. * +* * +* This program is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU General Public License for more details. * +* * +* You should have received a copy of the GNU General Public License * +* along with this program in the file LICENSE.GPL; if not, write to the * +* Free Software Foundation, Inc., * +* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * +***************************************************************************/ + +#include "config.h" + +#include "UiGuiSettingsDialog.h" +#include "UiGuiSettings.h" + +#include +#include +#include +#include +#include + +/* + \class UiGuiSettingsDialog + \ingroup grp_Settings + \brief Displays a dialog window with settings for UniversalIndentGUI +*/ + +/* + \brief The constructor calls the setup function for the ui created by uic. +*/ +UiGuiSettingsDialog::UiGuiSettingsDialog(TQWidget *parent, UiGuiSettings *settings) : + UiGuiSettingsDialogBase(parent) +{ + // Remember pointer to the UiGuiSettings object. + m_settings = settings; + + // For icon setup + const TQString ICONS_PATH(APP_ICONS_PATH); + // Application icon + setIcon(TQPixmap(ICONS_PATH + "preferences-system.png")); + + tabWidget->setTabIconSet(tabCommon, TQPixmap(ICONS_PATH + "applications-system.png")); + tabWidget->setTabIconSet(tabEditor, TQPixmap(ICONS_PATH + "accessories-text-editor.png")); + tabWidget->setTabIconSet(tabSyntaxHighlight, TQPixmap(ICONS_PATH + "syntax-highlight.png")); + + // Init the language selection combobox. + initTranslationSelection(); +} + +/* + \brief By calling this function the combobox for selecting the application language will + be initialized. + + Also the translation itself will be reinitialized. + */ +void UiGuiSettingsDialog::initTranslationSelection() +{ + // For icon setup + const TQString ICONS_PATH(APP_ICONS_PATH); + + // First empty the combo box. + cmbBoxLanguageSelection->clear(); + + // Now add an entry into the box for every language short. + for (const TQString &languageShort : m_settings->getAvailableTranslations()) + { + // Identify the language mnemonic and set the full name. + if (languageShort == "en") + { + cmbBoxLanguageSelection->insertItem(TQPixmap(ICONS_PATH + "language-en.png"), tr("English")); + } + else if (languageShort == "fr") + { + cmbBoxLanguageSelection->insertItem(TQPixmap(ICONS_PATH + "language-fr.png"), tr("French")); + } + else if (languageShort == "de") + { + cmbBoxLanguageSelection->insertItem(TQPixmap(ICONS_PATH + "language-de.png"), tr("German")); + } + else if (languageShort == "zh_TW") + { + cmbBoxLanguageSelection->insertItem(TQPixmap(ICONS_PATH + "language-zh_TW.png"), + tr("Chinese (Taiwan)")); + } + else if (languageShort == "ja") + { + cmbBoxLanguageSelection->insertItem(TQPixmap(ICONS_PATH + "language-ja.png"), tr("Japanese")); + } + else if (languageShort == "ru") + { + cmbBoxLanguageSelection->insertItem(TQPixmap(ICONS_PATH + "language-ru.png"), tr("Russian")); + } + else if (languageShort == "uk") + { + cmbBoxLanguageSelection->insertItem(TQPixmap(ICONS_PATH + "language-uk.png"), tr("Ukrainian")); + } + } +} + +/* + \brief Displays the dialog by calling the dialogs exec function. + + Before it gets all the values needed from the UiGuiSettings object. + */ +void UiGuiSettingsDialog::showDialog() +{ + // Init all settings dialog objects with values from settings. + cbLoadLastOpenedFileOnStartup->setChecked( + m_settings->getValueByName("LoadLastOpenedFileOnStartup").toBool()); + cbEnableIndenterParameterTooltips->setChecked( + m_settings->getValueByName("IndenterParameterTooltipsEnabled").toBool()); + cbWhiteSpaceIsVisible->setChecked( + m_settings->getValueByName("WhiteSpaceIsVisible").toBool()); + cbEnableSyntaxHL->setChecked( + m_settings->getValueByName("SyntaxHighlightingEnabled").toBool()); + sbRecentlyOpenedListSize->setValue(m_settings->getValueByName("RecentlyOpenedListSize").toInt()); + sbTabWidth->setValue(m_settings->getValueByName("TabWidth").toInt()); + + // Execute the dialog. + if (exec() == TQDialog::Accepted) + { + updateSettings(); + } +} + +/* + \brief This slot is called when the dialog box is closed by pressing the Ok button. + + Writes all settings to the UiGuiSettings object. + */ +void UiGuiSettingsDialog::updateSettings() +{ + m_settings->setValueByName("LoadLastOpenedFileOnStartup", + cbLoadLastOpenedFileOnStartup->isChecked()); + m_settings->setValueByName("IndenterParameterTooltipsEnabled", + cbEnableIndenterParameterTooltips->isChecked()); + m_settings->setValueByName("RecentlyOpenedListSize", sbRecentlyOpenedListSize->value()); + m_settings->setValueByName("WhiteSpaceIsVisible", cbWhiteSpaceIsVisible->isChecked()); + m_settings->setValueByName("TabWidth", sbTabWidth->value()); + m_settings->setValueByName("SyntaxHighlightingEnabled", cbEnableSyntaxHL->isChecked()); +} + +//--- /* +//--- \brief Catches language change events and retranslates all needed widgets. +//--- */ +//--- void UiGuiSettingsDialog::changeEvent(TQEvent *event) +//--- { +//--- if (event->type() == TQEvent::LanguageChange) +//--- { +//--- retranslateUi(this); +//--- // If this is not explicit set here, TQt < 4.3.0 does not translate the buttons. +//--- buttonBox->setStandardButtons( +//--- TQDialogButtonBox::Cancel | TQDialogButtonBox::NoButton | TQDialogButtonBox::Ok); +//--- +//--- //TODO: This has to be removed when the properties for the highlighters can be set. +//--- groupBoxSyntaxHighlighterProperties->setToolTip( +//--- "(Will be implemented soon)" + +//--- groupBoxSyntaxHighlighterProperties->toolTip()); +//--- +//--- TQStringList languageShortList = _settings->getAvailableTranslations(); +//--- +//--- // Now retranslate every entry in the language selection box. +//--- for (int i = 0; i < languageShortList.size(); i++) +//--- { +//--- TQString languageShort = languageShortList.at(i); +//--- +//--- // Identify the language mnemonic and set the full name. +//--- if (languageShort == "en") +//--- { +//--- cmbBoxLanguageSelection->setItemText(i, tr("English")); +//--- } +//--- else if (languageShort == "fr") +//--- { +//--- cmbBoxLanguageSelection->setItemText(i, tr("French")); +//--- } +//--- else if (languageShort == "de") +//--- { +//--- cmbBoxLanguageSelection->setItemText(i, tr("German")); +//--- } +//--- else if (languageShort == "zh_TW") +//--- { +//--- cmbBoxLanguageSelection->setItemText(i, tr("Chinese (Taiwan)")); +//--- } +//--- else if (languageShort == "ja") +//--- { +//--- cmbBoxLanguageSelection->setItemText(i, tr("Japanese")); +//--- } +//--- else if (languageShort == "ru") +//--- { +//--- cmbBoxLanguageSelection->setItemText(i, tr("Russian")); +//--- } +//--- else if (languageShort == "uk") +//--- { +//--- cmbBoxLanguageSelection->setItemText(i, tr("Ukrainian")); +//--- } +//--- else +//--- { +//--- cmbBoxLanguageSelection->setItemText(i, +//--- tr("Unknown language mnemonic ") + languageShort); +//--- } +//--- } +//--- } +//--- else +//--- { +//--- TQWidget::changeEvent(event); +//--- } +//--- } + +#include "UiGuiSettingsDialog.moc" diff --git a/src/__TODO/UiGuiSettingsDialog.h b/src/UiGuiSettingsDialog.h similarity index 79% rename from src/__TODO/UiGuiSettingsDialog.h rename to src/UiGuiSettingsDialog.h index eef08d6..5ef33c2 100644 --- a/src/__TODO/UiGuiSettingsDialog.h +++ b/src/UiGuiSettingsDialog.h @@ -20,36 +20,27 @@ #ifndef UIGUISETTINGSDIALOG_H #define UIGUISETTINGSDIALOG_H -#include - #include "UiGuiSettings.h" +#include "UiGuiSettingsDialogBase.h" -namespace Ui -{ - class SettingsDialog; -} - - -class UiGuiSettingsDialog : public TQDialog +class UiGuiSettingsDialog : public UiGuiSettingsDialogBase { TQ_OBJECT public: - UiGuiSettingsDialog(TQWidget *parent, TQSharedPointer settings); + UiGuiSettingsDialog(TQWidget *parent, UiGuiSettings *settings); public slots: - int showDialog(); + void showDialog(); private slots: - void writeWidgetValuesToSettings(); + void updateSettings(); private: - Ui::SettingsDialog *_settingsDialogForm; - - void changeEvent(TQEvent *event); +//--- void changeEvent(TQEvent *event); void initTranslationSelection(); - TQSharedPointer _settings; + UiGuiSettings *m_settings; }; -#endif // UIGUISETTINGSDIALOG_H +#endif diff --git a/src/UiGuiSettingsDialogBase.ui b/src/UiGuiSettingsDialogBase.ui new file mode 100755 index 0000000..963f240 --- /dev/null +++ b/src/UiGuiSettingsDialogBase.ui @@ -0,0 +1,338 @@ + + UiGuiSettingsDialogBase + + + UiGuiSettingsDialogBase + + + + 0 + 0 + 503 + 336 + + + + Settings + + + + + tabWidget + + + 0 + + + + tabCommon + + + Common + + + + + + languageLabel + + + Application language + + + cmbBoxLanguageSelection + + + Choose UniversalIndentGui language. + + + + + cmbBoxLanguageSelection + + + + 0 + 0 + + + + Choose UniversalIndentGui language. + + + + + spacer8 + + + Horizontal + + + + 20 + 40 + + + + + + + cbLoadLastOpenedFileOnStartup + + + Automatically open last file on startup + + + If checked, reopen the last used source code file on startup. + + + + + cbEnableIndenterParameterTooltips + + + Enable Parameter Tooltips + + + If checked, tool tips will show up for the indenter parameters. + + + + + + labelRecentlyOpenedListSize + + + Number of files in recently opened list + + + sbRecentlyOpenedListSize + + + Sets number of files in the list of recently opened files. + + + + + sbRecentlyOpenedListSize + + + + 0 + 0 + + + + 30 + + + 1 + + + Sets number of files in the list of recently opened files. + + + + + spacer7 + + + Horizontal + + + + 20 + 40 + + + + + + + spacer6 + + + Vertical + + + + 20 + 40 + + + + + + + + tabEditor + + + Editor + + + + + cbWhiteSpaceIsVisible + + + Display white space character (tabs, spaces, etc.) + + + Enables or disables displaying of white space characters in the editor. + + + + + + labelTabWidth + + + Displayed width of tabs + + + sbTabWidth + + + Defines how many spaces should be displayed in the editor for one tab. + + + + + sbTabWidth + + + + 0 + 0 + + + + 99 + + + 1 + + + Defines how many spaces should be displayed in the editor for one tab. + + + + + spacer5 + + + Horizontal + + + + 20 + 40 + + + + + + + spacer4 + + + Vertical + + + + 20 + 40 + + + + + + + + tabSyntaxHighlight + + + Syntax Highlighting + + + + + cbEnableSyntaxHL + + + Enable syntax highlighting + + + By enabling special key words of the source code are highlighted. + + + + + spacer2 + + + Vertical + + + + 20 + 40 + + + + + + + + + + spacer1 + + + TQt::Horizontal + + + + 40 + 20 + + + + + + okButton + + + &Ok + + + true + + + + + cancelButton + + + &Cancel + + + + + + + + okButton + clicked() + UiGuiSettingsDialogBase + accept() + + + cancelButton + clicked() + UiGuiSettingsDialogBase + reject() + + + diff --git a/src/__TODO/UiGuiSettingsDialog.cpp b/src/__TODO/UiGuiSettingsDialog.cpp deleted file mode 100644 index 46fc535..0000000 --- a/src/__TODO/UiGuiSettingsDialog.cpp +++ /dev/null @@ -1,205 +0,0 @@ -/*************************************************************************** -* Copyright (C) 2006-2012 by Thomas Schweitzer * -* thomas-schweitzer(at)arcor.de * -* * -* This program is free software; you can redistribute it and/or modify * -* it under the terms of the GNU General Public License version 2.0 as * -* published by the Free Software Foundation. * -* * -* This program is distributed in the hope that it will be useful, * -* but WITHOUT ANY WARRANTY; without even the implied warranty of * -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * -* GNU General Public License for more details. * -* * -* You should have received a copy of the GNU General Public License * -* along with this program in the file LICENSE.GPL; if not, write to the * -* Free Software Foundation, Inc., * -* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * -***************************************************************************/ - -#include "UiGuiSettingsDialog.h" -#include "ui_UiGuiSettingsDialog.h" - -#include "UiGuiSettings.h" - -/* - \class UiGuiSettingsDialog - \ingroup grp_Settings - \brief Displays a dialog window with settings for UniversalIndentGUI -*/ - -/* - \brief The constructor calls the setup function for the ui created by uic. -*/ -UiGuiSettingsDialog::UiGuiSettingsDialog(TQWidget *parent, - TQSharedPointer settings) : - TQDialog(parent) -{ - // Remember pointer to the UiGuiSettings object. - _settings = settings; - - // Init the user interface created by the UIC. - _settingsDialogForm = new Ui::SettingsDialog(); - _settingsDialogForm->setupUi(this); - - //TODO: This call has to be removed when the properties for the highlighters can be set - // with the settings dialog. - _settingsDialogForm->groupBoxSyntaxHighlighterProperties->setToolTip( - "(Will be implemented soon)" + - _settingsDialogForm->groupBoxSyntaxHighlighterProperties->toolTip()); - - // Connect the accepted signal to own function, to write values back to the UiGuiSettings object. - connect(this, SIGNAL(accepted()), this, SLOT(writeWidgetValuesToSettings())); - - // Init the language selection combobox. - initTranslationSelection(); -} - -/* - \brief By calling this function the combobox for selecting the application language will - be initialized. - - Also the translation itself will be reinitialized. - */ -void UiGuiSettingsDialog::initTranslationSelection() -{ - // First empty the combo box. - _settingsDialogForm->languageSelectionComboBox->clear(); - - // Now add an entry into the box for every language short. - foreach(TQString languageShort, _settings->getAvailableTranslations()) - { - // Identify the language mnemonic and set the full name. - if (languageShort == "en") - { - _settingsDialogForm->languageSelectionComboBox->addItem(TQIcon(TQString(":/language/language-" - + languageShort + ".png")), tr("English")); - } - else if (languageShort == "fr") - { - _settingsDialogForm->languageSelectionComboBox->addItem(TQIcon(TQString(":/language/language-" - + languageShort + ".png")), tr("French")); - } - else if (languageShort == "de") - { - _settingsDialogForm->languageSelectionComboBox->addItem(TQIcon(TQString(":/language/language-" - + languageShort + ".png")), tr("German")); - } - else if (languageShort == "zh_TW") - { - _settingsDialogForm->languageSelectionComboBox->addItem(TQIcon(TQString(":/language/language-" - + languageShort + ".png")), tr("Chinese (Taiwan)")); - } - else if (languageShort == "ja") - { - _settingsDialogForm->languageSelectionComboBox->addItem(TQIcon(TQString(":/language/language-" - + languageShort + ".png")), tr("Japanese")); - } - else if (languageShort == "ru") - { - _settingsDialogForm->languageSelectionComboBox->addItem(TQIcon(TQString(":/language/language-" - + languageShort + ".png")), tr("Russian")); - } - else if (languageShort == "uk") - { - _settingsDialogForm->languageSelectionComboBox->addItem(TQIcon(TQString(":/language/language-" - + languageShort + ".png")), tr("Ukrainian")); - } - else - { - _settingsDialogForm->languageSelectionComboBox->addItem(tr( - "Unknown language mnemonic ") + languageShort); - } - } -} - -/* - \brief Displays the dialog by calling the dialogs exec function. - - Before it gets all the values needed from the UiGuiSettings object. - */ -int UiGuiSettingsDialog::showDialog() -{ - // Init all settings dialog objects with values from settings. - _settings->setObjectPropertyToSettingValueRecursive(this); - - // Execute the dialog. - return exec(); -} - -/* - \brief This slot is called when the dialog box is closed by pressing the Ok button. - - Writes all settings to the UiGuiSettings object. - */ -void UiGuiSettingsDialog::writeWidgetValuesToSettings() -{ - // Write settings dialog object values to settings. - _settings->setSettingToObjectPropertyValueRecursive(this); -} - -/* - \brief Catches language change events and retranslates all needed widgets. - */ -void UiGuiSettingsDialog::changeEvent(TQEvent *event) -{ - if (event->type() == TQEvent::LanguageChange) - { - _settingsDialogForm->retranslateUi(this); - // If this is not explicit set here, TQt < 4.3.0 does not translate the buttons. - _settingsDialogForm->buttonBox->setStandardButtons( - TQDialogButtonBox::Cancel | TQDialogButtonBox::NoButton | TQDialogButtonBox::Ok); - - //TODO: This has to be removed when the properties for the highlighters can be set. - _settingsDialogForm->groupBoxSyntaxHighlighterProperties->setToolTip( - "(Will be implemented soon)" + - _settingsDialogForm->groupBoxSyntaxHighlighterProperties->toolTip()); - - TQStringList languageShortList = _settings->getAvailableTranslations(); - - // Now retranslate every entry in the language selection box. - for (int i = 0; i < languageShortList.size(); i++) - { - TQString languageShort = languageShortList.at(i); - - // Identify the language mnemonic and set the full name. - if (languageShort == "en") - { - _settingsDialogForm->languageSelectionComboBox->setItemText(i, tr("English")); - } - else if (languageShort == "fr") - { - _settingsDialogForm->languageSelectionComboBox->setItemText(i, tr("French")); - } - else if (languageShort == "de") - { - _settingsDialogForm->languageSelectionComboBox->setItemText(i, tr("German")); - } - else if (languageShort == "zh_TW") - { - _settingsDialogForm->languageSelectionComboBox->setItemText(i, tr("Chinese (Taiwan)")); - } - else if (languageShort == "ja") - { - _settingsDialogForm->languageSelectionComboBox->setItemText(i, tr("Japanese")); - } - else if (languageShort == "ru") - { - _settingsDialogForm->languageSelectionComboBox->setItemText(i, tr("Russian")); - } - else if (languageShort == "uk") - { - _settingsDialogForm->languageSelectionComboBox->setItemText(i, tr("Ukrainian")); - } - else - { - _settingsDialogForm->languageSelectionComboBox->setItemText(i, - tr("Unknown language mnemonic ") + languageShort); - } - } - } - else - { - TQWidget::changeEvent(event); - } -} diff --git a/src/__TODO/UiGuiSettingsDialog.ui b/src/__TODO/UiGuiSettingsDialog.ui deleted file mode 100755 index e9f3af6..0000000 --- a/src/__TODO/UiGuiSettingsDialog.ui +++ /dev/null @@ -1,460 +0,0 @@ - - - SettingsDialog - - - TQt::ApplicationModal - - - - 0 - 0 - 503 - 336 - - - - Settings - - - - :/mainWindow/preferences-system.png:/mainWindow/preferences-system.png - - - - - - 0 - - - - - :/settingsDialog/applications-system.png:/settingsDialog/applications-system.png - - - Common - - - - - - - - Displays all available translations for UniversalIndentGui and lets you choose one. - - - Application language - - - languageSelectionComboBox - - - - - - - - 0 - 0 - - - - Displays all available translations for UniversalIndentGui and lets you choose one. - - - language - - - currentIndex - - - - - - - TQt::Horizontal - - - - 40 - 20 - - - - - - - - - - If selected opens the source code file on startup that was opened last time. - - - Automatically open last file on startup - - - loadLastSourceCodeFileOnStartup - - - checked - - - - - - - If checked, tool tips will show up if the mouse cursor remains over an indenter parameter for a while. - - - Enable Parameter Tooltips - - - indenterParameterTooltipsEnabled - - - checked - - - - - - - - - Sets how many files should be remembered in the list of recently opened files. - - - Number of files in recently opened list - - - - - - - - 0 - 0 - - - - Sets how many files should be remembered in the list of recently opened files. - - - 1 - - - 30 - - - 1 - - - recentlyOpenedListSize - - - value - - - - - - - TQt::Horizontal - - - - 40 - 20 - - - - - - - - - - TQt::Vertical - - - - 20 - 40 - - - - - - - - - - :/settingsDialog/accessories-text-editor.png:/settingsDialog/accessories-text-editor.png - - - Editor - - - - - - Enables or disables displaying of white space characters in the editor. - - - Display white space character (tabs, spaces, etc.) - - - whiteSpaceIsVisible - - - checked - - - - - - - - - Sets width in single spaces used for tabs - - - Defines how many spaces should be displayed in the editor for one tab. - - - Displayed width of tabs - - - - - - - - 0 - 0 - - - - Defines how many spaces should be displayed in the editor for one tab character. - - - 1 - - - 99 - - - 1 - - - tabWidth - - - value - - - - - - - TQt::Horizontal - - - - 40 - 20 - - - - - - - - - - TQt::Vertical - - - - 20 - 40 - - - - - - - - - - :/settingsDialog/syntax-highlight.png:/settingsDialog/syntax-highlight.png - - - Syntax Highlighting - - - - - - By enabling special key words of the source code are highlighted. - - - Enable syntax highlighting - - - SyntaxHighlightingEnabled - - - checked - - - - - - - false - - - Lets you make settings for all properties of the available syntax highlighters, like font and color. - - - Highlighter settings - - - - - - -1 - - - - - - - -1 - - - - - - - - - Set the font for the current selected highlighter property. - - - Set Font - - - - - - - Set the color for the current selected highlighter property. - - - Set Color - - - - - - - TQt::Vertical - - - - 20 - 40 - - - - - - - - - - - - - TQt::Vertical - - - - 20 - 40 - - - - - - - - - - - - TQt::Horizontal - - - TQDialogButtonBox::Cancel|TQDialogButtonBox::Ok - - - - - - - - - - - buttonBox - accepted() - SettingsDialog - accept() - - - 250 - 316 - - - 153 - 236 - - - - - buttonBox - rejected() - SettingsDialog - reject() - - - 327 - 316 - - - 282 - 236 - - - - - enableProxyCheckBox - toggled(bool) - widget - setEnabled(bool) - - - 73 - 68 - - - 76 - 95 - - - - -