From ae3256947f8ac390d0efa271f9721b3ac92f2999 Mon Sep 17 00:00:00 2001 From: Michele Calgaro Date: Mon, 7 Nov 2022 11:31:26 +0900 Subject: Added toolbar GUI. The logic of each button has not been implemented yet. Signed-off-by: Michele Calgaro --- src/CMakeLists.txt | 2 +- src/MainWindow.cpp | 110 +++++++++++++++++---------------- src/MainWindow.h | 13 ++-- src/MainWindowBase.ui | 21 +++++++ src/ToolBarWidget.ui | 116 +++++++++++++++++++++++++++++++++++ src/__TODO/MainWindow.ui | 25 -------- src/__TODO/ToolBarWidget.ui | 124 -------------------------------------- src/__TODO/UiGuiSettingsDialog.ui | 2 +- 8 files changed, 203 insertions(+), 210 deletions(-) create mode 100755 src/ToolBarWidget.ui delete mode 100755 src/__TODO/ToolBarWidget.ui diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index a911d9c..19c34a8 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -26,7 +26,7 @@ link_directories( set( target universal-indent-gui-tqt ) set( ${target}_SRCS - MainWindowBase.ui MainWindow.cpp main.cpp + MainWindowBase.ui ToolBarWidget.ui MainWindow.cpp main.cpp UiGuiVersion.cpp ) diff --git a/src/MainWindow.cpp b/src/MainWindow.cpp index c3c6f1c..2d730ac 100644 --- a/src/MainWindow.cpp +++ b/src/MainWindow.cpp @@ -24,7 +24,7 @@ ///-- #include "debugging/TSLogger.h" ///-- #include "SettingsPaths.h" ///-- -///-- #include "ui_ToolBarWidget.h" +#include "ToolBarWidget.h" ///-- #include "AboutDialog.h" ///-- #include "AboutDialogGraphicsView.h" ///-- #include "UiGuiSettings.h" @@ -34,7 +34,9 @@ ///-- #include #include +#include #include +#include ///-- #include ///-- #include ///-- #include @@ -93,13 +95,13 @@ MainWindow::MainWindow(TQString file2OpenOnStart, TQWidget *parent) : ///-- ///-- // Initialize the language of the application. ///-- initApplicationLanguage(); -///-- -///-- // Creates the main window and initializes it. - initMainWindow(); -///-- -///-- // Create toolbar and insert it into the main window. -///-- initToolBar(); -///-- + + // Creates the main window and initializes it. + initMainWindow(); + + // Create toolbar and insert it into the main window. + initToolBar(); + ///-- // Create the text edit component using the TQScintilla widget. ///-- initTextEditor(); ///-- @@ -117,7 +119,6 @@ MainWindow::MainWindow(TQString file2OpenOnStart, TQWidget *parent) : ///-- // Generate about dialog box ///-- _aboutDialog = new AboutDialog(this, TQt::SplashScreen); ///-- _aboutDialogGraphicsView = new AboutDialogGraphicsView(_aboutDialog, this); -///-- connect(_toolBarWidget->pbAbout, SIGNAL(clicked()), this, SLOT(showAboutDialog())); connect(actionAboutUniversalIndentGUITQt, SIGNAL(activated()), this, SLOT(showAboutDialog())); ///-- ///-- // Generate settings dialog box @@ -148,7 +149,7 @@ MainWindow::MainWindow(TQString file2OpenOnStart, TQWidget *parent) : ///-- */ void MainWindow::initMainWindow() { - // Setup icons + // For icon setup TQString ICONS_PATH(APP_ICONS_PATH); // Application icon setIcon(TQPixmap(ICONS_PATH + "universalIndentGUI_64x64.png")); @@ -238,33 +239,40 @@ void MainWindow::initMainWindow() ///-- _settings->registerObjectSlot(this, "updateRecentlyOpenedList()", "recentlyOpenedListSize"); } -///-- /*! -///-- \brief Creates and inits the tool bar. It is added to the main window. -///-- */ -///-- void MainWindow::initToolBar() -///-- { -///-- // Create the tool bar and add it to the main window. -///-- _toolBarWidget = new Ui::ToolBarWidget(); -///-- TQWidget *helpWidget = new TQWidget(); -///-- _toolBarWidget->setupUi(helpWidget); -///-- _mainWindowForm->toolBar->addWidget(helpWidget); -///-- _mainWindowForm->toolBar->setAllowedAreas(TQt::TopToolBarArea | TQt::BottomToolBarArea); -///-- -///-- // Connect the tool bar widgets to their functions. -///-- _settings->registerObjectProperty(_toolBarWidget->enableSyntaxHighlightningCheckBox, "checked", +/*! + \brief Creates and inits the tool bar. It is added to the main window. + */ +void MainWindow::initToolBar() +{ + // For icon setup + TQString ICONS_PATH(APP_ICONS_PATH); + + // Create the tool bar and add it to the main window. + m_toolBarWidget = new ToolBarWidget(toolBar); + + // Connect the tool bar widgets to their functions. +///-- _settings->registerObjectProperty(_toolBarWidget->cbEnableSyntaxHL, "checked", ///-- "SyntaxHighlightingEnabled"); -///-- _toolBarWidget->enableSyntaxHighlightningCheckBox->hide(); -///-- connect(_toolBarWidget->pbOpen_Source_File, SIGNAL(clicked()), this, -///-- SLOT(openSourceFileDialog())); -///-- connect(_toolBarWidget->pbExit, SIGNAL(clicked()), this, SLOT(close())); -///-- connect(_toolBarWidget->cbLivePreview, SIGNAL(toggled(bool)), this, -///-- SLOT(previewTurnedOnOff(bool))); -///-- connect(_toolBarWidget->cbLivePreview, SIGNAL(toggled( -///-- bool)), actionLiveIndentPreview, SLOT(setChecked(bool))); + m_toolBarWidget->cbEnableSyntaxHL->hide(); + + m_toolBarWidget->pbOpenSourceFile->setIconSet(TQPixmap(ICONS_PATH + "document-open.png")); + connect(m_toolBarWidget->pbOpenSourceFile, SIGNAL(clicked()), this, SLOT(openSourceFileDialog())); + + m_toolBarWidget->pbAbout->setIconSet(TQPixmap(ICONS_PATH + "info.png")); + connect(m_toolBarWidget->pbAbout, SIGNAL(clicked()), this, SLOT(showAboutDialog())); + + m_toolBarWidget->pbExit->setIconSet(TQPixmap(ICONS_PATH + "system-log-out.png")); + connect(m_toolBarWidget->pbExit, SIGNAL(clicked()), this, SLOT(close())); + + // Settings a pixmap hides the text in TQt3 + //m_toolBarWidget->cbLivePreview->setPixmap(TQPixmap(ICONS_PATH + "live-preview.png")); + connect(m_toolBarWidget->cbLivePreview, SIGNAL(toggled(bool)), this, SLOT(previewTurnedOnOff(bool))); + connect(m_toolBarWidget->cbLivePreview, SIGNAL(toggled(bool)), + actionLiveIndentPreview, SLOT(setChecked(bool))); ///-- connect(actionLiveIndentPreview, SIGNAL(toggled( -///-- bool)), _toolBarWidget->cbLivePreview, SLOT(setChecked(bool))); -///-- } -///-- +///-- bool)), m_toolBarWidget->cbLivePreview, SLOT(setChecked(bool))); +} + ///-- /*! ///-- \brief Create and initialize the text editor component. It uses the TQScintilla widget. ///-- */ @@ -503,7 +511,7 @@ void MainWindow::openSourceFileDialog(TQString fileName) ///-- ///-- openedSourceFileContent = loadFile(fileName); ///-- _sourceFileContent = openedSourceFileContent; -///-- if (_toolBarWidget->cbLivePreview->isChecked()) +///-- if (m_toolBarWidget->cbLivePreview->isChecked()) ///-- { ///-- callIndenter(); ///-- } @@ -636,7 +644,7 @@ bool MainWindow::saveSourceFile() ///-- { ///-- _textEditLastScrollPos = _textEditVScrollBar->value(); ///-- -///-- if (_toolBarWidget->cbLivePreview->isChecked()) +///-- if (m_toolBarWidget->cbLivePreview->isChecked()) ///-- { ///-- _sourceViewContent = _sourceFormattedContent; ///-- } @@ -745,7 +753,7 @@ bool MainWindow::saveSourceFile() ///-- } ///-- ///-- // Call the indenter to reformat the text. -///-- if (_toolBarWidget->cbLivePreview->isChecked()) +///-- if (m_toolBarWidget->cbLivePreview->isChecked()) ///-- { ///-- callIndenter(); ///-- _previewToggled = true; @@ -754,7 +762,7 @@ bool MainWindow::saveSourceFile() ///-- // Update the text editor. ///-- updateSourceView(); ///-- -///-- if (_toolBarWidget->cbLivePreview->isChecked() && !enteredCharacter.isNull() && +///-- if (m_toolBarWidget->cbLivePreview->isChecked() && !enteredCharacter.isNull() && ///-- enteredCharacter != 10) ///-- { ///-- //const char ch = enteredCharacter.toAscii(); @@ -832,7 +840,7 @@ bool MainWindow::saveSourceFile() ///-- _qSciSourceCodeEditor->setCursorPosition(cursorLine, cursorPos); ///-- } ///-- -///-- if (_toolBarWidget->cbLivePreview->isChecked()) +///-- if (m_toolBarWidget->cbLivePreview->isChecked()) ///-- { ///-- _sourceCodeChanged = false; ///-- } @@ -866,7 +874,7 @@ bool MainWindow::saveSourceFile() ///-- int cursorLine, cursorPos; ///-- _qSciSourceCodeEditor->getCursorPosition(&cursorLine, &cursorPos); ///-- -///-- if (_toolBarWidget->cbLivePreview->isChecked()) +///-- if (m_toolBarWidget->cbLivePreview->isChecked()) ///-- { ///-- callIndenter(); ///-- _previewToggled = true; @@ -901,15 +909,15 @@ bool MainWindow::saveSourceFile() ///-- setWindowModified(true); ///-- } ///-- } -///-- -///-- /*! -///-- \brief This slot is called whenever the preview button is turned on or off. -///-- -///-- It calls the selected indenter to format the current source code if -///-- the code has been changed since the last indenter call. -///-- */ -///-- void MainWindow::previewTurnedOnOff(bool turnOn) -///-- { + +/*! + \brief This slot is called whenever the preview button is turned on or off. + + It calls the selected indenter to format the current source code if + the code has been changed since the last indenter call. + */ +void MainWindow::previewTurnedOnOff(bool turnOn) +{ ///-- _previewToggled = true; ///-- ///-- int cursorLine, cursorPos; @@ -953,7 +961,7 @@ bool MainWindow::saveSourceFile() ///-- { ///-- this->setWindowTitle("UniversalIndentGUI " + TQString( ///-- PROGRAM_VERSION_STRING) + " [*]" + _currentSourceFile); -///-- } +} /*! \brief Opens a dialog to save the current source code as a PDF document. diff --git a/src/MainWindow.h b/src/MainWindow.h index 663d161..103b26c 100644 --- a/src/MainWindow.h +++ b/src/MainWindow.h @@ -29,11 +29,8 @@ /// class AboutDialog; /// class AboutDialogGraphicsView; /// class UiGuiHighlighter; -/// class IndentHandler; -/// namespace Ui -/// { -/// class ToolBarWidget; -/// } +/// class IndentHandler +class ToolBarWidget; /// /// class TQLabel; /// class TQScrollBar; @@ -72,7 +69,7 @@ class MainWindow : public MainWindowBase ///-- void sourceCodeChangedHelperSlot(); ///-- void sourceCodeChangedSlot(); ///-- void indentSettingsChangedSlot(); -///-- void previewTurnedOnOff(bool turnOn); + void previewTurnedOnOff(bool turnOn); void exportToPDF(); void exportToHTML(); ///-- void languageChanged(int languageIndex); @@ -95,7 +92,7 @@ class MainWindow : public MainWindowBase ///-- void createHighlighterMenu(); ///-- bool initApplicationLanguage(); void initMainWindow(); -///-- void initToolBar(); + void initToolBar(); ///-- void initTextEditor(); ///-- void initSyntaxHighlighter(); ///-- void initIndenter(); @@ -135,7 +132,7 @@ class MainWindow : public MainWindowBase ///-- bool _previewToggled; ///-- TQStringList _encodingsList; ///-- -///-- Ui::ToolBarWidget *_toolBarWidget; + ToolBarWidget *m_toolBarWidget; ///-- IndentHandler *_indentHandler; ///-- TQLabel *_textEditLineColumnInfoLabel; }; diff --git a/src/MainWindowBase.ui b/src/MainWindowBase.ui index 56256f0..c5e124f 100755 --- a/src/MainWindowBase.ui +++ b/src/MainWindowBase.ui @@ -80,6 +80,27 @@ + + + + toolBar + + + Tools + + + TQt::Horizontal + + + + 5 + 5 + 1 + 1 + + + + diff --git a/src/ToolBarWidget.ui b/src/ToolBarWidget.ui new file mode 100755 index 0000000..19f3259 --- /dev/null +++ b/src/ToolBarWidget.ui @@ -0,0 +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 highlightning 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/__TODO/MainWindow.ui b/src/__TODO/MainWindow.ui index c7514a3..9ac95b1 100755 --- a/src/__TODO/MainWindow.ui +++ b/src/__TODO/MainWindow.ui @@ -92,31 +92,6 @@ false - - - - - - :/mainWindow/document-save-as.png:/mainWindow/document-save-as.png - - - Save Source File As... - - - Save Source File As... - - - Save Source File As... - - - Opens a file dialog to save the currently shown source code. - - - Ctrl+Shift+S - - - - diff --git a/src/__TODO/ToolBarWidget.ui b/src/__TODO/ToolBarWidget.ui deleted file mode 100755 index 8665cac..0000000 --- a/src/__TODO/ToolBarWidget.ui +++ /dev/null @@ -1,124 +0,0 @@ - - - ToolBarWidget - - - - 0 - 0 - 773 - 34 - - - - Form - - - - 6 - - - 0 - - - - - <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:8pt;">Opens a dialog for selecting a source code file.</span></p><p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;">This file will be used to show what the indent tool changes.</p></body></html> - - - Open Source File - - - - :/mainWindow/document-open.png:/mainWindow/document-open.png - - - - - - - <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg 2; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:MS Shell Dlg; font-size:8pt;">Turns the preview of the reformatted source code on and off.</p><p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:MS Shell Dlg; font-size:8pt;">In other words it switches between formatted and nonformatted code. (Ctrl+L)</p></body></html> - - - Live Indent Preview - - - - :/mainWindow/live-preview.png:/mainWindow/live-preview.png - - - Ctrl+L - - - - - - - <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg 2; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:MS Shell Dlg; font-size:8pt;">Enables and disables the highlightning of the source</p><p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:MS Shell Dlg; font-size:8pt;">code shown below. (Still needs some performance improvements) (Ctrl+H)</p></body></html> - - - Syntax Highlight - - - - :/mainWindow/syntax-highlight.png:/mainWindow/syntax-highlight.png - - - Ctrl+H - - - true - - - DONOTTRANSLATE:SyntaxHighlightingEnabled - - - - - - - TQt::Horizontal - - - - 40 - 20 - - - - - - - - <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">Shows info about UniversalIndentGUI</p></body></html> - - - About - - - - :/mainWindow/info.png:/mainWindow/info.png - - - - - - - <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">Quits the UniversalIndentGUI</p></body></html> - - - Exit - - - - :/mainWindow/system-log-out.png:/mainWindow/system-log-out.png - - - - - - - - - - diff --git a/src/__TODO/UiGuiSettingsDialog.ui b/src/__TODO/UiGuiSettingsDialog.ui index 88ed6be..e9f3af6 100755 --- a/src/__TODO/UiGuiSettingsDialog.ui +++ b/src/__TODO/UiGuiSettingsDialog.ui @@ -294,7 +294,7 @@ - + By enabling special key words of the source code are highlighted. -- cgit v1.2.1