From 7eee0a8a01c2d858b48745d0678fd5556253cd66 Mon Sep 17 00:00:00 2001 From: Dicene Date: Fri, 9 Aug 2019 07:19:36 -0400 Subject: [PATCH 01/21] Initial commit. Adds ctrl+tab shortcut and logic for moving from pane to pane in the trigger editor. --- src/dlgTriggerEditor.cpp | 163 +++++++++++++++++++++++++++++++++++++++ src/dlgTriggerEditor.h | 1 + 2 files changed, 164 insertions(+) diff --git a/src/dlgTriggerEditor.cpp b/src/dlgTriggerEditor.cpp index b2e4ef52f7b..6ddb404882e 100644 --- a/src/dlgTriggerEditor.cpp +++ b/src/dlgTriggerEditor.cpp @@ -504,6 +504,18 @@ dlgTriggerEditor::dlgTriggerEditor(Host* pH) showDebugAreaAction->setStatusTip(tr("Shows/Hides the separate Central Debug Console - when being displayed the system will be slower.")); connect(showDebugAreaAction, &QAction::triggered, this, &dlgTriggerEditor::slot_debug_mode); + QAction* nextSectionAction = new QAction(tr("Scripts"), this); + nextSectionAction->setShortcutContext(Qt::WindowShortcut); + //nextSectionAction->setShortcut("Ctrl+T"); + //nextSectionAction->setShortcut(QKeySequence::NextChild); + nextSectionAction->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_Tab)); + //nextSectionAction->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_Tab)); + nextSectionAction->setToolTip("ToolTip"); + nextSectionAction->setStatusTip("Next Section"); + nextSectionAction->setEnabled(true); + + connect(nextSectionAction, &QAction::triggered, this, &dlgTriggerEditor::slot_next_section); + toolBar = new QToolBar(); toolBar2 = new QToolBar(); @@ -512,6 +524,8 @@ dlgTriggerEditor::dlgTriggerEditor(Host* pH) slot_setToolBarIconSize(mudlet::self()->mToolbarIconSize); slot_setTreeWidgetIconSize(mudlet::self()->mEditorTreeWidgetIconSize); + toolBar->addAction(nextSectionAction); + toolBar->setMovable(true); toolBar->addAction(toggleActiveAction); toolBar->addAction(saveAction); @@ -7082,6 +7096,155 @@ void dlgTriggerEditor::slot_debug_mode() mudlet::mpDebugArea->setWindowTitle("Central Debug Console"); } +void dlgTriggerEditor::slot_next_section() +{ + //mpScriptsMainArea->setFocus(); + qDebug() << "slot_next_section"; + QMessageBox msgBox; + //msgBox.setText(("slot_next_section()")); + QString msg = ""; + msg = msg + ">>" + QApplication::focusWidget()->metaObject()->className() + "<<\n"; + msg = msg + QApplication::focusWidget()->objectName(); + auto widget = QApplication::focusWidget()->parentWidget(); + while (widget != nullptr){ + msg = msg + "->" + widget->objectName(); + widget = widget->parentWidget(); + } + msgBox.setText("Widget: " + msg); + + //msgBox.exec(); + + switch (mCurrentView) { + case EditorViewType::cmTriggerView: + if (QString("edbee::TextEditorComponent").compare(QApplication::focusWidget()->metaObject()->className()) == 0) { + treeWidget_triggers->setFocus(); + return; + } else if (treeWidget_triggers->hasFocus()) { + mpTriggersMainArea->lineEdit_trigger_name->setFocus(); + return; + } else if (mpTriggersMainArea->hasFocus()) { + mTriggerPatternEdit[0]->lineEdit_pattern->setFocus(); + return; + } else { + for (auto child : mpTriggersMainArea->scrollArea->findChildren()) { + if (child->hasFocus()){ + mpSourceEditorEdbee->setFocus(); + return; + } + } + for (auto child : mpTriggersMainArea->findChildren()) { + if (child->hasFocus()){ + mTriggerPatternEdit[0]->lineEdit_pattern->setFocus(); + return; + } + } + } + // Add default to trigger name field + break; + case EditorViewType::cmTimerView: + if (QString("edbee::TextEditorComponent").compare(QApplication::focusWidget()->metaObject()->className()) == 0) { + treeWidget_timers->setFocus(); + return; + } else if (treeWidget_timers->hasFocus()) { + mpTimersMainArea->lineEdit_timer_name->setFocus(); + return; + } else { + for (auto child : mpTimersMainArea->findChildren()) { + if (child->hasFocus()){ + mpSourceEditorEdbee->setFocus(); + return; + } + } + } + break; + case EditorViewType::cmAliasView: + if (QString("edbee::TextEditorComponent").compare(QApplication::focusWidget()->metaObject()->className()) == 0) { + treeWidget_aliases->setFocus(); + return; + } else if (treeWidget_aliases->hasFocus()) { + mpAliasMainArea->lineEdit_alias_name->setFocus(); + return; + } else { + for (auto child : mpAliasMainArea->findChildren()) { + if (child->hasFocus()){ + mpSourceEditorEdbee->setFocus(); + return; + } + } + } + break; + case EditorViewType::cmScriptView: + if (QString("edbee::TextEditorComponent").compare(QApplication::focusWidget()->metaObject()->className()) == 0) { + treeWidget_scripts->setFocus(); + return; + } else if (treeWidget_scripts->hasFocus()) { + mpScriptsMainArea->lineEdit_script_name->setFocus(); + return; + } else { + for (auto child : mpScriptsMainArea->findChildren()) { + if (child->hasFocus()){ + mpSourceEditorEdbee->setFocus(); + return; + } + } + } + break; + case EditorViewType::cmActionView: + if (QString("edbee::TextEditorComponent").compare(QApplication::focusWidget()->metaObject()->className()) == 0) { + treeWidget_actions->setFocus(); + return; + } else if (treeWidget_actions->hasFocus()) { + mpActionsMainArea->lineEdit_action_name->setFocus(); + return; + } else { + for (auto child : mpActionsMainArea->findChildren()) { + if (child->hasFocus()){ + mpSourceEditorEdbee->setFocus(); + return; + } + } + } + break; + case EditorViewType::cmKeysView: + if (QString("edbee::TextEditorComponent").compare(QApplication::focusWidget()->metaObject()->className()) == 0) { + treeWidget_keys->setFocus(); + return; + } else if (treeWidget_keys->hasFocus()) { + mpKeysMainArea->lineEdit_key_name->setFocus(); + return; + } else { + for (auto child : mpKeysMainArea->findChildren()) { + if (child->hasFocus()){ + mpSourceEditorEdbee->setFocus(); + return; + } + } + } + break; + case EditorViewType::cmVarsView: + if (QString("edbee::TextEditorComponent").compare(QApplication::focusWidget()->metaObject()->className()) == 0) { + treeWidget_variables->setFocus(); + return; + } else if (treeWidget_variables->hasFocus()) { + mpVarsMainArea->lineEdit_var_name->setFocus(); + return; + } else { + for (auto child : mpVarsMainArea->findChildren()) { + if (child->hasFocus()){ + mpSourceEditorEdbee->setFocus(); + return; + } + } + } + break; + case EditorViewType::cmUnknownView: + return; + }; + //mudlet::mpDebugArea->setVisible(!mudlet::debugMode); + //mudlet::debugMode = !mudlet::debugMode; + //mudlet::mpDebugArea->setWindowTitle("Central Debug Console"); +} + void dlgTriggerEditor::exportTrigger(const QString& fileName) { QString name; diff --git a/src/dlgTriggerEditor.h b/src/dlgTriggerEditor.h index 20bc3823655..e4609c6c006 100644 --- a/src/dlgTriggerEditor.h +++ b/src/dlgTriggerEditor.h @@ -226,6 +226,7 @@ public slots: void slot_import(); void slot_viewStatsAction(); void slot_debug_mode(); + void slot_next_section(); void slot_show_timers(); void slot_show_triggers(); void slot_show_scripts(); From 9959d9a2bccff5ad531ec1d19c21d5a484164d29 Mon Sep 17 00:00:00 2001 From: Dicene Date: Sat, 10 Aug 2019 00:23:36 -0400 Subject: [PATCH 02/21] Shortcut works without menu action. Forward tabbing logic seems to be right. Just missing reverse shortcut and logic. --- src/dlgTriggerEditor.cpp | 15 ++------------- 1 file changed, 2 insertions(+), 13 deletions(-) diff --git a/src/dlgTriggerEditor.cpp b/src/dlgTriggerEditor.cpp index 36a24cb5e1a..4f21f76078f 100644 --- a/src/dlgTriggerEditor.cpp +++ b/src/dlgTriggerEditor.cpp @@ -504,17 +504,8 @@ dlgTriggerEditor::dlgTriggerEditor(Host* pH) showDebugAreaAction->setStatusTip(tr("Shows/Hides the separate Central Debug Console - when being displayed the system will be slower.")); connect(showDebugAreaAction, &QAction::triggered, this, &dlgTriggerEditor::slot_debug_mode); - QAction* nextSectionAction = new QAction(tr("Scripts"), this); - nextSectionAction->setShortcutContext(Qt::WindowShortcut); - //nextSectionAction->setShortcut("Ctrl+T"); - //nextSectionAction->setShortcut(QKeySequence::NextChild); - nextSectionAction->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_Tab)); - //nextSectionAction->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_Tab)); - nextSectionAction->setToolTip("ToolTip"); - nextSectionAction->setStatusTip("Next Section"); - nextSectionAction->setEnabled(true); - - connect(nextSectionAction, &QAction::triggered, this, &dlgTriggerEditor::slot_next_section); + QShortcut *nextSectionShortcut = new QShortcut(QKeySequence(Qt::CTRL + Qt::Key_Tab), this); + QObject::connect(nextSectionShortcut, &QShortcut::activated, this, &dlgTriggerEditor::slot_next_section); toolBar = new QToolBar(); toolBar2 = new QToolBar(); @@ -524,8 +515,6 @@ dlgTriggerEditor::dlgTriggerEditor(Host* pH) slot_setToolBarIconSize(mudlet::self()->mToolbarIconSize); slot_setTreeWidgetIconSize(mudlet::self()->mEditorTreeWidgetIconSize); - toolBar->addAction(nextSectionAction); - toolBar->setMovable(true); toolBar->addAction(toggleActiveAction); toolBar->addAction(saveAction); From f92e0fb64919db216ac69b1e5673c4eea1d60b81 Mon Sep 17 00:00:00 2001 From: Dicene Date: Tue, 13 Aug 2019 13:11:48 -0400 Subject: [PATCH 03/21] Added CTRL+SHIFT+Tab shortcut to tab through sections in reverse order. --- src/dlgTriggerEditor.cpp | 133 ++++++++++++++++++++++++++++++++++++++- src/dlgTriggerEditor.h | 1 + 2 files changed, 131 insertions(+), 3 deletions(-) diff --git a/src/dlgTriggerEditor.cpp b/src/dlgTriggerEditor.cpp index 4f21f76078f..28bbda785c8 100644 --- a/src/dlgTriggerEditor.cpp +++ b/src/dlgTriggerEditor.cpp @@ -507,6 +507,9 @@ dlgTriggerEditor::dlgTriggerEditor(Host* pH) QShortcut *nextSectionShortcut = new QShortcut(QKeySequence(Qt::CTRL + Qt::Key_Tab), this); QObject::connect(nextSectionShortcut, &QShortcut::activated, this, &dlgTriggerEditor::slot_next_section); + QShortcut *previousSectionShortcut = new QShortcut(QKeySequence(Qt::CTRL + Qt::SHIFT + Qt::Key_Tab), this); + QObject::connect(previousSectionShortcut, &QShortcut::activated, this, &dlgTriggerEditor::slot_previous_section); + toolBar = new QToolBar(); toolBar2 = new QToolBar(); @@ -7229,9 +7232,133 @@ void dlgTriggerEditor::slot_next_section() case EditorViewType::cmUnknownView: return; }; - //mudlet::mpDebugArea->setVisible(!mudlet::debugMode); - //mudlet::debugMode = !mudlet::debugMode; - //mudlet::mpDebugArea->setWindowTitle("Central Debug Console"); +} + +void dlgTriggerEditor::slot_previous_section() +{ + switch (mCurrentView) { + case EditorViewType::cmTriggerView: + if (QString("edbee::TextEditorComponent").compare(QApplication::focusWidget()->metaObject()->className()) == 0) { + mTriggerPatternEdit[0]->lineEdit_pattern->setFocus(); + return; + } else if (treeWidget_triggers->hasFocus()) { + mpSourceEditorEdbee->setFocus(); + return; + } else { + for (auto child : mpTriggersMainArea->scrollArea->findChildren()) { + if (child->hasFocus()){ + mpTriggersMainArea->lineEdit_trigger_name->setFocus(); + return; + } + } + for (auto child : mpTriggersMainArea->findChildren()) { + if (child->hasFocus()){ + treeWidget_triggers->setFocus(); + return; + } + } + } + // Add default to trigger name field + break; + case EditorViewType::cmTimerView: + if (QString("edbee::TextEditorComponent").compare(QApplication::focusWidget()->metaObject()->className()) == 0) { + mpTimersMainArea->lineEdit_timer_name->setFocus(); + return; + } else if (treeWidget_timers->hasFocus()) { + mpSourceEditorEdbee->setFocus(); + return; + } else { + for (auto child : mpTimersMainArea->findChildren()) { + if (child->hasFocus()){ + treeWidget_timers->setFocus(); + return; + } + } + } + break; + case EditorViewType::cmAliasView: + if (QString("edbee::TextEditorComponent").compare(QApplication::focusWidget()->metaObject()->className()) == 0) { + mpAliasMainArea->lineEdit_alias_name->setFocus(); + return; + } else if (treeWidget_aliases->hasFocus()) { + mpSourceEditorEdbee->setFocus(); + return; + } else { + for (auto child : mpAliasMainArea->findChildren()) { + if (child->hasFocus()){ + treeWidget_aliases->setFocus(); + return; + } + } + } + break; + case EditorViewType::cmScriptView: + if (QString("edbee::TextEditorComponent").compare(QApplication::focusWidget()->metaObject()->className()) == 0) { + mpScriptsMainArea->lineEdit_script_name->setFocus(); + return; + } else if (treeWidget_scripts->hasFocus()) { + mpSourceEditorEdbee->setFocus(); + return; + } else { + for (auto child : mpScriptsMainArea->findChildren()) { + if (child->hasFocus()){ + treeWidget_scripts->setFocus(); + return; + } + } + } + break; + case EditorViewType::cmActionView: + if (QString("edbee::TextEditorComponent").compare(QApplication::focusWidget()->metaObject()->className()) == 0) { + mpActionsMainArea->lineEdit_action_name->setFocus(); + return; + } else if (treeWidget_actions->hasFocus()) { + mpSourceEditorEdbee->setFocus(); + return; + } else { + for (auto child : mpActionsMainArea->findChildren()) { + if (child->hasFocus()){ + treeWidget_actions->setFocus(); + return; + } + } + } + break; + case EditorViewType::cmKeysView: + if (QString("edbee::TextEditorComponent").compare(QApplication::focusWidget()->metaObject()->className()) == 0) { + mpKeysMainArea->lineEdit_key_name->setFocus(); + return; + } else if (treeWidget_keys->hasFocus()) { + mpSourceEditorEdbee->setFocus(); + return; + } else { + for (auto child : mpKeysMainArea->findChildren()) { + if (child->hasFocus()){ + treeWidget_keys->setFocus(); + return; + } + } + } + break; + case EditorViewType::cmVarsView: + if (QString("edbee::TextEditorComponent").compare(QApplication::focusWidget()->metaObject()->className()) == 0) { + mpVarsMainArea->lineEdit_var_name->setFocus(); + return; + } else if (treeWidget_variables->hasFocus()) { + mpSourceEditorEdbee->setFocus(); + return; + } else { + for (auto child : mpVarsMainArea->findChildren()) { + if (child->hasFocus()){ + treeWidget_variables->setFocus(); + return; + } + } + } + break; + case EditorViewType::cmUnknownView: + return; + }; } void dlgTriggerEditor::exportTrigger(const QString& fileName) diff --git a/src/dlgTriggerEditor.h b/src/dlgTriggerEditor.h index e4609c6c006..f821a937e16 100644 --- a/src/dlgTriggerEditor.h +++ b/src/dlgTriggerEditor.h @@ -227,6 +227,7 @@ public slots: void slot_viewStatsAction(); void slot_debug_mode(); void slot_next_section(); + void slot_previous_section(); void slot_show_timers(); void slot_show_triggers(); void slot_show_scripts(); From 24a1b5e56d437403ad40f7d0d86585b5711b9fcd Mon Sep 17 00:00:00 2001 From: Dicene Date: Tue, 13 Aug 2019 13:14:19 -0400 Subject: [PATCH 04/21] Removed unnecessary debug code. --- src/dlgTriggerEditor.cpp | 18 ------------------ 1 file changed, 18 deletions(-) diff --git a/src/dlgTriggerEditor.cpp b/src/dlgTriggerEditor.cpp index 28bbda785c8..4b74f929fdc 100644 --- a/src/dlgTriggerEditor.cpp +++ b/src/dlgTriggerEditor.cpp @@ -7090,22 +7090,6 @@ void dlgTriggerEditor::slot_debug_mode() void dlgTriggerEditor::slot_next_section() { - //mpScriptsMainArea->setFocus(); - qDebug() << "slot_next_section"; - QMessageBox msgBox; - //msgBox.setText(("slot_next_section()")); - QString msg = ""; - msg = msg + ">>" + QApplication::focusWidget()->metaObject()->className() + "<<\n"; - msg = msg + QApplication::focusWidget()->objectName(); - auto widget = QApplication::focusWidget()->parentWidget(); - while (widget != nullptr){ - msg = msg + "->" + widget->objectName(); - widget = widget->parentWidget(); - } - msgBox.setText("Widget: " + msg); - - //msgBox.exec(); - switch (mCurrentView) { case EditorViewType::cmTriggerView: if (QString("edbee::TextEditorComponent").compare(QApplication::focusWidget()->metaObject()->className()) == 0) { @@ -7131,7 +7115,6 @@ void dlgTriggerEditor::slot_next_section() } } } - // Add default to trigger name field break; case EditorViewType::cmTimerView: if (QString("edbee::TextEditorComponent").compare(QApplication::focusWidget()->metaObject()->className()) == 0) { @@ -7258,7 +7241,6 @@ void dlgTriggerEditor::slot_previous_section() } } } - // Add default to trigger name field break; case EditorViewType::cmTimerView: if (QString("edbee::TextEditorComponent").compare(QApplication::focusWidget()->metaObject()->className()) == 0) { From 42e29e6f6fa27ecf6c4dafc075a5623878ba82f9 Mon Sep 17 00:00:00 2001 From: Vadim Peretokin Date: Thu, 8 Aug 2019 10:32:16 +0200 Subject: [PATCH 05/21] Factor out drawing exits in the map into a separate method (#2941) * WIP * Const the variables that we can * Format --- 3rdparty/edbee-lib | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/3rdparty/edbee-lib b/3rdparty/edbee-lib index 051d679cfff..af9dc9fb5be 160000 --- a/3rdparty/edbee-lib +++ b/3rdparty/edbee-lib @@ -1 +1 @@ -Subproject commit 051d679cfff2c006e3c740ef6c0466180b2e79cd +Subproject commit af9dc9fb5bef8670494bf7720b461812acd96b64 From 5af1418afd7838ac9d109bf3ea329a0d52a5877a Mon Sep 17 00:00:00 2001 From: keneanung Date: Fri, 9 Aug 2019 16:03:33 +0200 Subject: [PATCH 06/21] Reorganize windows sdk (#2958) * Move declaration of install functions This allows us to use them singularly in a different context. --- .appveyor.yml | 2 +- CI/appveyor.build.ps1 | 2 +- CI/appveyor.functions.ps1 | 493 ++++++++++++++++++++++++++++++++ CI/appveyor.install.ps1 | 422 ++------------------------- CI/appveyor.set-environment.ps1 | 36 --- setup-windows-sdk.ps1 | 2 +- src/mudlet.pro | 2 +- 7 files changed, 516 insertions(+), 443 deletions(-) create mode 100644 CI/appveyor.functions.ps1 delete mode 100644 CI/appveyor.set-environment.ps1 diff --git a/.appveyor.yml b/.appveyor.yml index 4dbf97f1687..e8f6632ad7a 100644 --- a/.appveyor.yml +++ b/.appveyor.yml @@ -28,7 +28,7 @@ on_failure: - bash -c "curl --upload-file ./verbose_output.log https://transfer.sh/verbose_output.log" cache: - - '%MINGW_BASE_DIR% -> CI\appveyor.install.ps1' + - '%MINGW_BASE_DIR% -> CI\appveyor.install.ps1, CI\appveyor.functions.ps1' notifications: - provider: Webhook diff --git a/CI/appveyor.build.ps1 b/CI/appveyor.build.ps1 index be77bb259c9..c5c10f3c756 100644 --- a/CI/appveyor.build.ps1 +++ b/CI/appveyor.build.ps1 @@ -1,6 +1,6 @@ cd "$Env:APPVEYOR_BUILD_FOLDER" -. CI\appveyor.set-environment.ps1 +. CI\appveyor.functions.ps1 SetQtBaseDir "C:\src\verbose_output.log" SetMingwBaseDir "C:\src\verbose_output.log" SetLuarocksPath "C:\src\verbose_output.log" diff --git a/CI/appveyor.functions.ps1 b/CI/appveyor.functions.ps1 new file mode 100644 index 00000000000..5ca50ba3b9f --- /dev/null +++ b/CI/appveyor.functions.ps1 @@ -0,0 +1,493 @@ +# Some global variables / settings +$workingBaseDir = "C:\src\" +$logFile = "$workingBaseDir\verbose_output.log" +$ciScriptDir = (Get-Item -Path ".\" -Verbose).FullName + +if (-not $(Test-Path "$workingBaseDir")) { + New-Item "$workingBaseDir" -ItemType "directory" +} + +$64Bit = (Get-WmiObject Win32_OperatingSystem).OSArchitecture -eq "64-bit" +if($64Bit){ + $CMakePath = "C:\Program Files (x86)\CMake\bin" +} else { + $CMakePath = "C:\Program Files\CMake\bin" +} + +function SetQtBaseDir([string] $logFile) { + if(!(Test-Path Env:QT_BASE_DIR)){ + try + { + $Env:QT_BASE_DIR = Get-Command "qmake.exe" -ErrorAction Stop | Select-Object -ExpandProperty definition | Split-Path -Parent | Split-Path -Parent + } + catch + { + $Env:QT_BASE_DIR = "C:\Qt\5.12.3\mingw73_32" + } + } + Write-Output "Using $Env:QT_BASE_DIR as QT base directory." | Tee-Object -File "$logFile" -Append +} + +function SetMingwBaseDir([string] $logFile) { + if(!(Test-Path Env:MINGW_BASE_DIR)){ + $tmp = $Env:QT_BASE_DIR.Split("\\") + $tmp[-2] = "Tools" + $tmp[-1] = $tmp[-1] -replace "_32", "*" + $tmp = $tmp -join "\" | Resolve-Path + if($tmp -is [array]){ + $tmp = $tmp[-1] + } + $Env:MINGW_BASE_DIR = $tmp + } + Write-Output "Using $Env:MINGW_BASE_DIR as MinGW base directory." | Tee-Object -File "$logFile" -Append + + if(!(Test-Path Env:MINGW_BASE_DIR_BASH)){ + $Env:MINGW_BASE_DIR_BASH = $Env:MINGW_BASE_DIR -replace "\\", "/" -replace "C:", "/c" + } +} + +function SetLuarocksPath([string] $logFile) { + $Env:LUA_CPATH = "$Env:MINGW_BASE_DIR\lib\lua\5.1\?.dll;$Env:LUA_CPATH" + Write-Output "Using $Env:LUA_CPATH as LuaRocks path." | Tee-Object -File "$logFile" -Append +} + +# Helper functions +# see http://patrick.lioi.net/2011/08/18/powershell-and-calling-external-executables/ +function script:exec { + [CmdletBinding()] + + param( + [Parameter(Position=0,Mandatory=1)][string]$cmd, + [Parameter(Position=1,Mandatory=0)][string[]]$parameter = @(), + [Parameter(Position=2,Mandatory=0)][string]$errorMessage = ("Error executing command: {0}" -f $cmd) + ) + # ignore standard error for external programs + $global:ErrorActionPreference = "Continue" + $outLog = "$workingBaseDir\stdout.log" + $errLog = "$workingBaseDir\stderr.log" + if($parameter.Length -eq 0){ + $exitCode = (Start-Process -FilePath $cmd -Wait -PassThru -RedirectStandardOutput "$outLog" -RedirectStandardError "$errLog" -NoNewWindow).ExitCode + } else { + $exitCode = (Start-Process -FilePath $cmd -ArgumentList $parameter -Wait -PassThru -RedirectStandardOutput "$outLog" -RedirectStandardError "$errLog" -NoNewWindow).ExitCode + } + Get-Content $outLog, $errLog | Out-File $logFile -Append + if ($exitCode -ne 0) + { + throw $errorMessage + } + # restore exit behavior + $global:ErrorActionPreference = "Stop" +} + +# Checks, whether sh.exe is found in the PATH. If so, these parts get filtered out and the remaining PATH gets returned. +function filterPathForSh { + $noShPath = ($Env:PATH.Split(';') | Where-Object { -NOT (Test-Path (Join-Path $_ "sh.exe") -PathType Leaf) }) -join ';' + return $noShPath +} + +function PartSkeleton([string] $content) { + Write-Output "==== $content ====" | Tee-Object -File "$logFile" -Append +} + +function StartPart([string] $partName) { + PartSkeleton "compiling and installing $partName" +} + +function FinishPart([string] $partName) { + PartSkeleton "$partName compiled and installed" +} + +function Step([string] $stepName) { + Write-Output "---- $stepName ----" | Tee-Object -File "$logFile" -Append +} + +function DownloadFile([string] $url, [string] $outputFile, [bool] $bigDownload = $false) { + $stepText = "Downloading" + if ($bigDownload) + { + $stepText = "$stepText, this is a huge download and may take a while" + } + Step $stepText + (New-Object System.Net.WebClient).DownloadFile($url, "$workingBaseDir\$outputFile") >> "$logFile" 2>&1 +} + +function ExtractTar([string] $tarFile, [string] $outputPath) { + Step "Extracting source distribution" + $file = Get-ChildItem $tarFile + exec "7z" @("x", "$($file.FullName)", "-y") + exec "7z" @("-o$outputPath", "x", "$($file.Directory)\$($file.BaseName)", "-y") +} + +function ExtractZip([string] $zipFile, [string] $outputPath) { + Step "Extracting source distribution" + exec "7z" @("-o$outputPath", "x", "$zipFile", "-y") +} + +function RunAutoReconfig(){ + Step "Running autoreconf" + exec "bash" @("-c", "`"autoreconf -i`"") +} + +function RunConfigure([string] $configureArguments = "--prefix=$Env:MINGW_BASE_DIR_BASH") { + Step "Running configure" + exec "bash" @("-c", "`"./configure $configureArguments MAKE=mingw32-make`"") +} + +function RunMake([string] $makefile = "Makefile"){ + For ($retries=1; $retries -le 3; $retries++){ + Step "Running make" + try{ + exec "mingw32-make" @("-f", "$makefile", "-j", $(Get-WmiObject win32_processor | Select -ExpandProperty "NumberOfLogicalProcessors")) + break + }Catch{ + Write-Output "Attempt $retries failed." | Tee-Object -File "$logFile" -Append + if ($retries -lt 3) { + Write-Output "Retrying..." | Tee-Object -File "$logFile" -Append + }else{ + throw $_.Exception + } + } + } +} + +function RunMakeInstall([string] $makefile = "Makefile"){ + Step "Running make install" + exec "mingw32-make" @("install", "-f", "$makefile") +} + +function CheckAndInstall([string] $dependencyName, [string] $signalFile, [scriptblock] $installationFunction){ + StartPart $dependencyName + if(Test-Path "$signalFile" -PathType Leaf){ + Step "$dependencyName is already installed, skipping..." + } else { + Set-Location "$workingBaseDir" + & $installationFunction + } + FinishPart $dependencyName +} + +# installation functions +function InstallSevenZ() { + if($64Bit){ + $downloadUrl = "https://www.7-zip.org/a/7z1900-x64.exe" + } else { + $downloadUrl = "https://www.7-zip.org/a/7z1900.exe" + } + DownloadFile "$downloadUrl" "7z-installer.exe" + Step "installing 7z" + exec ".\7z-installer.exe" ("/S", "/D=`"C:\Program Files\7-Zip`"") +} + +function InstallCmake() { + DownloadFile "https://github.com/Kitware/CMake/releases/download/v3.14.4/cmake-3.14.4-win32-x86.msi" "cmake-installer.msi" + Step "installing cmake" + exec "msiexec.exe" @("/q", "/li", "$workingBaseDir\cmake-installer.log", "/i", "cmake-installer.msi") + if(Test-Path -Path "$workingBaseDir\cmake-installer.log" -PathType Leaf){ + Get-Content "$workingBaseDir\cmake-installer.log" | Out-File $logFile -Append + } +} + +function InstallMingwGet() { + DownloadFile "https://osdn.net/frs/redir.php?m=rwthaachen&f=mingw%2F68260%2Fmingw-get-0.6.3-mingw32-pre-20170905-1-bin.zip" "mingw-get.zip" + if (!(Test-Path -Path "C:\MinGW" -PathType Container)) { + Step "Creating MinGW path" + New-Item -Path "C:\MinGW" -ItemType "directory" >> "$logFile" 2>&1 + } + ExtractZip "mingw-get.zip" "C:\MinGW" +} + +function InstallMsys() { + Step "Updating mingw-get info" + exec "mingw-get" @("update") + Step "Installing mingw32-autotools" + exec "mingw-get" @("install", "mingw32-autotools") +} + +function InstallBoost() { + DownloadFile "https://sourceforge.net/projects/boost/files/boost/1.67.0/boost_1_67_0.tar.gz/download" "boost.tar.gz" $true + if (!(Test-Path -Path "C:\Libraries\" -PathType Container)) { + Step "Creating Boost path" + New-Item -Path "C:\Libraries\" -ItemType "directory" >> "$logFile" 2>&1 + } + ExtractTar "boost.tar.gz" "." + Step "Copying folder" + Move-Item "boost_1_67_0" "C:\Libraries\" >> "$logFile" 2>&1 +} + +function InstallQt() { + DownloadFile "http://download.qt.io/official_releases/online_installers/qt-unified-windows-x86-online.exe" "qt-installer.exe" + Step "Installing" + exec ".\qt-installer.exe" @("--script=`"$(split-path -parent $script:MyInvocation.MyCommand.Path)\qt-silent-install.qs`"") +} + +function InstallPython() { + DownloadFile "https://www.python.org/ftp/python/2.7.14/python-2.7.14.msi" "python-installer.msi" $true + exec "msiexec.exe" @("/q", "/li", "$workingBaseDir\python-installer.log", "/i", "python-installer.msi") + if(Test-Path -Path "$workingBaseDir\python-installer.log" -PathType Leaf){ + Get-Content "$workingBaseDir\python-installer.log" | Out-File $logFile -Append + } +} + +function InstallOpenssl() { + DownloadFile "http://wiki.overbyte.eu/arch/openssl-1.0.2s-win32.zip" "openssl-win32.zip" + ExtractZip "openssl-win32.zip" "openssl" + Step "installing" + exec "XCOPY" @("/S", "/I", "/Q", "openssl", "$Env:MINGW_BASE_DIR\bin") +} + +function InstallHunspell() { + DownloadFile "https://github.com/hunspell/hunspell/archive/v1.6.2.tar.gz" "hunspell.tar.gz" + ExtractTar "hunspell.tar.gz" "hunspell" + Set-Location "hunspell\hunspell-1.6.2" + Step "Changing src\tools\Makefile.am" + (Get-Content src\tools\Makefile.am -Raw) -replace 'hzip ', '' | Out-File -encoding ASCII src\tools\Makefile.am >> "$logFile" 2>&1 + RunAutoReconfig + RunConfigure + RunMake + RunMakeInstall +} + +function InstallYajl() { + $Env:Path = $NoShPath + DownloadFile "https://github.com/lloyd/yajl/tarball/2.1.0" "yajl-2.1.0.tar.gz" + ExtractTar "yajl-2.1.0.tar.gz" "yajl-2.1.0" + Set-Location "yajl-2.1.0\lloyd-yajl-66cb08c" + Step "changing CMakeLists.txt" + (Get-Content CMakeLists.txt -Raw) -replace '\/W4' -replace '(?<=SET\(linkFlags)[^\)]+' -replace '\/wd4996 \/wd4255 \/wd4130 \/wd4100 \/wd4711' -replace '(?<=SET\(CMAKE_C_FLAGS_DEBUG .)\/D \DEBUG \/Od \/Z7', '-g' -replace '(?<=SET\(CMAKE_C_FLAGS_RELEASE .)\/D NDEBUG \/O2', '-O2' | Out-File -encoding ASCII CMakeLists.txt >> "$logFile" 2>&1 + if (!(Test-Path -Path "build" -PathType Container)) { + Step "Creating yajl build path" + New-Item build -ItemType Directory >> "$logFile" 2>&1 + } + Set-Location build + Step "running cmake" + exec "cmake" @("-G", "`"MinGW Makefiles`"", "..") + RunMake + Step "installing" + Copy-Item "yajl-2.1.0\lib\*" "$Env:MINGW_BASE_DIR\bin" + exec "XCOPY" @("/S", "/I", "/Q", "yajl-2.1.0\include", "$Env:MINGW_BASE_DIR\include") + $Env:Path = $ShPath +} + +function InstallLua() { + DownloadFile "http://www.lua.org/ftp/lua-5.1.5.tar.gz" "lua-5.1.5.tar.gz" + ExtractTar "lua-5.1.5.tar.gz" "lua-5.1.5" + DownloadFile "https://github.com/Tieske/luawinmake/archive/master.zip" "luawinmake.zip" + ExtractZip "luawinmake.zip" "luawinmake" + Step "copying luawinmake files" + exec "XCOPY" @("/Y", "/S", "/I", "/Q", "$workingBaseDir\luawinmake\luawinmake-master\etc", "$workingBaseDir\lua-5.1.5\lua-5.1.5\etc") + Set-Location lua-5.1.5\lua-5.1.5 + Step "compiling lua" + exec "etc\winmake" + Step "installing lua" + exec "etc\winmake" @("install", "$Env:MINGW_BASE_DIR") +} + +function InstallPcre() { + DownloadFile "https://ftp.pcre.org/pub/pcre/pcre-8.43.zip" "pcre.zip" + ExtractZip "pcre.zip" "pcre" + Set-Location pcre\pcre-8.43 + RunConfigure "--enable-utf --enable-unicode-properties --enable-pcre16 --prefix=$Env:MINGW_BASE_DIR_BASH" + RunMake + RunMakeInstall +} + +function InstallSqlite() { + DownloadFile "https://sqlite.org/2019/sqlite-autoconf-3280000.tar.gz" "sqlite.tar.gz" + ExtractTar "sqlite.tar.gz" "sqlite" + Set-Location sqlite\sqlite-autoconf-3280000 + Step "building sqlite" + exec "gcc" @("-c", "sqlite3.c", "-O2", "-DSQLITE_ENABLE_FTS4", "-DSQLITE_ENABLE_RTREE") + exec "ar" @("rcs", "libsqlite3.a", "sqlite3.o") + Step "installing sqlite" + Copy-Item "libsqlite3.a" "$Env:MINGW_BASE_DIR\lib" + Copy-Item "sqlite3.h" "$Env:MINGW_BASE_DIR\include" +} + +function InstallZlib() { + DownloadFile "http://zlib.net/zlib-1.2.11.tar.gz" "zlib-1.2.11.tar.gz" + ExtractTar "zlib-1.2.11.tar.gz" "zlib" + Set-Location zlib\zlib-1.2.11 + RunMake "win32/Makefile.gcc" + $Env:INCLUDE_PATH = "$Env:MINGW_BASE_DIR\include" + $Env:LIBRARY_PATH = "$Env:MINGW_BASE_DIR\lib" + $Env:BINARY_PATH = "$Env:MINGW_BASE_DIR\bin" + RunMakeInstall "win32/Makefile.gcc" + Copy-Item "zlib1.dll" "$Env:MINGW_BASE_DIR\bin" + Copy-Item "libz.dll.a" "$Env:MINGW_BASE_DIR\lib" +} + +function InstallLibzip() { + $Env:Path = $NoShPath + DownloadFile "https://libzip.org/download/libzip-1.5.2.tar.gz" "libzip.tar.gz" + ExtractTar "libzip.tar.gz" "libzip" + Set-Location libzip\libzip-1.5.2 + if (!(Test-Path -Path "build" -PathType Container)) { + Step "Creating libzip build path" + New-Item build -ItemType Directory >> "$logFile" 2>&1 + } + Set-Location build + Step "running cmake" + exec "cmake" @("-G", "`"MinGW Makefiles`"", "-DCMAKE_INSTALL_PREFIX=`"$Env:MINGW_BASE_DIR`"", "-DENABLE_OPENSSL=OFF", "..") + RunMake + RunMakeInstall + $Env:Path = $ShPath +} + +function InstallZziplib() { + DownloadFile "https://github.com/keneanung/zziplib/archive/FixZzipStrndup.tar.gz" "zziplib-FixZzipStrndup.tar.gz" + ExtractTar "zziplib-FixZzipStrndup.tar.gz" "zziplib" + Set-Location zziplib\zziplib-FixZzipStrndup + + Step "changing configure script" + (Get-Content configure -Raw) -replace 'uname -msr', 'uname -ms' | Out-File -encoding ASCII configure >> "$logFile" 2>&1 + RunConfigure "--disable-mmap --prefix=$Env:MINGW_BASE_DIR_BASH" + RunMake + RunMakeInstall + Set-Location "$workingBaseDir" +} + +function InstallLuarocks() { + DownloadFile "http://luarocks.github.io/luarocks/releases/luarocks-3.1.2-win32.zip" "luarocks.zip" + ExtractZip "luarocks.zip" "luarocks" + Set-Location luarocks\luarocks-3.1.2-win32 + Step "installing luarocks" + exec ".\install.bat" @("/P", "C:\LuaRocks", "/MW", "/Q") + Set-Location \LuaRocks\lua\luarocks\core + Step "changing luarocks config" + (Get-Content cfg.lua) -replace 'mingw32-gcc', 'gcc' | Out-File -encoding ASCII cfg.lua >> "$logFile" 2>&1 +} + +function InstallPugixml() { + $Env:Path = $NoShPath + DownloadFile "http://github.com/zeux/pugixml/releases/download/v1.9/pugixml-1.9.zip" "pugixml-1.9.zip" + ExtractZip "pugixml-1.9.zip" "pugixml" + Set-Location pugixml\pugixml-1.9 + if (!(Test-Path -Path "build" -PathType Container)) { + Step "Creating pugixml build path" + New-Item build -ItemType Directory >> "$logFile" 2>&1 + } + Set-Location build + Step "running cmake" + exec "cmake" @("-G", "`"MinGW Makefiles`"", "-DCMAKE_INSTALL_PREFIX=`"$Env:MINGW_BASE_DIR`"", "..") + RunMake + RunMakeInstall + $Env:Path = $ShPath +} + +function InstallLfs() { + Set-Location \LuaRocks + exec ".\luarocks" @("--tree=`"$Env:MINGW_BASE_DIR`"", "install", "LuaFileSystem") +} + +function InstallLuasql() { + Set-Location \LuaRocks + exec ".\luarocks" @("--tree=`"$Env:MINGW_BASE_DIR`"", "install", "LuaSQL-SQLite3", "SQLITE_INCDIR=`"$Env:MINGW_BASE_DIR\include`"", "SQLITE_LIBDIR=`"$Env:MINGW_BASE_DIR\lib`"") +} + +function InstallRexPcre() { + Set-Location \LuaRocks + exec ".\luarocks" @("--tree=`"$Env:MINGW_BASE_DIR`"", "install", "lrexlib-pcre", "PCRE_LIBDIR=`"$Env:MINGW_BASE_DIR\lib`"", "PCRE_INCDIR=`"$Env:MINGW_BASE_DIR\include`"") +} + +function InstallLuaUtf8() { + Set-Location \LuaRocks + exec ".\luarocks" @("--tree=`"$Env:MINGW_BASE_DIR`"", "install", "luautf8") +} + +function InstallLuaYajl() { + Set-Location \LuaRocks + $Env:LIBRARY_PATH = "$Env:LIBRARY_PATH;$Env:MINGW_BASE_DIR/bin" + exec ".\luarocks" @("--tree=`"$Env:MINGW_BASE_DIR`"", "install", "lua-yajl", "YAJL_LIBDIR=`"$Env:MINGW_BASE_DIR\bin`"", "YAJL_INCDIR=`"$Env:MINGW_BASE_DIR\include`"") +} + +function InstallLuaZip () { + Set-Location "$workingBaseDir" + DownloadFile "https://github.com/rjpcomputing/luazip/archive/master.zip" "luazip.zip" + ExtractZip "luazip.zip" "luazip" + Set-Location luazip\luazip-master + Step "installing luazip" + exec "gcc" @("-O2", "-c", "-o", "src/luazip.o", "-I`"$Env:MINGW_BASE_DIR/include`"", "src/luazip.c") + exec "gcc" @("-shared", "-o", "zip.dll", "src/luazip.o", "-L`"$Env:MINGW_BASE_DIR/lib`"", "-lzzip", "-lz", "`"$Env:MINGW_BASE_DIR/bin/lua51.dll`"", "-lm") + Copy-Item "zip.dll" "$Env:MINGW_BASE_DIR\lib\lua\5.1" +} + +function InstallLuaModules(){ + CheckAndInstall "lfs" "$Env:MINGW_BASE_DIR\\lib\lua\5.1\lfs.dll" { InstallLfs } + CheckAndInstall "luasql.sqlite3" "$Env:MINGW_BASE_DIR\\lib\lua\5.1\luasql\sqlite3.dll" { InstallLuasql } + CheckAndInstall "rex.pcre" "$Env:MINGW_BASE_DIR\\lib\lua\5.1\rex_pcre.dll" { InstallRexPcre } + CheckAndInstall "lua-utf8" "$Env:MINGW_BASE_DIR\\lib\lua\5.1\lua-utf8.dll" { InstallLuaUtf8 } + CheckAndInstall "lua-yajl" "$Env:MINGW_BASE_DIR\\lib\lua\5.1\yajl.dll" { InstallLuaYajl } + CheckAndInstall "luazip" "$Env:MINGW_BASE_DIR\\lib\lua\5.1\zip.dll" { InstallLuaZip } +} + +function CheckAndInstall7z(){ + CheckAndInstall "7z" "C:\Program Files\7-Zip\7z.exe" { InstallSevenZ } +} + +function CheckAndInstallCmake(){ + CheckAndInstall "cmake" "$CMakePath\cmake.exe" { InstallCmake } +} + +function CheckAndInstallMingwGet(){ + CheckAndInstall "mingw-get" "C:\MinGW\bin\mingw-get.exe" { InstallMingwGet } +} + +function CheckAndInstallMsys(){ + CheckAndInstall "MSYS and autotools" "C:\MinGW\bin\autoconf" { InstallMsys } +} + +function CheckAndInstallBoost(){ + CheckAndInstall "Boost" "C:\Libraries\boost_1_67_0\bootstrap.bat" { InstallBoost } +} + +function CheckAndInstallQt(){ + CheckAndInstall "Qt" "$Env:QT_BASE_DIR\bin\qmake.exe" { InstallQt } +} + +function CheckAndInstallPython(){ + CheckAndInstall "Python" "C:\Python27\python.exe" { InstallPython } +} + +function CheckAndInstallOpenSSL(){ + CheckAndInstall "openssl" "$Env:MINGW_BASE_DIR\bin\ssleay32.dll" { InstallOpenssl } +} + +function CheckAndInstallHunspell(){ + CheckAndInstall "hunspell" "$Env:MINGW_BASE_DIR\bin\libhunspell-1.6-0.dll" { InstallHunspell } +} + +function CheckAndInstallYajl(){ + CheckAndInstall "yajl" "$Env:MINGW_BASE_DIR\bin\libyajl.dll" { InstallYajl } +} + +function CheckAndInstallLua(){ + CheckAndInstall "lua" "$Env:MINGW_BASE_DIR\bin\lua51.dll" { InstallLua } +} + +function CheckAndInstallPcre(){ + CheckAndInstall "pcre" "$Env:MINGW_BASE_DIR\bin\libpcre-1.dll" { InstallPcre } +} + +function CheckAndInstallSqlite(){ + CheckAndInstall "sqlite" "$Env:MINGW_BASE_DIR\lib\libsqlite3.a" { InstallSqlite } +} + +function CheckAndInstallZlib(){ + CheckAndInstall "zlib" "$Env:MINGW_BASE_DIR\bin\zlib1.dll" { InstallZlib } +} + +function CheckAndInstallLibzip(){ + CheckAndInstall "libzip" "$Env:MINGW_BASE_DIR\include\zipconf.h" { InstallLibzip } +} + +function CheckAndInstallZziplib(){ + CheckAndInstall "zziplib" "$Env:MINGW_BASE_DIR\lib\libzzip.la" { InstallZziplib } +} + +function CheckAndInstallLuarocks(){ + CheckAndInstall "luarocks" "C:\LuaRocks\luarocks.bat" { InstallLuarocks } +} + +function CheckAndInstallPugixml(){ + CheckAndInstall "pugixml" "$Env:MINGW_BASE_DIR\lib\libpugixml.a" { InstallPugixml } +} \ No newline at end of file diff --git a/CI/appveyor.install.ps1 b/CI/appveyor.install.ps1 index 942def2657d..7a80bf8d2eb 100644 --- a/CI/appveyor.install.ps1 +++ b/CI/appveyor.install.ps1 @@ -5,405 +5,21 @@ $global:ErrorActionPreference = "Stop" # credit: https://stackoverflow.com/questions/41618766/powershell-invoke-webrequest-fails-with-ssl-tls-secure-channel/48030563#48030563 [Net.ServicePointManager]::SecurityProtocol = [System.Security.Authentication.SslProtocols] "tls, tls11, tls12" -# Some global variables / settings -$workingBaseDir = "C:\src\" -$logFile = "$workingBaseDir\verbose_output.log" -$ciScriptDir = (Get-Item -Path ".\" -Verbose).FullName +. .\appveyor.functions.ps1 -if (-not $(Test-Path "$workingBaseDir")) { - New-Item "$workingBaseDir" -ItemType "directory" -} - -$64Bit = (Get-WmiObject Win32_OperatingSystem).OSArchitecture -eq "64-bit" -if($64Bit){ - $CMakePath = "C:\Program Files (x86)\CMake\bin" -} else { - $CMakePath = "C:\Program Files\CMake\bin" -} - -. .\appveyor.set-environment.ps1 SetQtBaseDir "$logFile" $Env:PATH = "$CMakePath;C:\MinGW\bin;C:\MinGW\msys\1.0\bin;C:\Program Files\7-Zip;$Env:PATH" -# Helper functions -# see http://patrick.lioi.net/2011/08/18/powershell-and-calling-external-executables/ -function script:exec { - [CmdletBinding()] - - param( - [Parameter(Position=0,Mandatory=1)][string]$cmd, - [Parameter(Position=1,Mandatory=0)][string[]]$parameter = @(), - [Parameter(Position=2,Mandatory=0)][string]$errorMessage = ("Error executing command: {0}" -f $cmd) - ) - # ignore standard error for external programs - $global:ErrorActionPreference = "Continue" - $outLog = "$workingBaseDir\stdout.log" - $errLog = "$workingBaseDir\stderr.log" - if($parameter.Length -eq 0){ - $exitCode = (Start-Process -FilePath $cmd -Wait -PassThru -RedirectStandardOutput "$outLog" -RedirectStandardError "$errLog" -NoNewWindow).ExitCode - } else { - $exitCode = (Start-Process -FilePath $cmd -ArgumentList $parameter -Wait -PassThru -RedirectStandardOutput "$outLog" -RedirectStandardError "$errLog" -NoNewWindow).ExitCode - } - Get-Content $outLog, $errLog | Out-File $logFile -Append - if ($exitCode -ne 0) - { - throw $errorMessage - } - # restore exit behavior - $global:ErrorActionPreference = "Stop" -} - -# Checks, whether sh.exe is found in the PATH. If so, these parts get filtered out and the remaining PATH gets returned. -function filterPathForSh { - $noShPath = ($Env:PATH.Split(';') | Where-Object { -NOT (Test-Path (Join-Path $_ "sh.exe") -PathType Leaf) }) -join ';' - return $noShPath -} - -function PartSkeleton([string] $content) { - Write-Output "==== $content ====" | Tee-Object -File "$logFile" -Append -} - -function StartPart([string] $partName) { - PartSkeleton "compiling and installing $partName" -} - -function FinishPart([string] $partName) { - PartSkeleton "$partName compiled and installed" -} - -function Step([string] $stepName) { - Write-Output "---- $stepName ----" | Tee-Object -File "$logFile" -Append -} - -function DownloadFile([string] $url, [string] $outputFile, [bool] $bigDownload = $false) { - $stepText = "Downloading" - if ($bigDownload) - { - $stepText = "$stepText, this is a huge download and may take a while" - } - Step $stepText - (New-Object System.Net.WebClient).DownloadFile($url, "$workingBaseDir\$outputFile") >> "$logFile" 2>&1 -} - -function ExtractTar([string] $tarFile, [string] $outputPath) { - Step "Extracting source distribution" - $file = Get-ChildItem $tarFile - exec "7z" @("x", "$($file.FullName)", "-y") - exec "7z" @("-o$outputPath", "x", "$($file.Directory)\$($file.BaseName)", "-y") -} - -function ExtractZip([string] $zipFile, [string] $outputPath) { - Step "Extracting source distribution" - exec "7z" @("-o$outputPath", "x", "$zipFile", "-y") -} - -function RunAutoReconfig(){ - Step "Running autoreconf" - exec "bash" @("-c", "`"autoreconf -i`"") -} - -function RunConfigure([string] $configureArguments = "--prefix=$Env:MINGW_BASE_DIR_BASH") { - Step "Running configure" - exec "bash" @("-c", "`"./configure $configureArguments MAKE=mingw32-make`"") -} - -function RunMake([string] $makefile = "Makefile"){ - For ($retries=1; $retries -le 3; $retries++){ - Step "Running make" - try{ - exec "mingw32-make" @("-f", "$makefile", "-j", $(Get-WmiObject win32_processor | Select -ExpandProperty "NumberOfLogicalProcessors")) - break - }Catch{ - Write-Output "Attempt $retries failed." | Tee-Object -File "$logFile" -Append - if ($retries -lt 3) { - Write-Output "Retrying..." | Tee-Object -File "$logFile" -Append - }else{ - throw $_.Exception - } - } - } -} - -function RunMakeInstall([string] $makefile = "Makefile"){ - Step "Running make install" - exec "mingw32-make" @("install", "-f", "$makefile") -} - -function CheckAndInstall([string] $dependencyName, [string] $signalFile, [scriptblock] $installationFunction){ - StartPart $dependencyName - if(Test-Path "$signalFile" -PathType Leaf){ - Step "$dependencyName is already installed, skipping..." - } else { - Set-Location "$workingBaseDir" - & $installationFunction - } - FinishPart $dependencyName -} - -# installation functions -function InstallSevenZ() { - if($64Bit){ - $downloadUrl = "https://www.7-zip.org/a/7z1900-x64.exe" - } else { - $downloadUrl = "https://www.7-zip.org/a/7z1900.exe" - } - DownloadFile "$downloadUrl" "7z-installer.exe" - Step "installing 7z" - exec ".\7z-installer.exe" ("/S", "/D=`"C:\Program Files\7-Zip`"") -} - -function InstallCmake() { - DownloadFile "https://github.com/Kitware/CMake/releases/download/v3.14.4/cmake-3.14.4-win32-x86.msi" "cmake-installer.msi" - Step "installing cmake" - exec "msiexec.exe" @("/q", "/li", "$workingBaseDir\cmake-installer.log", "/i", "cmake-installer.msi") - if(Test-Path -Path "$workingBaseDir\cmake-installer.log" -PathType Leaf){ - Get-Content "$workingBaseDir\cmake-installer.log" | Out-File $logFile -Append - } -} - -function InstallMingwGet() { - DownloadFile "https://osdn.net/frs/redir.php?m=rwthaachen&f=mingw%2F68260%2Fmingw-get-0.6.3-mingw32-pre-20170905-1-bin.zip" "mingw-get.zip" - if (!(Test-Path -Path "C:\MinGW" -PathType Container)) { - Step "Creating MinGW path" - New-Item -Path "C:\MinGW" -ItemType "directory" >> "$logFile" 2>&1 - } - ExtractZip "mingw-get.zip" "C:\MinGW" -} - -function InstallMsys() { - Step "Updating mingw-get info" - exec "mingw-get" @("update") - Step "Installing mingw32-autotools" - exec "mingw-get" @("install", "mingw32-autotools") -} - -function InstallBoost() { - DownloadFile "https://sourceforge.net/projects/boost/files/boost/1.67.0/boost_1_67_0.tar.gz/download" "boost.tar.gz" $true - if (!(Test-Path -Path "C:\Libraries\" -PathType Container)) { - Step "Creating Boost path" - New-Item -Path "C:\Libraries\" -ItemType "directory" >> "$logFile" 2>&1 - } - ExtractTar "boost.tar.gz" "." - Step "Copying folder" - Move-Item "boost_1_67_0" "C:\Libraries\" >> "$logFile" 2>&1 -} - -function InstallQt() { - DownloadFile "http://download.qt.io/official_releases/online_installers/qt-unified-windows-x86-online.exe" "qt-installer.exe" - Step "Installing" - exec ".\qt-installer.exe" @("--script=`"$(split-path -parent $script:MyInvocation.MyCommand.Path)\qt-silent-install.qs`"") -} - -function InstallPython() { - DownloadFile "https://www.python.org/ftp/python/2.7.14/python-2.7.14.msi" "python-installer.msi" $true - exec "msiexec.exe" @("/q", "/li", "$workingBaseDir\python-installer.log", "/i", "python-installer.msi") - if(Test-Path -Path "$workingBaseDir\python-installer.log" -PathType Leaf){ - Get-Content "$workingBaseDir\python-installer.log" | Out-File $logFile -Append - } -} - -function InstallOpenssl() { - DownloadFile "http://wiki.overbyte.eu/arch/openssl-1.0.2s-win32.zip" "openssl-win32.zip" - ExtractZip "openssl-win32.zip" "openssl" - Step "installing" - exec "XCOPY" @("/S", "/I", "/Q", "openssl", "$Env:MINGW_BASE_DIR\bin") -} - -function InstallHunspell() { - DownloadFile "https://github.com/hunspell/hunspell/archive/v1.6.2.tar.gz" "hunspell.tar.gz" - ExtractTar "hunspell.tar.gz" "hunspell" - Set-Location "hunspell\hunspell-1.6.2" - Step "Changing src\tools\Makefile.am" - (Get-Content src\tools\Makefile.am -Raw) -replace 'hzip ', '' | Out-File -encoding ASCII src\tools\Makefile.am >> "$logFile" 2>&1 - RunAutoReconfig - RunConfigure - RunMake - RunMakeInstall -} - -function InstallYajl() { - $Env:Path = $NoShPath - DownloadFile "https://github.com/lloyd/yajl/tarball/2.1.0" "yajl-2.1.0.tar.gz" - ExtractTar "yajl-2.1.0.tar.gz" "yajl-2.1.0" - Set-Location "yajl-2.1.0\lloyd-yajl-66cb08c" - Step "changing CMakeLists.txt" - (Get-Content CMakeLists.txt -Raw) -replace '\/W4' -replace '(?<=SET\(linkFlags)[^\)]+' -replace '\/wd4996 \/wd4255 \/wd4130 \/wd4100 \/wd4711' -replace '(?<=SET\(CMAKE_C_FLAGS_DEBUG .)\/D \DEBUG \/Od \/Z7', '-g' -replace '(?<=SET\(CMAKE_C_FLAGS_RELEASE .)\/D NDEBUG \/O2', '-O2' | Out-File -encoding ASCII CMakeLists.txt >> "$logFile" 2>&1 - if (!(Test-Path -Path "build" -PathType Container)) { - Step "Creating yajl build path" - New-Item build -ItemType Directory >> "$logFile" 2>&1 - } - Set-Location build - Step "running cmake" - exec "cmake" @("-G", "`"MinGW Makefiles`"", "..") - RunMake - Step "installing" - Copy-Item "yajl-2.1.0\lib\*" "$Env:MINGW_BASE_DIR\bin" - exec "XCOPY" @("/S", "/I", "/Q", "yajl-2.1.0\include", "$Env:MINGW_BASE_DIR\include") - $Env:Path = $ShPath -} - -function InstallLua() { - DownloadFile "http://www.lua.org/ftp/lua-5.1.5.tar.gz" "lua-5.1.5.tar.gz" - ExtractTar "lua-5.1.5.tar.gz" "lua-5.1.5" - DownloadFile "https://github.com/Tieske/luawinmake/archive/master.zip" "luawinmake.zip" - ExtractZip "luawinmake.zip" "luawinmake" - Step "copying luawinmake files" - exec "XCOPY" @("/Y", "/S", "/I", "/Q", "$workingBaseDir\luawinmake\luawinmake-master\etc", "$workingBaseDir\lua-5.1.5\lua-5.1.5\etc") - Set-Location lua-5.1.5\lua-5.1.5 - Step "compiling lua" - exec "etc\winmake" - Step "installing lua" - exec "etc\winmake" @("install", "$Env:MINGW_BASE_DIR") -} - -function InstallPcre() { - DownloadFile "https://ftp.pcre.org/pub/pcre/pcre-8.43.zip" "pcre.zip" - ExtractZip "pcre.zip" "pcre" - Set-Location pcre\pcre-8.43 - RunConfigure "--enable-utf --enable-unicode-properties --enable-pcre16 --prefix=$Env:MINGW_BASE_DIR_BASH" - RunMake - RunMakeInstall -} - -function InstallSqlite() { - DownloadFile "https://sqlite.org/2019/sqlite-autoconf-3280000.tar.gz" "sqlite.tar.gz" - ExtractTar "sqlite.tar.gz" "sqlite" - Set-Location sqlite\sqlite-autoconf-3280000 - Step "building sqlite" - exec "gcc" @("-c", "sqlite3.c", "-O2", "-DSQLITE_ENABLE_FTS4", "-DSQLITE_ENABLE_RTREE") - exec "ar" @("rcs", "libsqlite3.a", "sqlite3.o") - Step "installing sqlite" - Copy-Item "libsqlite3.a" "$Env:MINGW_BASE_DIR\lib" - Copy-Item "sqlite3.h" "$Env:MINGW_BASE_DIR\include" -} - -function InstallZlib() { - DownloadFile "http://zlib.net/zlib-1.2.11.tar.gz" "zlib-1.2.11.tar.gz" - ExtractTar "zlib-1.2.11.tar.gz" "zlib" - Set-Location zlib\zlib-1.2.11 - RunMake "win32/Makefile.gcc" - $Env:INCLUDE_PATH = "$Env:MINGW_BASE_DIR\include" - $Env:LIBRARY_PATH = "$Env:MINGW_BASE_DIR\lib" - $Env:BINARY_PATH = "$Env:MINGW_BASE_DIR\bin" - RunMakeInstall "win32/Makefile.gcc" - Copy-Item "zlib1.dll" "$Env:MINGW_BASE_DIR\bin" - Copy-Item "libz.dll.a" "$Env:MINGW_BASE_DIR\lib" -} - -function InstallLibzip() { - $Env:Path = $NoShPath - DownloadFile "https://libzip.org/download/libzip-1.5.2.tar.gz" "libzip.tar.gz" - ExtractTar "libzip.tar.gz" "libzip" - Set-Location libzip\libzip-1.5.2 - if (!(Test-Path -Path "build" -PathType Container)) { - Step "Creating libzip build path" - New-Item build -ItemType Directory >> "$logFile" 2>&1 - } - Set-Location build - Step "running cmake" - exec "cmake" @("-G", "`"MinGW Makefiles`"", "-DCMAKE_INSTALL_PREFIX=`"$Env:MINGW_BASE_DIR`"", "-DENABLE_OPENSSL=OFF", "..") - RunMake - RunMakeInstall - $Env:Path = $ShPath -} - -function InstallZziplib() { - DownloadFile "https://github.com/keneanung/zziplib/archive/FixZzipStrndup.tar.gz" "zziplib-FixZzipStrndup.tar.gz" - ExtractTar "zziplib-FixZzipStrndup.tar.gz" "zziplib" - Set-Location zziplib\zziplib-FixZzipStrndup - - Step "changing configure script" - (Get-Content configure -Raw) -replace 'uname -msr', 'uname -ms' | Out-File -encoding ASCII configure >> "$logFile" 2>&1 - RunConfigure "--disable-mmap --prefix=$Env:MINGW_BASE_DIR_BASH" - RunMake - RunMakeInstall - Set-Location "$workingBaseDir" -} - -function InstallLuarocks() { - DownloadFile "http://luarocks.github.io/luarocks/releases/luarocks-3.1.2-win32.zip" "luarocks.zip" - ExtractZip "luarocks.zip" "luarocks" - Set-Location luarocks\luarocks-3.1.2-win32 - Step "installing luarocks" - exec ".\install.bat" @("/P", "C:\LuaRocks", "/MW", "/Q") - Set-Location \LuaRocks\lua\luarocks\core - Step "changing luarocks config" - (Get-Content cfg.lua) -replace 'mingw32-gcc', 'gcc' | Out-File -encoding ASCII cfg.lua >> "$logFile" 2>&1 -} - -function InstallPugixml() { - $Env:Path = $NoShPath - DownloadFile "http://github.com/zeux/pugixml/releases/download/v1.9/pugixml-1.9.zip" "pugixml-1.9.zip" - ExtractZip "pugixml-1.9.zip" "pugixml" - Set-Location pugixml\pugixml-1.9 - if (!(Test-Path -Path "build" -PathType Container)) { - Step "Creating pugixml build path" - New-Item build -ItemType Directory >> "$logFile" 2>&1 - } - Set-Location build - Step "running cmake" - exec "cmake" @("-G", "`"MinGW Makefiles`"", "-DCMAKE_INSTALL_PREFIX=`"$Env:MINGW_BASE_DIR`"", "..") - RunMake - RunMakeInstall - $Env:Path = $ShPath -} - -function InstallLfs() { - Set-Location \LuaRocks - exec ".\luarocks" @("--tree=`"$Env:MINGW_BASE_DIR`"", "install", "LuaFileSystem") -} - -function InstallLuasql() { - Set-Location \LuaRocks - exec ".\luarocks" @("--tree=`"$Env:MINGW_BASE_DIR`"", "install", "LuaSQL-SQLite3", "SQLITE_INCDIR=`"$Env:MINGW_BASE_DIR\include`"", "SQLITE_LIBDIR=`"$Env:MINGW_BASE_DIR\lib`"") -} - -function InstallRexPcre() { - Set-Location \LuaRocks - exec ".\luarocks" @("--tree=`"$Env:MINGW_BASE_DIR`"", "install", "lrexlib-pcre", "PCRE_LIBDIR=`"$Env:MINGW_BASE_DIR\lib`"", "PCRE_INCDIR=`"$Env:MINGW_BASE_DIR\include`"") -} - -function InstallLuaUtf8() { - Set-Location \LuaRocks - exec ".\luarocks" @("--tree=`"$Env:MINGW_BASE_DIR`"", "install", "luautf8") -} - -function InstallLuaYajl() { - Set-Location \LuaRocks - $Env:LIBRARY_PATH = "$Env:LIBRARY_PATH;$Env:MINGW_BASE_DIR/bin" - exec ".\luarocks" @("--tree=`"$Env:MINGW_BASE_DIR`"", "install", "lua-yajl", "YAJL_LIBDIR=`"$Env:MINGW_BASE_DIR\bin`"", "YAJL_INCDIR=`"$Env:MINGW_BASE_DIR\include`"") -} - -function InstallLuaZip () { - Set-Location "$workingBaseDir" - DownloadFile "https://github.com/rjpcomputing/luazip/archive/master.zip" "luazip.zip" - ExtractZip "luazip.zip" "luazip" - Set-Location luazip\luazip-master - Step "installing luazip" - exec "gcc" @("-O2", "-c", "-o", "src/luazip.o", "-I`"$Env:MINGW_BASE_DIR/include`"", "src/luazip.c") - exec "gcc" @("-shared", "-o", "zip.dll", "src/luazip.o", "-L`"$Env:MINGW_BASE_DIR/lib`"", "-lzzip", "-lz", "`"$Env:MINGW_BASE_DIR/bin/lua51.dll`"", "-lm") - Copy-Item "zip.dll" "$Env:MINGW_BASE_DIR\lib\lua\5.1" -} - -function InstallLuaModules(){ - CheckAndInstall "lfs" "$Env:MINGW_BASE_DIR\\lib\lua\5.1\lfs.dll" { InstallLfs } - CheckAndInstall "luasql.sqlite3" "$Env:MINGW_BASE_DIR\\lib\lua\5.1\luasql\sqlite3.dll" { InstallLuasql } - CheckAndInstall "rex.pcre" "$Env:MINGW_BASE_DIR\\lib\lua\5.1\rex_pcre.dll" { InstallRexPcre } - CheckAndInstall "lua-utf8" "$Env:MINGW_BASE_DIR\\lib\lua\5.1\lua-utf8.dll" { InstallLuaUtf8 } - CheckAndInstall "lua-yajl" "$Env:MINGW_BASE_DIR\\lib\lua\5.1\yajl.dll" { InstallLuaYajl } - CheckAndInstall "luazip" "$Env:MINGW_BASE_DIR\\lib\lua\5.1\zip.dll" { InstallLuaZip } -} - # install dependencies -CheckAndInstall "7z" "C:\Program Files\7-Zip\7z.exe" { InstallSevenZ } -CheckAndInstall "cmake" "$CMakePath\cmake.exe" { InstallCmake } -CheckAndInstall "mingw-get" "C:\MinGW\bin\mingw-get.exe" { InstallMingwGet } -CheckAndInstall "MSYS and autotools" "C:\MinGW\bin\autoconf" { InstallMsys } -CheckAndInstall "Boost" "C:\Libraries\boost_1_67_0\bootstrap.bat" { InstallBoost } -CheckAndInstall "Qt" "$Env:QT_BASE_DIR\bin\qmake.exe" { InstallQt } -CheckAndInstall "Python" "C:\Python27\python.exe" { InstallPython } +CheckAndInstall7z +CheckAndInstallCmake +CheckAndInstallMingwGet +CheckAndInstallMsys +CheckAndInstallBoost +CheckAndInstallQt +CheckAndInstallPython # Adapt the PATH variable again as we may have installed some dependencies just now and can determine their location. SetMingwBaseDir "$logFile" @@ -413,15 +29,15 @@ $Env:PATH = $ShPath # But on the other hand we keep sh.exe in the PATH to easily run "configure" scripts. So we create 2 variables and assign PATH accordingly. $NoShPath = filterPathForSh -CheckAndInstall "openssl" "$Env:MINGW_BASE_DIR\bin\ssleay32.dll" { InstallOpenssl } -CheckAndInstall "hunspell" "$Env:MINGW_BASE_DIR\bin\libhunspell-1.6-0.dll" { InstallHunspell } -CheckAndInstall "yajl" "$Env:MINGW_BASE_DIR\bin\libyajl.dll" { InstallYajl } -CheckAndInstall "lua" "$Env:MINGW_BASE_DIR\bin\lua51.dll" { InstallLua } -CheckAndInstall "pcre" "$Env:MINGW_BASE_DIR\bin\libpcre-1.dll" { InstallPcre } -CheckAndInstall "sqlite" "$Env:MINGW_BASE_DIR\lib\libsqlite3.a" { InstallSqlite } -CheckAndInstall "zlib" "$Env:MINGW_BASE_DIR\bin\zlib1.dll" { InstallZlib } -CheckAndInstall "libzip" "$Env:MINGW_BASE_DIR\include\zipconf.h" { InstallLibzip } -CheckAndInstall "zziplib" "$Env:MINGW_BASE_DIR\lib\libzzip.la" { InstallZziplib } -CheckAndInstall "luarocks" "C:\LuaRocks\luarocks.bat" { InstallLuarocks } -CheckAndInstall "pugixml" "$Env:MINGW_BASE_DIR\lib\libpugixml.a" { InstallPugixml } +CheckAndInstallOpenSSL +CheckAndInstallHunspell +CheckAndInstallYajl +CheckAndInstallLua +CheckAndInstallPcre +CheckAndInstallSqlite +CheckAndInstallZlib +CheckAndInstallLibzip +CheckAndInstallZziplib +CheckAndInstallLuarocks +CheckAndInstallPugixml InstallLuaModules diff --git a/CI/appveyor.set-environment.ps1 b/CI/appveyor.set-environment.ps1 deleted file mode 100644 index 4e7eabb8634..00000000000 --- a/CI/appveyor.set-environment.ps1 +++ /dev/null @@ -1,36 +0,0 @@ -function SetQtBaseDir([string] $logFile) { - if(!(Test-Path Env:QT_BASE_DIR)){ - try - { - $Env:QT_BASE_DIR = Get-Command "qmake.exe" -ErrorAction Stop | Select-Object -ExpandProperty definition | Split-Path -Parent | Split-Path -Parent - } - catch - { - $Env:QT_BASE_DIR = "C:\Qt\5.12.3\mingw73_32" - } - } - Write-Output "Using $Env:QT_BASE_DIR as QT base directory." | Tee-Object -File "$logFile" -Append -} - -function SetMingwBaseDir([string] $logFile) { - if(!(Test-Path Env:MINGW_BASE_DIR)){ - $tmp = $Env:QT_BASE_DIR.Split("\\") - $tmp[-2] = "Tools" - $tmp[-1] = $tmp[-1] -replace "_32", "*" - $tmp = $tmp -join "\" | Resolve-Path - if($tmp -is [array]){ - $tmp = $tmp[-1] - } - $Env:MINGW_BASE_DIR = $tmp - } - Write-Output "Using $Env:MINGW_BASE_DIR as MinGW base directory." | Tee-Object -File "$logFile" -Append - - if(!(Test-Path Env:MINGW_BASE_DIR_BASH)){ - $Env:MINGW_BASE_DIR_BASH = $Env:MINGW_BASE_DIR -replace "\\", "/" -replace "C:", "/c" - } -} - -function SetLuarocksPath([string] $logFile) { - $Env:LUA_CPATH = "$Env:MINGW_BASE_DIR\lib\lua\5.1\?.dll;$Env:LUA_CPATH" - Write-Output "Using $Env:LUA_CPATH as LuaRocks path." | Tee-Object -File "$logFile" -Append -} diff --git a/setup-windows-sdk.ps1 b/setup-windows-sdk.ps1 index c3224e61e57..e36f9ef0505 100644 --- a/setup-windows-sdk.ps1 +++ b/setup-windows-sdk.ps1 @@ -12,7 +12,7 @@ else { cd "$sourceDir" -. CI\appveyor.set-environment.ps1 +. CI\appveyor.functions.ps1 SetQtBaseDir "C:\src\verbose_output.log" SetMingwBaseDir "C:\src\verbose_output.log" SetLuarocksPath "C:\src\verbose_output.log" diff --git a/src/mudlet.pro b/src/mudlet.pro index eaa3b1583df..3de8d695f9c 100644 --- a/src/mudlet.pro +++ b/src/mudlet.pro @@ -1337,7 +1337,7 @@ DISTFILES += \ ../CI/appveyor.after_success.ps1 \ ../CI/appveyor.install.ps1 \ ../CI/appveyor.set-build-info.ps1 \ - ../CI/appveyor.set-environment.ps1 \ + ../CI/appveyor.functions.ps1 \ ../CI/appveyor.build.ps1 \ mudlet-lua/lua/ldoc.css \ mudlet-lua/genDoc.sh \ From 348fb80989b1d8a781dabc4c39fb1421dcf08477 Mon Sep 17 00:00:00 2001 From: Vadim Peretokin Date: Fri, 9 Aug 2019 18:47:06 +0200 Subject: [PATCH 07/21] Use our own edbee with updated QsLog (#2914) Intention is to send all improvements upstream but not be delayed by them getting merged. --- .gitmodules | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitmodules b/.gitmodules index 78fa6152bf7..284a5023777 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,6 +1,6 @@ [submodule "3rdparty/edbee-lib"] path = 3rdparty/edbee-lib - url = http://github.com/dicene/edbee-lib.git + url = https://github.com/Mudlet/edbee-lib.git [submodule "3rdparty/lua_code_formatter"] path = 3rdparty/lcf url = https://github.com/martin-eden/lua_code_formatter.git From cd785abe6d6d249733225efaad6ce8a9e24db086 Mon Sep 17 00:00:00 2001 From: Vadim Peretokin Date: Sun, 11 Aug 2019 16:59:37 +0200 Subject: [PATCH 08/21] Fix userwindows not going away on profile close (#2959) --- src/mudlet.cpp | 141 ++++++++++++------------------------------------- src/mudlet.h | 1 - 2 files changed, 33 insertions(+), 109 deletions(-) diff --git a/src/mudlet.cpp b/src/mudlet.cpp index 3011e5d6062..d5a282b24be 100644 --- a/src/mudlet.cpp +++ b/src/mudlet.cpp @@ -499,8 +499,6 @@ mudlet::mudlet() connect(dactionShowMap, &QAction::triggered, this, &mudlet::slot_mapper); connect(dactionOptions, &QAction::triggered, this, &mudlet::slot_show_options_dialog); connect(dactionAbout, &QAction::triggered, this, &mudlet::slot_show_about_dialog); - // PLACEMARKER: Save for later restoration (2 of 2) (by adding a "Close" (profile) option to first menu on menu bar: - // connect(mactionCloseProfile, &QAction::triggered, this, &mudlet::slot_close_profile); // we historically use Alt on Windows and Linux, but that is uncomfortable on macOS #if defined(Q_OS_MACOS) @@ -1404,16 +1402,17 @@ void mudlet::slot_close_profile_requested(int tab) pH->stopAllTriggers(); pH->mpEditorDialog->close(); - for (auto consoleName : hostConsoleMap.keys()) { - hostConsoleMap[consoleName]->close(); - hostConsoleMap.remove(consoleName); + for (auto consoleName : hostConsoleMap.keys()) { if (dockWindowMap.contains(consoleName)) { dockWindowMap[consoleName]->setAttribute(Qt::WA_DeleteOnClose); dockWindowMap[consoleName]->close(); removeDockWidget(dockWindowMap[consoleName]); dockWindowMap.remove(consoleName); } + + hostConsoleMap[consoleName]->close(); + hostConsoleMap.remove(consoleName); } if (pH->mpNotePad) { @@ -1460,80 +1459,6 @@ void mudlet::slot_close_profile_requested(int tab) } } -// Not currently used - may not be properly functional anymore! -void mudlet::slot_close_profile() -{ - if (mpCurrentActiveHost) { - if (mConsoleMap.contains(mpCurrentActiveHost)) { - Host* pH = mpCurrentActiveHost; - if (pH) { - std::list> hostTToolBarMap = pH->getActionUnit()->getToolBarList(); - QMap& dockWindowMap = pH->mpConsole->mDockWidgetMap; - QMap& hostConsoleMap = pH->mpConsole->mSubConsoleMap; - QString name = pH->getName(); - - pH->closingDown(); - - // disconnect before removing objects from memory as sysDisconnectionEvent needs that stuff. - pH->mTelnet.disconnectIt(); - - mpCurrentActiveHost->mpEditorDialog->close(); - for (auto consoleName : hostConsoleMap.keys()) { - hostConsoleMap[consoleName]->close(); - hostConsoleMap.remove(consoleName); - - if (dockWindowMap.contains(consoleName)) { - dockWindowMap[consoleName]->setAttribute(Qt::WA_DeleteOnClose); - dockWindowMap[consoleName]->close(); - removeDockWidget(dockWindowMap[consoleName]); - dockWindowMap.remove(consoleName); - } - } - - if (pH->mpNotePad) { - pH->mpNotePad->save(); - pH->mpNotePad->setAttribute(Qt::WA_DeleteOnClose); - pH->mpNotePad->close(); - pH->mpNotePad = nullptr; - } - - for (TToolBar* pTB : hostTToolBarMap) { - if (pTB) { - pTB->setAttribute(Qt::WA_DeleteOnClose); - pTB->deleteLater(); - } - } - - // close IRC client window if it is open. - if (mpIrcClientMap.contains(pH)) { - mpIrcClientMap[pH]->setAttribute(Qt::WA_DeleteOnClose); - mpIrcClientMap[pH]->deleteLater(); - } - - // Wait for disconnection to complete - while (pH->mTelnet.getConnectionState() != QAbstractSocket::UnconnectedState) { - QApplication::processEvents(); - } - - mConsoleMap[pH]->close(); - if (mTabMap.contains(name)) { - mpTabBar->removeTab(mpTabBar->currentIndex()); - mConsoleMap.remove(pH); - // PLACEMARKER: Host destruction (2) - normal case - int hostCount = mHostManager.getHostCount(); - emit signal_hostDestroyed(pH, --hostCount); - mHostManager.deleteHost(name); - mTabMap.remove(name); - } - mpCurrentActiveHost = Q_NULLPTR; - } - } - - } else { - disableToolbarButtons(); - } -} - void mudlet::slot_tab_changed(int tabID) { if ((tabID != -1) && (!mTabMap.contains(mpTabBar->tabData(tabID).toString()))) { @@ -1985,56 +1910,56 @@ bool mudlet::openWindow(Host* pHost, const QString& name, bool loadLayout) } auto hostName(pHost->getName()); - auto pC = pHost->mpConsole->mSubConsoleMap.value(name); - auto pD = pHost->mpConsole->mDockWidgetMap.value(name); + auto console = pHost->mpConsole->mSubConsoleMap.value(name); + auto dockwidget = pHost->mpConsole->mDockWidgetMap.value(name); - if (!pC && !pD) { + if (!console && !dockwidget) { // The name is not used in either the QMaps of all user created TConsole // or TDockWidget instances - so we can make a NEW one: - pD = new TDockWidget(pHost, name); - pD->setObjectName(QStringLiteral("dockWindow_%1_%2").arg(hostName, name)); - pD->setContentsMargins(0, 0, 0, 0); - pD->setFeatures(QDockWidget::AllDockWidgetFeatures); - pD->setWindowTitle(tr("User window - %1 - %2").arg(hostName, name)); - pHost->mpConsole->mDockWidgetMap.insert(name, pD); + dockwidget = new TDockWidget(pHost, name); + dockwidget->setObjectName(QStringLiteral("dockWindow_%1_%2").arg(hostName, name)); + dockwidget->setContentsMargins(0, 0, 0, 0); + dockwidget->setFeatures(QDockWidget::AllDockWidgetFeatures); + dockwidget->setWindowTitle(tr("User window - %1 - %2").arg(hostName, name)); + pHost->mpConsole->mDockWidgetMap.insert(name, dockwidget); // It wasn't obvious but the parent passed to the TConsole constructor // is sliced down to a QWidget and is NOT a TDockWidget pointer: - pC = new TConsole(pHost, TConsole::UserWindow, pD->widget()); - pC->setObjectName(QStringLiteral("dockWindowConsole_%1_%2").arg(hostName, name)); + console = new TConsole(pHost, TConsole::UserWindow, dockwidget->widget()); + console->setObjectName(QStringLiteral("dockWindowConsole_%1_%2").arg(hostName, name)); // Without this the TConsole instance inside the TDockWidget will be // left being called the default value of "main": - pC->mConsoleName = name; - pC->setContentsMargins(0, 0, 0, 0); - pD->setTConsole(pC); - pC->show(); - pC->layerCommandLine->hide(); - pC->mpScrollBar->hide(); - pHost->mpConsole->mSubConsoleMap.insert(name, pC); + console->mConsoleName = name; + console->setContentsMargins(0, 0, 0, 0); + dockwidget->setTConsole(console); + console->show(); + console->layerCommandLine->hide(); + console->mpScrollBar->hide(); + pHost->mpConsole->mSubConsoleMap.insert(name, console); // TODO: Allow user to specify alternate dock locations - and for it to be floating and not docked initially! - addDockWidget(Qt::RightDockWidgetArea, pD); + addDockWidget(Qt::RightDockWidgetArea, dockwidget); setWindowFontSize(pHost, name, 10); - if (loadLayout && !pD->hasLayoutAlready) { + if (loadLayout && !dockwidget->hasLayoutAlready) { loadWindowLayout(); - pD->hasLayoutAlready = true; + dockwidget->hasLayoutAlready = true; } return true; - } else if (pC && pD) { + } else if (console && dockwidget) { // The name is used in BOTH the QMaps of all user created TConsole // and TDockWidget instances - so we HAVE an existing user window, // Lets confirm this: - Q_ASSERT_X(pC->getType()==TConsole::UserWindow, "mudlet::openWindow(...)", "An existing TConsole was expected to be marked as a User Window type but it isn't"); - pD->update(); + Q_ASSERT_X(console->getType()==TConsole::UserWindow, "mudlet::openWindow(...)", "An existing TConsole was expected to be marked as a User Window type but it isn't"); + dockwidget->update(); //do not change the ->show() order! Otherwise, it will automatically minimize the floating/dock window(!!) - pC->show(); - pD->show(); - pC->showWindow(name); + console->show(); + dockwidget->show(); + console->showWindow(name); - if (loadLayout && !pD->hasLayoutAlready) { + if (loadLayout && !dockwidget->hasLayoutAlready) { loadWindowLayout(); - pD->hasLayoutAlready = true; + dockwidget->hasLayoutAlready = true; } return true; diff --git a/src/mudlet.h b/src/mudlet.h index 76f770200e4..cd09b81bfbe 100644 --- a/src/mudlet.h +++ b/src/mudlet.h @@ -495,7 +495,6 @@ public slots: private slots: - void slot_close_profile(); void slot_tab_changed(int); void show_help_dialog(); void slot_show_connection_dialog(); From 0ea6d681ae44e271a1bd73e38b42dec34f8dea52 Mon Sep 17 00:00:00 2001 From: Vadim Peretokin Date: Mon, 12 Aug 2019 14:15:39 +0200 Subject: [PATCH 09/21] Don't show SSL certificate info until we have one in Profile Preferences (#2953) * Don't show SSL certificate info until we have one & streamline UI * Remove colorroles --- src/dlgProfilePreferences.cpp | 112 ++++++++++++++++++---------------- src/ui/profile_preferences.ui | 82 ++++++++++++------------- 2 files changed, 97 insertions(+), 97 deletions(-) diff --git a/src/dlgProfilePreferences.cpp b/src/dlgProfilePreferences.cpp index 45552af835b..da0e57e5c98 100644 --- a/src/dlgProfilePreferences.cpp +++ b/src/dlgProfilePreferences.cpp @@ -837,65 +837,67 @@ void dlgProfilePreferences::initWithHost(Host* pHost) #if !defined(QT_NO_SSL) if (QSslSocket::supportsSsl() && pHost->mSslTsl) { QSslCertificate cert = pHost->mTelnet.getPeerCertificate(); - ssl_issuer_label->setText(cert.issuerInfo(QSslCertificate::CommonName).join(",")); - ssl_issued_label->setText(cert.subjectInfo(QSslCertificate::CommonName).join(",")); - ssl_expires_label->setText(cert.expiryDate().toString(Qt::LocalDate)); - ssl_serial_label->setText(QString::fromStdString(cert.serialNumber().toStdString())); - checkBox_self_signed->setStyleSheet(QString()); - checkBox_expired->setStyleSheet(QString()); - ssl_issuer_label->setStyleSheet(QString()); - ssl_expires_label->setStyleSheet(QString()); - checkBox_ssl->setStyleSheet(QString()); - - if (!pHost->mTelnet.getSslErrors().empty()) { - // handle ssl errors - notificationAreaIconLabelWarning->show(); - notificationArea->show(); - notificationAreaMessageBox->show(); - //notificationAreaMessageBox->setText(pHost->mTelnet.errorString()); - - QList sslErrors = pHost->mTelnet.getSslErrors(); - - for (int a = 0; a < sslErrors.count(); a++) { - QString thisError = QStringLiteral("
  • %1
  • ").arg(sslErrors.at(a).errorString()); - notificationAreaMessageBox->setText(QStringLiteral("%1\n%2").arg(notificationAreaMessageBox->text(), thisError)); - - if (sslErrors.at(a).error() == QSslError::SelfSignedCertificate) { - checkBox_self_signed->setStyleSheet(QStringLiteral("font-weight: bold; background: yellow")); - ssl_issuer_label->setStyleSheet(QStringLiteral("font-weight: bold; color: red; background: yellow")); - } - if (sslErrors.at(a).error() == QSslError::CertificateExpired) { - checkBox_expired->setStyleSheet(QStringLiteral("font-weight: bold; background: yellow")); - ssl_expires_label->setStyleSheet(QStringLiteral("font-weight: bold; color: red; background: yellow")); + if (cert.isNull()) { + groupBox_ssl_certificate->hide(); + } else { + ssl_issuer_label->setText(cert.issuerInfo(QSslCertificate::CommonName).join(",")); + ssl_issued_label->setText(cert.subjectInfo(QSslCertificate::CommonName).join(",")); + ssl_expires_label->setText(cert.expiryDate().toString(Qt::LocalDate)); + ssl_serial_label->setText(QString::fromStdString(cert.serialNumber().toStdString())); + checkBox_self_signed->setStyleSheet(""); + checkBox_expired->setStyleSheet(""); + ssl_issuer_label->setStyleSheet(""); + ssl_expires_label->setStyleSheet(""); + + if (!pHost->mTelnet.getSslErrors().empty()) { + // handle ssl errors + notificationAreaIconLabelWarning->show(); + notificationArea->show(); + notificationAreaMessageBox->show(); + //notificationAreaMessageBox->setText(pHost->mTelnet.errorString()); + + QList sslErrors = pHost->mTelnet.getSslErrors(); + + for (int a = 0; a < sslErrors.count(); a++) { + QString thisError = QStringLiteral("
  • %1
  • ").arg(sslErrors.at(a).errorString()); + notificationAreaMessageBox->setText(QStringLiteral("%1\n%2").arg(notificationAreaMessageBox->text(), thisError)); + + if (sslErrors.at(a).error() == QSslError::SelfSignedCertificate) { + checkBox_self_signed->setStyleSheet(QStringLiteral("font-weight: bold; background: yellow")); + ssl_issuer_label->setStyleSheet(QStringLiteral("font-weight: bold; color: red; background: yellow")); + } + if (sslErrors.at(a).error() == QSslError::CertificateExpired) { + checkBox_expired->setStyleSheet(QStringLiteral("font-weight: bold; background: yellow")); + ssl_expires_label->setStyleSheet(QStringLiteral("font-weight: bold; color: red; background: yellow")); + } } - } - } else if (pHost->mTelnet.error() == QAbstractSocket::SslHandshakeFailedError) { - // handle failed handshake, likely not ssl socket - notificationAreaIconLabelError->show(); - notificationArea->show(); - notificationAreaMessageBox->show(); - notificationAreaMessageBox->setText(pHost->mTelnet.errorString()); - checkBox_ssl->setStyleSheet(QStringLiteral("font-weight: bold; background: yellow")); - } - if (pHost->mTelnet.error() == QAbstractSocket::SslInternalError) { - // handle ssl library error - notificationAreaIconLabelError->show(); - notificationArea->show(); - notificationAreaMessageBox->show(); - notificationAreaMessageBox->setText(pHost->mTelnet.errorString()); - } - if (pHost->mTelnet.error() == QAbstractSocket::SslInvalidUserDataError) { - // handle invalid data (certificate, key, cypher, etc.) - notificationAreaIconLabelError->show(); - notificationArea->show(); - notificationAreaMessageBox->show(); - notificationAreaMessageBox->setText(pHost->mTelnet.errorString()); + } else if (pHost->mTelnet.error() == QAbstractSocket::SslHandshakeFailedError) { + // handle failed handshake, likely not ssl socket + notificationAreaIconLabelError->show(); + notificationArea->show(); + notificationAreaMessageBox->show(); + notificationAreaMessageBox->setText(pHost->mTelnet.errorString()); + } + if (pHost->mTelnet.error() == QAbstractSocket::SslInternalError) { + // handle ssl library error + notificationAreaIconLabelError->show(); + notificationArea->show(); + notificationAreaMessageBox->show(); + notificationAreaMessageBox->setText(pHost->mTelnet.errorString()); + } + if (pHost->mTelnet.error() == QAbstractSocket::SslInvalidUserDataError) { + // handle invalid data (certificate, key, cypher, etc.) + notificationAreaIconLabelError->show(); + notificationArea->show(); + notificationAreaMessageBox->show(); + notificationAreaMessageBox->setText(pHost->mTelnet.errorString()); + } } } #endif - checkBox_ssl->setChecked(pHost->mSslTsl); + groupBox_ssl->setChecked(pHost->mSslTsl); checkBox_self_signed->setChecked(pHost->mSslIgnoreSelfSigned); checkBox_expired->setChecked(pHost->mSslIgnoreExpired); checkBox_ignore_all->setChecked(pHost->mSslIgnoreAll); @@ -1169,6 +1171,8 @@ void dlgProfilePreferences::clearHostDetails() lineEdit_discordUserName->clear(); lineEdit_discordUserDiscriminator->clear(); + groupBox_ssl_certificate->hide(); + notificationArea->hide(); groupBox_proxy->setDisabled(true); // Remove the reference to the Host/profile in the title: @@ -2282,7 +2286,7 @@ void dlgProfilePreferences::slot_save_and_exit() pHost->mProxyPassword = lineEdit_proxyPassword->text(); //tab security - pHost->mSslTsl = checkBox_ssl->isChecked(); + pHost->mSslTsl = groupBox_ssl->isChecked(); pHost->mSslIgnoreExpired = checkBox_expired->isChecked(); pHost->mSslIgnoreSelfSigned = checkBox_self_signed->isChecked(); pHost->mSslIgnoreAll = checkBox_ignore_all->isChecked(); diff --git a/src/ui/profile_preferences.ui b/src/ui/profile_preferences.ui index 18fcd1fa637..583453b990a 100644 --- a/src/ui/profile_preferences.ui +++ b/src/ui/profile_preferences.ui @@ -6,7 +6,7 @@ 0 0 - 747 + 883 808 @@ -2789,20 +2789,16 @@ - SSL/TLS + TLS/SSL secure connection + + + true + + + false - - - - - - - Secure connection - - - - + @@ -2888,37 +2884,7 @@ - - - - - - - Accept self-signed certificates - - - - - - - - - - Accept expired certificates - - - - - - - - - Accept all certificate errors (unsecure) - - - - @@ -4845,6 +4811,36 @@ + + + + + + + Accept self-signed certificates + + + + + + + + + + Accept expired certificates + + + + + + + + + + Accept all certificate errors (unsecure) + + + From 41b5abf0029d869a835e68e50b2168ff4978ae6f Mon Sep 17 00:00:00 2001 From: Vadim Peretokin Date: Mon, 12 Aug 2019 15:02:40 +0200 Subject: [PATCH 10/21] Add a workaround for mapper creation breaking getMainWindowSize() (#2945) * Add a workaround for mapper creation breaking getMainWindowSize() * Revert "Fix errors when creating new triggers (#2868)" This reverts commit 0578c6142889baee5c65d22b958960b1539e31ec. * Fix typo --- src/TConsole.cpp | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/TConsole.cpp b/src/TConsole.cpp index aa4c0c4bf6f..79bcf7af604 100644 --- a/src/TConsole.cpp +++ b/src/TConsole.cpp @@ -2249,7 +2249,22 @@ void TConsole::createMapper(int x, int y, int width, int height) } mpMapper->resize(width, height); mpMapper->move(x, y); + + // Qt bug workaround: on Windows and during profile load only, if the mapper widget is created + // it gives a height and width to mpLeftToolBar, mpRightToolBar, and mpTopToolBar for + // some reason. Those widgets size back down immediately after on their own (?!), however if + // getMainWindowSize() is called right after map create, the sizes reported will be wrong +#if defined(Q_OS_WIN32) + mpLeftToolBar->setHidden(true); + mpRightToolBar->setHidden(true); + mpTopToolBar->setHidden(true); mpMapper->show(); + mpLeftToolBar->setVisible(true); + mpRightToolBar->setVisible(true); + mpTopToolBar->setVisible(true); +#else + mpMapper->show(); +#endif } bool TConsole::createButton(const QString& name, int x, int y, int width, int height, bool fillBackground) From 005bc9b4514f1e3402b62e23baf66ebce46585fd Mon Sep 17 00:00:00 2001 From: Vadim Peretokin Date: Mon, 12 Aug 2019 15:22:42 +0200 Subject: [PATCH 11/21] Don't include TLS code code when it's not available (#2965) --- src/ctelnet.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/ctelnet.cpp b/src/ctelnet.cpp index c1a6d0f1f5a..4b2776cb08f 100644 --- a/src/ctelnet.cpp +++ b/src/ctelnet.cpp @@ -128,16 +128,18 @@ cTelnet::cTelnet(Host* pH, const QString& profileName) // initialize the socket after the Host initialisation is complete so we can access mSslTsl QTimer::singleShot(0, this, [this]() { +#if !defined(QT_NO_SSL) if (mpHost->mSslTsl) { connect(&socket, &QSslSocket::encrypted, this, &cTelnet::handle_socket_signal_connected); } else { connect(&socket, &QAbstractSocket::connected, this, &cTelnet::handle_socket_signal_connected); } - connect(&socket, &QAbstractSocket::disconnected, this, &cTelnet::handle_socket_signal_disconnected); - connect(&socket, &QIODevice::readyRead, this, &cTelnet::handle_socket_signal_readyRead); -#if !defined(QT_NO_SSL) connect(&socket, qOverload&>(&QSslSocket::sslErrors), this, &cTelnet::handle_socket_signal_sslError); +#else + connect(&socket, &QAbstractSocket::connected, this, &cTelnet::handle_socket_signal_connected); #endif + connect(&socket, &QAbstractSocket::disconnected, this, &cTelnet::handle_socket_signal_disconnected); + connect(&socket, &QIODevice::readyRead, this, &cTelnet::handle_socket_signal_readyRead); }); From a20e0b32d9d2ca0a327f8d27d9fc0c009e34ec04 Mon Sep 17 00:00:00 2001 From: keneanung Date: Mon, 12 Aug 2019 12:04:02 +0000 Subject: [PATCH 12/21] Use correct URL to download the coverity software --- CI/travis.linux.install.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CI/travis.linux.install.sh b/CI/travis.linux.install.sh index ecddbf43c7c..ba7c4e5e8a2 100755 --- a/CI/travis.linux.install.sh +++ b/CI/travis.linux.install.sh @@ -14,7 +14,7 @@ if [ "${TRAVIS_EVENT_TYPE}" = "cron" ]; then # download coverity tool only for cron jobs mkdir coverity cd coverity - wget https://scan.coverity.com/download/linux --post-data "token=${COVERITY_SCAN_TOKEN}&project=Mudlet%2FMudlet" -O coverity_tool.tgz + wget https://scan.coverity.com/download/linux64 --post-data "token=${COVERITY_SCAN_TOKEN}&project=Mudlet%2FMudlet" -O coverity_tool.tgz if [ $? -ne 0 ]; then echo Download Coverity analysis tool failed! exit 1 From a862bca12704f59de1cc42674cff0646cc1b1c05 Mon Sep 17 00:00:00 2001 From: Vadim Peretokin Date: Mon, 12 Aug 2019 20:28:48 +0200 Subject: [PATCH 13/21] Raise minimum to Qt 5.11 (#2944) * Raise minimum to Qt 5.11 * Update Travis minimum Qt build --- .travis.yml | 14 +++++++------- src/CMakeLists.txt | 19 +++---------------- src/mudlet.pro | 4 ++-- 3 files changed, 12 insertions(+), 25 deletions(-) diff --git a/.travis.yml b/.travis.yml index ab1f207c679..760e65c7a65 100644 --- a/.travis.yml +++ b/.travis.yml @@ -9,10 +9,10 @@ sudo: false addons: apt: sources: &add-sources - - sourceline: 'ppa:beineri/opt-qt571-xenial' + - sourceline: 'ppa:beineri/opt-qt-5.11.3-xenial' - sourceline: 'ppa:beineri/opt-qt-5.12.3-xenial' - sourceline: 'ppa:ondrej/php' # more-or-less up to date libzip - - sourceline: 'ppa:ubuntu-toolchain-r/test' # gcc 9 + - sourceline: 'ppa:ubuntu-toolchain-r/test' # gcc 7 packages: &common-packages - libhunspell-dev - lua5.1 @@ -115,15 +115,15 @@ matrix: compiler: gcc env: - Q_OR_C_MAKE=cmake - - QT_VERSION=57 # actually Qt 5.7, used to check minimum supported Qt works + - QT_VERSION=511 # actually Qt 5.11, used to check minimum supported Qt works addons: apt: sources: *add-sources - packages: &qt57-packages + packages: &qt511-packages - *common-packages - - qt57base - - qt57multimedia - - qt57tools + - qt511base + - qt511multimedia + - qt511tools before_cache: - if [ "${TRAVIS_OS_NAME}" = "osx" ]; then brew cleanup; fi before_install: diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 6db93739e52..d42ca81980f 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -334,25 +334,12 @@ if((APPLE) AND (PKG_CONFIG_FOUND)) endif() endif() -find_package(Qt5 5.7 REQUIRED COMPONENTS Core Multimedia Network OpenGL UiTools Widgets Concurrent) - -# This is not present before Qt 5.7: +find_package(Qt5 5.11 REQUIRED COMPONENTS Core Multimedia Network OpenGL UiTools Widgets Concurrent) find_package(Qt5 COMPONENTS Gamepad QUIET) - -# This is not present before Qt 5.9: find_package(Qt5 COMPONENTS TextToSpeech QUIET) -if (Qt5Core_VERSION VERSION_LESS 5.7) - message(FATAL_ERROR "Mudlet requires Qt 5.7 or later, yours is ${Qt5Core_VERSION}") -elif(Qt5Core_VERSION VERSION_LESS 5.9) - # Qt Gamepad was a Technology Preview in 5.7 - # Qt Gamepad was a Technology Preview 2 in 5.8 - # Qt Speech (or at least the TTS part) was a Technology Preview in 5.8 - message(WARNING "Qt version: ${Qt5Core_VERSION} - Gamepad and TextToSpeech may not be supported, as officially they requires 5.9 and 5.10 respectively") -elif(Qt5Core_VERSION VERSION_LESS 5.10) - # Qt Speech (or at least the TTS part) was a Technology Preview 2 in 5.9, now supported on Mingw - # Qt Gamepad was officially released in 5.9 - message(WARNING "Qt version: ${Qt5Core_VERSION} - TextToSpeech may not be supported, officially it requires 5.10") +if (Qt5Core_VERSION VERSION_LESS 5.11) + message(FATAL_ERROR "Mudlet requires Qt 5.11 or later, yours is ${Qt5Core_VERSION}") else() # Qt Speech (or at least the TTS part) was officially release in 5.10 message(STATUS "Qt version: ${Qt5Core_VERSION}") diff --git a/src/mudlet.pro b/src/mudlet.pro index 3de8d695f9c..af6b72a4441 100644 --- a/src/mudlet.pro +++ b/src/mudlet.pro @@ -34,8 +34,8 @@ # # ############################################################################ -lessThan(QT_MAJOR_VERSION, 5)|if(lessThan(QT_MAJOR_VERSION,6):lessThan(QT_MINOR_VERSION, 7)) { - error("Mudlet requires Qt 5.7 or later") +lessThan(QT_MAJOR_VERSION, 5)|if(lessThan(QT_MAJOR_VERSION,6):lessThan(QT_MINOR_VERSION, 11)) { + error("Mudlet requires Qt 5.11 or later") } # Including IRC Library From 42d764b79ee2b5dd47dce64a579820b1dd557110 Mon Sep 17 00:00:00 2001 From: Vadim Peretokin Date: Tue, 13 Aug 2019 10:26:59 +0200 Subject: [PATCH 14/21] Remove < Qt 5.11 workarounds (#2969) --- src/T2DMap.cpp | 7 ++----- src/TLuaInterpreter.cpp | 5 +---- src/TMap.cpp | 2 -- src/dlgTriggerEditor.cpp | 5 ----- src/main.cpp | 8 -------- 5 files changed, 3 insertions(+), 24 deletions(-) diff --git a/src/T2DMap.cpp b/src/T2DMap.cpp index c3093adbccd..cc78b458ad0 100644 --- a/src/T2DMap.cpp +++ b/src/T2DMap.cpp @@ -806,16 +806,13 @@ void T2DMap::paintEvent(QPaintEvent* e) } static quint8 roomVnumMargin = 10; roomVNumFont.setBold(true); -#if (QT_VERSION >= QT_VERSION_CHECK(5, 10, 0)) - // QFont::PreferNoShaping is only available in Qt 5.10 or later + // QFont::PreferOutline will help to select a font that will scale to any // size - which is important for good rendering over a range of sizes // QFont::PreferAntialias will look better - except perhaps at very small // sizes (but we prevent that by checking in the method call afterwards): roomVNumFont.setStyleStrategy(QFont::StyleStrategy(QFont::PreferNoShaping|QFont::PreferAntialias|QFont::PreferOutline)); -#else - roomVNumFont.setStyleStrategy(QFont::StyleStrategy(QFont::PreferAntialias|QFont::PreferOutline)); -#endif + isFontBigEnoughToShowRoomVnum = sizeFontToFitTextInRect(roomVNumFont, roomTestRect, QStringLiteral("8").repeated(mMaxRoomIdDigits), roomVnumMargin); } diff --git a/src/TLuaInterpreter.cpp b/src/TLuaInterpreter.cpp index 55a154b8924..8151ff5678b 100644 --- a/src/TLuaInterpreter.cpp +++ b/src/TLuaInterpreter.cpp @@ -10384,11 +10384,8 @@ int TLuaInterpreter::downloadFile(lua_State* L) } QNetworkRequest request = QNetworkRequest(url); -#if (QT_VERSION >= QT_VERSION_CHECK(5, 9, 0)) request.setAttribute(QNetworkRequest::RedirectPolicyAttribute, QNetworkRequest::NoLessSafeRedirectPolicy); -#else - request.setAttribute(QNetworkRequest::FollowRedirectsAttribute, true); -#endif + // This should fix: https://bugs.launchpad.net/mudlet/+bug/1366781 request.setRawHeader(QByteArray("User-Agent"), QByteArray(QStringLiteral("Mozilla/5.0 (Mudlet/%1%2)").arg(APP_VERSION, APP_BUILD).toUtf8().constData())); #ifndef QT_NO_SSL diff --git a/src/TMap.cpp b/src/TMap.cpp index f681c3a270a..777cde765c7 100644 --- a/src/TMap.cpp +++ b/src/TMap.cpp @@ -1492,9 +1492,7 @@ bool TMap::restore(QString location, bool downloadIfNotFound) mMapSymbolFont.setStyleStrategy(static_cast(( mIsOnlyMapSymbolFontToBeUsed ? QFont::NoFontMerging : 0) | QFont::PreferOutline | QFont::PreferAntialias | QFont::PreferQuality -#if QT_VERSION >= 0x050a00 | QFont::PreferNoShaping -#endif )); if (mVersion >= 14) { diff --git a/src/dlgTriggerEditor.cpp b/src/dlgTriggerEditor.cpp index 4b74f929fdc..9d8465262aa 100644 --- a/src/dlgTriggerEditor.cpp +++ b/src/dlgTriggerEditor.cpp @@ -753,12 +753,7 @@ dlgTriggerEditor::dlgTriggerEditor(Host* pH) widget_searchTerm->updateGeometry(); if (mAutosaveInterval > 0) { -#if QT_VERSION < QT_VERSION_CHECK(5, 9, 0) - startTimer(mAutosaveInterval * 1000 * 60); -#else startTimer(mAutosaveInterval * 1min); -#endif - } } diff --git a/src/main.cpp b/src/main.cpp index 30a41bb5cad..c13a9e45205 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -370,14 +370,6 @@ int main(int argc, char* argv[]) // seed random number generator (should be done once per lifetime) qsrand(static_cast(QTime::currentTime().msecsSinceStartOfDay())); - // workaround latency spikes with wifi on Qt < 5.9.4, see https://github.com/Mudlet/Mudlet/issues/1587 - // set the timeout to infinite -#if (QT_VERSION < QT_VERSION_CHECK(5, 9, 4)) - if (qgetenv("QT_BEARER_POLL_TIMEOUT").isEmpty()) { - qputenv("QT_BEARER_POLL_TIMEOUT", QByteArray::number(-1)); - } -#endif - QString homeDirectory = mudlet::getMudletPath(mudlet::mainPath); QDir dir; bool first_launch = false; From 3d449b5eaed5f49a5322f6c54ad041cfde699d62 Mon Sep 17 00:00:00 2001 From: Vadim Peretokin Date: Tue, 13 Aug 2019 10:27:16 +0200 Subject: [PATCH 15/21] Replace a couple of cases of std::tie with auto (#2967) * Replace a couple of cases of std::tie with auto * A few more --- src/TLuaInterpreter.cpp | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/src/TLuaInterpreter.cpp b/src/TLuaInterpreter.cpp index 8151ff5678b..fd473cf5e8b 100644 --- a/src/TLuaInterpreter.cpp +++ b/src/TLuaInterpreter.cpp @@ -1153,10 +1153,8 @@ int TLuaInterpreter::setProfileIcon(lua_State* L) } Host& host = getHostFromLua(L); - bool success; - QString message; - std::tie(success, message) = mudlet::self()->setProfileIcon(host.getName(), iconPath); + auto[success, message] = mudlet::self()->setProfileIcon(host.getName(), iconPath); if (success) { lua_pushboolean(L, true); return 1; @@ -1171,10 +1169,8 @@ int TLuaInterpreter::setProfileIcon(lua_State* L) int TLuaInterpreter::resetProfileIcon(lua_State* L) { Host& host = getHostFromLua(L); - bool success; - QString message; - std::tie(success, message) = mudlet::self()->resetProfileIcon(host.getName()); + auto [success, message] = mudlet::self()->resetProfileIcon(host.getName()); if (success) { lua_pushboolean(L, true); return 1; From bc47b9d9248d34ff88ad1c107a4f28ec794a64e0 Mon Sep 17 00:00:00 2001 From: Vadim Peretokin Date: Tue, 13 Aug 2019 10:27:29 +0200 Subject: [PATCH 16/21] Fix Coverity TTimer mRepeating initialiser warning (#2972) --- src/TTimer.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/TTimer.cpp b/src/TTimer.cpp index 4a67a579302..96e0b78b644 100644 --- a/src/TTimer.cpp +++ b/src/TTimer.cpp @@ -39,6 +39,7 @@ TTimer::TTimer(TTimer* parent, Host* pHost) , mNeedsToBeCompiled(true) , mpQTimer(new QTimer) , mModuleMember(false) +, mRepeating(false) { mpQTimer->stop(); mpQTimer->setProperty(scmProperty_HostName, mpHost->getName()); From 3f8351449bf230e04854d20b4914110afe4908bf Mon Sep 17 00:00:00 2001 From: Vadim Peretokin Date: Tue, 13 Aug 2019 10:27:42 +0200 Subject: [PATCH 17/21] Fix updateDialog uninitialised in constructor (#2973) --- src/updater.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/updater.cpp b/src/updater.cpp index 63ff0f01bb3..d7f192d78b4 100644 --- a/src/updater.cpp +++ b/src/updater.cpp @@ -37,7 +37,10 @@ // and promptly quits. Installer updates Mudlet and launches Mudlet when its done // mac: handled completely outside of Mudlet by Sparkle -Updater::Updater(QObject* parent, QSettings* settings) : QObject(parent), mUpdateInstalled(false), mpInstallOrRestart(new QPushButton(tr("Update"))) +Updater::Updater(QObject* parent, QSettings* settings) : QObject(parent) +, mUpdateInstalled(false) +, mpInstallOrRestart(new QPushButton(tr("Update"))) +, updateDialog(nullptr) { Q_ASSERT_X(settings, "updater", "QSettings object is required for the updater to work"); this->settings = settings; From 5c2fe2ec7595ed3f1a535a9517f465646e24e5b9 Mon Sep 17 00:00:00 2001 From: Vadim Peretokin Date: Tue, 13 Aug 2019 10:27:54 +0200 Subject: [PATCH 18/21] Fix nullptr warning around curVar (#2974) --- src/LuaInterface.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/LuaInterface.cpp b/src/LuaInterface.cpp index 857580ec282..d6c6c030ef1 100644 --- a/src/LuaInterface.cpp +++ b/src/LuaInterface.cpp @@ -248,9 +248,13 @@ bool LuaInterface::reparentVariable(QTreeWidgetItem* newP, QTreeWidgetItem* cIte //if both exist: //this means we were moved from inside a table to inside another table //and in both instances, this table was not _G + TVar* curVar = varUnit->getWVar(cItem); + if (!curVar) { + return false; + } + L = interpreter->pGlobalLua; TVar* newParent = varUnit->getWVar(newP); - TVar* curVar = varUnit->getWVar(cItem); TVar* oldParent = varUnit->getWVar(oldP); TVar* from = oldParent; TVar* to = newParent; From 8e9953c63a5a775df81b460ac7ae7d55543ec3ee Mon Sep 17 00:00:00 2001 From: Vadim Peretokin Date: Tue, 13 Aug 2019 10:28:08 +0200 Subject: [PATCH 19/21] Fix a possible nullptr dereference if the room wasn't found for some reason (#2975) --- src/T2DMap.cpp | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/T2DMap.cpp b/src/T2DMap.cpp index cc78b458ad0..19c5fc55f09 100644 --- a/src/T2DMap.cpp +++ b/src/T2DMap.cpp @@ -447,10 +447,14 @@ void T2DMap::slot_switchArea(const QString& newAreaName) } } - mOx = closestCenterRoom->x; - // Map y coordinates are reversed on 2D map! - mOy = -closestCenterRoom->y; - mOz = closestCenterRoom->z; + if (closestCenterRoom) { + mOx = closestCenterRoom->x; + // Map y coordinates are reversed on 2D map! + mOy = -closestCenterRoom->y; + mOz = closestCenterRoom->z; + } else { + mOx = mOy = mOz = 0; + } } if (!validRoomFound) { From 2f27a75cd67da3d37ec17056d4ae6b2ac1889c51 Mon Sep 17 00:00:00 2001 From: Vadim Peretokin Date: Tue, 13 Aug 2019 10:28:40 +0200 Subject: [PATCH 20/21] getRoom() will return nullptr if the room id is negative (#2976) --- src/TLuaInterpreter.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/TLuaInterpreter.cpp b/src/TLuaInterpreter.cpp index fd473cf5e8b..4e4c579c419 100644 --- a/src/TLuaInterpreter.cpp +++ b/src/TLuaInterpreter.cpp @@ -4848,6 +4848,10 @@ int TLuaInterpreter::searchRoom(lua_State* L) if (!roomIdsFound.isEmpty()) { for (int i : roomIdsFound) { TRoom* pR = host.mpMap->mpRoomDB->getRoom(i); + if (!pR) { + continue; + } + QString name = pR->name; int roomID = pR->getId(); lua_pushnumber(L, roomID); From a88198d389d23b68bf4855fabe2cd2c48ac48a44 Mon Sep 17 00:00:00 2001 From: Vadim Peretokin Date: Tue, 13 Aug 2019 16:02:18 +0200 Subject: [PATCH 21/21] Add autocomplete toggle (#2679) * Update tooltip, more than IRE now provide maps (#2668) * Add autocomplete toggle to profile * Update to a version of edbee with autocomplete toggle * Wire in the autocomplete toggle * Use correct host variable * Add missing toggle call --- src/Host.cpp | 1 + src/Host.h | 2 ++ src/XMLexport.cpp | 1 + src/XMLimport.cpp | 3 +++ src/dlgProfilePreferences.cpp | 6 +++++- src/dlgTriggerEditor.cpp | 3 +++ src/ui/profile_preferences.ui | 24 ++++++++++++++++++++---- 7 files changed, 35 insertions(+), 5 deletions(-) diff --git a/src/Host.cpp b/src/Host.cpp index 24bffb2b39b..d9cff4ff22f 100644 --- a/src/Host.cpp +++ b/src/Host.cpp @@ -98,6 +98,7 @@ Host::Host(int port, const QString& hostname, const QString& login, const QStrin , mUSE_UNIX_EOL(false) , mWrapAt(100) , mWrapIndentCount(0) +, mEditorAutoComplete(true) , mEditorTheme(QLatin1String("Mudlet")) , mEditorThemeFile(QLatin1String("Mudlet.tmTheme")) , mThemePreviewItemID(-1) diff --git a/src/Host.h b/src/Host.h index c7aa19e412b..031a331d3a4 100644 --- a/src/Host.h +++ b/src/Host.h @@ -336,6 +336,8 @@ class Host : public QObject int mWrapAt; int mWrapIndentCount; + bool mEditorAutoComplete; + // code editor theme (human-friendly name) QString mEditorTheme; // code editor theme file on disk for edbee to load diff --git a/src/XMLexport.cpp b/src/XMLexport.cpp index 8fdeab33165..ba1e14bd691 100644 --- a/src/XMLexport.cpp +++ b/src/XMLexport.cpp @@ -411,6 +411,7 @@ void XMLexport::writeHost(Host* pHost, pugi::xml_node mudletPackage) host.append_attribute("mShowRoomIDs") = pHost->mShowRoomID ? "yes" : "no"; host.append_attribute("mShowPanel") = pHost->mShowPanel ? "yes" : "no"; host.append_attribute("mHaveMapperScript") = pHost->mHaveMapperScript ? "yes" : "no"; + host.append_attribute("mEditorAutoComplete") = pHost->mEditorAutoComplete ? "yes" : "no"; host.append_attribute("mEditorTheme") = pHost->mEditorTheme.toUtf8().constData(); host.append_attribute("mEditorThemeFile") = pHost->mEditorThemeFile.toUtf8().constData(); host.append_attribute("mThemePreviewItemID") = QString::number(pHost->mThemePreviewItemID).toUtf8().constData(); diff --git a/src/XMLimport.cpp b/src/XMLimport.cpp index f76c4f99acc..000caab126c 100644 --- a/src/XMLimport.cpp +++ b/src/XMLimport.cpp @@ -810,6 +810,9 @@ void XMLimport::readHostPackage(Host* pHost) pHost->mShowInfo = (attributes().value("mShowInfo") == "yes"); pHost->mAcceptServerGUI = (attributes().value("mAcceptServerGUI") == "yes"); pHost->mMapperUseAntiAlias = (attributes().value("mMapperUseAntiAlias") == "yes"); + if (attributes().hasAttribute(QStringLiteral("mEditorAutoComplete"))) { + pHost->mEditorAutoComplete = (attributes().value(QStringLiteral("mEditorAutoComplete")) == "yes"); + } if (attributes().hasAttribute(QLatin1String("mEditorTheme"))) { pHost->mEditorTheme = attributes().value(QLatin1String("mEditorTheme")).toString(); } diff --git a/src/dlgProfilePreferences.cpp b/src/dlgProfilePreferences.cpp index da0e57e5c98..9af3b20ca45 100644 --- a/src/dlgProfilePreferences.cpp +++ b/src/dlgProfilePreferences.cpp @@ -1200,8 +1200,9 @@ void dlgProfilePreferences::loadEditorTab() : edbee::TextEditorConfig::HideWhitespaces); config->setUseLineSeparator(mudlet::self()->mEditorTextOptions & QTextOption::ShowLineAndParagraphSeparators); config->setFont(pHost->mDisplayFont); + config->setAutocompleteAutoShow(pHost->mEditorAutoComplete); config->endChanges(); - edbeePreviewWidget->textDocument()->setLanguageGrammar(edbee::Edbee::instance()->grammarManager()->detectGrammarWithFilename(QLatin1Literal("Buck.lua"))); + edbeePreviewWidget->textDocument()->setLanguageGrammar(edbee::Edbee::instance()->grammarManager()->detectGrammarWithFilename(QStringLiteral("Buck.lua"))); // disable shadows as their purpose (notify there is more text) is performed by scrollbars already edbeePreviewWidget->textScrollArea()->enableShadowWidget(false); @@ -1230,6 +1231,8 @@ void dlgProfilePreferences::loadEditorTab() theme_download_label->hide(); + checkBox_autocompleteLuaCode->setChecked(pHost->mEditorAutoComplete); + // changes the theme being previewed connect(code_editor_theme_selection_combobox, static_cast(&QComboBox::currentIndexChanged), this, &dlgProfilePreferences::slot_theme_selected); @@ -2391,6 +2394,7 @@ void dlgProfilePreferences::slot_save_and_exit() pHost->setWideAmbiguousEAsianGlyphs(checkBox_useWideAmbiguousEastAsianGlyphs->checkState()); pHost->mEditorTheme = code_editor_theme_selection_combobox->currentText(); pHost->mEditorThemeFile = code_editor_theme_selection_combobox->currentData().toString(); + pHost->mEditorAutoComplete = checkBox_autocompleteLuaCode->isChecked(); if (pHost->mpEditorDialog) { pHost->mpEditorDialog->setThemeAndOtherSettings(pHost->mEditorTheme); } diff --git a/src/dlgTriggerEditor.cpp b/src/dlgTriggerEditor.cpp index 9d8465262aa..479a339d3c8 100644 --- a/src/dlgTriggerEditor.cpp +++ b/src/dlgTriggerEditor.cpp @@ -567,6 +567,7 @@ dlgTriggerEditor::dlgTriggerEditor(Host* pH) ? edbee::TextEditorConfig::ShowWhitespaces : edbee::TextEditorConfig::HideWhitespaces); config->setUseLineSeparator(mudlet::self()->mEditorTextOptions & QTextOption::ShowLineAndParagraphSeparators); + config->setAutocompleteAutoShow(mpHost->mEditorAutoComplete); config->endChanges(); connect(comboBox_searchTerms, qOverload(&QComboBox::activated), this, &dlgTriggerEditor::slot_searchMudletItems); @@ -8425,6 +8426,7 @@ void dlgTriggerEditor::clearDocument(edbee::TextEditorWidget* ew, const QString& config->setCaretBlinkRate(200); config->setIndentSize(2); config->setCaretWidth(1); + config->setAutocompleteAutoShow(mpHost->mEditorAutoComplete); config->endChanges(); // If undo is not disabled when setting the initial text, the @@ -8448,6 +8450,7 @@ void dlgTriggerEditor::setThemeAndOtherSettings(const QString& theme) ? edbee::TextEditorConfig::ShowWhitespaces : edbee::TextEditorConfig::HideWhitespaces); localConfig->setUseLineSeparator(mudlet::self()->mEditorTextOptions & QTextOption::ShowLineAndParagraphSeparators); + localConfig->setAutocompleteAutoShow(mpHost->mEditorAutoComplete); localConfig->endChanges(); } diff --git a/src/ui/profile_preferences.ui b/src/ui/profile_preferences.ui index 583453b990a..a3df681c8b3 100644 --- a/src/ui/profile_preferences.ui +++ b/src/ui/profile_preferences.ui @@ -42,7 +42,7 @@ QTabWidget::Rounded - 0 + 3 @@ -1172,8 +1172,8 @@ Editor - - + + Theme @@ -1253,7 +1253,23 @@ - + + + + Autocomplete + + + + + + Autocomplete Lua functions in code editor + + + + + + + Qt::Vertical