diff options
author | Michele Calgaro <michele.calgaro@yahoo.it> | 2022-07-16 15:18:45 +0900 |
---|---|---|
committer | Michele Calgaro <michele.calgaro@yahoo.it> | 2022-07-16 15:18:45 +0900 |
commit | d017bd37253ae35b29d82e3277b9adcbb4517dd0 (patch) | |
tree | d884d5cf71c4dd350d1abcf752c438e117a872d5 /src | |
parent | a0148cf62fc298126980a7dc27603b123e1d764c (diff) | |
download | universal-indent-gui-tqt-d017bd37253ae35b29d82e3277b9adcbb4517dd0.tar.gz universal-indent-gui-tqt-d017bd37253ae35b29d82e3277b9adcbb4517dd0.zip |
Convert files to unix format. Convert C++ header names to C header names.
Signed-off-by: Michele Calgaro <michele.calgaro@yahoo.it>
Diffstat (limited to 'src')
33 files changed, 2178 insertions, 2178 deletions
diff --git a/src/AboutDialog.cpp b/src/AboutDialog.cpp index aa4953a..13957ed 100755 --- a/src/AboutDialog.cpp +++ b/src/AboutDialog.cpp @@ -22,11 +22,11 @@ #include "UiGuiVersion.h" -#include <QUrl> -#include <QDesktopServices> -#include <QScrollBar> -#include <QTimer> -#include <QLocale> +#include <tqurl.h> +#include <tqdesktopservices.h> +#include <tqscrollbar.h> +#include <tqtimer.h> +#include <tqlocale.h> /*! \class AboutDialog diff --git a/src/AboutDialog.h b/src/AboutDialog.h index f713d71..adbdf13 100755 --- a/src/AboutDialog.h +++ b/src/AboutDialog.h @@ -20,7 +20,7 @@ #ifndef ABOUTDIALOG_H #define ABOUTDIALOG_H -#include <QDialog> +#include <tqdialog.h> namespace Ui { class AboutDialog; diff --git a/src/AboutDialogGraphicsView.cpp b/src/AboutDialogGraphicsView.cpp index d97cc70..52cb6e1 100755 --- a/src/AboutDialogGraphicsView.cpp +++ b/src/AboutDialogGraphicsView.cpp @@ -21,11 +21,11 @@ #include "AboutDialog.h" -#include <QtGui> -#include <QDesktopWidget> -#include <QDate> -#include <QTimeLine> -#include <QSplashScreen> +#include <tqtgui.h> +#include <tqdesktopwidget.h> +#include <tqdate.h> +#include <tqtimeline.h> +#include <tqsplashscreen.h> /*! \class AboutDialogGraphicsView diff --git a/src/AboutDialogGraphicsView.h b/src/AboutDialogGraphicsView.h index ba22c0e..c673149 100755 --- a/src/AboutDialogGraphicsView.h +++ b/src/AboutDialogGraphicsView.h @@ -19,7 +19,7 @@ #ifndef ABOUTDIALOGGRAPHICSVIEW_H #define ABOUTDIALOGGRAPHICSVIEW_H -#include <QGraphicsView> +#include <tqgraphicsview.h> class AboutDialog; diff --git a/src/FindDialog.ui b/src/FindDialog.ui index 943f5a5..f22f574 100755 --- a/src/FindDialog.ui +++ b/src/FindDialog.ui @@ -1,121 +1,121 @@ -<?xml version="1.0" encoding="UTF-8"?>
-<ui version="4.0">
- <class>FindDialog</class>
- <widget class="QDialog" name="FindDialog">
- <property name="geometry">
- <rect>
- <x>0</x>
- <y>0</y>
- <width>347</width>
- <height>227</height>
- </rect>
- </property>
- <property name="windowTitle">
- <string>Find</string>
- </property>
- <layout class="QVBoxLayout" name="verticalLayout">
- <item>
- <widget class="QLabel" name="label">
- <property name="sizePolicy">
- <sizepolicy hsizetype="Preferred" vsizetype="Maximum">
- <horstretch>0</horstretch>
- <verstretch>0</verstretch>
- </sizepolicy>
- </property>
- <property name="text">
- <string>Find what:</string>
- </property>
- </widget>
- </item>
- <item>
- <widget class="QComboBox" name="comboBox">
- <property name="editable">
- <bool>true</bool>
- </property>
- </widget>
- </item>
- <item>
- <widget class="QGroupBox" name="groupBox">
- <property name="sizePolicy">
- <sizepolicy hsizetype="Preferred" vsizetype="MinimumExpanding">
- <horstretch>0</horstretch>
- <verstretch>0</verstretch>
- </sizepolicy>
- </property>
- <property name="title">
- <string>Find options</string>
- </property>
- <layout class="QVBoxLayout" name="verticalLayout_2">
- <item>
- <widget class="QCheckBox" name="checkBox">
- <property name="text">
- <string>Match case</string>
- </property>
- </widget>
- </item>
- <item>
- <widget class="QCheckBox" name="checkBox_2">
- <property name="text">
- <string>Match whole word</string>
- </property>
- </widget>
- </item>
- <item>
- <widget class="QCheckBox" name="checkBox_3">
- <property name="text">
- <string>Search forward</string>
- </property>
- <property name="checked">
- <bool>true</bool>
- </property>
- </widget>
- </item>
- <item>
- <widget class="QCheckBox" name="checkBox_4">
- <property name="text">
- <string>Use Regular Expressions</string>
- </property>
- </widget>
- </item>
- </layout>
- </widget>
- </item>
- <item>
- <spacer name="verticalSpacer">
- <property name="orientation">
- <enum>Qt::Vertical</enum>
- </property>
- <property name="sizeHint" stdset="0">
- <size>
- <width>20</width>
- <height>40</height>
- </size>
- </property>
- </spacer>
- </item>
- <item>
- <layout class="QHBoxLayout" name="horizontalLayout">
- <property name="sizeConstraint">
- <enum>QLayout::SetMaximumSize</enum>
- </property>
- <item>
- <widget class="QPushButton" name="pushButton">
- <property name="text">
- <string>Find Next</string>
- </property>
- </widget>
- </item>
- <item>
- <widget class="QPushButton" name="pushButton_2">
- <property name="text">
- <string>Close</string>
- </property>
- </widget>
- </item>
- </layout>
- </item>
- </layout>
- </widget>
- <resources/>
- <connections/>
-</ui>
+<?xml version="1.0" encoding="UTF-8"?> +<ui version="4.0"> + <class>FindDialog</class> + <widget class="QDialog" name="FindDialog"> + <property name="geometry"> + <rect> + <x>0</x> + <y>0</y> + <width>347</width> + <height>227</height> + </rect> + </property> + <property name="windowTitle"> + <string>Find</string> + </property> + <layout class="QVBoxLayout" name="verticalLayout"> + <item> + <widget class="QLabel" name="label"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Preferred" vsizetype="Maximum"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="text"> + <string>Find what:</string> + </property> + </widget> + </item> + <item> + <widget class="QComboBox" name="comboBox"> + <property name="editable"> + <bool>true</bool> + </property> + </widget> + </item> + <item> + <widget class="QGroupBox" name="groupBox"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Preferred" vsizetype="MinimumExpanding"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="title"> + <string>Find options</string> + </property> + <layout class="QVBoxLayout" name="verticalLayout_2"> + <item> + <widget class="QCheckBox" name="checkBox"> + <property name="text"> + <string>Match case</string> + </property> + </widget> + </item> + <item> + <widget class="QCheckBox" name="checkBox_2"> + <property name="text"> + <string>Match whole word</string> + </property> + </widget> + </item> + <item> + <widget class="QCheckBox" name="checkBox_3"> + <property name="text"> + <string>Search forward</string> + </property> + <property name="checked"> + <bool>true</bool> + </property> + </widget> + </item> + <item> + <widget class="QCheckBox" name="checkBox_4"> + <property name="text"> + <string>Use Regular Expressions</string> + </property> + </widget> + </item> + </layout> + </widget> + </item> + <item> + <spacer name="verticalSpacer"> + <property name="orientation"> + <enum>Qt::Vertical</enum> + </property> + <property name="sizeHint" stdset="0"> + <size> + <width>20</width> + <height>40</height> + </size> + </property> + </spacer> + </item> + <item> + <layout class="QHBoxLayout" name="horizontalLayout"> + <property name="sizeConstraint"> + <enum>QLayout::SetMaximumSize</enum> + </property> + <item> + <widget class="QPushButton" name="pushButton"> + <property name="text"> + <string>Find Next</string> + </property> + </widget> + </item> + <item> + <widget class="QPushButton" name="pushButton_2"> + <property name="text"> + <string>Close</string> + </property> + </widget> + </item> + </layout> + </item> + </layout> + </widget> + <resources/> + <connections/> +</ui> diff --git a/src/IndentHandler.cpp b/src/IndentHandler.cpp index a1109c4..2446fa3 100755 --- a/src/IndentHandler.cpp +++ b/src/IndentHandler.cpp @@ -25,32 +25,32 @@ #include "UiGuiIniFileParser.h" #include "SettingsPaths.h" -#include <QToolBox> -#include <QVBoxLayout> -#include <QApplication> -#include <QCheckBox> -#include <QComboBox> -#include <QToolButton> -#include <QFile> -#include <QProcess> -#include <QSettings> -#include <QStringList> -#include <QLineEdit> -#include <QSpinBox> -#include <QLabel> -#include <QByteArray> -#include <QDir> -#include <QMessageBox> -#include <QMainWindow> -#include <QTextStream> -#include <QTextCodec> -#include <QtScript> -#include <QDesktopServices> -#include <QMenu> -#include <QAction> -#include <QContextMenuEvent> -#include <QFileDialog> -#include <QtDebug> +#include <tqtoolbox.h> +#include <tqvboxlayout.h> +#include <tqapplication.h> +#include <tqcheckbox.h> +#include <tqcombobox.h> +#include <tqtoolbutton.h> +#include <tqfile.h> +#include <tqprocess.h> +#include <tqsettings.h> +#include <tqstringlist.h> +#include <tqlineedit.h> +#include <tqspinbox.h> +#include <tqlabel.h> +#include <tqbytearray.h> +#include <tqdir.h> +#include <tqmessagebox.h> +#include <tqmainwindow.h> +#include <tqtextstream.h> +#include <tqtextcodec.h> +#include <tqtscript.h> +#include <tqdesktopservices.h> +#include <tqmenu.h> +#include <tqaction.h> +#include <tqcontextmenuevent.h> +#include <tqfiledialog.h> +#include <tqtdebug.h> #ifdef Q_OS_WIN32 #include <Windows.h> diff --git a/src/IndentHandler.h b/src/IndentHandler.h index 3ccb553..3f20d82 100755 --- a/src/IndentHandler.h +++ b/src/IndentHandler.h @@ -20,7 +20,7 @@ #ifndef INDENTHANDLER_H #define INDENTHANDLER_H -#include <QWidget> +#include <tqwidget.h> class UiGuiErrorMessage; class UiGuiIniFileParser; diff --git a/src/MainWindow.cpp b/src/MainWindow.cpp index f7b6185..3c12f81 100755 --- a/src/MainWindow.cpp +++ b/src/MainWindow.cpp @@ -33,26 +33,26 @@ #include "IndentHandler.h" #include "UpdateCheckDialog.h" -#include <QWidget> -#include <QLabel> -#include <QString> -#include <QScrollBar> -#include <QTextCursor> -#include <QFileDialog> -#include <QTextStream> -#include <QTextDocument> -#include <QPrinter> -#include <QPrintDialog> -#include <QCloseEvent> -#include <QHelpEvent> -#include <QToolTip> -#include <QTranslator> -#include <QLocale> -#include <QTextCodec> -#include <QDate> -#include <QUrl> -#include <QMessageBox> -#include <QtDebug> +#include <tqwidget.h> +#include <tqlabel.h> +#include <tqstring.h> +#include <tqscrollbar.h> +#include <tqtextcursor.h> +#include <tqfiledialog.h> +#include <tqtextstream.h> +#include <tqtextdocument.h> +#include <tqprinter.h> +#include <tqprintdialog.h> +#include <tqcloseevent.h> +#include <tqhelpevent.h> +#include <tqtooltip.h> +#include <tqtranslator.h> +#include <tqlocale.h> +#include <tqtextcodec.h> +#include <tqdate.h> +#include <tqurl.h> +#include <tqmessagebox.h> +#include <tqtdebug.h> #include <Qsci/qsciscintilla.h> #include <Qsci/qsciprinter.h> diff --git a/src/MainWindow.h b/src/MainWindow.h index 1205a46..4de1450 100755 --- a/src/MainWindow.h +++ b/src/MainWindow.h @@ -20,7 +20,7 @@ #ifndef MAINWINDOW_H #define MAINWINDOW_H -#include <QMainWindow> +#include <tqmainwindow.h> #include "UiGuiSettings.h" diff --git a/src/SettingsPaths.cpp b/src/SettingsPaths.cpp index f556491..27f9fca 100755 --- a/src/SettingsPaths.cpp +++ b/src/SettingsPaths.cpp @@ -1,275 +1,275 @@ -/***************************************************************************
- * 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 "SettingsPaths.h"
-
-#include <QCoreApplication>
-#include <QFile>
-#include <QDir>
-#include <QDirIterator>
-#include <QStack>
-#include <QtDebug>
-
-#include <stdlib.h>
-
-//! \defgroup grp_Settings All concerning applications settings.
-
-/*!
- \class SettingsPaths
- \ingroup grp_Settings
- \brief SettingsPaths is a pure static functions class from which info about the
- paths needed for settings can be retrieved.
-*/
-
-bool SettingsPaths::_alreadyInitialized = false;
-QString SettingsPaths::_applicationBinaryPath = "";
-QString SettingsPaths::_settingsPath = "";
-QString SettingsPaths::_globalFilesPath = "";
-QString SettingsPaths::_indenterPath = "";
-QString SettingsPaths::_tempPath = "";
-bool SettingsPaths::_portableMode = false;
-
-
-/*!
- \brief Initializes all available information about the paths.
-
- Mainly during this init it is detected whether to start in portable mode or not. This is
- done by testing whether the directory "config" is in the same directory as this
- applications executable file.
- In portable mode all data is ONLY written to subdirectories of the applications executable file.
- Means also that the directory "indenters" has to be there.
- In not portable mode (multiuser mode) only users home directory is used for writing config data.
- */
-void SettingsPaths::init() {
- _alreadyInitialized = true;
-
- qDebug() << __LINE__ << " " << __FUNCTION__ << ": Initializing application paths.";
-
- // Get the applications binary path, with respect to MacOSXs use of the .app folder.
- _applicationBinaryPath = QCoreApplication::applicationDirPath();
- // Remove any trailing slashes
- while ( _applicationBinaryPath.right(1) == "/" ) {
- _applicationBinaryPath.chop(1);
- }
-
-#ifdef UNIVERSALINDENTGUI_NPP_EXPORTS
- _applicationBinaryPath += "/plugins/uigui";
-#endif
-
-#ifdef Q_OS_MAC
- // Because on Mac universal binaries are used, the binary path is not equal
- // to the applications (.app) path. So get the .apps path here.
- int indexOfDotApp = _applicationBinaryPath.indexOf(".app");
- if ( indexOfDotApp != -1 ) {
- // Cut off after the dot of ".app".
- _applicationBinaryPath = _applicationBinaryPath.left( indexOfDotApp-1 );
- // Cut off after the first slash that was in front of ".app" (normally this is the word "UniversalIndentGUI")
- _applicationBinaryPath = _applicationBinaryPath.left( _applicationBinaryPath.lastIndexOf("/") );
- }
-#endif
-
- // If the "config" directory is a subdir of the applications binary path, use this one (portable mode)
- _settingsPath = _applicationBinaryPath + "/config";
- if ( QFile::exists( _settingsPath ) ) {
- _portableMode = true;
- QDir dirCreator;
- _globalFilesPath = _applicationBinaryPath;
- _indenterPath = _applicationBinaryPath + "/indenters";
- dirCreator.mkpath( _settingsPath );
- _tempPath = _applicationBinaryPath + "/temp";
- //TODO: If the portable drive has write protection, use local temp path and clean it up on exit.
- dirCreator.mkpath( _tempPath );
- }
- // ... otherwise use the system specific global application data path.
- else {
- _portableMode = false;
- QDir dirCreator;
-#ifdef Q_OS_WIN
- // Get the local users application settings directory.
- // Remove any trailing slashes.
- _settingsPath = QDir::fromNativeSeparators( qgetenv("APPDATA") );
- while ( _settingsPath.right(1) == "/" ) {
- _settingsPath.chop(1);
- }
- _settingsPath = _settingsPath + "/UniversalIndentGUI";
-
- // On windows systems the directories "indenters", "translations" are subdirs of the _applicationBinaryPath.
- _globalFilesPath = _applicationBinaryPath;
-#else
- // Remove any trailing slashes.
- _settingsPath = QDir::homePath();
- while ( _settingsPath.right(1) == "/" ) {
- _settingsPath.chop(1);
- }
- _settingsPath = _settingsPath + "/.universalindentgui";
- _globalFilesPath = "/usr/share/universalindentgui";
-#endif
- dirCreator.mkpath( _settingsPath );
- // If a highlighter config file does not exist in the users home config dir
- // copy the default config file over there.
- if ( !QFile::exists(_settingsPath+"/UiGuiSyntaxHighlightConfig.ini") ) {
- QFile::copy( _globalFilesPath+"/config/UiGuiSyntaxHighlightConfig.ini", _settingsPath+"/UiGuiSyntaxHighlightConfig.ini" );
- }
- _indenterPath = _globalFilesPath + "/indenters";
-
- // On different systems it may be that "QDir::tempPath()" ends with a "/" or not. So check this.
- // Remove any trailing slashes.
- _tempPath = QDir::tempPath();
- while ( _tempPath.right(1) == "/" ) {
- _tempPath.chop(1);
- }
- _tempPath = _tempPath + "/UniversalIndentGUI";
-
-#if defined(Q_OS_WIN32)
- dirCreator.mkpath( _tempPath );
-#else
- // On Unix based systems create a random temporary directory for security
- // reasons. Otherwise an evil human being could create a symbolic link
- // to an important existing file which gets overwritten when UiGUI writes
- // into this normally temporary but linked file.
- char *pathTemplate = new char[_tempPath.length()+8];
- QByteArray pathTemplateQBA = QString(_tempPath + "-XXXXXX").toAscii();
- delete [] pathTemplate;
- pathTemplate = pathTemplateQBA.data();
- pathTemplate = mkdtemp( pathTemplate );
- _tempPath = pathTemplate;
-#endif
- }
-
- qDebug() << __LINE__ << " " << __FUNCTION__ << ": Paths are:" \
- "<ul><li>_applicationBinaryPath=" << _applicationBinaryPath \
- << "</li><li>_settingsPath=" << _settingsPath \
- << "</li><li>_globalFilesPath=" << _globalFilesPath \
- << "</li><li>_indenterPath=" << _indenterPath \
- << "</li><li>_tempPath=" << _tempPath \
- << "</li><li>Running in portable mode=" << _portableMode << "</li></ul>";
-}
-
-
-/*!
- \brief Returns the path of the applications executable.
- */
-const QString SettingsPaths::getApplicationBinaryPath() {
- if ( !_alreadyInitialized ) {
- SettingsPaths::init();
- }
- return _applicationBinaryPath;
-}
-
-
-/*!
- \brief Returns the path where all settings are being/should be written to.
- */
-const QString SettingsPaths::getSettingsPath() {
- if ( !_alreadyInitialized ) {
- SettingsPaths::init();
- }
- return _settingsPath;
-}
-
-
-/*!
- \brief Returns the path where the files concerning all users reside. For example translations.
- */
-const QString SettingsPaths::getGlobalFilesPath() {
- if ( !_alreadyInitialized ) {
- SettingsPaths::init();
- }
- return _globalFilesPath;
-}
-
-
-/*!
- \brief Returns the path where the indenter executables reside.
- */
-const QString SettingsPaths::getIndenterPath() {
- if ( !_alreadyInitialized ) {
- SettingsPaths::init();
- }
- return _indenterPath;
-}
-
-
-/*!
- \brief Returns the path where the where all temporary data should be written to.
- */
-const QString SettingsPaths::getTempPath() {
- if ( !_alreadyInitialized ) {
- SettingsPaths::init();
- }
- return _tempPath;
-}
-
-
-/*!
- \brief Returns true if portable mode shall be used.
- */
-bool SettingsPaths::getPortableMode() {
- if ( !_alreadyInitialized ) {
- SettingsPaths::init();
- }
- return _portableMode;
-}
-
-
-/*!
- \brief Completely deletes the created temporary directory with all of its content.
- */
-void SettingsPaths::cleanAndRemoveTempDir() {
- QDirIterator dirIterator(_tempPath, QDirIterator::Subdirectories);
- QStack<QString> directoryStack;
- bool noErrorsOccurred = true;
-
- while ( dirIterator.hasNext() ) {
- QString currentDirOrFile = dirIterator.next();
- // If this dummy call isn't done here, calling "dirIterator.fileInfo().isDir()" later somehow fails.
- dirIterator.fileInfo();
-
- if ( !currentDirOrFile.isEmpty() && dirIterator.fileName() != "." && dirIterator.fileName() != ".." ) {
- // There is a path on the stack but the current path doesn't start with that path.
- // So we changed into another parent directory and the one on the stack can be deleted
- // since it must be empty.
- if ( !directoryStack.isEmpty() && !currentDirOrFile.startsWith(directoryStack.top()) ) {
- QString dirToBeRemoved = directoryStack.pop();
- bool couldRemoveDir = QDir(dirToBeRemoved).rmdir(dirToBeRemoved);
- noErrorsOccurred &= couldRemoveDir;
- if ( couldRemoveDir == false )
- qWarning() << __LINE__ << " " << __FUNCTION__ << "Could not remove the directory: " << dirToBeRemoved;
- //qDebug() << "Removing Dir " << directoryStack.pop();
- }
-
- // If the iterator currently points to a directory push it onto the stack.
- if ( dirIterator.fileInfo().isDir() ) {
- directoryStack.push( currentDirOrFile );
- //qDebug() << "Pushing onto Stack " << currentDirOrFile;
- }
- // otherwise it must be a file, so delete it.
- else {
- bool couldRemoveFile = QFile::remove( currentDirOrFile );
- noErrorsOccurred &= couldRemoveFile;
- if ( couldRemoveFile == false )
- qWarning() << __LINE__ << " " << __FUNCTION__ << "Could not remove the file: " << currentDirOrFile;
- //qDebug() << "Removing File " << currentDirOrFile;
- }
- }
- }
- noErrorsOccurred &= QDir(_tempPath).rmdir(_tempPath);
- if ( noErrorsOccurred == false )
- qWarning() << __LINE__ << " " << __FUNCTION__ << "While cleaning up the temp dir an error occurred.";
-}
+/*************************************************************************** + * 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 "SettingsPaths.h" + +#include <tqcoreapplication.h> +#include <tqfile.h> +#include <tqdir.h> +#include <tqdiriterator.h> +#include <tqstack.h> +#include <tqtdebug.h> + +#include <stdlib.h> + +//! \defgroup grp_Settings All concerning applications settings. + +/*! + \class SettingsPaths + \ingroup grp_Settings + \brief SettingsPaths is a pure static functions class from which info about the + paths needed for settings can be retrieved. +*/ + +bool SettingsPaths::_alreadyInitialized = false; +QString SettingsPaths::_applicationBinaryPath = ""; +QString SettingsPaths::_settingsPath = ""; +QString SettingsPaths::_globalFilesPath = ""; +QString SettingsPaths::_indenterPath = ""; +QString SettingsPaths::_tempPath = ""; +bool SettingsPaths::_portableMode = false; + + +/*! + \brief Initializes all available information about the paths. + + Mainly during this init it is detected whether to start in portable mode or not. This is + done by testing whether the directory "config" is in the same directory as this + applications executable file. + In portable mode all data is ONLY written to subdirectories of the applications executable file. + Means also that the directory "indenters" has to be there. + In not portable mode (multiuser mode) only users home directory is used for writing config data. + */ +void SettingsPaths::init() { + _alreadyInitialized = true; + + qDebug() << __LINE__ << " " << __FUNCTION__ << ": Initializing application paths."; + + // Get the applications binary path, with respect to MacOSXs use of the .app folder. + _applicationBinaryPath = QCoreApplication::applicationDirPath(); + // Remove any trailing slashes + while ( _applicationBinaryPath.right(1) == "/" ) { + _applicationBinaryPath.chop(1); + } + +#ifdef UNIVERSALINDENTGUI_NPP_EXPORTS + _applicationBinaryPath += "/plugins/uigui"; +#endif + +#ifdef Q_OS_MAC + // Because on Mac universal binaries are used, the binary path is not equal + // to the applications (.app) path. So get the .apps path here. + int indexOfDotApp = _applicationBinaryPath.indexOf(".app"); + if ( indexOfDotApp != -1 ) { + // Cut off after the dot of ".app". + _applicationBinaryPath = _applicationBinaryPath.left( indexOfDotApp-1 ); + // Cut off after the first slash that was in front of ".app" (normally this is the word "UniversalIndentGUI") + _applicationBinaryPath = _applicationBinaryPath.left( _applicationBinaryPath.lastIndexOf("/") ); + } +#endif + + // If the "config" directory is a subdir of the applications binary path, use this one (portable mode) + _settingsPath = _applicationBinaryPath + "/config"; + if ( QFile::exists( _settingsPath ) ) { + _portableMode = true; + QDir dirCreator; + _globalFilesPath = _applicationBinaryPath; + _indenterPath = _applicationBinaryPath + "/indenters"; + dirCreator.mkpath( _settingsPath ); + _tempPath = _applicationBinaryPath + "/temp"; + //TODO: If the portable drive has write protection, use local temp path and clean it up on exit. + dirCreator.mkpath( _tempPath ); + } + // ... otherwise use the system specific global application data path. + else { + _portableMode = false; + QDir dirCreator; +#ifdef Q_OS_WIN + // Get the local users application settings directory. + // Remove any trailing slashes. + _settingsPath = QDir::fromNativeSeparators( qgetenv("APPDATA") ); + while ( _settingsPath.right(1) == "/" ) { + _settingsPath.chop(1); + } + _settingsPath = _settingsPath + "/UniversalIndentGUI"; + + // On windows systems the directories "indenters", "translations" are subdirs of the _applicationBinaryPath. + _globalFilesPath = _applicationBinaryPath; +#else + // Remove any trailing slashes. + _settingsPath = QDir::homePath(); + while ( _settingsPath.right(1) == "/" ) { + _settingsPath.chop(1); + } + _settingsPath = _settingsPath + "/.universalindentgui"; + _globalFilesPath = "/usr/share/universalindentgui"; +#endif + dirCreator.mkpath( _settingsPath ); + // If a highlighter config file does not exist in the users home config dir + // copy the default config file over there. + if ( !QFile::exists(_settingsPath+"/UiGuiSyntaxHighlightConfig.ini") ) { + QFile::copy( _globalFilesPath+"/config/UiGuiSyntaxHighlightConfig.ini", _settingsPath+"/UiGuiSyntaxHighlightConfig.ini" ); + } + _indenterPath = _globalFilesPath + "/indenters"; + + // On different systems it may be that "QDir::tempPath()" ends with a "/" or not. So check this. + // Remove any trailing slashes. + _tempPath = QDir::tempPath(); + while ( _tempPath.right(1) == "/" ) { + _tempPath.chop(1); + } + _tempPath = _tempPath + "/UniversalIndentGUI"; + +#if defined(Q_OS_WIN32) + dirCreator.mkpath( _tempPath ); +#else + // On Unix based systems create a random temporary directory for security + // reasons. Otherwise an evil human being could create a symbolic link + // to an important existing file which gets overwritten when UiGUI writes + // into this normally temporary but linked file. + char *pathTemplate = new char[_tempPath.length()+8]; + QByteArray pathTemplateQBA = QString(_tempPath + "-XXXXXX").toAscii(); + delete [] pathTemplate; + pathTemplate = pathTemplateQBA.data(); + pathTemplate = mkdtemp( pathTemplate ); + _tempPath = pathTemplate; +#endif + } + + qDebug() << __LINE__ << " " << __FUNCTION__ << ": Paths are:" \ + "<ul><li>_applicationBinaryPath=" << _applicationBinaryPath \ + << "</li><li>_settingsPath=" << _settingsPath \ + << "</li><li>_globalFilesPath=" << _globalFilesPath \ + << "</li><li>_indenterPath=" << _indenterPath \ + << "</li><li>_tempPath=" << _tempPath \ + << "</li><li>Running in portable mode=" << _portableMode << "</li></ul>"; +} + + +/*! + \brief Returns the path of the applications executable. + */ +const QString SettingsPaths::getApplicationBinaryPath() { + if ( !_alreadyInitialized ) { + SettingsPaths::init(); + } + return _applicationBinaryPath; +} + + +/*! + \brief Returns the path where all settings are being/should be written to. + */ +const QString SettingsPaths::getSettingsPath() { + if ( !_alreadyInitialized ) { + SettingsPaths::init(); + } + return _settingsPath; +} + + +/*! + \brief Returns the path where the files concerning all users reside. For example translations. + */ +const QString SettingsPaths::getGlobalFilesPath() { + if ( !_alreadyInitialized ) { + SettingsPaths::init(); + } + return _globalFilesPath; +} + + +/*! + \brief Returns the path where the indenter executables reside. + */ +const QString SettingsPaths::getIndenterPath() { + if ( !_alreadyInitialized ) { + SettingsPaths::init(); + } + return _indenterPath; +} + + +/*! + \brief Returns the path where the where all temporary data should be written to. + */ +const QString SettingsPaths::getTempPath() { + if ( !_alreadyInitialized ) { + SettingsPaths::init(); + } + return _tempPath; +} + + +/*! + \brief Returns true if portable mode shall be used. + */ +bool SettingsPaths::getPortableMode() { + if ( !_alreadyInitialized ) { + SettingsPaths::init(); + } + return _portableMode; +} + + +/*! + \brief Completely deletes the created temporary directory with all of its content. + */ +void SettingsPaths::cleanAndRemoveTempDir() { + QDirIterator dirIterator(_tempPath, QDirIterator::Subdirectories); + QStack<QString> directoryStack; + bool noErrorsOccurred = true; + + while ( dirIterator.hasNext() ) { + QString currentDirOrFile = dirIterator.next(); + // If this dummy call isn't done here, calling "dirIterator.fileInfo().isDir()" later somehow fails. + dirIterator.fileInfo(); + + if ( !currentDirOrFile.isEmpty() && dirIterator.fileName() != "." && dirIterator.fileName() != ".." ) { + // There is a path on the stack but the current path doesn't start with that path. + // So we changed into another parent directory and the one on the stack can be deleted + // since it must be empty. + if ( !directoryStack.isEmpty() && !currentDirOrFile.startsWith(directoryStack.top()) ) { + QString dirToBeRemoved = directoryStack.pop(); + bool couldRemoveDir = QDir(dirToBeRemoved).rmdir(dirToBeRemoved); + noErrorsOccurred &= couldRemoveDir; + if ( couldRemoveDir == false ) + qWarning() << __LINE__ << " " << __FUNCTION__ << "Could not remove the directory: " << dirToBeRemoved; + //qDebug() << "Removing Dir " << directoryStack.pop(); + } + + // If the iterator currently points to a directory push it onto the stack. + if ( dirIterator.fileInfo().isDir() ) { + directoryStack.push( currentDirOrFile ); + //qDebug() << "Pushing onto Stack " << currentDirOrFile; + } + // otherwise it must be a file, so delete it. + else { + bool couldRemoveFile = QFile::remove( currentDirOrFile ); + noErrorsOccurred &= couldRemoveFile; + if ( couldRemoveFile == false ) + qWarning() << __LINE__ << " " << __FUNCTION__ << "Could not remove the file: " << currentDirOrFile; + //qDebug() << "Removing File " << currentDirOrFile; + } + } + } + noErrorsOccurred &= QDir(_tempPath).rmdir(_tempPath); + if ( noErrorsOccurred == false ) + qWarning() << __LINE__ << " " << __FUNCTION__ << "While cleaning up the temp dir an error occurred."; +} diff --git a/src/SettingsPaths.h b/src/SettingsPaths.h index 71f17e3..3442216 100755 --- a/src/SettingsPaths.h +++ b/src/SettingsPaths.h @@ -1,50 +1,50 @@ -/***************************************************************************
- * 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. *
- ***************************************************************************/
-
-#ifndef SETTINGSPATHS_H
-#define SETTINGSPATHS_H
-
-class QString;
-
-
-class SettingsPaths
-{
-public:
- static void init();
- static const QString getApplicationBinaryPath();
- static const QString getSettingsPath();
- static const QString getGlobalFilesPath();
- static const QString getIndenterPath();
- static const QString getTempPath();
- static bool getPortableMode();
- static void cleanAndRemoveTempDir();
-
-private:
- SettingsPaths();
-
- static bool _alreadyInitialized;
- static QString _applicationBinaryPath;
- static QString _settingsPath;
- static QString _globalFilesPath;
- static QString _indenterPath;
- static QString _tempPath;
- static bool _portableMode;
-};
-
-#endif // SETTINGSPATHS_H
+/*************************************************************************** + * 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. * + ***************************************************************************/ + +#ifndef SETTINGSPATHS_H +#define SETTINGSPATHS_H + +class QString; + + +class SettingsPaths +{ +public: + static void init(); + static const QString getApplicationBinaryPath(); + static const QString getSettingsPath(); + static const QString getGlobalFilesPath(); + static const QString getIndenterPath(); + static const QString getTempPath(); + static bool getPortableMode(); + static void cleanAndRemoveTempDir(); + +private: + SettingsPaths(); + + static bool _alreadyInitialized; + static QString _applicationBinaryPath; + static QString _settingsPath; + static QString _globalFilesPath; + static QString _indenterPath; + static QString _tempPath; + static bool _portableMode; +}; + +#endif // SETTINGSPATHS_H diff --git a/src/TemplateBatchScript.cpp b/src/TemplateBatchScript.cpp index 00c96ce..e8a91e8 100755 --- a/src/TemplateBatchScript.cpp +++ b/src/TemplateBatchScript.cpp @@ -20,7 +20,7 @@ #include "TemplateBatchScript.h" // Need to include QObject here so that platform specific defines like Q_OS_WIN32 are set. -#include <QObject> +#include <tqobject.h> /*! \brief The only and static function of this class returns a batch or shell script diff --git a/src/TemplateBatchScript.h b/src/TemplateBatchScript.h index ff14ade..4a71a11 100755 --- a/src/TemplateBatchScript.h +++ b/src/TemplateBatchScript.h @@ -1,31 +1,31 @@ -/***************************************************************************
- * 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. *
- ***************************************************************************/
-
-#ifndef TEMPLATEBATCHSCRIPT_H
-#define TEMPLATEBATCHSCRIPT_H
-
-class TemplateBatchScript
-{
-private:
- TemplateBatchScript();
-public:
- static const char* getTemplateBatchScript();
-};
-
-#endif // TEMPLATEBATCHSCRIPT_H
+/*************************************************************************** + * 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. * + ***************************************************************************/ + +#ifndef TEMPLATEBATCHSCRIPT_H +#define TEMPLATEBATCHSCRIPT_H + +class TemplateBatchScript +{ +private: + TemplateBatchScript(); +public: + static const char* getTemplateBatchScript(); +}; + +#endif // TEMPLATEBATCHSCRIPT_H diff --git a/src/UiGuiErrorMessage.cpp b/src/UiGuiErrorMessage.cpp index 424a709..63aed21 100755 --- a/src/UiGuiErrorMessage.cpp +++ b/src/UiGuiErrorMessage.cpp @@ -19,7 +19,7 @@ #include "UiGuiErrorMessage.h" -#include <QCheckBox> +#include <tqcheckbox.h> /*! \class UiGuiErrorMessage diff --git a/src/UiGuiErrorMessage.h b/src/UiGuiErrorMessage.h index f520795..ce5b405 100755 --- a/src/UiGuiErrorMessage.h +++ b/src/UiGuiErrorMessage.h @@ -1,43 +1,43 @@ -/***************************************************************************
- * 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. *
- ***************************************************************************/
-
-#ifndef UIGUIERRORMESSAGE_H
-#define UIGUIERRORMESSAGE_H
-
-#include <QErrorMessage>
-
-class QCheckBox;
-
-
-class UiGuiErrorMessage : public QErrorMessage
-{
- Q_OBJECT
-
-public:
- UiGuiErrorMessage(QWidget *parent = 0);
- ~UiGuiErrorMessage(void);
- void showMessage( const QString &message );
- void showMessage( const QString &title, const QString &message );
-
-private:
- QCheckBox *_showAgainCheckBox;
- QStringList _errorMessageList;
-};
-
-#endif // UIGUIERRORMESSAGE_H
+/*************************************************************************** + * 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. * + ***************************************************************************/ + +#ifndef UIGUIERRORMESSAGE_H +#define UIGUIERRORMESSAGE_H + +#include <tqerrormessage.h> + +class QCheckBox; + + +class UiGuiErrorMessage : public QErrorMessage +{ + Q_OBJECT + +public: + UiGuiErrorMessage(QWidget *parent = 0); + ~UiGuiErrorMessage(void); + void showMessage( const QString &message ); + void showMessage( const QString &title, const QString &message ); + +private: + QCheckBox *_showAgainCheckBox; + QStringList _errorMessageList; +}; + +#endif // UIGUIERRORMESSAGE_H diff --git a/src/UiGuiHighlighter.cpp b/src/UiGuiHighlighter.cpp index ac74909..e35a8ec 100755 --- a/src/UiGuiHighlighter.cpp +++ b/src/UiGuiHighlighter.cpp @@ -21,10 +21,10 @@ #include "SettingsPaths.h" -#include <QSettings> -#include <QMenu> -#include <QScrollBar> -#include <QCoreApplication> +#include <tqsettings.h> +#include <tqmenu.h> +#include <tqscrollbar.h> +#include <tqcoreapplication.h> #include <Qsci/qsciscintilla.h> #include <Qsci/qscilexer.h> diff --git a/src/UiGuiHighlighter.h b/src/UiGuiHighlighter.h index d0d60d4..4ac0f35 100755 --- a/src/UiGuiHighlighter.h +++ b/src/UiGuiHighlighter.h @@ -20,10 +20,10 @@ #ifndef UIGUIHIGHLIGHTER_H #define UIGUIHIGHLIGHTER_H -#include <QObject> -#include <QMap> -#include <QFont> -#include <QColor> +#include <tqobject.h> +#include <tqmap.h> +#include <tqfont.h> +#include <tqcolor.h> class QAction; class QSettings; diff --git a/src/UiGuiIndentServer.cpp b/src/UiGuiIndentServer.cpp index 0dfc93f..8a93094 100755 --- a/src/UiGuiIndentServer.cpp +++ b/src/UiGuiIndentServer.cpp @@ -19,10 +19,10 @@ #include "UiGuiIndentServer.h" -#include <QTcpServer> -#include <QTcpSocket> -#include <QMessageBox> -#include <QtDebug> +#include <tqtcpserver.h> +#include <tqtcpsocket.h> +#include <tqmessagebox.h> +#include <tqtdebug.h> //! \defgroup grp_Server All concerning the server component. diff --git a/src/UiGuiIndentServer.h b/src/UiGuiIndentServer.h index 837693a..79f4606 100755 --- a/src/UiGuiIndentServer.h +++ b/src/UiGuiIndentServer.h @@ -1,55 +1,55 @@ -/***************************************************************************
- * 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. *
- ***************************************************************************/
-
-#ifndef UIGUIINDENTSERVER_H
-#define UIGUIINDENTSERVER_H
-
-#include <QObject>
-
-class QTcpServer;
-class QTcpSocket;
-
-
-class UiGuiIndentServer : public QObject
-{
- Q_OBJECT
-
-public:
- UiGuiIndentServer(void);
- ~UiGuiIndentServer(void);
-
-public slots:
- void startServer();
- void stopServer();
-
-private slots:
- void handleNewConnection();
- void handleReceivedData();
- void sendMessage(const QString &message);
- void checkIfReadyForHandleRequest();
-
-private:
- QTcpServer *_tcpServer;
- QByteArray _dataToSend;
- bool _readyForHandleRequest;
- QTcpSocket *_currentClientConnection;
- quint32 _blockSize;
-};
-
-#endif // UIGUIINDENTSERVER_H
+/*************************************************************************** + * 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. * + ***************************************************************************/ + +#ifndef UIGUIINDENTSERVER_H +#define UIGUIINDENTSERVER_H + +#include <tqobject.h> + +class QTcpServer; +class QTcpSocket; + + +class UiGuiIndentServer : public QObject +{ + Q_OBJECT + +public: + UiGuiIndentServer(void); + ~UiGuiIndentServer(void); + +public slots: + void startServer(); + void stopServer(); + +private slots: + void handleNewConnection(); + void handleReceivedData(); + void sendMessage(const QString &message); + void checkIfReadyForHandleRequest(); + +private: + QTcpServer *_tcpServer; + QByteArray _dataToSend; + bool _readyForHandleRequest; + QTcpSocket *_currentClientConnection; + quint32 _blockSize; +}; + +#endif // UIGUIINDENTSERVER_H diff --git a/src/UiGuiIniFileParser.cpp b/src/UiGuiIniFileParser.cpp index 84542e0..9e1a023 100755 --- a/src/UiGuiIniFileParser.cpp +++ b/src/UiGuiIniFileParser.cpp @@ -19,10 +19,10 @@ #include "UiGuiIniFileParser.h" -#include <QFile> -#include <QStringList> -#include <QVariant> -#include <QTextStream> +#include <tqfile.h> +#include <tqstringlist.h> +#include <tqvariant.h> +#include <tqtextstream.h> //! \defgroup grp_Settings All concerning applications settings. diff --git a/src/UiGuiIniFileParser.h b/src/UiGuiIniFileParser.h index cbbc3c9..84c19a7 100755 --- a/src/UiGuiIniFileParser.h +++ b/src/UiGuiIniFileParser.h @@ -1,52 +1,52 @@ -/***************************************************************************
- * 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. *
- ***************************************************************************/
-
-#ifndef UIGUIINIFILEPARSER_H
-#define UIGUIINIFILEPARSER_H
-
-#include <QMap>
-#include <QString>
-
-#include <vector>
-
-class QStringList;
-class QVariant;
-
-
-class UiGuiIniFileParser
-{
-public:
- UiGuiIniFileParser(void);
- UiGuiIniFileParser(const QString &iniFileName);
- ~UiGuiIniFileParser(void);
- QVariant value(const QString &keyName, const QString &defaultValue = "");
- QStringList childGroups();
-
-protected:
- void init();
-
-private:
- void parseIniFile();
-
- QString _iniFileName;
- std::vector<QString> _sections;
- QMap<QString, QVariant> _keyValueMap;
-};
-
-#endif // UIGUIINIFILEPARSER_H
+/*************************************************************************** + * 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. * + ***************************************************************************/ + +#ifndef UIGUIINIFILEPARSER_H +#define UIGUIINIFILEPARSER_H + +#include <tqmap.h> +#include <tqstring.h> + +#include <vector> + +class QStringList; +class QVariant; + + +class UiGuiIniFileParser +{ +public: + UiGuiIniFileParser(void); + UiGuiIniFileParser(const QString &iniFileName); + ~UiGuiIniFileParser(void); + QVariant value(const QString &keyName, const QString &defaultValue = ""); + QStringList childGroups(); + +protected: + void init(); + +private: + void parseIniFile(); + + QString _iniFileName; + std::vector<QString> _sections; + QMap<QString, QVariant> _keyValueMap; +}; + +#endif // UIGUIINIFILEPARSER_H diff --git a/src/UiGuiSettings.cpp b/src/UiGuiSettings.cpp index f997ec3..5d8349b 100755 --- a/src/UiGuiSettings.cpp +++ b/src/UiGuiSettings.cpp @@ -1,688 +1,688 @@ -/***************************************************************************
-* 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 "UiGuiSettings.h"
-
-#include "SettingsPaths.h"
-
-#include <QSettings>
-#include <QPoint>
-#include <QSize>
-#include <QDir>
-#include <QDate>
-#include <QStringList>
-#include <QCoreApplication>
-#include <QMetaMethod>
-#include <QMetaProperty>
-#include <QWidget>
-
-//! \defgroup grp_Settings All concerning the settings.
-
-/*!
- \class UiGuiSettings
- \ingroup grp_Settings
- \brief Handles the settings of the program. Reads them on startup and saves them on exit.
- Is a singleton class and can only be accessed via getInstance().
-*/
-
-// Inits the single class instance pointer.
-QWeakPointer<UiGuiSettings> UiGuiSettings::_instance;
-
-
-/*!
- \brief The constructor for the settings.
-*/
-UiGuiSettings::UiGuiSettings() : QObject() {
- // Create the main application settings object from the UniversalIndentGUI.ini file.
- _qsettings = new QSettings(SettingsPaths::getSettingsPath() + "/UniversalIndentGUI.ini", QSettings::IniFormat, this);
-
- _indenterDirctoryStr = SettingsPaths::getGlobalFilesPath() + "/indenters";
- readAvailableTranslations();
- initSettings();
-}
-
-
-/*!
- \brief Returns the instance of the settings class. If no instance exists, ONE will be created.
- */
-QSharedPointer<UiGuiSettings> UiGuiSettings::getInstance() {
- QSharedPointer<UiGuiSettings> sharedInstance = _instance.toStrongRef();
- if ( sharedInstance.isNull() ) {
- // Create the settings object, which loads all UiGui settings from a file.
- sharedInstance = QSharedPointer<UiGuiSettings>(new UiGuiSettings());
- _instance = sharedInstance.toWeakRef();
- }
-
- return sharedInstance;
-}
-
-
-/*!
- \brief The destructor saves the settings to a file.
- */
-UiGuiSettings::~UiGuiSettings() {
- // Convert the language setting from an integer index to a string.
- int index = _qsettings->value("UniversalIndentGUI/language", 0).toInt();
- if ( index < 0 || index >= _availableTranslations.size() )
- index = 0;
-
- _qsettings->setValue( "UniversalIndentGUI/language", _availableTranslations.at(index) );
-}
-
-
-/*!
- \brief Scans the translations directory for available translation files and
- stores them in the QList \a _availableTranslations.
- */
-void UiGuiSettings::readAvailableTranslations() {
- QString languageShort;
- QStringList languageFileList;
-
- // English is the default language. A translation file does not exist but to have a menu entry, added here.
- languageFileList << "universalindent_en.qm";
-
- // Find all translation files in the "translations" directory.
- QDir translationDirectory = QDir( SettingsPaths::getGlobalFilesPath() + "/translations" );
- languageFileList << translationDirectory.entryList( QStringList("universalindent_*.qm") );
-
- // Loop for each found translation file
- foreach ( languageShort, languageFileList ) {
- // Remove the leading string "universalindent_" from the filename.
- languageShort.remove(0,16);
- // Remove trailing file extension ".qm".
- languageShort.chop(3);
-
- _availableTranslations.append(languageShort);
- }
-}
-
-
-/*!
- \brief Returns a list of the mnemonics of the available translations.
- */
-QStringList UiGuiSettings::getAvailableTranslations() {
- return _availableTranslations;
-}
-
-
-/*!
- \brief Returns the value of the by \a settingsName defined setting as QVariant.
-
- If the named setting does not exist, 0 is being returned.
-*/
-QVariant UiGuiSettings::getValueByName(QString settingName) {
- return _qsettings->value("UniversalIndentGUI/" + settingName);
-}
-
-
-/*!
- \brief Loads the settings for the main application.
-
- Settings are for example last selected indenter, last loaded source code file and so on.
-*/
-bool UiGuiSettings::initSettings()
-{
- // Read the version string saved in the settings file.
- _qsettings->setValue( "UniversalIndentGUI/version", _qsettings->value("UniversalIndentGUI/version", "") );
-
- // Read windows last size and position from the settings file.
- _qsettings->setValue( "UniversalIndentGUI/maximized", _qsettings->value("UniversalIndentGUI/maximized", false) );
- _qsettings->setValue( "UniversalIndentGUI/position", _qsettings->value("UniversalIndentGUI/position", QPoint(50, 50)) );
- _qsettings->setValue( "UniversalIndentGUI/size", _qsettings->value("UniversalIndentGUI/size", QSize(800, 600)) );
-
- // Read last selected encoding for the opened source code file.
- _qsettings->setValue( "UniversalIndentGUI/encoding", _qsettings->value("UniversalIndentGUI/encoding", "UTF-8") );
-
- // Read maximum length of list for recently opened files.
- _qsettings->setValue( "UniversalIndentGUI/recentlyOpenedListSize", _qsettings->value("UniversalIndentGUI/recentlyOpenedListSize", 5) );
-
- // Read if last opened source code file should be loaded on startup.
- _qsettings->setValue( "UniversalIndentGUI/loadLastSourceCodeFileOnStartup", _qsettings->value("UniversalIndentGUI/loadLastSourceCodeFileOnStartup", true) );
-
- // Read last opened source code file from the settings file.
- _qsettings->setValue( "UniversalIndentGUI/lastSourceCodeFile", _qsettings->value("UniversalIndentGUI/lastSourceCodeFile", _indenterDirctoryStr+"/example.cpp") );
-
- // Read last selected indenter from the settings file.
- int selectedIndenter = _qsettings->value("UniversalIndentGUI/selectedIndenter", 0).toInt();
- if ( selectedIndenter < 0 ) {
- selectedIndenter = 0;
- }
- _qsettings->setValue( "UniversalIndentGUI/selectedIndenter", selectedIndenter );
-
- // Read if syntax highlighting is enabled.
- _qsettings->setValue( "UniversalIndentGUI/SyntaxHighlightingEnabled", _qsettings->value("UniversalIndentGUI/SyntaxHighlightingEnabled", true) );
-
- // Read if white space characters should be displayed.
- _qsettings->setValue( "UniversalIndentGUI/whiteSpaceIsVisible", _qsettings->value("UniversalIndentGUI/whiteSpaceIsVisible", false) );
-
- // Read if indenter parameter tool tips are enabled.
- _qsettings->setValue( "UniversalIndentGUI/indenterParameterTooltipsEnabled", _qsettings->value("UniversalIndentGUI/indenterParameterTooltipsEnabled", true) );
-
- // Read the tab width from the settings file.
- _qsettings->setValue( "UniversalIndentGUI/tabWidth", _qsettings->value("UniversalIndentGUI/tabWidth", 4) );
-
- // Read the last selected language and stores the index it has in the list of available translations.
- _qsettings->setValue( "UniversalIndentGUI/language", _availableTranslations.indexOf( _qsettings->value("UniversalIndentGUI/language", "").toString() ) );
-
- // Read the update check settings from the settings file.
- _qsettings->setValue( "UniversalIndentGUI/CheckForUpdate", _qsettings->value("UniversalIndentGUI/CheckForUpdate", false) );
- _qsettings->setValue( "UniversalIndentGUI/LastUpdateCheck", _qsettings->value("UniversalIndentGUI/LastUpdateCheck", QDate(1900,1,1)) );
-
- // Read the main window state.
- _qsettings->setValue( "UniversalIndentGUI/MainWindowState", _qsettings->value("UniversalIndentGUI/MainWindowState", QByteArray()) );
-
- return true;
-}
-
-
-/*!
- \brief Register the by \a propertyName defined property of \a obj to be connected to the setting defined by \a settingName.
-
- The \a propertyName must be one of those that are listed in the Qt "Properties" documentation section of a Qt Object.
- All further needed info is retrieved via the \a obj's MetaObject, like the to the property bound signal.
- */
-bool UiGuiSettings::registerObjectProperty( QObject *obj, const QString &propertyName, const QString &settingName )
-{
- const QMetaObject *metaObject = obj->metaObject();
- bool connectSuccess = false;
-
- // Connect to the objects destroyed signal, so that it will be correctly unregistered.
- connectSuccess = connect(obj, SIGNAL(destroyed(QObject*)), this, SLOT(unregisterObjectProperty(QObject*)));
-
- int indexOfProp = metaObject->indexOfProperty( qPrintable(propertyName) );
- if ( connectSuccess && indexOfProp > -1 ) {
- QMetaProperty mProp = metaObject->property(indexOfProp);
-
- // Connect to the property's value changed signal.
- if ( mProp.hasNotifySignal() ) {
- QMetaMethod signal = mProp.notifySignal();
- //QString teststr = qPrintable(SIGNAL() + QString(signal.signature()));
- // The command "SIGNAL() + QString(signal.signature())" assembles the signal methods signature to a valid Qt SIGNAL.
- connectSuccess = connect(obj, qPrintable(SIGNAL() + QString(signal.signature())), this, SLOT(handleObjectPropertyChange()));
- }
-
- if ( connectSuccess ) {
- _registeredObjectProperties[obj] = QStringList() << propertyName << settingName;
- }
- else {
- //TODO: Write a debug warning to the log.
- disconnect(obj, SIGNAL(destroyed(QObject*)), this, SLOT(unregisterObjectProperty(QObject*)));
- return false;
- }
-
- // If setting already exists, set the objects property to the setting value.
- if ( _qsettings->contains("UniversalIndentGUI/" + settingName) ) {
- mProp.write(obj, _qsettings->value("UniversalIndentGUI/" + settingName));
- }
- // Otherwise add the setting and set it to the value of the objects property.
- else {
- _qsettings->setValue("UniversalIndentGUI/" + settingName, mProp.read(obj));
- }
- }
- else {
- //TODO: Write a debug warning to the log.
- disconnect(obj, SIGNAL(destroyed(QObject*)), this, SLOT(unregisterObjectProperty(QObject*)));
- return false;
- }
-
- return true;
-}
-
-
-/*!
- \brief Searches the child QObjects of \a obj for a property name and setting name definition within
- their custom properties and registers this property name to that setting name if both were found.
-
- The custom properties, for which are searched, are "connectedPropertyName" and "connectedSettingName",
- where "connectedPropertyName" is the name of a QObject property as it is documented in the QtDocs, and
- "connectedSettingName" is the name of a setting here within UiGuiSettings. If the mentioned setting
- name doesn't exist, it will be created.
-
- Returns true, if all found property and setting definitions could be successfully registered.
- Returns false, if any of those registrations fails.
- */
-bool UiGuiSettings::registerObjectPropertyRecursive(QObject *obj) {
- return checkCustomPropertiesAndCallFunction(obj, &UiGuiSettings::registerObjectProperty);
-}
-
-
-/*!
- \brief Assigns the by \a settingName defined setting value to the by \a propertyName defined property of \a obj.
-
- Returns true, if the value could be assigned, otherwise returns false, which is the case if settingName doesn't exist
- within the settings or if the mentioned propertyName wasn't found for the \a obj.
- */
-bool UiGuiSettings::setObjectPropertyToSettingValue( QObject *obj, const QString &propertyName, const QString &settingName )
-{
- const QMetaObject *metaObject = obj->metaObject();
-
- int indexOfProp = metaObject->indexOfProperty( qPrintable(propertyName) );
- if ( indexOfProp > -1 ) {
- QMetaProperty mProp = metaObject->property(indexOfProp);
-
- // If setting already exists, set the objects property to the setting value.
- if ( _qsettings->contains("UniversalIndentGUI/" + settingName) ) {
- mProp.write(obj, _qsettings->value("UniversalIndentGUI/" + settingName));
- }
- // The setting didn't exist so return that setting the objects property failed.
- else {
- //TODO: Write a debug warning to the log.
- return false;
- }
- }
- else {
- //TODO: Write a debug warning to the log.
- return false;
- }
-
- return true;
-}
-
-
-/*!
- \brief Searches the child QObjects of \a obj for a property name and setting name definition within
- their custom properties and sets each property to settings value.
-
- The custom properties, for which are searched, are "connectedPropertyName" and "connectedSettingName",
- where "connectedPropertyName" is the name of a QObject property as it is documented in the QtDocs, and
- "connectedSettingName" is the name of a setting here within UiGuiSettings.
-
- Returns true, if all found property and setting definitions could be successfully registered.
- Returns false, if any of those registrations fails.
- */
-bool UiGuiSettings::setObjectPropertyToSettingValueRecursive(QObject *obj) {
- return checkCustomPropertiesAndCallFunction(obj, &UiGuiSettings::setObjectPropertyToSettingValue);
-}
-
-
-/*!
- \brief Assigns the by \a propertyName defined property's value of \a obj to the by \a settingName defined setting.
-
- If the \a settingName didn't exist yet, it will be created.
-
- Returns true, if the value could be assigned, otherwise returns false, which is the case if the mentioned
- propertyName wasn't found for the \a obj.
- */
-bool UiGuiSettings::setSettingToObjectPropertyValue( QObject *obj, const QString &propertyName, const QString &settingName )
-{
- const QMetaObject *metaObject = obj->metaObject();
-
- int indexOfProp = metaObject->indexOfProperty( qPrintable(propertyName) );
- if ( indexOfProp > -1 ) {
- QMetaProperty mProp = metaObject->property(indexOfProp);
-
- setValueByName(settingName, mProp.read(obj));
- }
- else {
- //TODO: Write a debug warning to the log.
- return false;
- }
-
- return true;
-}
-
-
-/*!
- \brief Searches the child QObjects of \a obj for a property name and setting name definition within
- their custom properties and sets each setting to the property value.
-
- The custom properties, for which are searched, are "connectedPropertyName" and "connectedSettingName",
- where "connectedPropertyName" is the name of a QObject property as it is documented in the QtDocs, and
- "connectedSettingName" is the name of a setting here within UiGuiSettings. If the settingName
- didn't exist yet, it will be created.
-
- Returns true, if all found property and setting definitions could be successfully registered.
- Returns false, if any of those registrations fails.
- */
-bool UiGuiSettings::setSettingToObjectPropertyValueRecursive(QObject *obj) {
- return checkCustomPropertiesAndCallFunction(obj, &UiGuiSettings::setSettingToObjectPropertyValue);
-}
-
-
-/*!
- \brief Iterates over all \a objs child QObjects and checks whether they have the custom properties
- "connectedPropertyName" and "connectedSettingName" set. If both are set, it invokes the \a callBackFunc
- with both.
- */
-bool UiGuiSettings::checkCustomPropertiesAndCallFunction(QObject *obj, bool (UiGuiSettings::*callBackFunc)(QObject *obj, const QString &propertyName, const QString &settingName)) {
- bool success = true;
-
- // Find all widgets that have PropertyName and SettingName defined in their style sheet.
- QList<QObject *> allObjects = obj->findChildren<QObject *>();
- foreach (QObject *object, allObjects) {
- QString propertyName = object->property("connectedPropertyName").toString();
- QString settingName = object->property("connectedSettingName").toString();
-
- // If property and setting name were found, register that widget with the settings.
- if ( !propertyName.isEmpty() && !settingName.isEmpty() ) {
- success &= (this->*callBackFunc)( object, propertyName, settingName );
- }
- }
-
- return success;
-}
-
-
-/*!
- \brief The with a certain property registered \a obj gets unregistered.
- */
-void UiGuiSettings::unregisterObjectProperty(QObject *obj) {
- if ( _registeredObjectProperties.contains(obj) ) {
- const QMetaObject *metaObject = obj->metaObject();
- QString propertyName = _registeredObjectProperties[obj].first();
- QString settingName = _registeredObjectProperties[obj].last();
-
- bool connectSuccess = false;
- int indexOfProp = metaObject->indexOfProperty( qPrintable(propertyName) );
- if ( indexOfProp > -1 ) {
- QMetaProperty mProp = metaObject->property(indexOfProp);
-
- // Disconnect to the property's value changed signal.
- if ( mProp.hasNotifySignal() ) {
- QMetaMethod signal = mProp.notifySignal();
- // The command "SIGNAL() + QString(signal.signature())" assembles the signal methods signature to a valid Qt SIGNAL.
- connectSuccess = disconnect(obj, qPrintable(SIGNAL() + QString(signal.signature())), this, SLOT(handleObjectPropertyChange()));
- }
- }
- _registeredObjectProperties.remove(obj);
- }
-}
-
-
-/*!
- \brief Registers a slot form the \a obj by its \a slotName to be invoked, if the by \a settingName defined
- setting changes.
-
- The registered slot may have no parameters or exactly one. If it accepts one parameter, whenever the setting
- \a settingName changes the slot gets tried to be invoked with the settings value as parameter. This only works,
- if the slot parameter is of the same type as the setting.
- */
-bool UiGuiSettings::registerObjectSlot(QObject *obj, const QString &slotName, const QString &settingName) {
-
- const QMetaObject *metaObject = obj->metaObject();
-
- bool connectSuccess = false;
- // Connect to the objects destroyed signal, so that it will be correctly unregistered.
- connectSuccess = connect(obj, SIGNAL(destroyed(QObject*)), this, SLOT(unregisterObjectSlot(QObject*)));
-
- QString normalizedSlotName = QMetaObject::normalizedSignature( qPrintable(slotName) );
- int indexOfMethod = metaObject->indexOfMethod( qPrintable(normalizedSlotName) );
- if ( connectSuccess && indexOfMethod > -1 ) {
- QMetaMethod mMethod = metaObject->method(indexOfMethod);
- //QMetaMethod::Access access = mMethod.access();
- //QMetaMethod::MethodType methType = mMethod.methodType();
-
- // Since the method can at maximum be invoked with the setting value as argument,
- // only methods taking max one argument are allowed.
- if ( mMethod.parameterTypes().size() <= 1 ) {
- _registeredObjectSlots.insert(obj, QStringList() << normalizedSlotName << settingName);
- }
- else {
- //TODO: Write a debug warning to the log.
- disconnect(obj, SIGNAL(destroyed(QObject*)), this, SLOT(unregisterObjectSlot(QObject*)));
- return false;
- }
- }
- else {
- //TODO: Write a debug warning to the log.
- disconnect(obj, SIGNAL(destroyed(QObject*)), this, SLOT(unregisterObjectSlot(QObject*)));
- return false;
- }
-
- return true;
-}
-
-
-/*!
- \brief If \a obj, \a slotName and \a settingName are given, that certain connection is unregistered.
- If only \a obj is given, all to this object registered slot-setting connections are unregistered.
- */
-void UiGuiSettings::unregisterObjectSlot(QObject *obj, const QString &slotName, const QString &settingName) {
- //const QMetaObject *metaObject = obj->metaObject();
- QString normalizedSlotName = QMetaObject::normalizedSignature( qPrintable(slotName) );
- QMutableMapIterator<QObject*, QStringList> it(_registeredObjectSlots);
- while (it.hasNext()) {
- it.next();
- if (it.key() == obj && slotName.isEmpty() && settingName.isEmpty())
- it.remove();
- else if (it.key() == obj && it.value().first() == slotName && it.value().last() == settingName)
- it.remove();
- }
-}
-
-
-/*!
- \brief This private slot gets invoked whenever a registered objects property changes
- and distributes the new value to all other to the same settingName registered objects.
- */
-void UiGuiSettings::handleObjectPropertyChange() {
- QObject *obj = QObject::sender();
- QString className = obj->metaObject()->className();
- const QMetaObject *metaObject = obj->metaObject();
- QString propertyName = _registeredObjectProperties[obj].first();
- QString settingName = _registeredObjectProperties[obj].last();
-
- int indexOfProp = metaObject->indexOfProperty( qPrintable(propertyName) );
- if ( indexOfProp > -1 ) {
- QMetaProperty mProp = metaObject->property(indexOfProp);
- setValueByName(settingName, mProp.read(obj));
- }
-}
-
-
-/*!
- \brief Sets the setting defined by \a settingName to \a value.
-
- When setting a changed value, all to this settingName registered objects get
- the changed value set too.
- If the \a settingName didn't exist yet, it will be created.
- */
-void UiGuiSettings::setValueByName(const QString &settingName, const QVariant &value) {
- // Do the updating only, if the setting was really changed.
- if ( _qsettings->value("UniversalIndentGUI/" + settingName) != value ) {
- _qsettings->setValue("UniversalIndentGUI/" + settingName, value);
-
- // Set the new value for all registered object properties for settingName.
- for ( QMap<QObject*, QStringList>::ConstIterator it = _registeredObjectProperties.begin(); it != _registeredObjectProperties.end(); ++it ) {
- if ( it.value().last() == settingName ) {
- QObject *obj = it.key();
- const QMetaObject *metaObject = obj->metaObject();
- QString propertyName = it.value().first();
-
- int indexOfProp = metaObject->indexOfProperty( qPrintable(propertyName) );
- if ( indexOfProp > -1 ) {
- QMetaProperty mProp = metaObject->property(indexOfProp);
- mProp.write(obj, value);
- }
- }
- }
-
- // Invoke all registered object methods for settingName.
- for ( QMap<QObject*, QStringList>::ConstIterator it = _registeredObjectSlots.begin(); it != _registeredObjectSlots.end(); ++it ) {
- if ( it.value().last() == settingName ) {
- QObject *obj = it.key();
- const QMetaObject *metaObject = obj->metaObject();
- QString slotName = it.value().first();
-
- int indexOfMethod = metaObject->indexOfMethod( qPrintable(slotName) );
- if ( indexOfMethod > -1 ) {
- QMetaMethod mMethod = metaObject->method(indexOfMethod);
- //QMetaMethod::Access access = mMethod.access();
- //QMetaMethod::MethodType methType = mMethod.methodType();
-
- bool success = false;
-
- // Handle registered slots taking one parameter.
- if ( mMethod.parameterTypes().size() == 1 ) {
- if ( mMethod.parameterTypes().first() == value.typeName() ) {
- success = invokeMethodWithValue(obj, mMethod, value);
- }
- }
- // Handle registered slots taking zero parameters.
- else {
- success = mMethod.invoke( obj, Qt::DirectConnection );
- }
-
- if ( success == false ) {
- // TODO: Write a warning to the log if no success.
- }
- }
- }
- }
- }
-}
-
-
-#include <QBitArray>
-#include <QBitmap>
-#include <QBrush>
-#include <QCursor>
-#include <QDateTime>
-#include <QFont>
-#include <QIcon>
-#include <QKeySequence>
-#include <QLocale>
-#include <QPalette>
-#include <QPen>
-#include <QSizePolicy>
-#include <QTextFormat>
-#include <QTextLength>
-#include <QUrl>
-#if QT_VERSION >= 0x040600
-#include <QMatrix4x4>
-#include <QVector2D>
-#endif
-
-bool UiGuiSettings::invokeMethodWithValue( QObject *obj, QMetaMethod mMethod, QVariant value )
-{
- switch (value.type()) {
- case QVariant::BitArray :
- return mMethod.invoke( obj, Qt::DirectConnection, Q_ARG(QBitArray, value.toBitArray()) );
- case QVariant::Bitmap :
- return mMethod.invoke( obj, Qt::DirectConnection, Q_ARG(QBitmap, value.value<QBitmap>()) );
- case QVariant::Bool :
- return mMethod.invoke( obj, Qt::DirectConnection, Q_ARG(bool, value.toBool()) );
- case QVariant::Brush :
- return mMethod.invoke( obj, Qt::DirectConnection, Q_ARG(QBrush, value.value<QBrush>()) );
- case QVariant::ByteArray :
- return mMethod.invoke( obj, Qt::DirectConnection, Q_ARG(QByteArray, value.toByteArray()) );
- case QVariant::Char :
- return mMethod.invoke( obj, Qt::DirectConnection, Q_ARG(QChar, value.toChar()) );
- case QVariant::Color :
- return mMethod.invoke( obj, Qt::DirectConnection, Q_ARG(QColor, value.value<QColor>()) );
- case QVariant::Cursor :
- return mMethod.invoke( obj, Qt::DirectConnection, Q_ARG(QCursor, value.value<QCursor>()) );
- case QVariant::Date :
- return mMethod.invoke( obj, Qt::DirectConnection, Q_ARG(QDate, value.toDate()) );
- case QVariant::DateTime :
- return mMethod.invoke( obj, Qt::DirectConnection, Q_ARG(QDateTime, value.toDateTime()) );
- case QVariant::Double :
- return mMethod.invoke( obj, Qt::DirectConnection, Q_ARG(double, value.toDouble()) );
- case QVariant::Font :
- return mMethod.invoke( obj, Qt::DirectConnection, Q_ARG(QFont, value.value<QFont>()) );
- case QVariant::Hash :
- return mMethod.invoke( obj, Qt::DirectConnection, Q_ARG(QVariantHash, value.toHash()) );
- case QVariant::Icon :
- return mMethod.invoke( obj, Qt::DirectConnection, Q_ARG(QIcon, value.value<QIcon>()) );
- case QVariant::Image :
- return mMethod.invoke( obj, Qt::DirectConnection, Q_ARG(QImage, value.value<QImage>()) );
- case QVariant::Int :
- return mMethod.invoke( obj, Qt::DirectConnection, Q_ARG(int, value.toInt()) );
- case QVariant::KeySequence :
- return mMethod.invoke( obj, Qt::DirectConnection, Q_ARG(QKeySequence, value.value<QKeySequence>()) );
- case QVariant::Line :
- return mMethod.invoke( obj, Qt::DirectConnection, Q_ARG(QLine, value.toLine()) );
- case QVariant::LineF :
- return mMethod.invoke( obj, Qt::DirectConnection, Q_ARG(QLineF, value.toLineF()) );
- case QVariant::List :
- return mMethod.invoke( obj, Qt::DirectConnection, Q_ARG(QVariantList, value.toList()) );
- case QVariant::Locale :
- return mMethod.invoke( obj, Qt::DirectConnection, Q_ARG(QLocale, value.toLocale()) );
- case QVariant::LongLong :
- return mMethod.invoke( obj, Qt::DirectConnection, Q_ARG(qlonglong, value.toLongLong()) );
- case QVariant::Map :
- return mMethod.invoke( obj, Qt::DirectConnection, Q_ARG(QVariantMap, value.toMap()) );
- case QVariant::Matrix :
- return mMethod.invoke( obj, Qt::DirectConnection, Q_ARG(QMatrix, value.value<QMatrix>()) );
- case QVariant::Transform :
- return mMethod.invoke( obj, Qt::DirectConnection, Q_ARG(QTransform, value.value<QTransform>()) );
-#if QT_VERSION >= 0x040600
- case QVariant::Matrix4x4 :
- return mMethod.invoke( obj, Qt::DirectConnection, Q_ARG(QMatrix4x4, value.value<QMatrix4x4>()) );
-#endif
- case QVariant::Palette :
- return mMethod.invoke( obj, Qt::DirectConnection, Q_ARG(QPalette, value.value<QPalette>()) );
- case QVariant::Pen :
- return mMethod.invoke( obj, Qt::DirectConnection, Q_ARG(QPen, value.value<QPen>()) );
- case QVariant::Pixmap :
- return mMethod.invoke( obj, Qt::DirectConnection, Q_ARG(QPixmap, value.value<QPixmap>()) );
- case QVariant::Point :
- return mMethod.invoke( obj, Qt::DirectConnection, Q_ARG(QPoint, value.toPoint()) );
- // case QVariant::PointArray :
- // return Q_ARG(QPointArray, value.value<QPointArray>()) );
- case QVariant::PointF :
- return mMethod.invoke( obj, Qt::DirectConnection, Q_ARG(QPointF, value.toPointF()) );
- case QVariant::Polygon :
- return mMethod.invoke( obj, Qt::DirectConnection, Q_ARG(QPolygon, value.value<QPolygon>()) );
-#if QT_VERSION >= 0x040600
- case QVariant::Quaternion :
- return mMethod.invoke( obj, Qt::DirectConnection, Q_ARG(QQuaternion, value.value<QQuaternion>()) );
-#endif
- case QVariant::Rect :
- return mMethod.invoke( obj, Qt::DirectConnection, Q_ARG(QRect, value.toRect()) );
- case QVariant::RectF :
- return mMethod.invoke( obj, Qt::DirectConnection, Q_ARG(QRectF, value.toRectF()) );
- case QVariant::RegExp :
- return mMethod.invoke( obj, Qt::DirectConnection, Q_ARG(QRegExp, value.toRegExp()) );
- case QVariant::Region :
- return mMethod.invoke( obj, Qt::DirectConnection, Q_ARG(QRegion, value.value<QRegion>()) );
- case QVariant::Size :
- return mMethod.invoke( obj, Qt::DirectConnection, Q_ARG(QSize, value.toSize()) );
- case QVariant::SizeF :
- return mMethod.invoke( obj, Qt::DirectConnection, Q_ARG(QSizeF, value.toSizeF()) );
- case QVariant::SizePolicy :
- return mMethod.invoke( obj, Qt::DirectConnection, Q_ARG(QSizePolicy, value.value<QSizePolicy>()) );
- case QVariant::String :
- return mMethod.invoke( obj, Qt::DirectConnection, Q_ARG(QString, value.toString()) );
- case QVariant::StringList :
- return mMethod.invoke( obj, Qt::DirectConnection, Q_ARG(QStringList, value.toStringList()) );
- case QVariant::TextFormat :
- return mMethod.invoke( obj, Qt::DirectConnection, Q_ARG(QTextFormat, value.value<QTextFormat>()) );
- case QVariant::TextLength :
- return mMethod.invoke( obj, Qt::DirectConnection, Q_ARG(QTextLength, value.value<QTextLength>()) );
- case QVariant::Time :
- return mMethod.invoke( obj, Qt::DirectConnection, Q_ARG(QTime, value.toTime()) );
- case QVariant::UInt :
- return mMethod.invoke( obj, Qt::DirectConnection, Q_ARG(uint, value.toUInt()) );
- case QVariant::ULongLong :
- return mMethod.invoke( obj, Qt::DirectConnection, Q_ARG(qulonglong, value.toULongLong()) );
- case QVariant::Url :
- return mMethod.invoke( obj, Qt::DirectConnection, Q_ARG(QUrl, value.toUrl()) );
-#if QT_VERSION >= 0x040600
- case QVariant::Vector2D :
- return mMethod.invoke( obj, Qt::DirectConnection, Q_ARG(QVector2D, value.value<QVector2D>()) );
- case QVariant::Vector3D :
- return mMethod.invoke( obj, Qt::DirectConnection, Q_ARG(QVector3D, value.value<QVector3D>()) );
- case QVariant::Vector4D :
- return mMethod.invoke( obj, Qt::DirectConnection, Q_ARG(QVector4D, value.value<QVector4D>()) );
-#endif
- default:
- return false;
- }
-}
+/*************************************************************************** +* 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 "UiGuiSettings.h" + +#include "SettingsPaths.h" + +#include <tqsettings.h> +#include <tqpoint.h> +#include <tqsize.h> +#include <tqdir.h> +#include <tqdate.h> +#include <tqstringlist.h> +#include <tqcoreapplication.h> +#include <tqmetamethod.h> +#include <tqmetaproperty.h> +#include <tqwidget.h> + +//! \defgroup grp_Settings All concerning the settings. + +/*! + \class UiGuiSettings + \ingroup grp_Settings + \brief Handles the settings of the program. Reads them on startup and saves them on exit. + Is a singleton class and can only be accessed via getInstance(). +*/ + +// Inits the single class instance pointer. +QWeakPointer<UiGuiSettings> UiGuiSettings::_instance; + + +/*! + \brief The constructor for the settings. +*/ +UiGuiSettings::UiGuiSettings() : QObject() { + // Create the main application settings object from the UniversalIndentGUI.ini file. + _qsettings = new QSettings(SettingsPaths::getSettingsPath() + "/UniversalIndentGUI.ini", QSettings::IniFormat, this); + + _indenterDirctoryStr = SettingsPaths::getGlobalFilesPath() + "/indenters"; + readAvailableTranslations(); + initSettings(); +} + + +/*! + \brief Returns the instance of the settings class. If no instance exists, ONE will be created. + */ +QSharedPointer<UiGuiSettings> UiGuiSettings::getInstance() { + QSharedPointer<UiGuiSettings> sharedInstance = _instance.toStrongRef(); + if ( sharedInstance.isNull() ) { + // Create the settings object, which loads all UiGui settings from a file. + sharedInstance = QSharedPointer<UiGuiSettings>(new UiGuiSettings()); + _instance = sharedInstance.toWeakRef(); + } + + return sharedInstance; +} + + +/*! + \brief The destructor saves the settings to a file. + */ +UiGuiSettings::~UiGuiSettings() { + // Convert the language setting from an integer index to a string. + int index = _qsettings->value("UniversalIndentGUI/language", 0).toInt(); + if ( index < 0 || index >= _availableTranslations.size() ) + index = 0; + + _qsettings->setValue( "UniversalIndentGUI/language", _availableTranslations.at(index) ); +} + + +/*! + \brief Scans the translations directory for available translation files and + stores them in the QList \a _availableTranslations. + */ +void UiGuiSettings::readAvailableTranslations() { + QString languageShort; + QStringList languageFileList; + + // English is the default language. A translation file does not exist but to have a menu entry, added here. + languageFileList << "universalindent_en.qm"; + + // Find all translation files in the "translations" directory. + QDir translationDirectory = QDir( SettingsPaths::getGlobalFilesPath() + "/translations" ); + languageFileList << translationDirectory.entryList( QStringList("universalindent_*.qm") ); + + // Loop for each found translation file + foreach ( languageShort, languageFileList ) { + // Remove the leading string "universalindent_" from the filename. + languageShort.remove(0,16); + // Remove trailing file extension ".qm". + languageShort.chop(3); + + _availableTranslations.append(languageShort); + } +} + + +/*! + \brief Returns a list of the mnemonics of the available translations. + */ +QStringList UiGuiSettings::getAvailableTranslations() { + return _availableTranslations; +} + + +/*! + \brief Returns the value of the by \a settingsName defined setting as QVariant. + + If the named setting does not exist, 0 is being returned. +*/ +QVariant UiGuiSettings::getValueByName(QString settingName) { + return _qsettings->value("UniversalIndentGUI/" + settingName); +} + + +/*! + \brief Loads the settings for the main application. + + Settings are for example last selected indenter, last loaded source code file and so on. +*/ +bool UiGuiSettings::initSettings() +{ + // Read the version string saved in the settings file. + _qsettings->setValue( "UniversalIndentGUI/version", _qsettings->value("UniversalIndentGUI/version", "") ); + + // Read windows last size and position from the settings file. + _qsettings->setValue( "UniversalIndentGUI/maximized", _qsettings->value("UniversalIndentGUI/maximized", false) ); + _qsettings->setValue( "UniversalIndentGUI/position", _qsettings->value("UniversalIndentGUI/position", QPoint(50, 50)) ); + _qsettings->setValue( "UniversalIndentGUI/size", _qsettings->value("UniversalIndentGUI/size", QSize(800, 600)) ); + + // Read last selected encoding for the opened source code file. + _qsettings->setValue( "UniversalIndentGUI/encoding", _qsettings->value("UniversalIndentGUI/encoding", "UTF-8") ); + + // Read maximum length of list for recently opened files. + _qsettings->setValue( "UniversalIndentGUI/recentlyOpenedListSize", _qsettings->value("UniversalIndentGUI/recentlyOpenedListSize", 5) ); + + // Read if last opened source code file should be loaded on startup. + _qsettings->setValue( "UniversalIndentGUI/loadLastSourceCodeFileOnStartup", _qsettings->value("UniversalIndentGUI/loadLastSourceCodeFileOnStartup", true) ); + + // Read last opened source code file from the settings file. + _qsettings->setValue( "UniversalIndentGUI/lastSourceCodeFile", _qsettings->value("UniversalIndentGUI/lastSourceCodeFile", _indenterDirctoryStr+"/example.cpp") ); + + // Read last selected indenter from the settings file. + int selectedIndenter = _qsettings->value("UniversalIndentGUI/selectedIndenter", 0).toInt(); + if ( selectedIndenter < 0 ) { + selectedIndenter = 0; + } + _qsettings->setValue( "UniversalIndentGUI/selectedIndenter", selectedIndenter ); + + // Read if syntax highlighting is enabled. + _qsettings->setValue( "UniversalIndentGUI/SyntaxHighlightingEnabled", _qsettings->value("UniversalIndentGUI/SyntaxHighlightingEnabled", true) ); + + // Read if white space characters should be displayed. + _qsettings->setValue( "UniversalIndentGUI/whiteSpaceIsVisible", _qsettings->value("UniversalIndentGUI/whiteSpaceIsVisible", false) ); + + // Read if indenter parameter tool tips are enabled. + _qsettings->setValue( "UniversalIndentGUI/indenterParameterTooltipsEnabled", _qsettings->value("UniversalIndentGUI/indenterParameterTooltipsEnabled", true) ); + + // Read the tab width from the settings file. + _qsettings->setValue( "UniversalIndentGUI/tabWidth", _qsettings->value("UniversalIndentGUI/tabWidth", 4) ); + + // Read the last selected language and stores the index it has in the list of available translations. + _qsettings->setValue( "UniversalIndentGUI/language", _availableTranslations.indexOf( _qsettings->value("UniversalIndentGUI/language", "").toString() ) ); + + // Read the update check settings from the settings file. + _qsettings->setValue( "UniversalIndentGUI/CheckForUpdate", _qsettings->value("UniversalIndentGUI/CheckForUpdate", false) ); + _qsettings->setValue( "UniversalIndentGUI/LastUpdateCheck", _qsettings->value("UniversalIndentGUI/LastUpdateCheck", QDate(1900,1,1)) ); + + // Read the main window state. + _qsettings->setValue( "UniversalIndentGUI/MainWindowState", _qsettings->value("UniversalIndentGUI/MainWindowState", QByteArray()) ); + + return true; +} + + +/*! + \brief Register the by \a propertyName defined property of \a obj to be connected to the setting defined by \a settingName. + + The \a propertyName must be one of those that are listed in the Qt "Properties" documentation section of a Qt Object. + All further needed info is retrieved via the \a obj's MetaObject, like the to the property bound signal. + */ +bool UiGuiSettings::registerObjectProperty( QObject *obj, const QString &propertyName, const QString &settingName ) +{ + const QMetaObject *metaObject = obj->metaObject(); + bool connectSuccess = false; + + // Connect to the objects destroyed signal, so that it will be correctly unregistered. + connectSuccess = connect(obj, SIGNAL(destroyed(QObject*)), this, SLOT(unregisterObjectProperty(QObject*))); + + int indexOfProp = metaObject->indexOfProperty( qPrintable(propertyName) ); + if ( connectSuccess && indexOfProp > -1 ) { + QMetaProperty mProp = metaObject->property(indexOfProp); + + // Connect to the property's value changed signal. + if ( mProp.hasNotifySignal() ) { + QMetaMethod signal = mProp.notifySignal(); + //QString teststr = qPrintable(SIGNAL() + QString(signal.signature())); + // The command "SIGNAL() + QString(signal.signature())" assembles the signal methods signature to a valid Qt SIGNAL. + connectSuccess = connect(obj, qPrintable(SIGNAL() + QString(signal.signature())), this, SLOT(handleObjectPropertyChange())); + } + + if ( connectSuccess ) { + _registeredObjectProperties[obj] = QStringList() << propertyName << settingName; + } + else { + //TODO: Write a debug warning to the log. + disconnect(obj, SIGNAL(destroyed(QObject*)), this, SLOT(unregisterObjectProperty(QObject*))); + return false; + } + + // If setting already exists, set the objects property to the setting value. + if ( _qsettings->contains("UniversalIndentGUI/" + settingName) ) { + mProp.write(obj, _qsettings->value("UniversalIndentGUI/" + settingName)); + } + // Otherwise add the setting and set it to the value of the objects property. + else { + _qsettings->setValue("UniversalIndentGUI/" + settingName, mProp.read(obj)); + } + } + else { + //TODO: Write a debug warning to the log. + disconnect(obj, SIGNAL(destroyed(QObject*)), this, SLOT(unregisterObjectProperty(QObject*))); + return false; + } + + return true; +} + + +/*! + \brief Searches the child QObjects of \a obj for a property name and setting name definition within + their custom properties and registers this property name to that setting name if both were found. + + The custom properties, for which are searched, are "connectedPropertyName" and "connectedSettingName", + where "connectedPropertyName" is the name of a QObject property as it is documented in the QtDocs, and + "connectedSettingName" is the name of a setting here within UiGuiSettings. If the mentioned setting + name doesn't exist, it will be created. + + Returns true, if all found property and setting definitions could be successfully registered. + Returns false, if any of those registrations fails. + */ +bool UiGuiSettings::registerObjectPropertyRecursive(QObject *obj) { + return checkCustomPropertiesAndCallFunction(obj, &UiGuiSettings::registerObjectProperty); +} + + +/*! + \brief Assigns the by \a settingName defined setting value to the by \a propertyName defined property of \a obj. + + Returns true, if the value could be assigned, otherwise returns false, which is the case if settingName doesn't exist + within the settings or if the mentioned propertyName wasn't found for the \a obj. + */ +bool UiGuiSettings::setObjectPropertyToSettingValue( QObject *obj, const QString &propertyName, const QString &settingName ) +{ + const QMetaObject *metaObject = obj->metaObject(); + + int indexOfProp = metaObject->indexOfProperty( qPrintable(propertyName) ); + if ( indexOfProp > -1 ) { + QMetaProperty mProp = metaObject->property(indexOfProp); + + // If setting already exists, set the objects property to the setting value. + if ( _qsettings->contains("UniversalIndentGUI/" + settingName) ) { + mProp.write(obj, _qsettings->value("UniversalIndentGUI/" + settingName)); + } + // The setting didn't exist so return that setting the objects property failed. + else { + //TODO: Write a debug warning to the log. + return false; + } + } + else { + //TODO: Write a debug warning to the log. + return false; + } + + return true; +} + + +/*! + \brief Searches the child QObjects of \a obj for a property name and setting name definition within + their custom properties and sets each property to settings value. + + The custom properties, for which are searched, are "connectedPropertyName" and "connectedSettingName", + where "connectedPropertyName" is the name of a QObject property as it is documented in the QtDocs, and + "connectedSettingName" is the name of a setting here within UiGuiSettings. + + Returns true, if all found property and setting definitions could be successfully registered. + Returns false, if any of those registrations fails. + */ +bool UiGuiSettings::setObjectPropertyToSettingValueRecursive(QObject *obj) { + return checkCustomPropertiesAndCallFunction(obj, &UiGuiSettings::setObjectPropertyToSettingValue); +} + + +/*! + \brief Assigns the by \a propertyName defined property's value of \a obj to the by \a settingName defined setting. + + If the \a settingName didn't exist yet, it will be created. + + Returns true, if the value could be assigned, otherwise returns false, which is the case if the mentioned + propertyName wasn't found for the \a obj. + */ +bool UiGuiSettings::setSettingToObjectPropertyValue( QObject *obj, const QString &propertyName, const QString &settingName ) +{ + const QMetaObject *metaObject = obj->metaObject(); + + int indexOfProp = metaObject->indexOfProperty( qPrintable(propertyName) ); + if ( indexOfProp > -1 ) { + QMetaProperty mProp = metaObject->property(indexOfProp); + + setValueByName(settingName, mProp.read(obj)); + } + else { + //TODO: Write a debug warning to the log. + return false; + } + + return true; +} + + +/*! + \brief Searches the child QObjects of \a obj for a property name and setting name definition within + their custom properties and sets each setting to the property value. + + The custom properties, for which are searched, are "connectedPropertyName" and "connectedSettingName", + where "connectedPropertyName" is the name of a QObject property as it is documented in the QtDocs, and + "connectedSettingName" is the name of a setting here within UiGuiSettings. If the settingName + didn't exist yet, it will be created. + + Returns true, if all found property and setting definitions could be successfully registered. + Returns false, if any of those registrations fails. + */ +bool UiGuiSettings::setSettingToObjectPropertyValueRecursive(QObject *obj) { + return checkCustomPropertiesAndCallFunction(obj, &UiGuiSettings::setSettingToObjectPropertyValue); +} + + +/*! + \brief Iterates over all \a objs child QObjects and checks whether they have the custom properties + "connectedPropertyName" and "connectedSettingName" set. If both are set, it invokes the \a callBackFunc + with both. + */ +bool UiGuiSettings::checkCustomPropertiesAndCallFunction(QObject *obj, bool (UiGuiSettings::*callBackFunc)(QObject *obj, const QString &propertyName, const QString &settingName)) { + bool success = true; + + // Find all widgets that have PropertyName and SettingName defined in their style sheet. + QList<QObject *> allObjects = obj->findChildren<QObject *>(); + foreach (QObject *object, allObjects) { + QString propertyName = object->property("connectedPropertyName").toString(); + QString settingName = object->property("connectedSettingName").toString(); + + // If property and setting name were found, register that widget with the settings. + if ( !propertyName.isEmpty() && !settingName.isEmpty() ) { + success &= (this->*callBackFunc)( object, propertyName, settingName ); + } + } + + return success; +} + + +/*! + \brief The with a certain property registered \a obj gets unregistered. + */ +void UiGuiSettings::unregisterObjectProperty(QObject *obj) { + if ( _registeredObjectProperties.contains(obj) ) { + const QMetaObject *metaObject = obj->metaObject(); + QString propertyName = _registeredObjectProperties[obj].first(); + QString settingName = _registeredObjectProperties[obj].last(); + + bool connectSuccess = false; + int indexOfProp = metaObject->indexOfProperty( qPrintable(propertyName) ); + if ( indexOfProp > -1 ) { + QMetaProperty mProp = metaObject->property(indexOfProp); + + // Disconnect to the property's value changed signal. + if ( mProp.hasNotifySignal() ) { + QMetaMethod signal = mProp.notifySignal(); + // The command "SIGNAL() + QString(signal.signature())" assembles the signal methods signature to a valid Qt SIGNAL. + connectSuccess = disconnect(obj, qPrintable(SIGNAL() + QString(signal.signature())), this, SLOT(handleObjectPropertyChange())); + } + } + _registeredObjectProperties.remove(obj); + } +} + + +/*! + \brief Registers a slot form the \a obj by its \a slotName to be invoked, if the by \a settingName defined + setting changes. + + The registered slot may have no parameters or exactly one. If it accepts one parameter, whenever the setting + \a settingName changes the slot gets tried to be invoked with the settings value as parameter. This only works, + if the slot parameter is of the same type as the setting. + */ +bool UiGuiSettings::registerObjectSlot(QObject *obj, const QString &slotName, const QString &settingName) { + + const QMetaObject *metaObject = obj->metaObject(); + + bool connectSuccess = false; + // Connect to the objects destroyed signal, so that it will be correctly unregistered. + connectSuccess = connect(obj, SIGNAL(destroyed(QObject*)), this, SLOT(unregisterObjectSlot(QObject*))); + + QString normalizedSlotName = QMetaObject::normalizedSignature( qPrintable(slotName) ); + int indexOfMethod = metaObject->indexOfMethod( qPrintable(normalizedSlotName) ); + if ( connectSuccess && indexOfMethod > -1 ) { + QMetaMethod mMethod = metaObject->method(indexOfMethod); + //QMetaMethod::Access access = mMethod.access(); + //QMetaMethod::MethodType methType = mMethod.methodType(); + + // Since the method can at maximum be invoked with the setting value as argument, + // only methods taking max one argument are allowed. + if ( mMethod.parameterTypes().size() <= 1 ) { + _registeredObjectSlots.insert(obj, QStringList() << normalizedSlotName << settingName); + } + else { + //TODO: Write a debug warning to the log. + disconnect(obj, SIGNAL(destroyed(QObject*)), this, SLOT(unregisterObjectSlot(QObject*))); + return false; + } + } + else { + //TODO: Write a debug warning to the log. + disconnect(obj, SIGNAL(destroyed(QObject*)), this, SLOT(unregisterObjectSlot(QObject*))); + return false; + } + + return true; +} + + +/*! + \brief If \a obj, \a slotName and \a settingName are given, that certain connection is unregistered. + If only \a obj is given, all to this object registered slot-setting connections are unregistered. + */ +void UiGuiSettings::unregisterObjectSlot(QObject *obj, const QString &slotName, const QString &settingName) { + //const QMetaObject *metaObject = obj->metaObject(); + QString normalizedSlotName = QMetaObject::normalizedSignature( qPrintable(slotName) ); + QMutableMapIterator<QObject*, QStringList> it(_registeredObjectSlots); + while (it.hasNext()) { + it.next(); + if (it.key() == obj && slotName.isEmpty() && settingName.isEmpty()) + it.remove(); + else if (it.key() == obj && it.value().first() == slotName && it.value().last() == settingName) + it.remove(); + } +} + + +/*! + \brief This private slot gets invoked whenever a registered objects property changes + and distributes the new value to all other to the same settingName registered objects. + */ +void UiGuiSettings::handleObjectPropertyChange() { + QObject *obj = QObject::sender(); + QString className = obj->metaObject()->className(); + const QMetaObject *metaObject = obj->metaObject(); + QString propertyName = _registeredObjectProperties[obj].first(); + QString settingName = _registeredObjectProperties[obj].last(); + + int indexOfProp = metaObject->indexOfProperty( qPrintable(propertyName) ); + if ( indexOfProp > -1 ) { + QMetaProperty mProp = metaObject->property(indexOfProp); + setValueByName(settingName, mProp.read(obj)); + } +} + + +/*! + \brief Sets the setting defined by \a settingName to \a value. + + When setting a changed value, all to this settingName registered objects get + the changed value set too. + If the \a settingName didn't exist yet, it will be created. + */ +void UiGuiSettings::setValueByName(const QString &settingName, const QVariant &value) { + // Do the updating only, if the setting was really changed. + if ( _qsettings->value("UniversalIndentGUI/" + settingName) != value ) { + _qsettings->setValue("UniversalIndentGUI/" + settingName, value); + + // Set the new value for all registered object properties for settingName. + for ( QMap<QObject*, QStringList>::ConstIterator it = _registeredObjectProperties.begin(); it != _registeredObjectProperties.end(); ++it ) { + if ( it.value().last() == settingName ) { + QObject *obj = it.key(); + const QMetaObject *metaObject = obj->metaObject(); + QString propertyName = it.value().first(); + + int indexOfProp = metaObject->indexOfProperty( qPrintable(propertyName) ); + if ( indexOfProp > -1 ) { + QMetaProperty mProp = metaObject->property(indexOfProp); + mProp.write(obj, value); + } + } + } + + // Invoke all registered object methods for settingName. + for ( QMap<QObject*, QStringList>::ConstIterator it = _registeredObjectSlots.begin(); it != _registeredObjectSlots.end(); ++it ) { + if ( it.value().last() == settingName ) { + QObject *obj = it.key(); + const QMetaObject *metaObject = obj->metaObject(); + QString slotName = it.value().first(); + + int indexOfMethod = metaObject->indexOfMethod( qPrintable(slotName) ); + if ( indexOfMethod > -1 ) { + QMetaMethod mMethod = metaObject->method(indexOfMethod); + //QMetaMethod::Access access = mMethod.access(); + //QMetaMethod::MethodType methType = mMethod.methodType(); + + bool success = false; + + // Handle registered slots taking one parameter. + if ( mMethod.parameterTypes().size() == 1 ) { + if ( mMethod.parameterTypes().first() == value.typeName() ) { + success = invokeMethodWithValue(obj, mMethod, value); + } + } + // Handle registered slots taking zero parameters. + else { + success = mMethod.invoke( obj, Qt::DirectConnection ); + } + + if ( success == false ) { + // TODO: Write a warning to the log if no success. + } + } + } + } + } +} + + +#include <tqbitarray.h> +#include <tqbitmap.h> +#include <tqbrush.h> +#include <tqcursor.h> +#include <tqdatetime.h> +#include <tqfont.h> +#include <tqicon.h> +#include <tqkeysequence.h> +#include <tqlocale.h> +#include <tqpalette.h> +#include <tqpen.h> +#include <tqsizepolicy.h> +#include <tqtextformat.h> +#include <tqtextlength.h> +#include <tqurl.h> +#if QT_VERSION >= 0x040600 +#include <tqmatrix4x4.h> +#include <tqvector2d.h> +#endif + +bool UiGuiSettings::invokeMethodWithValue( QObject *obj, QMetaMethod mMethod, QVariant value ) +{ + switch (value.type()) { + case QVariant::BitArray : + return mMethod.invoke( obj, Qt::DirectConnection, Q_ARG(QBitArray, value.toBitArray()) ); + case QVariant::Bitmap : + return mMethod.invoke( obj, Qt::DirectConnection, Q_ARG(QBitmap, value.value<QBitmap>()) ); + case QVariant::Bool : + return mMethod.invoke( obj, Qt::DirectConnection, Q_ARG(bool, value.toBool()) ); + case QVariant::Brush : + return mMethod.invoke( obj, Qt::DirectConnection, Q_ARG(QBrush, value.value<QBrush>()) ); + case QVariant::ByteArray : + return mMethod.invoke( obj, Qt::DirectConnection, Q_ARG(QByteArray, value.toByteArray()) ); + case QVariant::Char : + return mMethod.invoke( obj, Qt::DirectConnection, Q_ARG(QChar, value.toChar()) ); + case QVariant::Color : + return mMethod.invoke( obj, Qt::DirectConnection, Q_ARG(QColor, value.value<QColor>()) ); + case QVariant::Cursor : + return mMethod.invoke( obj, Qt::DirectConnection, Q_ARG(QCursor, value.value<QCursor>()) ); + case QVariant::Date : + return mMethod.invoke( obj, Qt::DirectConnection, Q_ARG(QDate, value.toDate()) ); + case QVariant::DateTime : + return mMethod.invoke( obj, Qt::DirectConnection, Q_ARG(QDateTime, value.toDateTime()) ); + case QVariant::Double : + return mMethod.invoke( obj, Qt::DirectConnection, Q_ARG(double, value.toDouble()) ); + case QVariant::Font : + return mMethod.invoke( obj, Qt::DirectConnection, Q_ARG(QFont, value.value<QFont>()) ); + case QVariant::Hash : + return mMethod.invoke( obj, Qt::DirectConnection, Q_ARG(QVariantHash, value.toHash()) ); + case QVariant::Icon : + return mMethod.invoke( obj, Qt::DirectConnection, Q_ARG(QIcon, value.value<QIcon>()) ); + case QVariant::Image : + return mMethod.invoke( obj, Qt::DirectConnection, Q_ARG(QImage, value.value<QImage>()) ); + case QVariant::Int : + return mMethod.invoke( obj, Qt::DirectConnection, Q_ARG(int, value.toInt()) ); + case QVariant::KeySequence : + return mMethod.invoke( obj, Qt::DirectConnection, Q_ARG(QKeySequence, value.value<QKeySequence>()) ); + case QVariant::Line : + return mMethod.invoke( obj, Qt::DirectConnection, Q_ARG(QLine, value.toLine()) ); + case QVariant::LineF : + return mMethod.invoke( obj, Qt::DirectConnection, Q_ARG(QLineF, value.toLineF()) ); + case QVariant::List : + return mMethod.invoke( obj, Qt::DirectConnection, Q_ARG(QVariantList, value.toList()) ); + case QVariant::Locale : + return mMethod.invoke( obj, Qt::DirectConnection, Q_ARG(QLocale, value.toLocale()) ); + case QVariant::LongLong : + return mMethod.invoke( obj, Qt::DirectConnection, Q_ARG(qlonglong, value.toLongLong()) ); + case QVariant::Map : + return mMethod.invoke( obj, Qt::DirectConnection, Q_ARG(QVariantMap, value.toMap()) ); + case QVariant::Matrix : + return mMethod.invoke( obj, Qt::DirectConnection, Q_ARG(QMatrix, value.value<QMatrix>()) ); + case QVariant::Transform : + return mMethod.invoke( obj, Qt::DirectConnection, Q_ARG(QTransform, value.value<QTransform>()) ); +#if QT_VERSION >= 0x040600 + case QVariant::Matrix4x4 : + return mMethod.invoke( obj, Qt::DirectConnection, Q_ARG(QMatrix4x4, value.value<QMatrix4x4>()) ); +#endif + case QVariant::Palette : + return mMethod.invoke( obj, Qt::DirectConnection, Q_ARG(QPalette, value.value<QPalette>()) ); + case QVariant::Pen : + return mMethod.invoke( obj, Qt::DirectConnection, Q_ARG(QPen, value.value<QPen>()) ); + case QVariant::Pixmap : + return mMethod.invoke( obj, Qt::DirectConnection, Q_ARG(QPixmap, value.value<QPixmap>()) ); + case QVariant::Point : + return mMethod.invoke( obj, Qt::DirectConnection, Q_ARG(QPoint, value.toPoint()) ); + // case QVariant::PointArray : + // return Q_ARG(QPointArray, value.value<QPointArray>()) ); + case QVariant::PointF : + return mMethod.invoke( obj, Qt::DirectConnection, Q_ARG(QPointF, value.toPointF()) ); + case QVariant::Polygon : + return mMethod.invoke( obj, Qt::DirectConnection, Q_ARG(QPolygon, value.value<QPolygon>()) ); +#if QT_VERSION >= 0x040600 + case QVariant::Quaternion : + return mMethod.invoke( obj, Qt::DirectConnection, Q_ARG(QQuaternion, value.value<QQuaternion>()) ); +#endif + case QVariant::Rect : + return mMethod.invoke( obj, Qt::DirectConnection, Q_ARG(QRect, value.toRect()) ); + case QVariant::RectF : + return mMethod.invoke( obj, Qt::DirectConnection, Q_ARG(QRectF, value.toRectF()) ); + case QVariant::RegExp : + return mMethod.invoke( obj, Qt::DirectConnection, Q_ARG(QRegExp, value.toRegExp()) ); + case QVariant::Region : + return mMethod.invoke( obj, Qt::DirectConnection, Q_ARG(QRegion, value.value<QRegion>()) ); + case QVariant::Size : + return mMethod.invoke( obj, Qt::DirectConnection, Q_ARG(QSize, value.toSize()) ); + case QVariant::SizeF : + return mMethod.invoke( obj, Qt::DirectConnection, Q_ARG(QSizeF, value.toSizeF()) ); + case QVariant::SizePolicy : + return mMethod.invoke( obj, Qt::DirectConnection, Q_ARG(QSizePolicy, value.value<QSizePolicy>()) ); + case QVariant::String : + return mMethod.invoke( obj, Qt::DirectConnection, Q_ARG(QString, value.toString()) ); + case QVariant::StringList : + return mMethod.invoke( obj, Qt::DirectConnection, Q_ARG(QStringList, value.toStringList()) ); + case QVariant::TextFormat : + return mMethod.invoke( obj, Qt::DirectConnection, Q_ARG(QTextFormat, value.value<QTextFormat>()) ); + case QVariant::TextLength : + return mMethod.invoke( obj, Qt::DirectConnection, Q_ARG(QTextLength, value.value<QTextLength>()) ); + case QVariant::Time : + return mMethod.invoke( obj, Qt::DirectConnection, Q_ARG(QTime, value.toTime()) ); + case QVariant::UInt : + return mMethod.invoke( obj, Qt::DirectConnection, Q_ARG(uint, value.toUInt()) ); + case QVariant::ULongLong : + return mMethod.invoke( obj, Qt::DirectConnection, Q_ARG(qulonglong, value.toULongLong()) ); + case QVariant::Url : + return mMethod.invoke( obj, Qt::DirectConnection, Q_ARG(QUrl, value.toUrl()) ); +#if QT_VERSION >= 0x040600 + case QVariant::Vector2D : + return mMethod.invoke( obj, Qt::DirectConnection, Q_ARG(QVector2D, value.value<QVector2D>()) ); + case QVariant::Vector3D : + return mMethod.invoke( obj, Qt::DirectConnection, Q_ARG(QVector3D, value.value<QVector3D>()) ); + case QVariant::Vector4D : + return mMethod.invoke( obj, Qt::DirectConnection, Q_ARG(QVector4D, value.value<QVector4D>()) ); +#endif + default: + return false; + } +} diff --git a/src/UiGuiSettings.h b/src/UiGuiSettings.h index 54f4dca..c818199 100755 --- a/src/UiGuiSettings.h +++ b/src/UiGuiSettings.h @@ -1,83 +1,83 @@ -/***************************************************************************
-* 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. *
-***************************************************************************/
-
-#ifndef UIGUISETTINGS_H
-#define UIGUISETTINGS_H
-
-#include <QObject>
-#include <QStringList>
-#include <QMultiMap>
-#include <QSharedPointer>
-
-class QSettings;
-
-
-class UiGuiSettings : public QObject
-{
- Q_OBJECT
-private:
- UiGuiSettings();
- static QWeakPointer<UiGuiSettings> _instance;
-
-public:
- static QSharedPointer<UiGuiSettings> getInstance();
- ~UiGuiSettings();
-
- bool registerObjectProperty(QObject *obj, const QString &propertyName, const QString &settingName);
- bool registerObjectPropertyRecursive(QObject *obj);
- bool setObjectPropertyToSettingValue(QObject *obj, const QString &propertyName, const QString &settingName);
- bool setObjectPropertyToSettingValueRecursive(QObject *obj);
- bool setSettingToObjectPropertyValue(QObject *obj, const QString &propertyName, const QString &settingName);
- bool setSettingToObjectPropertyValueRecursive(QObject *obj);
- bool registerObjectSlot(QObject *obj, const QString &slotName, const QString &settingName);
- QVariant getValueByName(QString settingName);
- QStringList getAvailableTranslations();
-
-public slots:
- void setValueByName(const QString &settingName, const QVariant &value);
- void unregisterObjectProperty(QObject *obj);
- void unregisterObjectSlot(QObject *obj, const QString &slotName = "", const QString &settingName = "");
-
-protected:
- bool initSettings();
- bool invokeMethodWithValue(QObject *obj, QMetaMethod mMethod, QVariant value);
- bool checkCustomPropertiesAndCallFunction(QObject *obj, bool (UiGuiSettings::*callBackFunc)(QObject *obj, const QString &propertyName, const QString &settingName));
-
-private slots:
- void handleObjectPropertyChange();
-
-private:
- void readAvailableTranslations();
-
- //! Stores the mnemonics of the available translations.
- QStringList _availableTranslations;
-
- //! The settings file.
- QSettings *_qsettings;
-
- //! Maps an QObject to a string list containing the property name and the associated setting name.
- QMap<QObject*, QStringList> _registeredObjectProperties;
-
- //! Maps QObjects to a string list containing the method name and the associated setting name.
- QMultiMap<QObject*, QStringList> _registeredObjectSlots;
-
- QString _indenterDirctoryStr;
-};
-
-#endif // UIGUISETTINGS_H
+/*************************************************************************** +* 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. * +***************************************************************************/ + +#ifndef UIGUISETTINGS_H +#define UIGUISETTINGS_H + +#include <tqobject.h> +#include <tqstringlist.h> +#include <tqmultimap.h> +#include <tqsharedpointer.h> + +class QSettings; + + +class UiGuiSettings : public QObject +{ + Q_OBJECT +private: + UiGuiSettings(); + static QWeakPointer<UiGuiSettings> _instance; + +public: + static QSharedPointer<UiGuiSettings> getInstance(); + ~UiGuiSettings(); + + bool registerObjectProperty(QObject *obj, const QString &propertyName, const QString &settingName); + bool registerObjectPropertyRecursive(QObject *obj); + bool setObjectPropertyToSettingValue(QObject *obj, const QString &propertyName, const QString &settingName); + bool setObjectPropertyToSettingValueRecursive(QObject *obj); + bool setSettingToObjectPropertyValue(QObject *obj, const QString &propertyName, const QString &settingName); + bool setSettingToObjectPropertyValueRecursive(QObject *obj); + bool registerObjectSlot(QObject *obj, const QString &slotName, const QString &settingName); + QVariant getValueByName(QString settingName); + QStringList getAvailableTranslations(); + +public slots: + void setValueByName(const QString &settingName, const QVariant &value); + void unregisterObjectProperty(QObject *obj); + void unregisterObjectSlot(QObject *obj, const QString &slotName = "", const QString &settingName = ""); + +protected: + bool initSettings(); + bool invokeMethodWithValue(QObject *obj, QMetaMethod mMethod, QVariant value); + bool checkCustomPropertiesAndCallFunction(QObject *obj, bool (UiGuiSettings::*callBackFunc)(QObject *obj, const QString &propertyName, const QString &settingName)); + +private slots: + void handleObjectPropertyChange(); + +private: + void readAvailableTranslations(); + + //! Stores the mnemonics of the available translations. + QStringList _availableTranslations; + + //! The settings file. + QSettings *_qsettings; + + //! Maps an QObject to a string list containing the property name and the associated setting name. + QMap<QObject*, QStringList> _registeredObjectProperties; + + //! Maps QObjects to a string list containing the method name and the associated setting name. + QMultiMap<QObject*, QStringList> _registeredObjectSlots; + + QString _indenterDirctoryStr; +}; + +#endif // UIGUISETTINGS_H diff --git a/src/UiGuiSettingsDialog.h b/src/UiGuiSettingsDialog.h index 582d436..9f53262 100755 --- a/src/UiGuiSettingsDialog.h +++ b/src/UiGuiSettingsDialog.h @@ -20,7 +20,7 @@ #ifndef UIGUISETTINGSDIALOG_H #define UIGUISETTINGSDIALOG_H -#include <QDialog> +#include <tqdialog.h> #include "UiGuiSettings.h" diff --git a/src/UiGuiSystemInfo.cpp b/src/UiGuiSystemInfo.cpp index 6763bf8..b83a636 100755 --- a/src/UiGuiSystemInfo.cpp +++ b/src/UiGuiSystemInfo.cpp @@ -1,227 +1,227 @@ -/***************************************************************************
- * 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 "UiGuiSystemInfo.h"
-
-#include <QString>
-#include <QSysInfo>
-#include <QProcess>
-#include <QFile>
-
-UiGuiSystemInfo::UiGuiSystemInfo() {
-}
-
-
-/*!
- \brief Returns the operating system UiGUI is currently running on as one string.
-
- The String contains name and version of the os. E.g. Linux Ubuntu 9.04.
- */
-QString UiGuiSystemInfo::getOperatingSystem() {
- QString operatingSystemString = "";
-
-#if defined(Q_WS_WIN)
- switch ( QSysInfo::WindowsVersion ) {
- case QSysInfo::WV_32s :
- operatingSystemString = "Windows 3.1 with Win 32s";
- break;
- case QSysInfo::WV_95 :
- operatingSystemString = "Windows 95";
- break;
- case QSysInfo::WV_98 :
- operatingSystemString = "Windows 98";
- break;
- case QSysInfo::WV_Me :
- operatingSystemString = "Windows Me";
- break;
- case QSysInfo::WV_NT :
- operatingSystemString = "Windows NT (operating system version 4.0)";
- break;
- case QSysInfo::WV_2000 :
- operatingSystemString = "Windows 2000 (operating system version 5.0)";
- break;
- case QSysInfo::WV_XP :
- operatingSystemString = "Windows XP (operating system version 5.1)";
- break;
- case QSysInfo::WV_2003 :
- operatingSystemString = "Windows Server 2003, Windows Server 2003 R2, Windows Home Server, Windows XP Professional x64 Edition (operating system version 5.2)";
- break;
- case QSysInfo::WV_VISTA :
- operatingSystemString = "Windows Vista, Windows Server 2008 (operating system version 6.0)";
- break;
- case QSysInfo::WV_WINDOWS7 :
- operatingSystemString = "Windows 7 (operating system version 6.1)";
- break;
- case QSysInfo::WV_CE :
- operatingSystemString = "Windows CE";
- break;
- case QSysInfo::WV_CENET :
- operatingSystemString = "Windows CE .NET";
- break;
- case QSysInfo::WV_CE_5 :
- operatingSystemString = "Windows CE 5.x";
- break;
- case QSysInfo::WV_CE_6 :
- operatingSystemString = "Windows CE 6.x";
- break;
- default :
- operatingSystemString = "Unknown Windows operating system.";
- break;
- }
-#elif defined(Q_WS_MAC)
- switch ( QSysInfo::MacintoshVersion ) {
- case QSysInfo::MV_9 :
- operatingSystemString = "Mac OS 9 (unsupported)";
- break;
- case QSysInfo::MV_10_0 :
- operatingSystemString = "Mac OS X 10.0 Cheetah (unsupported)";
- break;
- case QSysInfo::MV_10_1 :
- operatingSystemString = "Mac OS X 10.1 Puma (unsupported)";
- break;
- case QSysInfo::MV_10_2 :
- operatingSystemString = "Mac OS X 10.2 Jaguar (unsupported)";
- break;
- case QSysInfo::MV_10_3 :
- operatingSystemString = "Mac OS X 10.3 Panther";
- break;
- case QSysInfo::MV_10_4 :
- operatingSystemString = "Mac OS X 10.4 Tiger";
- break;
- case QSysInfo::MV_10_5 :
- operatingSystemString = "Mac OS X 10.5 Leopard";
- break;
- case QSysInfo::MV_10_6 :
- operatingSystemString = "Mac OS X 10.6 Snow Leopard";
- break;
- case QSysInfo::MV_Unknown :
- operatingSystemString = "An unknown and currently unsupported platform";
- break;
- default :
- operatingSystemString = "Unknown Mac operating system.";
- break;
- }
-#else
- //TODO: Detect Unix, Linux etc. distro as described on http://www.novell.com/coolsolutions/feature/11251.html
- operatingSystemString = "Linux";
- QProcess process;
-
- process.start("uname -s");
- bool result = process.waitForFinished(1000);
- QString os = process.readAllStandardOutput().trimmed();
-
- process.start("uname -r");
- result = process.waitForFinished(1000);
- QString rev = process.readAllStandardOutput().trimmed();
-
- process.start("uname -m");
- result = process.waitForFinished(1000);
- QString mach = process.readAllStandardOutput().trimmed();
-
- if ( os == "SunOS" ) {
- os = "Solaris";
-
- process.start("uname -p");
- result = process.waitForFinished(1000);
- QString arch = process.readAllStandardOutput().trimmed();
-
- process.start("uname -v");
- result = process.waitForFinished(1000);
- QString timestamp = process.readAllStandardOutput().trimmed();
-
- operatingSystemString = os + " " + rev + " (" + arch + " " + timestamp + ")";
- }
- else if ( os == "AIX" ) {
- process.start("oslevel -r");
- result = process.waitForFinished(1000);
- QString oslevel = process.readAllStandardOutput().trimmed();
-
- operatingSystemString = os + "oslevel " + oslevel;
- }
- else if ( os == "Linux" ) {
- QString dist;
- QString pseudoname;
- QString kernel = rev;
-
- if ( QFile::exists("/etc/redhat-release") ) {
- dist = "RedHat";
-
- process.start("sh -c \"cat /etc/redhat-release | sed s/.*\\(// | sed s/\\)//\"");
- result = process.waitForFinished(1000);
- pseudoname = process.readAllStandardOutput().trimmed();
-
- process.start("sh -c \"cat /etc/redhat-release | sed s/.*release\\ // | sed s/\\ .*//\"");
- result = process.waitForFinished(1000);
- rev = process.readAllStandardOutput().trimmed();
- }
- else if ( QFile::exists("/etc/SUSE-release") ) {
- process.start("sh -c \"cat /etc/SUSE-release | tr '\\n' ' '| sed s/VERSION.*//\"");
- result = process.waitForFinished(1000);
- dist = process.readAllStandardOutput().trimmed();
-
- process.start("sh -c \"cat /etc/SUSE-release | tr '\\n' ' ' | sed s/.*=\\ //\"");
- result = process.waitForFinished(1000);
- rev = process.readAllStandardOutput().trimmed();
- }
- else if ( QFile::exists("/etc/mandrake-release") ) {
- dist = "Mandrake";
-
- process.start("sh -c \"cat /etc/mandrake-release | sed s/.*\\(// | sed s/\\)//\"");
- result = process.waitForFinished(1000);
- pseudoname = process.readAllStandardOutput().trimmed();
-
- process.start("sh -c \"cat /etc/mandrake-release | sed s/.*release\\ // | sed s/\\ .*//\"");
- result = process.waitForFinished(1000);
- rev = process.readAllStandardOutput().trimmed();
- }
- else if ( QFile::exists("/etc/lsb-release") ) {
- dist = "Ubuntu";
-
- QString processCall = "sh -c \"cat /etc/lsb-release | tr '\\n' ' ' | sed s/.*DISTRIB_RELEASE=// | sed s/\\ .*//\"";
- process.start( processCall );
- result = process.waitForFinished(1000);
- rev = process.readAllStandardOutput().trimmed();
- QString errorStr = process.readAllStandardError();
-
- process.start("sh -c \"cat /etc/lsb-release | tr '\\n' ' ' | sed s/.*DISTRIB_CODENAME=// | sed s/\\ .*//\"");
- result = process.waitForFinished(1000);
- pseudoname = process.readAllStandardOutput().trimmed();
- }
- else if ( QFile::exists("/etc/debian_version") ) {
- dist = "Debian";
-
- process.start("cat /etc/debian_version");
- result = process.waitForFinished(1000);
- dist += process.readAllStandardOutput().trimmed();
-
- rev = "";
- }
-
- if ( QFile::exists("/etc/UnitedLinux-release") ) {
- process.start("sh -c \"cat /etc/UnitedLinux-release | tr '\\n' ' ' | sed s/VERSION.*//\"");
- result = process.waitForFinished(1000);
- dist += process.readAllStandardOutput().trimmed();
- }
-
- operatingSystemString = os + " " + dist + " " + rev + " (" + pseudoname + " " + kernel + " " + mach + ")";
- }
-#endif
-
- return operatingSystemString;
-}
+/*************************************************************************** + * 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 "UiGuiSystemInfo.h" + +#include <tqstring.h> +#include <tqsysinfo.h> +#include <tqprocess.h> +#include <tqfile.h> + +UiGuiSystemInfo::UiGuiSystemInfo() { +} + + +/*! + \brief Returns the operating system UiGUI is currently running on as one string. + + The String contains name and version of the os. E.g. Linux Ubuntu 9.04. + */ +QString UiGuiSystemInfo::getOperatingSystem() { + QString operatingSystemString = ""; + +#if defined(Q_WS_WIN) + switch ( QSysInfo::WindowsVersion ) { + case QSysInfo::WV_32s : + operatingSystemString = "Windows 3.1 with Win 32s"; + break; + case QSysInfo::WV_95 : + operatingSystemString = "Windows 95"; + break; + case QSysInfo::WV_98 : + operatingSystemString = "Windows 98"; + break; + case QSysInfo::WV_Me : + operatingSystemString = "Windows Me"; + break; + case QSysInfo::WV_NT : + operatingSystemString = "Windows NT (operating system version 4.0)"; + break; + case QSysInfo::WV_2000 : + operatingSystemString = "Windows 2000 (operating system version 5.0)"; + break; + case QSysInfo::WV_XP : + operatingSystemString = "Windows XP (operating system version 5.1)"; + break; + case QSysInfo::WV_2003 : + operatingSystemString = "Windows Server 2003, Windows Server 2003 R2, Windows Home Server, Windows XP Professional x64 Edition (operating system version 5.2)"; + break; + case QSysInfo::WV_VISTA : + operatingSystemString = "Windows Vista, Windows Server 2008 (operating system version 6.0)"; + break; + case QSysInfo::WV_WINDOWS7 : + operatingSystemString = "Windows 7 (operating system version 6.1)"; + break; + case QSysInfo::WV_CE : + operatingSystemString = "Windows CE"; + break; + case QSysInfo::WV_CENET : + operatingSystemString = "Windows CE .NET"; + break; + case QSysInfo::WV_CE_5 : + operatingSystemString = "Windows CE 5.x"; + break; + case QSysInfo::WV_CE_6 : + operatingSystemString = "Windows CE 6.x"; + break; + default : + operatingSystemString = "Unknown Windows operating system."; + break; + } +#elif defined(Q_WS_MAC) + switch ( QSysInfo::MacintoshVersion ) { + case QSysInfo::MV_9 : + operatingSystemString = "Mac OS 9 (unsupported)"; + break; + case QSysInfo::MV_10_0 : + operatingSystemString = "Mac OS X 10.0 Cheetah (unsupported)"; + break; + case QSysInfo::MV_10_1 : + operatingSystemString = "Mac OS X 10.1 Puma (unsupported)"; + break; + case QSysInfo::MV_10_2 : + operatingSystemString = "Mac OS X 10.2 Jaguar (unsupported)"; + break; + case QSysInfo::MV_10_3 : + operatingSystemString = "Mac OS X 10.3 Panther"; + break; + case QSysInfo::MV_10_4 : + operatingSystemString = "Mac OS X 10.4 Tiger"; + break; + case QSysInfo::MV_10_5 : + operatingSystemString = "Mac OS X 10.5 Leopard"; + break; + case QSysInfo::MV_10_6 : + operatingSystemString = "Mac OS X 10.6 Snow Leopard"; + break; + case QSysInfo::MV_Unknown : + operatingSystemString = "An unknown and currently unsupported platform"; + break; + default : + operatingSystemString = "Unknown Mac operating system."; + break; + } +#else + //TODO: Detect Unix, Linux etc. distro as described on http://www.novell.com/coolsolutions/feature/11251.html + operatingSystemString = "Linux"; + QProcess process; + + process.start("uname -s"); + bool result = process.waitForFinished(1000); + QString os = process.readAllStandardOutput().trimmed(); + + process.start("uname -r"); + result = process.waitForFinished(1000); + QString rev = process.readAllStandardOutput().trimmed(); + + process.start("uname -m"); + result = process.waitForFinished(1000); + QString mach = process.readAllStandardOutput().trimmed(); + + if ( os == "SunOS" ) { + os = "Solaris"; + + process.start("uname -p"); + result = process.waitForFinished(1000); + QString arch = process.readAllStandardOutput().trimmed(); + + process.start("uname -v"); + result = process.waitForFinished(1000); + QString timestamp = process.readAllStandardOutput().trimmed(); + + operatingSystemString = os + " " + rev + " (" + arch + " " + timestamp + ")"; + } + else if ( os == "AIX" ) { + process.start("oslevel -r"); + result = process.waitForFinished(1000); + QString oslevel = process.readAllStandardOutput().trimmed(); + + operatingSystemString = os + "oslevel " + oslevel; + } + else if ( os == "Linux" ) { + QString dist; + QString pseudoname; + QString kernel = rev; + + if ( QFile::exists("/etc/redhat-release") ) { + dist = "RedHat"; + + process.start("sh -c \"cat /etc/redhat-release | sed s/.*\\(// | sed s/\\)//\""); + result = process.waitForFinished(1000); + pseudoname = process.readAllStandardOutput().trimmed(); + + process.start("sh -c \"cat /etc/redhat-release | sed s/.*release\\ // | sed s/\\ .*//\""); + result = process.waitForFinished(1000); + rev = process.readAllStandardOutput().trimmed(); + } + else if ( QFile::exists("/etc/SUSE-release") ) { + process.start("sh -c \"cat /etc/SUSE-release | tr '\\n' ' '| sed s/VERSION.*//\""); + result = process.waitForFinished(1000); + dist = process.readAllStandardOutput().trimmed(); + + process.start("sh -c \"cat /etc/SUSE-release | tr '\\n' ' ' | sed s/.*=\\ //\""); + result = process.waitForFinished(1000); + rev = process.readAllStandardOutput().trimmed(); + } + else if ( QFile::exists("/etc/mandrake-release") ) { + dist = "Mandrake"; + + process.start("sh -c \"cat /etc/mandrake-release | sed s/.*\\(// | sed s/\\)//\""); + result = process.waitForFinished(1000); + pseudoname = process.readAllStandardOutput().trimmed(); + + process.start("sh -c \"cat /etc/mandrake-release | sed s/.*release\\ // | sed s/\\ .*//\""); + result = process.waitForFinished(1000); + rev = process.readAllStandardOutput().trimmed(); + } + else if ( QFile::exists("/etc/lsb-release") ) { + dist = "Ubuntu"; + + QString processCall = "sh -c \"cat /etc/lsb-release | tr '\\n' ' ' | sed s/.*DISTRIB_RELEASE=// | sed s/\\ .*//\""; + process.start( processCall ); + result = process.waitForFinished(1000); + rev = process.readAllStandardOutput().trimmed(); + QString errorStr = process.readAllStandardError(); + + process.start("sh -c \"cat /etc/lsb-release | tr '\\n' ' ' | sed s/.*DISTRIB_CODENAME=// | sed s/\\ .*//\""); + result = process.waitForFinished(1000); + pseudoname = process.readAllStandardOutput().trimmed(); + } + else if ( QFile::exists("/etc/debian_version") ) { + dist = "Debian"; + + process.start("cat /etc/debian_version"); + result = process.waitForFinished(1000); + dist += process.readAllStandardOutput().trimmed(); + + rev = ""; + } + + if ( QFile::exists("/etc/UnitedLinux-release") ) { + process.start("sh -c \"cat /etc/UnitedLinux-release | tr '\\n' ' ' | sed s/VERSION.*//\""); + result = process.waitForFinished(1000); + dist += process.readAllStandardOutput().trimmed(); + } + + operatingSystemString = os + " " + dist + " " + rev + " (" + pseudoname + " " + kernel + " " + mach + ")"; + } +#endif + + return operatingSystemString; +} diff --git a/src/UiGuiSystemInfo.h b/src/UiGuiSystemInfo.h index 08dca5b..3ed56ca 100755 --- a/src/UiGuiSystemInfo.h +++ b/src/UiGuiSystemInfo.h @@ -1,35 +1,35 @@ -/***************************************************************************
- * 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. *
- ***************************************************************************/
-
-#ifndef UIGUISYSTEMINFO_H
-#define UIGUISYSTEMINFO_H
-
-class QString;
-
-
-class UiGuiSystemInfo
-{
-public:
- static QString getOperatingSystem();
-
-private:
- UiGuiSystemInfo();
-};
-
-#endif // UIGUISYSTEMINFO_H
+/*************************************************************************** + * 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. * + ***************************************************************************/ + +#ifndef UIGUISYSTEMINFO_H +#define UIGUISYSTEMINFO_H + +class QString; + + +class UiGuiSystemInfo +{ +public: + static QString getOperatingSystem(); + +private: + UiGuiSystemInfo(); +}; + +#endif // UIGUISYSTEMINFO_H diff --git a/src/UiGuiVersion.cpp b/src/UiGuiVersion.cpp index 375df0e..8ddcdd8 100755 --- a/src/UiGuiVersion.cpp +++ b/src/UiGuiVersion.cpp @@ -1,61 +1,61 @@ -/***************************************************************************
- * 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 "UiGuiVersion.h"
-
-#include <QString>
-#include <QStringList>
-#include <QDate>
-
-namespace UiGuiVersion {
-/*!
- \brief Returns the build date as a localized string, e.g. "9. Februar 2009". If
- there was some kind of error, the returned string is empty.
- */
-QString getBuildDate() {
- QStringList monthNames;
- QString buildDateString = "";
-
- monthNames << "Jan" << "Feb" << "Mar" << "Apr" << "May" << "Jun" << "Jul" << "Aug" << "Sep" << "Oct" << "Nov" << "Dez";
- QStringList buildDateStringList = QString(__DATE__).simplified().split(' '); // __DATE__ returns eg "Feb 4 2009"
-
- if ( buildDateStringList.count() == 3 ) {
- QDate buildDate(buildDateStringList.last().toInt(), monthNames.indexOf( buildDateStringList.first() )+1, buildDateStringList.at(1).toInt());
- buildDateString = buildDate.toString("d. MMMM yyyy");
- }
-
- return buildDateString;
-}
-
-
-/*!
- \brief Returns the revision number, that the current build is based on, as string. If
- there was some kind of error, the returned string is empty.
- */
-QString getBuildRevision() {
- QString buildRevision = "";
- QStringList buildRevisionStringList = QString(PROGRAM_REVISION).simplified().split(' ');
-
- if ( buildRevisionStringList.count() == 3 ) {
- buildRevision = buildRevisionStringList.at(1); // PROGRAM_REVISION is eg "$Revision: 907 $"
- }
-
- return buildRevision;
-}
-} // namespace UiGuiVersion
+/*************************************************************************** + * 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 "UiGuiVersion.h" + +#include <tqstring.h> +#include <tqstringlist.h> +#include <tqdate.h> + +namespace UiGuiVersion { +/*! + \brief Returns the build date as a localized string, e.g. "9. Februar 2009". If + there was some kind of error, the returned string is empty. + */ +QString getBuildDate() { + QStringList monthNames; + QString buildDateString = ""; + + monthNames << "Jan" << "Feb" << "Mar" << "Apr" << "May" << "Jun" << "Jul" << "Aug" << "Sep" << "Oct" << "Nov" << "Dez"; + QStringList buildDateStringList = QString(__DATE__).simplified().split(' '); // __DATE__ returns eg "Feb 4 2009" + + if ( buildDateStringList.count() == 3 ) { + QDate buildDate(buildDateStringList.last().toInt(), monthNames.indexOf( buildDateStringList.first() )+1, buildDateStringList.at(1).toInt()); + buildDateString = buildDate.toString("d. MMMM yyyy"); + } + + return buildDateString; +} + + +/*! + \brief Returns the revision number, that the current build is based on, as string. If + there was some kind of error, the returned string is empty. + */ +QString getBuildRevision() { + QString buildRevision = ""; + QStringList buildRevisionStringList = QString(PROGRAM_REVISION).simplified().split(' '); + + if ( buildRevisionStringList.count() == 3 ) { + buildRevision = buildRevisionStringList.at(1); // PROGRAM_REVISION is eg "$Revision: 907 $" + } + + return buildRevision; +} +} // namespace UiGuiVersion diff --git a/src/UiGuiVersion.h b/src/UiGuiVersion.h index 41aff77..696313f 100755 --- a/src/UiGuiVersion.h +++ b/src/UiGuiVersion.h @@ -1,39 +1,39 @@ -/***************************************************************************
- * 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. *
- ***************************************************************************/
-
-#ifndef UIGUIVERSION_H
-#define UIGUIVERSION_H
-
-class QString;
-
-// Define the version number here. Update this as the last file before a release.
-#define PROGRAM_VERSION 1.2.0
-#define PROGRAM_VERSION_STRING "1.2.0"
-#define RESOURCE_VERSION 1,2,0,0
-#define RESOURCE_VERSION_STRING "1,2,0,0\0"
-#define PROGRAM_REVISION "$Revision: 1070 $"
-
-namespace UiGuiVersion {
-
- QString getBuildDate();
- QString getBuildRevision();
-
-}
-
-#endif // UIGUIVERSION_H
+/*************************************************************************** + * 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. * + ***************************************************************************/ + +#ifndef UIGUIVERSION_H +#define UIGUIVERSION_H + +class QString; + +// Define the version number here. Update this as the last file before a release. +#define PROGRAM_VERSION 1.2.0 +#define PROGRAM_VERSION_STRING "1.2.0" +#define RESOURCE_VERSION 1,2,0,0 +#define RESOURCE_VERSION_STRING "1,2,0,0\0" +#define PROGRAM_REVISION "$Revision: 1070 $" + +namespace UiGuiVersion { + + QString getBuildDate(); + QString getBuildRevision(); + +} + +#endif // UIGUIVERSION_H diff --git a/src/UpdateCheckDialog.cpp b/src/UpdateCheckDialog.cpp index a5a58d8..9a352a7 100755 --- a/src/UpdateCheckDialog.cpp +++ b/src/UpdateCheckDialog.cpp @@ -23,16 +23,16 @@ #include "UiGuiSettings.h" #include "UiGuiVersion.h" -#include <QMessageBox> -#include <QDesktopServices> -#include <QNetworkAccessManager> -#include <QTimer> -#include <QDate> -#include <QUrl> -#include <QRegExpValidator> -#include <QNetworkRequest> -#include <QNetworkReply> -#include <QNetworkProxy> +#include <tqmessagebox.h> +#include <tqdesktopservices.h> +#include <tqnetworkaccessmanager.h> +#include <tqtimer.h> +#include <tqdate.h> +#include <tqurl.h> +#include <tqregexpvalidator.h> +#include <tqnetworkrequest.h> +#include <tqnetworkreply.h> +#include <tqnetworkproxy.h> /*! \class UpdateCheckDialog diff --git a/src/UpdateCheckDialog.h b/src/UpdateCheckDialog.h index f0dfe81..85082cd 100755 --- a/src/UpdateCheckDialog.h +++ b/src/UpdateCheckDialog.h @@ -1,73 +1,73 @@ -/***************************************************************************
- * 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. *
- ***************************************************************************/
-
-#ifndef UPDATECHECKDIALOG_H
-#define UPDATECHECKDIALOG_H
-
-#include <QDialog>
-#include <QDialogButtonBox>
-
-class UiGuiSettings;
-namespace Ui {
- class UpdateCheckDialog;
-}
-
-class QTimer;
-class QDesktopServices;
-class QNetworkAccessManager;
-class QNetworkReply;
-
-
-class UpdateCheckDialog : public QDialog
-{
- Q_OBJECT
-
-public:
- UpdateCheckDialog(QSharedPointer<UiGuiSettings> settings, QWidget *parent = NULL);
- ~UpdateCheckDialog();
-
-public slots:
- void checkForUpdateAndShowDialog();
- void checkForUpdate();
-
-private slots:
- void checkResultsOfFetchedPadXMLFile(QNetworkReply *networkReply);
- void handleUpdateCheckDialogButtonClicked(QAbstractButton *clickedButton);
- void updateUpdateCheckProgressBar();
- void initProxySettings();
-
-private:
- Ui::UpdateCheckDialog *_updateCheckDialogForm;
-
- void getPadXMLFile();
- void showCheckingForUpdateDialog();
- void showNewVersionAvailableDialog(QString newVersion);
- void showNoNewVersionAvailableDialog();
- int convertVersionStringToNumber(QString versionString);
-
- QSharedPointer<UiGuiSettings> _settings;
- bool _manualUpdateRequested;
- QNetworkAccessManager *_networkAccessManager;
- QNetworkReply *_currentNetworkReply;
- QDialogButtonBox::ButtonRole _roleOfClickedButton;
- QTimer *_updateCheckProgressTimer;
- int _updateCheckProgressCounter;
-};
-
-#endif // UPDATECHECKDIALOG_H
+/*************************************************************************** + * 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. * + ***************************************************************************/ + +#ifndef UPDATECHECKDIALOG_H +#define UPDATECHECKDIALOG_H + +#include <tqdialog.h> +#include <tqdialogbuttonbox.h> + +class UiGuiSettings; +namespace Ui { + class UpdateCheckDialog; +} + +class QTimer; +class QDesktopServices; +class QNetworkAccessManager; +class QNetworkReply; + + +class UpdateCheckDialog : public QDialog +{ + Q_OBJECT + +public: + UpdateCheckDialog(QSharedPointer<UiGuiSettings> settings, QWidget *parent = NULL); + ~UpdateCheckDialog(); + +public slots: + void checkForUpdateAndShowDialog(); + void checkForUpdate(); + +private slots: + void checkResultsOfFetchedPadXMLFile(QNetworkReply *networkReply); + void handleUpdateCheckDialogButtonClicked(QAbstractButton *clickedButton); + void updateUpdateCheckProgressBar(); + void initProxySettings(); + +private: + Ui::UpdateCheckDialog *_updateCheckDialogForm; + + void getPadXMLFile(); + void showCheckingForUpdateDialog(); + void showNewVersionAvailableDialog(QString newVersion); + void showNoNewVersionAvailableDialog(); + int convertVersionStringToNumber(QString versionString); + + QSharedPointer<UiGuiSettings> _settings; + bool _manualUpdateRequested; + QNetworkAccessManager *_networkAccessManager; + QNetworkReply *_currentNetworkReply; + QDialogButtonBox::ButtonRole _roleOfClickedButton; + QTimer *_updateCheckProgressTimer; + int _updateCheckProgressCounter; +}; + +#endif // UPDATECHECKDIALOG_H diff --git a/src/debugging/TSLogger.cpp b/src/debugging/TSLogger.cpp index e7a912b..a13113e 100755 --- a/src/debugging/TSLogger.cpp +++ b/src/debugging/TSLogger.cpp @@ -1,251 +1,251 @@ -/***************************************************************************
- * 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 "TSLogger.h"
-#include "ui_TSLoggerDialog.h"
-
-#include "SettingsPaths.h"
-
-#include <QDateTime>
-#include <QFile>
-#include <QFileInfo>
-#include <QUrl>
-#include <QTextStream>
-#include <QDesktopServices>
-#include <QMessageBox>
-
-#include <ctime>
-
-using namespace tschweitzer;
-using namespace tschweitzer::debugging;
-
-TSLogger* TSLogger::_instance = NULL;
-
-/*!
- \class TSLogger
- \brief This class handles any kind of data logging, for debugging and whatever purpose.
-
- Beneath being able of displaying a dialog window containing all log messages of the
- current session, a log file in the systems temporary directory is used. Its name
- is "UiGUI_log.html".
-
- Setting a verbose level allows to only write messages that have the selected minimum
- priority to the log.
- */
-
-/*!
- \brief Returns the only existing instance of TSLogger. If the instance doesn't exist, it will be created.
- */
-TSLogger* TSLogger::getInstance(int verboseLevel) {
- if ( _instance == NULL )
- _instance = new TSLogger(verboseLevel);
-
- return _instance;
-}
-
-
-/*!
- \brief Returns the only existing instance of TSLogger. If the instance doesn't exist, it will be created.
- */
-TSLogger* TSLogger::getInstance() {
-#ifdef _DEBUG
- return TSLogger::getInstance(QtDebugMsg);
-#else
- return TSLogger::getInstance(QtWarningMsg);
-#endif
-}
-
-
-/*!
- \brief Initializes the dialog and sets the path to the log file in the systems temporary directory.
- Sets the default verbose level to warning level.
- */
-TSLogger::TSLogger(int verboseLevel) : QDialog() {
- _TSLoggerDialogForm = new Ui::TSLoggerDialog();
- _TSLoggerDialogForm->setupUi(this);
-#ifdef _DEBUG
- _verboseLevel = QtDebugMsg;
-#else
- _verboseLevel = QtMsgType(verboseLevel);
-#endif
-
- _logFileInitState = NOTINITIALZED;
-
- connect( _TSLoggerDialogForm->openLogFileFolderToolButton, SIGNAL(clicked()), this, SLOT(openLogFileFolder()) );
-
- // Make the main application not to wait for the logging window to close.
- setAttribute(Qt::WA_QuitOnClose, false);
-}
-
-
-/*!
- \brief Logs all incoming messages \a msg to the dialogs text edit and to the log file.
-
- Only messages whos \a type have a higher priority than the set verbose level are logged.
- */
-void TSLogger::messageHandler(QtMsgType type, const char *msg) {
- if ( _instance == NULL )
- _instance = TSLogger::getInstance();
-
-/*
- QMessageBox messageBox;
- QString messageBoxText = QString::fromUtf8( msg );
- messageBox.setText( messageBoxText );
- messageBox.setWindowModality( Qt::ApplicationModal );
- messageBox.exec();
-*/
-
- // Only log messages that have a higher or equal priority than set with the verbose level.
- if ( type < _instance->_verboseLevel )
- return;
-
- // Init log message with prepended date and time.
- QString message = QDateTime::currentDateTime().toString();
-
- // Depending on the QtMsgType prepend a different colored Debug, Warning, Critical or Fatal.
- switch (type) {
- case QtDebugMsg :
- message += " <span style=\"font-weight:bold; color:black;\">Debug:</span> ";
- break;
- case QtWarningMsg :
- message += " <span style=\"font-weight:bold; color:gold;\">Warning:</span> ";
- break;
- case QtCriticalMsg :
- message += "<span style=\"font-weight:bold; color:red;\">Critical:</span> ";
- break;
- case QtFatalMsg :
- message += " <span style=\"font-weight:bold; color:#D60000;\">Fatal:</span> ";
- // This one is no Qt message type, but can be used to send info messages to the log
- // by calling TSLogger::messageHandler() directly.
- case TSLoggerInfoMsg :
- message += " <span style=\"font-weight:bold; color:darkgray;\">Info:</span> ";
- break;
- }
-
- // Append the to UTF-8 back converted message parameter.
- message += QString::fromUtf8( msg ) + "<br/>\n";
-
- // Write the message to the log windows text edit.
- _instance->_TSLoggerDialogForm->logTextEdit->append( message );
-
- // Write/append the log message to the log file.
- _instance->writeToLogFile( message );
-
- // In case of a fatal error abort the application.
- if ( type == QtFatalMsg )
- abort();
-}
-
-
-/*!
- \brief Calling this the verbose level can be set in a range from 0 to 3
- which is equal to debug, warning, critical and fatal priority.
- */
-void TSLogger::setVerboseLevel(int level) {
- if ( level < 0 )
- _verboseLevel = QtDebugMsg;
- if ( level > 3 )
- _verboseLevel = QtFatalMsg;
- else
- _verboseLevel = QtMsgType(level);
-}
-
-
-/*!
- \brief Deletes the existing _instance of TSLogger.
- */
-void TSLogger::deleteInstance() {
- if ( _instance != NULL ) {
- delete _instance;
- _instance = NULL;
- }
-}
-
-
-/*!
- \brief Opens the folder that contains the created log file with the name "UiGUI_log.html".
- */
-void TSLogger::openLogFileFolder() {
- QDesktopServices::openUrl( QFileInfo( _logFile ).absolutePath() );
-}
-
-
-/*!
- \brief Writes the \a message to the used log file.
- */
-void TSLogger::writeToLogFile(const QString &message) {
- // If the file where all logging messages should go to isn't initilized yet, do that now.
- if ( _logFileInitState == NOTINITIALZED ) {
- _logFileInitState = INITIALIZING;
-
- // On different systems it may be that "QDir::tempPath()" ends with a "/" or not. So check this.
- // Remove any trailing slashes.
- QString tempPath = QFileInfo( SettingsPaths::getTempPath() ).absolutePath();
- while ( tempPath.right(1) == "/" ) {
- tempPath.chop(1);
- }
-
- // To make the temporary log file invulnerable against file symbolic link hacks
- // append the current date and time up to milliseconds to its name and a random character.
- QString logFileName = "UiGUI_log_" + QDateTime::currentDateTime().toString("yyyyMMdd");
- logFileName += "-" + QDateTime::currentDateTime().toString("hhmmsszzz");
- // By random decide whether to append a number or an upper or lower case character.
- qsrand( time(NULL) );
- unsigned char randomChar;
- switch ( qrand() % 3 ) {
- // Append a number from 0 to 9.
- case 0 :
- randomChar = qrand() % 10 + '0';
- break;
- // Append a upper case characer between A and Z.
- case 1 :
- randomChar = qrand() % 26 + 'A';
- break;
- // Append a lower case characer between a and z.
- default :
- randomChar = qrand() % 26 + 'a';
- break;
- }
- logFileName += "_" + QString(randomChar) + ".html";
-
- _logFile.setFileName( tempPath + "/" + logFileName );
-
- // Set the tooltip of the open log file folder button to show the unique name of the log file.
- _TSLoggerDialogForm->openLogFileFolderToolButton->setToolTip( _TSLoggerDialogForm->openLogFileFolderToolButton->toolTip() + " (" + logFileName + ")" );
-
- _logFileInitState = INITIALZED;
- }
-
- // Add the message to the message queue.
- _messageQueue << message;
-
- // If the logging file is initialzed, write all messages contained in the message queue into the file.
- if ( _logFileInitState == INITIALZED ) {
- // Write/append the log message to the log file.
- if ( _logFile.open(QIODevice::WriteOnly | QIODevice::Text | QIODevice::Append) ) {
- QTextStream out(&_logFile);
-
- while ( !_messageQueue.isEmpty() ) {
- out << _messageQueue.takeFirst() << "\n";
- }
-
- _logFile.close();
- }
- }
-}
+/*************************************************************************** + * 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 "TSLogger.h" +#include "ui_TSLoggerDialog.h" + +#include "SettingsPaths.h" + +#include <tqdatetime.h> +#include <tqfile.h> +#include <tqfileinfo.h> +#include <tqurl.h> +#include <tqtextstream.h> +#include <tqdesktopservices.h> +#include <tqmessagebox.h> + +#include <ctime> + +using namespace tschweitzer; +using namespace tschweitzer::debugging; + +TSLogger* TSLogger::_instance = NULL; + +/*! + \class TSLogger + \brief This class handles any kind of data logging, for debugging and whatever purpose. + + Beneath being able of displaying a dialog window containing all log messages of the + current session, a log file in the systems temporary directory is used. Its name + is "UiGUI_log.html". + + Setting a verbose level allows to only write messages that have the selected minimum + priority to the log. + */ + +/*! + \brief Returns the only existing instance of TSLogger. If the instance doesn't exist, it will be created. + */ +TSLogger* TSLogger::getInstance(int verboseLevel) { + if ( _instance == NULL ) + _instance = new TSLogger(verboseLevel); + + return _instance; +} + + +/*! + \brief Returns the only existing instance of TSLogger. If the instance doesn't exist, it will be created. + */ +TSLogger* TSLogger::getInstance() { +#ifdef _DEBUG + return TSLogger::getInstance(QtDebugMsg); +#else + return TSLogger::getInstance(QtWarningMsg); +#endif +} + + +/*! + \brief Initializes the dialog and sets the path to the log file in the systems temporary directory. + Sets the default verbose level to warning level. + */ +TSLogger::TSLogger(int verboseLevel) : QDialog() { + _TSLoggerDialogForm = new Ui::TSLoggerDialog(); + _TSLoggerDialogForm->setupUi(this); +#ifdef _DEBUG + _verboseLevel = QtDebugMsg; +#else + _verboseLevel = QtMsgType(verboseLevel); +#endif + + _logFileInitState = NOTINITIALZED; + + connect( _TSLoggerDialogForm->openLogFileFolderToolButton, SIGNAL(clicked()), this, SLOT(openLogFileFolder()) ); + + // Make the main application not to wait for the logging window to close. + setAttribute(Qt::WA_QuitOnClose, false); +} + + +/*! + \brief Logs all incoming messages \a msg to the dialogs text edit and to the log file. + + Only messages whos \a type have a higher priority than the set verbose level are logged. + */ +void TSLogger::messageHandler(QtMsgType type, const char *msg) { + if ( _instance == NULL ) + _instance = TSLogger::getInstance(); + +/* + QMessageBox messageBox; + QString messageBoxText = QString::fromUtf8( msg ); + messageBox.setText( messageBoxText ); + messageBox.setWindowModality( Qt::ApplicationModal ); + messageBox.exec(); +*/ + + // Only log messages that have a higher or equal priority than set with the verbose level. + if ( type < _instance->_verboseLevel ) + return; + + // Init log message with prepended date and time. + QString message = QDateTime::currentDateTime().toString(); + + // Depending on the QtMsgType prepend a different colored Debug, Warning, Critical or Fatal. + switch (type) { + case QtDebugMsg : + message += " <span style=\"font-weight:bold; color:black;\">Debug:</span> "; + break; + case QtWarningMsg : + message += " <span style=\"font-weight:bold; color:gold;\">Warning:</span> "; + break; + case QtCriticalMsg : + message += "<span style=\"font-weight:bold; color:red;\">Critical:</span> "; + break; + case QtFatalMsg : + message += " <span style=\"font-weight:bold; color:#D60000;\">Fatal:</span> "; + // This one is no Qt message type, but can be used to send info messages to the log + // by calling TSLogger::messageHandler() directly. + case TSLoggerInfoMsg : + message += " <span style=\"font-weight:bold; color:darkgray;\">Info:</span> "; + break; + } + + // Append the to UTF-8 back converted message parameter. + message += QString::fromUtf8( msg ) + "<br/>\n"; + + // Write the message to the log windows text edit. + _instance->_TSLoggerDialogForm->logTextEdit->append( message ); + + // Write/append the log message to the log file. + _instance->writeToLogFile( message ); + + // In case of a fatal error abort the application. + if ( type == QtFatalMsg ) + abort(); +} + + +/*! + \brief Calling this the verbose level can be set in a range from 0 to 3 + which is equal to debug, warning, critical and fatal priority. + */ +void TSLogger::setVerboseLevel(int level) { + if ( level < 0 ) + _verboseLevel = QtDebugMsg; + if ( level > 3 ) + _verboseLevel = QtFatalMsg; + else + _verboseLevel = QtMsgType(level); +} + + +/*! + \brief Deletes the existing _instance of TSLogger. + */ +void TSLogger::deleteInstance() { + if ( _instance != NULL ) { + delete _instance; + _instance = NULL; + } +} + + +/*! + \brief Opens the folder that contains the created log file with the name "UiGUI_log.html". + */ +void TSLogger::openLogFileFolder() { + QDesktopServices::openUrl( QFileInfo( _logFile ).absolutePath() ); +} + + +/*! + \brief Writes the \a message to the used log file. + */ +void TSLogger::writeToLogFile(const QString &message) { + // If the file where all logging messages should go to isn't initilized yet, do that now. + if ( _logFileInitState == NOTINITIALZED ) { + _logFileInitState = INITIALIZING; + + // On different systems it may be that "QDir::tempPath()" ends with a "/" or not. So check this. + // Remove any trailing slashes. + QString tempPath = QFileInfo( SettingsPaths::getTempPath() ).absolutePath(); + while ( tempPath.right(1) == "/" ) { + tempPath.chop(1); + } + + // To make the temporary log file invulnerable against file symbolic link hacks + // append the current date and time up to milliseconds to its name and a random character. + QString logFileName = "UiGUI_log_" + QDateTime::currentDateTime().toString("yyyyMMdd"); + logFileName += "-" + QDateTime::currentDateTime().toString("hhmmsszzz"); + // By random decide whether to append a number or an upper or lower case character. + qsrand( time(NULL) ); + unsigned char randomChar; + switch ( qrand() % 3 ) { + // Append a number from 0 to 9. + case 0 : + randomChar = qrand() % 10 + '0'; + break; + // Append a upper case characer between A and Z. + case 1 : + randomChar = qrand() % 26 + 'A'; + break; + // Append a lower case characer between a and z. + default : + randomChar = qrand() % 26 + 'a'; + break; + } + logFileName += "_" + QString(randomChar) + ".html"; + + _logFile.setFileName( tempPath + "/" + logFileName ); + + // Set the tooltip of the open log file folder button to show the unique name of the log file. + _TSLoggerDialogForm->openLogFileFolderToolButton->setToolTip( _TSLoggerDialogForm->openLogFileFolderToolButton->toolTip() + " (" + logFileName + ")" ); + + _logFileInitState = INITIALZED; + } + + // Add the message to the message queue. + _messageQueue << message; + + // If the logging file is initialzed, write all messages contained in the message queue into the file. + if ( _logFileInitState == INITIALZED ) { + // Write/append the log message to the log file. + if ( _logFile.open(QIODevice::WriteOnly | QIODevice::Text | QIODevice::Append) ) { + QTextStream out(&_logFile); + + while ( !_messageQueue.isEmpty() ) { + out << _messageQueue.takeFirst() << "\n"; + } + + _logFile.close(); + } + } +} diff --git a/src/debugging/TSLogger.h b/src/debugging/TSLogger.h index c7e7e62..97268f7 100755 --- a/src/debugging/TSLogger.h +++ b/src/debugging/TSLogger.h @@ -20,8 +20,8 @@ #ifndef TSLogger_H #define TSLogger_H -#include <QDialog> -#include <QFile> +#include <tqdialog.h> +#include <tqfile.h> namespace Ui { class TSLoggerDialog; diff --git a/src/main.cpp b/src/main.cpp index 6e09f3e..77e3444 100755 --- a/src/main.cpp +++ b/src/main.cpp @@ -28,9 +28,9 @@ #include "IndentHandler.h" #include "SettingsPaths.h" -#include <QApplication> -#include <QTextCodec> -#include <QDebug> +#include <tqapplication.h> +#include <tqtextcodec.h> +#include <tqdebug.h> #include <string> #include <iostream> |