Change Noir theme & run NSIS uninstaller before upgrade

This commit is contained in:
Alex Spataru 2021-10-13 01:46:12 -05:00
parent d2909a8aa2
commit 836cae2dd5
10 changed files with 196 additions and 25 deletions

View File

@ -162,18 +162,20 @@ Widgets.Window {
text: qsTr("Widget:")
} ComboBox {
id: widget
visible: !showGroupWidget
Layout.fillWidth: true
visible: !showGroupWidget
enabled: !showGroupWidget
model: Cpp_JSON_Editor.availableDatasetLevelWidgets()
currentIndex: Cpp_JSON_Editor.datasetWidgetIndex(group, dataset)
onCurrentIndexChanged: {
if (visible)
if (visible && currentIndex !== Cpp_JSON_Editor.datasetWidgetIndex(group, dataset))
Cpp_JSON_Editor.setDatasetWidget(group, dataset, currentIndex)
}
} TextField {
readOnly: true
Layout.fillWidth: true
visible: showGroupWidget
enabled: showGroupWidget
text: Cpp_JSON_Editor.datasetWidget(group, dataset)
}

View File

@ -53,7 +53,7 @@ DropArea {
// Get dropped file URL and remove prefixed "file://"
var path = drop.urls[0].toString()
if (Qt.platform.os !== "windows")
if (!Cpp_IsWin)
path = path.replace(/^(file:\/{2})/,"");
else
path = path.replace(/^(file:\/{3})/,"");

View File

@ -148,7 +148,7 @@ ApplicationWindow {
title: Cpp_AppName
width: minimumWidth
height: minimumHeight
minimumHeight: Qt.platform.os === "osx" ? 720 : 740
minimumHeight: Cpp_IsMac ? 720 : 740
//
// Theme options
@ -275,13 +275,13 @@ ApplicationWindow {
//
Loader {
asynchronous: false
active: Qt.platform.os !== "osx"
active: !Cpp_IsMac
sourceComponent: PlatformDependent.Menubar {
Component.onCompleted: root.menuBar = this
}
} Loader {
asynchronous: false
active: Qt.platform.os === "osx"
active: Cpp_IsMac
sourceComponent: PlatformDependent.MenubarMacOS {}
}

View File

@ -19,9 +19,9 @@
"placeholderText":"#666666",
"toolbarGradient1":"#323030",
"toolbarGradient2":"#292929",
"menubarGradient1":"#323030",
"menubarGradient2":"#323030",
"menubarText":"#ffffff",
"menubarGradient1":"#ffffff",
"menubarGradient2":"#ffffff",
"menubarText":"#000000",
"dialogBackground":"#f2f2f2",
"consoleText":"#424242",
"consoleBase":"#f2f2f2",

View File

@ -68,8 +68,23 @@ RequestExecutionLevel admin
OutFile "${EXECNAME}-${VERSIONMAJOR}.${VERSIONMINOR}.${VERSIONBUILD}-Windows.exe"
Function .onInit
setShellVarContext all
!insertmacro VerifyUserIsAdmin
setShellVarContext all
!insertmacro VerifyUserIsAdmin
ReadRegStr $R0 HKLM \
"Software\Microsoft\Windows\CurrentVersion\Uninstall\${PROGRAM_NAME}" \
"UninstallString"
StrCmp $R0 "" done
MessageBox MB_OKCANCEL|MB_ICONEXCLAMATION \
"${APPNAME} is already installed. $\n$\nClick `OK` to remove the \
previous version or `Cancel` to cancel this upgrade." \
IDOK uninst
Abort
uninst:
ClearErrors
Exec $INSTDIR\uninstall.exe
FunctionEnd
Section "${APPNAME} (required)" SecDummy

View File

@ -452,9 +452,9 @@ bool Editor::datasetGraph(const int group, const int dataset)
{
auto set = getDataset(group, dataset);
if (set)
return set->m_graph;
return set->graph();
return 0;
return false;
}
/**
@ -468,9 +468,9 @@ bool Editor::datasetFftPlot(const int group, const int dataset)
{
auto set = getDataset(group, dataset);
if (set)
return set->m_fft;
return set->fft();
return 0;
return false;
}
/**
@ -485,9 +485,9 @@ bool Editor::datasetLogPlot(const int group, const int dataset)
{
auto set = getDataset(group, dataset);
if (set)
return set->m_log;
return set->log();
return 0;
return false;
}
/**
@ -500,9 +500,9 @@ QString Editor::datasetTitle(const int group, const int dataset)
{
auto set = getDataset(group, dataset);
if (set)
return set->m_title;
return set->title();
return 0;
return "";
}
/**
@ -515,9 +515,9 @@ QString Editor::datasetUnits(const int group, const int dataset)
{
auto set = getDataset(group, dataset);
if (set)
return set->m_units;
return set->units();
return 0;
return "";
}
/**
@ -530,9 +530,9 @@ QString Editor::datasetWidget(const int group, const int dataset)
{
auto set = getDataset(group, dataset);
if (set)
return set->m_widget;
return set->widget();
return 0;
return "";
}
/**

View File

@ -165,6 +165,18 @@ void ModuleManager::initializeQmlInterface()
auto ioNetwork = IO::DataSources::Network::getInstance();
auto miscThemeManager = Misc::ThemeManager::getInstance();
// Operating system flags
bool isWin = false;
bool isMac = false;
bool isNix = false;
#if defined(Q_OS_MAC)
isMac = true;
#elif defined(Q_OS_WIN)
isWin = true;
#else
isNix = true;
#endif
// Qt version QML flag
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
bool qt6 = false;
@ -181,6 +193,9 @@ void ModuleManager::initializeQmlInterface()
// Register C++ modules with QML
auto c = engine()->rootContext();
c->setContextProperty("Cpp_Qt6", qt6);
c->setContextProperty("Cpp_IsWin", isWin);
c->setContextProperty("Cpp_IsMac", isMac);
c->setContextProperty("Cpp_IsNix", isNix);
c->setContextProperty("Cpp_Updater", updater);
c->setContextProperty("Cpp_IO_Serial", ioSerial);
c->setContextProperty("Cpp_CSV_Export", csvExport);

View File

@ -0,0 +1,92 @@
/*
* Copyright (c) 2020-2021 Alex Spataru <https://github.com/alex-spataru>
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
#include "Map.h"
#include "UI/Dashboard.h"
#include "Misc/ThemeManager.h"
using namespace Widgets;
/**
* Generates the user interface elements & layout
*/
Map::Map(const int index)
: m_index(index)
{
// Get pointers to serial studio modules
auto dash = UI::Dashboard::getInstance();
auto theme = Misc::ThemeManager::getInstance();
// Invalid index, abort initialization
if (m_index < 0 || m_index >= dash->mapCount())
return;
// Set window palette
QPalette palette;
palette.setColor(QPalette::Base, theme->widgetWindowBackground());
palette.setColor(QPalette::Window, theme->widgetWindowBackground());
setPalette(palette);
// Configure layout
m_layout.setContentsMargins(12, 12, 12, 12);
setLayout(&m_layout);
// React to dashboard events
connect(dash, SIGNAL(updated()), this, SLOT(updateData()));
}
/**
* Checks if the widget is enabled, if so, the widget shall be updated
* to display the latest data frame.
*
* If the widget is disabled (e.g. the user hides it, or the external
* window is hidden), then the widget shall ignore the update request.
*/
void Map::updateData()
{
// Widget not enabled, do nothing
if (!isEnabled())
return;
// Get group pointer
auto dash = UI::Dashboard::getInstance();
auto group = dash->getGroups(m_index);
if (!group)
return;
// Get latitiude/longitude from datasets
qreal lat = 0;
qreal lon = 0;
for (int i = 0; i < group->datasetCount(); ++i)
{
auto dataset = group->getDataset(i);
if (dataset)
{
if (dataset->widget() == "lat")
lat = dataset->value().toDouble();
else if (dataset->widget() == "lon")
lon = dataset->value().toDouble();
}
}
// Update map coordinates
}

View File

@ -0,0 +1,47 @@
/*
* Copyright (c) 2020-2021 Alex Spataru <https://github.com/alex-spataru>
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
#ifndef WIDGETS_MAP_H
#define WIDGETS_MAP_H
#include <QWidget>
#include <QVBoxLayout>
namespace Widgets
{
class Map : public QWidget
{
Q_OBJECT
public:
Map(const int index = -1);
private slots:
void updateData();
private:
int m_index;
QVBoxLayout m_layout;
};
}
#endif

View File

@ -23,6 +23,7 @@
#include "WidgetLoader.h"
#include "Bar.h"
#include "Map.h"
#include "Plot.h"
#include "Gauge.h"
#include "Compass.h"
@ -32,7 +33,6 @@
#include "MultiPlot.h"
#include "Accelerometer.h"
#include <QPushButton>
#include <QApplication>
#include <UI/Dashboard.h>
#include <Misc/ThemeManager.h>
@ -266,7 +266,7 @@ void WidgetLoader::setWidgetIndex(const int index)
m_widget = new Accelerometer(relativeIndex());
break;
case UI::Dashboard::WidgetType::Map:
m_widget = new QPushButton("Map");
m_widget = new Map(relativeIndex());
break;
default:
break;