changeset 798:4950731d52c1

Port to Qt5. Seems to work.
author Matti Hamalainen <ccr@tnsp.org>
date Wed, 12 Apr 2017 11:59:44 +0300
parents 718e09837d7b
children 18eb32d29a4f
files UniversalIndentGUI.pro src/AboutDialogGraphicsView.h src/IndentHandler.cpp src/MainWindow.cpp src/SettingsPaths.cpp src/UiGuiSettings.cpp src/debugging/TSLogger.cpp src/debugging/TSLogger.h src/main.cpp
diffstat 9 files changed, 47 insertions(+), 45 deletions(-) [+]
line wrap: on
line diff
--- a/UniversalIndentGUI.pro	Tue Mar 17 11:09:14 2015 -0600
+++ b/UniversalIndentGUI.pro	Wed Apr 12 11:59:44 2017 +0300
@@ -1,6 +1,6 @@
 TEMPLATE = app
 QT += network
-QT += script
+QT += script gui widgets printsupport
 
 unix:TARGET = universalindentgui
 win32:TARGET = UniversalIndentGUI
@@ -23,7 +23,7 @@
  ICON = resources/UniversalIndentGUI.icns
 }
 else {
- LIBS += -lqscintilla2
+ LIBS += -lqt5scintilla2
 }
 
 CONFIG(release, debug|release) {
@@ -37,10 +37,10 @@
 ##########################
 message(Updating language files)
 lupdate = lupdate
-unix:lupdate = lupdate-qt4
+unix:lupdate = lupdate
 macx:lupdate = lupdate
 lrelease = lrelease
-unix:lrelease = lrelease-qt4
+unix:lrelease = lrelease
 macx:lrelease = lrelease
 # Update translation files
 message ( Updating universalindent.ts )
--- a/src/AboutDialogGraphicsView.h	Tue Mar 17 11:09:14 2015 -0600
+++ b/src/AboutDialogGraphicsView.h	Wed Apr 12 11:59:44 2017 +0300
@@ -19,12 +19,12 @@
 #ifndef ABOUTDIALOGGRAPHICSVIEW_H
 #define ABOUTDIALOGGRAPHICSVIEW_H
 
+#include <QApplication>
 #include <QGraphicsView>
-
-class AboutDialog;
-
-class QTimeLine;
-class QSplashScreen;
+#include <QTimeLine>
+#include <QSplashScreen>
+#include <QGraphicsProxyWidget>
+#include "AboutDialog.h"
 
 
 class AboutDialogGraphicsView : public QGraphicsView
--- a/src/IndentHandler.cpp	Tue Mar 17 11:09:14 2015 -0600
+++ b/src/IndentHandler.cpp	Wed Apr 12 11:59:44 2017 +0300
@@ -499,7 +499,7 @@
         delete [] buffer;
 
         // Check whether the short path still contains some kind of non ascii characters.
-        if ( _tempDirctoryStr.length() != _tempDirctoryStr.toAscii().length() ) {
+        if ( _tempDirctoryStr.length() != _tempDirctoryStr.toUtf8().length() ) {
             qWarning() << __LINE__ << " " << __FUNCTION__ << ": Shortened path still contains non ascii characters. Could cause some indenters not to work properly!";
         }
     }
@@ -705,7 +705,7 @@
     QFile cfgFile( filePathName );
 
     cfgFile.open( QFile::ReadWrite | QFile::Text );
-    cfgFile.write( paramString.toAscii() );
+    cfgFile.write( paramString.toUtf8() );
     cfgFile.close();
 }
 
@@ -1497,21 +1497,21 @@
     _indenterSelectionCombobox->setToolTip( tr("<html><head><meta name=\"qrichtext\" content=\"1\" /></head><body style=\" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;\"><p style=\" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\">Shows the currently chosen indenters name and lets you choose other available indenters</p></body></html>") );
     _indenterParameterHelpButton->setToolTip( tr("Brings you to the online manual of the currently selected indenter, where you can get further help on the possible parameters.") );
 
-    _actionLoadIndenterConfigFile->setText(QApplication::translate("IndentHandler", "Load Indenter Config File", 0, QApplication::UnicodeUTF8));
-    _actionLoadIndenterConfigFile->setStatusTip(QApplication::translate("IndentHandler", "Opens a file dialog to load the original config file of the indenter.", 0, QApplication::UnicodeUTF8));
-    _actionLoadIndenterConfigFile->setShortcut(QApplication::translate("IndentHandler", "Alt+O", 0, QApplication::UnicodeUTF8));
+    _actionLoadIndenterConfigFile->setText(QApplication::translate("IndentHandler", "Load Indenter Config File", 0));
+    _actionLoadIndenterConfigFile->setStatusTip(QApplication::translate("IndentHandler", "Opens a file dialog to load the original config file of the indenter.", 0));
+    _actionLoadIndenterConfigFile->setShortcut(QApplication::translate("IndentHandler", "Alt+O", 0));
 
-    _actionSaveIndenterConfigFile->setText(QApplication::translate("IndentHandler", "Save Indenter Config File", 0, QApplication::UnicodeUTF8));
-    _actionSaveIndenterConfigFile->setStatusTip(QApplication::translate("IndentHandler", "Opens a dialog to save the current indenter configuration to a file.", 0, QApplication::UnicodeUTF8));
-    _actionSaveIndenterConfigFile->setShortcut(QApplication::translate("IndentHandler", "Alt+S", 0, QApplication::UnicodeUTF8));
+    _actionSaveIndenterConfigFile->setText(QApplication::translate("IndentHandler", "Save Indenter Config File", 0));
+    _actionSaveIndenterConfigFile->setStatusTip(QApplication::translate("IndentHandler", "Opens a dialog to save the current indenter configuration to a file.", 0));
+    _actionSaveIndenterConfigFile->setShortcut(QApplication::translate("IndentHandler", "Alt+S", 0));
 
-    _actionCreateShellScript->setText(QApplication::translate("IndentHandler", "Create Indenter Call Shell Script", 0, QApplication::UnicodeUTF8));
-    _actionCreateShellScript->setToolTip(QApplication::translate("IndentHandler", "Create a shell script that calls the current selected indenter for formatting an as parameter given file with the current indent settings.", 0, QApplication::UnicodeUTF8));
-    _actionCreateShellScript->setStatusTip(QApplication::translate("IndentHandler", "Create a shell script that calls the current selected indenter for formatting an as parameter given file with the current indent settings.", 0, QApplication::UnicodeUTF8));
+    _actionCreateShellScript->setText(QApplication::translate("IndentHandler", "Create Indenter Call Shell Script", 0));
+    _actionCreateShellScript->setToolTip(QApplication::translate("IndentHandler", "Create a shell script that calls the current selected indenter for formatting an as parameter given file with the current indent settings.", 0));
+    _actionCreateShellScript->setStatusTip(QApplication::translate("IndentHandler", "Create a shell script that calls the current selected indenter for formatting an as parameter given file with the current indent settings.", 0));
 
-    _actionResetIndenterParameters->setText(QApplication::translate("IndentHandler", "Reset indenter parameters", 0, QApplication::UnicodeUTF8));
-    _actionResetIndenterParameters->setToolTip(QApplication::translate("IndentHandler", "Resets all indenter parameters to the default values.", 0, QApplication::UnicodeUTF8));
-    _actionResetIndenterParameters->setStatusTip(QApplication::translate("IndentHandler", "Resets all indenter parameters to the default values.", 0, QApplication::UnicodeUTF8));
+    _actionResetIndenterParameters->setText(QApplication::translate("IndentHandler", "Reset indenter parameters", 0));
+    _actionResetIndenterParameters->setToolTip(QApplication::translate("IndentHandler", "Resets all indenter parameters to the default values.", 0));
+    _actionResetIndenterParameters->setStatusTip(QApplication::translate("IndentHandler", "Resets all indenter parameters to the default values.", 0));
 }
 
 
@@ -1564,7 +1564,7 @@
         QFile::remove(fileName);
         QFile outCfgFile(fileName);
         outCfgFile.open( QFile::ReadWrite | QFile::Text );
-        outCfgFile.write( getParameterString().toAscii() );
+        outCfgFile.write( getParameterString().toUtf8() );
         outCfgFile.close();
     }
 }
@@ -1608,7 +1608,7 @@
         // Replace placeholder for script name in script template.
         indenterCallShellScript = indenterCallShellScript.replace( "__INDENTERCALLSTRINGSCRIPTNAME__", QFileInfo(shellScriptFileName).fileName() );
 
-        outSrcFile.write( indenterCallShellScript.toAscii() );
+        outSrcFile.write( indenterCallShellScript.toUtf8() );
 #if !defined(Q_OS_WIN32)
         // For none Windows systems set the files executable flag
         outSrcFile.setPermissions( outSrcFile.permissions() | QFile::ExeOwner | QFile::ExeUser| QFile::ExeGroup );
--- a/src/MainWindow.cpp	Tue Mar 17 11:09:14 2015 -0600
+++ b/src/MainWindow.cpp	Wed Apr 12 11:59:44 2017 +0300
@@ -53,6 +53,7 @@
 #include <QUrl>
 #include <QMessageBox>
 #include <QtDebug>
+#include <QMimeData>
 
 #include <Qsci/qsciscintilla.h>
 #include <Qsci/qsciprinter.h>
@@ -410,7 +411,7 @@
     else {
         QTextStream inSrcStrm(&inSrcFile);
         QApplication::setOverrideCursor(Qt::WaitCursor);
-        inSrcStrm.setCodec( QTextCodec::codecForName(_currentEncoding.toAscii()) );
+        inSrcStrm.setCodec( QTextCodec::codecForName(_currentEncoding.toUtf8()) );
         fileContent = inSrcStrm.readAll();
         QApplication::restoreOverrideCursor();
         inSrcFile.close();
@@ -502,7 +503,7 @@
         encoding = _encodingActionGroup->checkedAction()->text();
     }
     QTextStream outSrcStrm(&outSrcFile);
-    outSrcStrm.setCodec( QTextCodec::codecForName(encoding.toAscii()) );
+    outSrcStrm.setCodec( QTextCodec::codecForName(encoding.toUtf8()) );
     outSrcStrm << _savedSourceContent;
     outSrcFile.close();
 
@@ -536,7 +537,7 @@
         // Get current encoding.
         QString _currentEncoding = _encodingActionGroup->checkedAction()->text();
         QTextStream outSrcStrm(&outSrcFile);
-        outSrcStrm.setCodec( QTextCodec::codecForName(_currentEncoding.toAscii()) );
+        outSrcStrm.setCodec( QTextCodec::codecForName(_currentEncoding.toUtf8()) );
         outSrcStrm << _savedSourceContent;
         outSrcFile.close();
 
@@ -681,7 +682,7 @@
     updateSourceView();
 
     if ( _toolBarWidget->cbLivePreview->isChecked() && !enteredCharacter.isNull() && enteredCharacter != 10 ) {
-        //const char ch = enteredCharacter.toAscii();
+        //const char ch = enteredCharacter.toUtf8();
 
         int saveCursorLine = cursorLine;
         int saveCursorPos = cursorPos;
@@ -899,7 +900,7 @@
         QFile::remove(fileName);
         QFile outSrcFile(fileName);
         outSrcFile.open( QFile::ReadWrite | QFile::Text );
-        outSrcFile.write( sourceCodeAsHTML.toAscii() );
+        outSrcFile.write( sourceCodeAsHTML.toUtf8() );
         outSrcFile.close();
     }
 }
@@ -1139,7 +1140,7 @@
             QApplication::setOverrideCursor(Qt::WaitCursor);
             QString encodingName = encodingAction->text();
             _currentEncoding = encodingName;
-            inSrcStrm.setCodec( QTextCodec::codecForName(encodingName.toAscii()) );
+            inSrcStrm.setCodec( QTextCodec::codecForName(encodingName.toUtf8()) );
             fileContent = inSrcStrm.readAll();
             QApplication::restoreOverrideCursor();
             inSrcFile.close();
--- a/src/SettingsPaths.cpp	Tue Mar 17 11:09:14 2015 -0600
+++ b/src/SettingsPaths.cpp	Wed Apr 12 11:59:44 2017 +0300
@@ -144,7 +144,7 @@
         // 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();
+        QByteArray pathTemplateQBA = QString(_tempPath + "-XXXXXX").toUtf8();
         delete [] pathTemplate;
         pathTemplate = pathTemplateQBA.data();
         pathTemplate = mkdtemp( pathTemplate );
--- a/src/UiGuiSettings.cpp	Tue Mar 17 11:09:14 2015 -0600
+++ b/src/UiGuiSettings.cpp	Wed Apr 12 11:59:44 2017 +0300
@@ -181,7 +181,7 @@
     _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", true) );
+    _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.
@@ -212,9 +212,9 @@
         // 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()));
+            //QString teststr = qPrintable(SIGNAL() + QString(signal.methodSignature()));
+            // The command "SIGNAL() + QString(signal.methodSignature())" assembles the signal methods signature to a valid Qt SIGNAL.
+            connectSuccess = connect(obj, qPrintable(SIGNAL() + QString(signal.methodSignature())), this, SLOT(handleObjectPropertyChange()));
         }
 
         if ( connectSuccess ) {
@@ -396,8 +396,8 @@
             // 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()));
+                // The command "SIGNAL() + QString(signal.methodSignature())" assembles the signal methods signature to a valid Qt SIGNAL.
+                connectSuccess = disconnect(obj, qPrintable(SIGNAL() + QString(signal.methodSignature())), this, SLOT(handleObjectPropertyChange()));
             }
         }
         _registeredObjectProperties.remove(obj);
--- a/src/debugging/TSLogger.cpp	Tue Mar 17 11:09:14 2015 -0600
+++ b/src/debugging/TSLogger.cpp	Wed Apr 12 11:59:44 2017 +0300
@@ -99,7 +99,8 @@
 
     Only messages whos \a type have a higher priority than the set verbose level are logged.
  */
-void TSLogger::messageHandler(QtMsgType type, const char *msg) {
+void TSLogger::messageHandler(QtMsgType type, const QMessageLogContext &, const QString &msg)
+{
     if ( _instance == NULL )
         _instance = TSLogger::getInstance();
 
@@ -139,7 +140,7 @@
     }
 
     // Append the to UTF-8 back converted message parameter.
-    message += QString::fromUtf8( msg ) + "<br/>\n";
+    message += msg + "<br/>\n";
 
     // Write the message to the log windows text edit.
     _instance->_TSLoggerDialogForm->logTextEdit->append( message );
--- a/src/debugging/TSLogger.h	Tue Mar 17 11:09:14 2015 -0600
+++ b/src/debugging/TSLogger.h	Wed Apr 12 11:59:44 2017 +0300
@@ -38,7 +38,7 @@
 public:
     static TSLogger* getInstance(int verboseLevel);
     static TSLogger* getInstance();
-    static void messageHandler(QtMsgType type, const char *msg);
+    static void messageHandler(QtMsgType type, const QMessageLogContext &, const QString &msg);
     static void deleteInstance();
     void setVerboseLevel(int level);
 
--- a/src/main.cpp	Tue Mar 17 11:09:14 2015 -0600
+++ b/src/main.cpp	Wed Apr 12 11:59:44 2017 +0300
@@ -226,7 +226,6 @@
 
     // Init and install the logger function.
     // Setting UTF-8 as default 8-Bit encoding to ensure that qDebug does no false string conversion.
-    QTextCodec::setCodecForCStrings( QTextCodec::codecForName("UTF-8") );
     QTextCodec::setCodecForLocale( QTextCodec::codecForName("UTF-8") );
     // Force creation of an TSLogger instance here, to avoid recursion with SettingsPaths init function.
 #ifdef _DEBUG
@@ -234,9 +233,10 @@
 #else
     TSLogger::getInstance(verboseLevel);
 #endif
-    qInstallMsgHandler( TSLogger::messageHandler );
-    TSLogger::messageHandler( TSLoggerInfoMsg, QString("Starting UiGUI Version %1 %2").arg(PROGRAM_VERSION_STRING).arg(PROGRAM_REVISION).toAscii() );
-    TSLogger::messageHandler( TSLoggerInfoMsg, QString("Running on %1").arg(UiGuiSystemInfo::getOperatingSystem()).toAscii() );
+    QMessageLogContext ctx;
+    qInstallMessageHandler( TSLogger::messageHandler );
+    TSLogger::messageHandler( TSLoggerInfoMsg, ctx, QString("Starting UiGUI Version %1 %2").arg(PROGRAM_VERSION_STRING).arg(PROGRAM_REVISION) );
+    TSLogger::messageHandler( TSLoggerInfoMsg, ctx, QString("Running on %1").arg(UiGuiSystemInfo::getOperatingSystem()) );
 
     // Set default values for all by UniversalIndentGUI used settings objects.
     QCoreApplication::setOrganizationName("UniversalIndentGUI");