diff --git a/UniversalIndentGUI.pro b/UniversalIndentGUI.pro index 67f4f95..ff49dee 100755 --- a/UniversalIndentGUI.pro +++ b/UniversalIndentGUI.pro @@ -1,6 +1,8 @@ TEMPLATE = app -QT += network -QT += script +QT += network \ + script \ + widgets \ + printsupport unix:TARGET = universalindentgui win32:TARGET = UniversalIndentGUI @@ -23,7 +25,7 @@ macx { ICON = resources/UniversalIndentGUI.icns } else { - LIBS += -lqscintilla2 + LIBS += -lqscintilla2_qt5 } CONFIG(release, debug|release) { @@ -37,10 +39,10 @@ macx:pipe2nul = "&> /dev/null" ########################## message(Updating language files) lupdate = lupdate -unix:lupdate = lupdate-qt4 +unix:lupdate = lupdate-qt5 macx:lupdate = lupdate lrelease = lrelease -unix:lrelease = lrelease-qt4 +unix:lrelease = lrelease-qt5 macx:lrelease = lrelease # Update translation files message ( Updating universalindent.ts ) diff --git a/UniversalIndentGUI_NPP.pro b/UniversalIndentGUI_NPP.pro index c12c124..a26857e 100644 --- a/UniversalIndentGUI_NPP.pro +++ b/UniversalIndentGUI_NPP.pro @@ -1,6 +1,9 @@ TEMPLATE = lib CONFIG += plugin -QT += script +QT += network \ + script \ + widgets \ + printsupport TARGET = UniversalIndentGUI_NPP diff --git a/src/AboutDialogGraphicsView.cpp b/src/AboutDialogGraphicsView.cpp index d97cc70..2fd1ca6 100644 --- a/src/AboutDialogGraphicsView.cpp +++ b/src/AboutDialogGraphicsView.cpp @@ -21,7 +21,7 @@ #include "AboutDialog.h" -#include +#include #include #include #include diff --git a/src/IndentHandler.cpp b/src/IndentHandler.cpp index a1109c4..50ce5f1 100644 --- a/src/IndentHandler.cpp +++ b/src/IndentHandler.cpp @@ -499,7 +499,7 @@ QString IndentHandler::callExecutableIndenter(QString sourceCode, QString inputF 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.toLatin1().length() ) { qWarning() << __LINE__ << " " << __FUNCTION__ << ": Shortened path still contains non ascii characters. Could cause some indenters not to work properly!"; } } @@ -705,7 +705,7 @@ void IndentHandler::saveConfigFile(QString filePathName, QString paramString) { QFile cfgFile( filePathName ); cfgFile.open( QFile::ReadWrite | QFile::Text ); - cfgFile.write( paramString.toAscii() ); + cfgFile.write( paramString.toLatin1() ); cfgFile.close(); } @@ -1497,21 +1497,21 @@ void IndentHandler::retranslateUi() { _indenterSelectionCombobox->setToolTip( tr("

Shows the currently chosen indenters name and lets you choose other available indenters

") ); _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 @@ void IndentHandler::saveasIndentCfgFileDialog() { QFile::remove(fileName); QFile outCfgFile(fileName); outCfgFile.open( QFile::ReadWrite | QFile::Text ); - outCfgFile.write( getParameterString().toAscii() ); + outCfgFile.write( getParameterString().toLatin1() ); outCfgFile.close(); } } @@ -1608,7 +1608,7 @@ void IndentHandler::createIndenterCallShellScript() { // Replace placeholder for script name in script template. indenterCallShellScript = indenterCallShellScript.replace( "__INDENTERCALLSTRINGSCRIPTNAME__", QFileInfo(shellScriptFileName).fileName() ); - outSrcFile.write( indenterCallShellScript.toAscii() ); + outSrcFile.write( indenterCallShellScript.toLatin1() ); #if !defined(Q_OS_WIN32) // For none Windows systems set the files executable flag outSrcFile.setPermissions( outSrcFile.permissions() | QFile::ExeOwner | QFile::ExeUser| QFile::ExeGroup ); diff --git a/src/MainWindow.cpp b/src/MainWindow.cpp index f7b6185..517356d 100644 --- a/src/MainWindow.cpp +++ b/src/MainWindow.cpp @@ -53,6 +53,7 @@ #include #include #include +#include #include #include @@ -410,7 +411,7 @@ QString MainWindow::loadFile(QString filePath) { else { QTextStream inSrcStrm(&inSrcFile); QApplication::setOverrideCursor(Qt::WaitCursor); - inSrcStrm.setCodec( QTextCodec::codecForName(_currentEncoding.toAscii()) ); + inSrcStrm.setCodec( QTextCodec::codecForName(_currentEncoding.toLatin1()) ); fileContent = inSrcStrm.readAll(); QApplication::restoreOverrideCursor(); inSrcFile.close(); @@ -502,7 +503,7 @@ bool MainWindow::saveasSourceFileDialog(QAction *chosenEncodingAction) { encoding = _encodingActionGroup->checkedAction()->text(); } QTextStream outSrcStrm(&outSrcFile); - outSrcStrm.setCodec( QTextCodec::codecForName(encoding.toAscii()) ); + outSrcStrm.setCodec( QTextCodec::codecForName(encoding.toLatin1()) ); outSrcStrm << _savedSourceContent; outSrcFile.close(); @@ -536,7 +537,7 @@ bool MainWindow::saveSourceFile() { // Get current encoding. QString _currentEncoding = _encodingActionGroup->checkedAction()->text(); QTextStream outSrcStrm(&outSrcFile); - outSrcStrm.setCodec( QTextCodec::codecForName(_currentEncoding.toAscii()) ); + outSrcStrm.setCodec( QTextCodec::codecForName(_currentEncoding.toLatin1()) ); outSrcStrm << _savedSourceContent; outSrcFile.close(); @@ -681,7 +682,7 @@ void MainWindow::sourceCodeChangedSlot() { updateSourceView(); if ( _toolBarWidget->cbLivePreview->isChecked() && !enteredCharacter.isNull() && enteredCharacter != 10 ) { - //const char ch = enteredCharacter.toAscii(); + //const char ch = enteredCharacter.toLatin1(); int saveCursorLine = cursorLine; int saveCursorPos = cursorPos; @@ -899,7 +900,7 @@ void MainWindow::exportToHTML() { QFile::remove(fileName); QFile outSrcFile(fileName); outSrcFile.open( QFile::ReadWrite | QFile::Text ); - outSrcFile.write( sourceCodeAsHTML.toAscii() ); + outSrcFile.write( sourceCodeAsHTML.toLatin1() ); outSrcFile.close(); } } @@ -1139,7 +1140,7 @@ void MainWindow::encodingChanged(QAction* encodingAction) { QApplication::setOverrideCursor(Qt::WaitCursor); QString encodingName = encodingAction->text(); _currentEncoding = encodingName; - inSrcStrm.setCodec( QTextCodec::codecForName(encodingName.toAscii()) ); + inSrcStrm.setCodec( QTextCodec::codecForName(encodingName.toLatin1()) ); fileContent = inSrcStrm.readAll(); QApplication::restoreOverrideCursor(); inSrcFile.close(); diff --git a/src/SettingsPaths.cpp b/src/SettingsPaths.cpp index f556491..084c1e5 100644 --- a/src/SettingsPaths.cpp +++ b/src/SettingsPaths.cpp @@ -144,7 +144,7 @@ void SettingsPaths::init() { // 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").toLatin1(); delete [] pathTemplate; pathTemplate = pathTemplateQBA.data(); pathTemplate = mkdtemp( pathTemplate ); diff --git a/src/UiGuiSettings.cpp b/src/UiGuiSettings.cpp index 3aacf1f..62a898f 100644 --- a/src/UiGuiSettings.cpp +++ b/src/UiGuiSettings.cpp @@ -214,7 +214,7 @@ bool UiGuiSettings::registerObjectProperty( QObject *obj, const QString &propert 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())); + connectSuccess = connect(obj, qPrintable(SIGNAL() + QString(signal.methodSignature())), this, SLOT(handleObjectPropertyChange())); } if ( connectSuccess ) { @@ -397,7 +397,7 @@ void UiGuiSettings::unregisterObjectProperty(QObject *obj) { 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())); + connectSuccess = disconnect(obj, qPrintable(SIGNAL() + QString(signal.methodSignature())), this, SLOT(handleObjectPropertyChange())); } } _registeredObjectProperties.remove(obj); diff --git a/src/UniversalIndentGUI_NPP/UniversalIndentGUI_NPP.cpp b/src/UniversalIndentGUI_NPP/UniversalIndentGUI_NPP.cpp index 15f849e..dc47510 100644 --- a/src/UniversalIndentGUI_NPP/UniversalIndentGUI_NPP.cpp +++ b/src/UniversalIndentGUI_NPP/UniversalIndentGUI_NPP.cpp @@ -67,8 +67,8 @@ BOOL APIENTRY DllMain( HANDLE hModule, DWORD reasonForCall, LPVOID lpReserved ) // Force creation of an UiGuiLogger instance here, to avoid recursion with SettingsPaths init function. UiGuiLogger::getInstance(); qInstallMsgHandler( UiGuiLogger::messageHandler ); - UiGuiLogger::messageHandler( UiGuiInfoMsg, QString("Starting UiGUI Version %1 %2").arg(PROGRAM_VERSION_STRING).arg(PROGRAM_REVISION).toAscii() ); - UiGuiLogger::messageHandler( UiGuiInfoMsg, QString("Running on %1").arg(UiGuiSystemInfo::getOperatingSystem()).toAscii() ); + UiGuiLogger::messageHandler( UiGuiInfoMsg, QString("Starting UiGUI Version %1 %2").arg(PROGRAM_VERSION_STRING).arg(PROGRAM_REVISION).toLatin1() ); + UiGuiLogger::messageHandler( UiGuiInfoMsg, QString("Running on %1").arg(UiGuiSystemInfo::getOperatingSystem()).toLatin1() ); #ifdef _DEBUG UiGuiLogger::getInstance()->setVerboseLevel(0); @@ -307,7 +307,7 @@ void indentText() { QString indentedText = indentHandler->callIndenter(fullEditorText, "cpp"); - QByteArray indentedTextByteArray = indentedText.toAscii(); + QByteArray indentedTextByteArray = indentedText.toLatin1(); // Set whole text. ::SendMessage(getCurrentHScintilla(currentEdit), SCI_SETTEXT, 0, (LPARAM)indentedTextByteArray.constData()); @@ -327,7 +327,7 @@ void indentText() { QString indentedText = indentHandler->callIndenter(fullEditorText, "cpp"); - QByteArray indentedTextByteArray = indentedText.toAscii(); + QByteArray indentedTextByteArray = indentedText.toLatin1(); // Replace selected text. ::SendMessage(getCurrentHScintilla(currentEdit), SCI_REPLACESEL, 0, (LPARAM)indentedTextByteArray.constData()); diff --git a/src/debugging/TSLogger.cpp b/src/debugging/TSLogger.cpp index e7a912b..4c149e4 100644 --- a/src/debugging/TSLogger.cpp +++ b/src/debugging/TSLogger.cpp @@ -99,7 +99,7 @@ TSLogger::TSLogger(int verboseLevel) : QDialog() { 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(); @@ -131,15 +131,10 @@ void TSLogger::messageHandler(QtMsgType type, const char *msg) { break; case QtFatalMsg : message += " Fatal: "; - // 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 += " Info: "; - break; } // Append the to UTF-8 back converted message parameter. - message += QString::fromUtf8( msg ) + "
\n"; + message += msg + "
\n"; // Write the message to the log windows text edit. _instance->_TSLoggerDialogForm->logTextEdit->append( message ); diff --git a/src/debugging/TSLogger.h b/src/debugging/TSLogger.h index c7e7e62..0c869fd 100644 --- a/src/debugging/TSLogger.h +++ b/src/debugging/TSLogger.h @@ -38,7 +38,7 @@ class TSLogger : public QDialog 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); diff --git a/src/main.cpp b/src/main.cpp index 6e09f3e..a972f71 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -226,7 +226,6 @@ int main(int argc, char *argv[]) { // 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,9 @@ int main(int argc, char *argv[]) { #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() ); + qInstallMessageHandler( TSLogger::messageHandler ); + qInfo() << QString("Starting UiGUI Version %1 %2").arg(PROGRAM_VERSION_STRING).arg(PROGRAM_REVISION).toLatin1(); + qInfo() << QString("Running on %1").arg(UiGuiSystemInfo::getOperatingSystem()).toLatin1(); // Set default values for all by UniversalIndentGUI used settings objects. QCoreApplication::setOrganizationName("UniversalIndentGUI");