diff options
Diffstat (limited to 'src/MainWindow.cpp')
-rw-r--r-- | src/MainWindow.cpp | 110 |
1 files changed, 59 insertions, 51 deletions
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 <tqpixmap.h> #include <tqaction.h> +#include <tqcheckbox.h> #include <tqpopupmenu.h> +#include <tqpushbutton.h> ///-- #include <tqwidget.h> ///-- #include <tqlabel.h> ///-- #include <tqstring.h> @@ -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. |