summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichele Calgaro <[email protected]>2023-04-24 15:50:43 +0900
committerMichele Calgaro <[email protected]>2023-04-24 15:50:43 +0900
commitb3c19a6270926cc1e57aa1f33cb07af29eb3e896 (patch)
tree5bb9d88698aa83b31645732f4aa08b92701a9037
parent425e16ad894fd23d7c5b061acffba6cd04a1b1db (diff)
downloaduniversal-indent-gui-tqt-b3c19a6270926cc1e57aa1f33cb07af29eb3e896.tar.gz
universal-indent-gui-tqt-b3c19a6270926cc1e57aa1f33cb07af29eb3e896.zip
Added logic to open a file using the "Open source file" menu entry,
the toolbar button or by passing it as argument from CLI. Signed-off-by: Michele Calgaro <[email protected]>
-rw-r--r--debian/control2
-rw-r--r--src/MainWindow.cpp115
-rw-r--r--src/MainWindow.h4
-rwxr-xr-xsrc/main.cpp2
4 files changed, 59 insertions, 64 deletions
diff --git a/debian/control b/debian/control
index 006820f..440b560 100644
--- a/debian/control
+++ b/debian/control
@@ -4,7 +4,7 @@ Priority: optional
Maintainer: TDE Debian Team <[email protected]>
XSBC-Original-Maintainer: Thomas Schweitzer <[email protected]>
XSBC-Original-Uploaders: Fathi Boudra <[email protected]>
-Build-Depends: cdbs, debhelper (>= 9~), quilt, cmake-trinity, ninja-build, libtqtinterface-dev, libtqscintilla-dev
+Build-Depends: cdbs, debhelper (>= 9~), quilt, tde-cmake, ninja-build, libtqtinterface-dev, libtqscintilla-dev
Standards-Version: 3.9.3
Package: universal-indent-gui-tqt
diff --git a/src/MainWindow.cpp b/src/MainWindow.cpp
index ab3040d..9bffe4f 100644
--- a/src/MainWindow.cpp
+++ b/src/MainWindow.cpp
@@ -39,6 +39,7 @@
#include <tqcheckbox.h>
#include <tqcursor.h>
#include <tqfile.h>
+#include <tqfiledialog.h>
#include <tqfileinfo.h>
#include <tqlabel.h>
#include <tqlocale.h>
@@ -53,7 +54,6 @@
///-- #include <tqstring.h>
///-- #include <tqscrollbar.h>
///-- #include <tqtextcursor.h>
-///-- #include <tqfiledialog.h>
///-- #include <tqtextstream.h>
///-- #include <tqtextdocument.h>
///-- #include <tqprinter.h>
@@ -156,12 +156,12 @@ MainWindow::MainWindow(TQString file2OpenOnStart, TQWidget *parent) :
MainWindow::~MainWindow()
{
delete m_aboutDialog;
- ///-- _settings.clear();
+ UiGuiSettings::deleteInstance();
}
-///-- /*
-///-- \brief Initializes the main window by creating the main gui and make some _settings.
-///-- */
+/*
+ \brief Initializes the main window by creating the main gui and make some settings.
+ */
void MainWindow::initMainWindow()
{
// For icon setup
@@ -296,11 +296,6 @@ void MainWindow::initToolBar()
void MainWindow::initTextEditor()
{
// Create the TQScintilla widget and add it to the layout.
- //tqDebug("Trying to load TQScintilla library. If anything fails during loading, it might be "
- // "possible that the debug and release version of TQScintilla are mixed or the library "
- // "cannot be found at all.");
- // Try and catch doesn't seem to catch the runtime error when starting UiGUI release with
- // TQScintilla debug lib and the other way around.
try
{
m_qSciSourceCodeEditor = new TQextScintilla(this);
@@ -504,52 +499,54 @@ TQString MainWindow::loadFile(const TQString &filePath)
/*
\brief Calls the source file open dialog to load a source file for the formatting preview.
- If the file was successfully loaded the indenter will be called to generate the formatted source code.
+ If the file was successfully loaded, the indenter will be called to generate the formatted source code.
*/
-void MainWindow::openSourceFileDialog(TQString fileName)
+void MainWindow::openSourceFileDialog(const TQString &fileName)
{
-///-- // If the source code file is changed and the shown dialog for saving the file
-///-- // is canceled, also stop opening another source file.
-///-- if (!maybeSave())
-///-- {
-///-- return;
-///-- }
-///-- TQString openedSourceFileContent = "";
+ // If the source code file is changed and the shown dialog for saving the file
+ // is canceled, also stop opening another source file.
+ if (!maybeSave())
+ {
+ return;
+ }
+ TQString openedSourceFileContent = "";
+ TQString fileExtensions = "*.h *.c *.cpp *.*"; // Remove this line when the indenter is available
///-- TQString fileExtensions = tr("Supported by indenter") + " (" +
///-- _indentHandler->getPossibleIndenterFileExtensions() + ");;" + tr("All files") + " (*.*)";
///--
///-- //TQString openedSourceFileContent = openFileDialog( tr("Choose source code file"), "./",
-///-- // fileExtensions );
-///-- if (fileName.isEmpty())
-///-- {
-///-- fileName = TQFileDialog::getOpenFileName(this, tr(
-///-- "Choose source code file"), m_currentSourceFile, fileExtensions);
-///-- }
-///--
-///-- if (fileName != "")
-///-- {
-///-- m_currentSourceFile = fileName;
-///-- TQFileInfo fileInfo(fileName);
-///-- m_currentSourceFileExtension = fileInfo.suffix();
-///--
-///-- openedSourceFileContent = loadFile(fileName);
-///-- m_sourceFileContent = openedSourceFileContent;
-///-- if (m_toolBarWidget->cbLivePreview->isChecked())
-///-- {
-///-- callIndenter();
-///-- }
-///-- m_sourceCodeChanged = true;
-///-- m_previewToggled = true;
-///-- updateSourceView();
-///-- updateWindowTitle();
-///-- updateRecentlyOpenedList();
+///-- // fileExtensions );
+ TQString fileToOpen = fileName;
+ if (fileToOpen.isEmpty())
+ {
+ fileToOpen = TQFileDialog::getOpenFileName(m_currentSourceFile, fileExtensions, this, nullptr,
+ tr("Choose source code file"));
+ }
+
+ if (!fileToOpen.isEmpty())
+ {
+ m_currentSourceFile = fileToOpen;
+ TQFileInfo fileInfo(fileToOpen);
+ m_currentSourceFileExtension = fileInfo.extension(false);
+
+ openedSourceFileContent = loadFile(fileToOpen);
+ m_sourceFileContent = openedSourceFileContent;
+ if (m_toolBarWidget->cbLivePreview->isChecked())
+ {
+ callIndenter();
+ }
+ m_sourceCodeChanged = true;
+ m_previewToggled = true;
+ updateSourceView();
+ updateWindowTitle();
+ updateRecentlyOpenedList();
///-- _textEditLastScrollPos = 0;
///-- m_textEditVScrollBar->setValue(_textEditLastScrollPos);
-///--
-///-- m_savedSourceContent = openedSourceFileContent;
-///-- m_qSciSourceCodeEditor->setModified(false);
-///-- m_documentModified = false;
-///-- }
+
+ m_savedSourceContent = openedSourceFileContent;
+ m_qSciSourceCodeEditor->setModified(false);
+ m_documentModified = false;
+ }
}
/*
@@ -689,19 +686,19 @@ void MainWindow::updateSourceView()
///-- m_textEditVScrollBar->setValue(_textEditLastScrollPos);
}
-///-- /*
-///-- \brief Calls the selected indenter with the currently loaded source code to retrieve the formatted source code.
-///--
-///-- The original loaded source code file will not be changed.
-///-- */
-///-- void MainWindow::callIndenter()
-///-- {
-///-- TQApplication::setOverrideCursor(TQCursor(TQt::WaitCursor));
+/*
+ \brief Calls the selected indenter with the currently loaded source code to retrieve the formatted source code.
+
+ The original loaded source code file will not be changed.
+ */
+void MainWindow::callIndenter()
+{
+ TQApplication::setOverrideCursor(TQCursor(TQt::WaitCursor));
///-- m_sourceFormattedContent = _indentHandler->callIndenter(m_sourceFileContent,
///-- m_currentSourceFileExtension);
-///-- //updateSourceView();
-///-- TQApplication::restoreOverrideCursor();
-///-- }
+ updateSourceView();
+ TQApplication::restoreOverrideCursor();
+}
/*
\brief Switches the syntax highlighting corresponding to the value \a turnOn either on or off.
diff --git a/src/MainWindow.h b/src/MainWindow.h
index 773c1ec..340d9ed 100644
--- a/src/MainWindow.h
+++ b/src/MainWindow.h
@@ -53,11 +53,11 @@ class MainWindow : public MainWindowBase
///-- bool eventFilter(TQObject *obj, TQEvent *event);
///--
private slots:
- void openSourceFileDialog(TQString fileName = "");
+ void openSourceFileDialog(const TQString &fileName = TQString::null);
bool saveSourceFile();
bool saveasSourceFileDialog(TQAction *chosenEncodingAction = NULL);
void saveAsOtherEncoding(TQAction *chosenEncodingAction);
-///-- void callIndenter();
+ void callIndenter();
void updateSourceView();
void turnHighlightOnOff(bool turnOn);
void setWhiteSpaceVisibility(bool visible);
diff --git a/src/main.cpp b/src/main.cpp
index 97f66b4..e9e85b1 100755
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -24,7 +24,6 @@
#include "SettingsPaths.h"
// -- #include "UiGuiIndentServer.h"
// -- #include "UiGuiIniFileParser.h"
-#include "UiGuiSettings.h"
// -- #include "UiGuiSystemInfo.h"
#include "UiGuiVersion.h"
@@ -177,7 +176,6 @@ int main(int argc, char *argv[])
// -- delete indentHandler;
delete mainWindow;
- UiGuiSettings::deleteInstance();
// -- TSLogger::deleteInstance();
return returnValue;