From 0550152e172efec0828bb227f9433fd74a532b04 Mon Sep 17 00:00:00 2001 From: Michele Calgaro Date: Sat, 5 Apr 2025 23:18:18 +0900 Subject: Add dialog to display information about files and paths. This resolves issue #6. Signed-off-by: Michele Calgaro --- src/CMakeLists.txt | 2 + src/IndentHandler.cpp | 3 + src/IndentHandler.h | 41 +++--- src/MainWindow.cpp | 14 +- src/MainWindow.h | 8 +- src/MainWindowBase.ui | 16 +++ src/UiGuiInfoDialog.cpp | 67 ++++++++++ src/UiGuiInfoDialog.h | 40 ++++++ src/UiGuiInfoDialogBase.ui | 310 +++++++++++++++++++++++++++++++++++++++++++++ 9 files changed, 475 insertions(+), 26 deletions(-) create mode 100644 src/UiGuiInfoDialog.cpp create mode 100644 src/UiGuiInfoDialog.h create mode 100755 src/UiGuiInfoDialogBase.ui (limited to 'src') diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index b0db1b9..64c5ed2 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -27,6 +27,7 @@ set( ${target}_SRCS AboutDialogBase.ui MainWindowBase.ui ToolBarWidget.ui + UiGuiInfoDialogBase.ui UiGuiSettingsDialogBase.ui main.cpp @@ -35,6 +36,7 @@ set( ${target}_SRCS TemplateBatchScript.cpp UiGuiErrorMessage.cpp UiGuiHighlighter.cpp + UiGuiInfoDialog.cpp UiGuiIniFileParser.cpp UiGuiSettings.cpp diff --git a/src/IndentHandler.cpp b/src/IndentHandler.cpp index f7508e3..3fdb9b6 100644 --- a/src/IndentHandler.cpp +++ b/src/IndentHandler.cpp @@ -130,6 +130,7 @@ IndentHandler::IndentHandler(int indenterID, MainWindow *mainWindow, TQWidget *p TQSizePolicy::Expanding); m_toolBoxContainerLayout->addWidget(m_indenterParameterCategoriesToolBox); + m_indenterConfigFilename = ""; m_indenterExecutableCallString = ""; m_indenterExecutableSuffix = ""; @@ -594,6 +595,8 @@ bool IndentHandler::loadConfigFile(const TQString &filePathName) cfgFile.close(); } + m_indenterConfigFilename = filePathName; + // Search for name of each boolean parameter and set its value if found. for (const ParamBoolean &pBoolean : m_paramBooleans) { diff --git a/src/IndentHandler.h b/src/IndentHandler.h index dfeb41e..7282df3 100644 --- a/src/IndentHandler.h +++ b/src/IndentHandler.h @@ -143,32 +143,35 @@ class IndentHandler : public TQWidget UiGuiIniFileParser *m_indenterSettings; TQStringList m_indenterParameters; // The indenters name in a descriptive form - TQString m_indenterName; + TQString m_indenterName; + TQString m_indenterConfigFilename; // The indenters file name (w/o extension), that is being called - TQString m_indenterFileName; - TQString m_indenterDirectoryStr; - TQString m_tempDirectoryStr; - TQString m_settingsDirectoryStr; - TQStringList m_indenterIniFileList; - TQString m_globalConfigFilename; - TQString m_cfgFileParameterEnding; - TQString m_parameterOrder; - TQString m_inputFileParameter; - TQString m_inputFileName; - TQString m_outputFileParameter; - TQString m_outputFileName; - TQString m_fileTypes; - TQString m_useCfgFileParameter; - TQString m_indenterShowHelpParameter; + TQString m_indenterFileName; + TQString m_indenterDirectoryStr; + TQString m_tempDirectoryStr; + TQString m_settingsDirectoryStr; + TQStringList m_indenterIniFileList; + TQString m_globalConfigFilename; + TQString m_cfgFileParameterEnding; + TQString m_parameterOrder; + TQString m_inputFileParameter; + TQString m_inputFileName; + TQString m_outputFileParameter; + TQString m_outputFileName; + TQString m_fileTypes; + TQString m_useCfgFileParameter; + TQString m_indenterShowHelpParameter; MainWindow *m_mainWindow; TQWidget *m_parent; UiGuiErrorMessage *m_errorMessageDialog; - TQString m_indenterExecutableCallString; - TQString m_indenterExecutableSuffix; - bool m_indenterProcessFinished; + TQString m_indenterExecutableCallString; + TQString m_indenterExecutableSuffix; + bool m_indenterProcessFinished; //TODO: This function should go into a string helper/tool class/file. TQString encodeToHTML(const TQString &text); + + friend class UiGuiInfoDialog; }; #endif // INDENTHANDLER_H diff --git a/src/MainWindow.cpp b/src/MainWindow.cpp index a00bb52..aa9a14b 100644 --- a/src/MainWindow.cpp +++ b/src/MainWindow.cpp @@ -25,6 +25,7 @@ #include "AboutDialog.h" #include "IndentHandler.h" #include "SettingsPaths.h" +#include "UiGuiInfoDialog.h" #include "UiGuiSettings.h" #include "UiGuiSettingsDialog.h" #include "UiGuiVersion.h" @@ -71,7 +72,7 @@ MainWindow::MainWindow(TQString file2OpenOnStart, TQWidget *parent) : MainWindowBase(parent), m_aboutDialog(nullptr), m_qSciSourceCodeEditor(nullptr), m_uiGuiTranslator(nullptr), m_textEditLineColumnInfoLabel(nullptr), m_oldLinesNumber(0), m_openEncodingActions(), m_saveEncodingActions(), - m_encodingActionGroup(nullptr), m_saveEncodedActionGroup(nullptr), + m_encodingActionGroup(nullptr), m_saveEncodedActionGroup(nullptr), m_infoDialog(nullptr), m_highlighterActionGroup(nullptr), m_documentModified(false), m_previewToggled(true), m_indentHandler(nullptr), m_centralSplitter(nullptr), m_settingsDialog(nullptr), m_highlighter(nullptr), m_highlightingActions(), m_toolBarWidget(nullptr) @@ -109,9 +110,13 @@ MainWindow::MainWindow(TQString file2OpenOnStart, TQWidget *parent) : m_aboutDialog = new AboutDialog(this); connect(actionAboutUniversalIndentGUITQt, TQ_SIGNAL(activated()), this, TQ_SLOT(showAboutDialog())); + // Generate info dialog box + m_infoDialog = new UiGuiInfoDialog(this, m_indentHandler); + connect(actionShowInfo, TQ_SIGNAL(activated()), m_infoDialog, TQ_SLOT(showDialog())); + // Generate settings dialog box - m_settingsDialog = new UiGuiSettingsDialog(this, m_settings); - connect(actionShowSettings, TQ_SIGNAL(activated()), m_settingsDialog, TQ_SLOT(showDialog())); + m_settingsDialog = new UiGuiSettingsDialog(this, m_settings); + connect(actionShowSettings, TQ_SIGNAL(activated()), m_settingsDialog, TQ_SLOT(showDialog())); if (TQFile::exists(file2OpenOnStart)) { @@ -132,8 +137,6 @@ MainWindow::MainWindow(TQString file2OpenOnStart, TQWidget *parent) : MainWindow::~MainWindow() { - delete m_settingsDialog; - delete m_aboutDialog; UiGuiSettings::deleteInstance(); } @@ -158,6 +161,7 @@ void MainWindow::initMainWindow() actionMenuExport->setIconSet(TQPixmap(ICONS_PATH + "exporthtml.png")); actionExportPDF->setIconSet(TQPixmap(ICONS_PATH + "exportpdf.png")); actionExportHTML->setIconSet(TQPixmap(ICONS_PATH + "exporthtml.png")); + actionShowInfo->setIconSet(TQPixmap(ICONS_PATH + "info.png")); actionExit->setIconSet(TQPixmap(ICONS_PATH + "system-log-out.png")); // - Indenter menu actionLoadIndenterConfigFile->setIconSet(TQPixmap(ICONS_PATH + "load_indent_cfg.png")); diff --git a/src/MainWindow.h b/src/MainWindow.h index 8ff6da6..bb8ea10 100644 --- a/src/MainWindow.h +++ b/src/MainWindow.h @@ -26,11 +26,12 @@ class AboutDialog; -class UiGuiHighlighter; class IndentHandler; +class ToolBarWidget; +class UiGuiHighlighter; +class UiGuiInfoDialog; class UiGuiSettings; class UiGuiSettingsDialog; -class ToolBarWidget; class TQextScintilla; class TQLabel; @@ -108,6 +109,7 @@ class MainWindow : public MainWindowBase UiGuiHighlighter *m_highlighter; ///-- TQScrollBar *m_textEditVScrollBar; AboutDialog *m_aboutDialog; + UiGuiInfoDialog *m_infoDialog; UiGuiSettingsDialog *m_settingsDialog; int m_actionClearRecentlyOpenedListId; int m_recentlyOpenedListMaxSize; @@ -135,6 +137,8 @@ class MainWindow : public MainWindowBase ToolBarWidget *m_toolBarWidget; IndentHandler *m_indentHandler; TQLabel *m_textEditLineColumnInfoLabel; + + friend class UiGuiInfoDialog; }; #endif // MAINWINDOW_H diff --git a/src/MainWindowBase.ui b/src/MainWindowBase.ui index 229d41a..5856811 100755 --- a/src/MainWindowBase.ui +++ b/src/MainWindowBase.ui @@ -41,6 +41,8 @@ + + @@ -204,6 +206,20 @@ Export the currently visible source code as PDF document. + + + actionShowInfo + + + Show file and path info + + + Opens a window showing some info about the current open file and paths. + + + Ctrl+I + + actionExit diff --git a/src/UiGuiInfoDialog.cpp b/src/UiGuiInfoDialog.cpp new file mode 100644 index 0000000..4c05d7a --- /dev/null +++ b/src/UiGuiInfoDialog.cpp @@ -0,0 +1,67 @@ +/*************************************************************************** +* 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 "UiGuiInfoDialog.h" +#include "IndentHandler.h" +#include "MainWindow.h" +#include "SettingsPaths.h" + +#include +#include +#include + +/* + \class UiGuiInfoDialog + \brief Displays a dialog window with information about the current file + and about the paths used by the application +*/ + +UiGuiInfoDialog::UiGuiInfoDialog(TQWidget *parent, const IndentHandler *indenter) : + UiGuiInfoDialogBase(parent), m_mainWindow((const MainWindow*)parent), + m_indentHandler(indenter) +{ + // For icon setup + const TQString ICONS_PATH(APP_ICONS_PATH); + // Application icon + setIcon(TQPixmap(ICONS_PATH + "info.png")); + + tabWidget->setTabIconSet(tabFile, TQPixmap(ICONS_PATH + "accessories-text-editor.png")); + tabWidget->setTabIconSet(tabPaths, TQPixmap(ICONS_PATH + "syntax-highlight.png")); +} + +/* + \brief Displays the dialog by calling the dialogs exec function. + */ +void UiGuiInfoDialog::showDialog() +{ + // Populate all dialog objects + leFilename->setText(m_mainWindow->m_currentSourceFile); + leConfigFilename->setText(m_indentHandler->m_indenterConfigFilename); + leIndenter->setText(m_indentHandler->m_indenterName); + + leApplicationPath->setText(SettingsPaths::getApplicationBinaryPath()); + leSettingsPath->setText(SettingsPaths::getSettingsPath()); + leGlobalFilesPath->setText(SettingsPaths::getGlobalFilesPath()); + leIndentersPath->setText(SettingsPaths::getIndenterPath()); + leTempPath->setText(SettingsPaths::getTempPath()); + + // Execute the dialog. + exec(); +} + +#include "UiGuiInfoDialog.moc" diff --git a/src/UiGuiInfoDialog.h b/src/UiGuiInfoDialog.h new file mode 100644 index 0000000..0e7047e --- /dev/null +++ b/src/UiGuiInfoDialog.h @@ -0,0 +1,40 @@ +/*************************************************************************** +* 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. * +***************************************************************************/ + +#ifndef UIGUIINFODIALOG_H +#define UIGUIINFODIALOG_H + +#include "UiGuiInfoDialogBase.h" + +class IndentHandler; +class MainWindow; + +class UiGuiInfoDialog : public UiGuiInfoDialogBase +{ + TQ_OBJECT + + public: + UiGuiInfoDialog(TQWidget *parent, const IndentHandler *indenter); + + public slots: + void showDialog(); + + private: + const MainWindow *m_mainWindow; + const IndentHandler *m_indentHandler; +}; + +#endif diff --git a/src/UiGuiInfoDialogBase.ui b/src/UiGuiInfoDialogBase.ui new file mode 100755 index 0000000..b237aeb --- /dev/null +++ b/src/UiGuiInfoDialogBase.ui @@ -0,0 +1,310 @@ + + UiGuiInfoDialogBase + + + UiGuiInfoDialogBase + + + + 0 + 0 + 1100 + 300 + + + + Info + + + + + tabWidget + + + 0 + + + + tabFile + + + File + + + + + unnamed + + + 11 + + + 6 + + + + filenameLabel + + + Open file + + + Name of the open file + + + + + leFilename + + + Name of the open file + + + true + + + + + configFilenameLabel + + + Config file + + + Name of the config file + + + + + leConfigFilename + + + Name of the config file + + + true + + + + + indenterLabel + + + Indender + + + Name of the indenter + + + + + leIndenter + + + Name of the indenter + + + true + + + + + + spacer2 + + + TQt::Vertical + + + + 40 + 20 + + + + + + + + tabPaths + + + Paths + + + + + unnamed + + + 11 + + + 6 + + + + applicationPathLabel + + + Application + + + Name of the folder containing the application binary + + + + + leApplicationPath + + + Name of the folder containing the application binary + + + true + + + + + settingsPathLabel + + + Settings + + + Name of the folder containing the application settings + + + + + leSettingsPath + + + Name of the folder containing the application settings + + + true + + + + + globalFilesPathLabel + + + Global files + + + Name of the folder containing the global files + + + + + leGlobalFilesPath + + + Name of the folder containing the global files + + + true + + + + + indentersPathLabel + + + Indenters + + + Name of the folder containing the indenter files + + + + + leIndentersPath + + + Name of the folder containing the indenter files + + + true + + + + + tempPathLabel + + + Temp files + + + Name of the folder containing the temporary files + + + + + leTempPath + + + Name of the folder containing the temporary files + + + true + + + + + + spacer2 + + + TQt::Vertical + + + + 40 + 20 + + + + + + + + + + spacer1 + + + TQt::Horizontal + + + + 40 + 20 + + + + + + okButton + + + &Ok + + + true + + + + + + + + okButton + clicked() + UiGuiInfoDialogBase + accept() + + + -- cgit v1.2.3