diff --git a/README.txt b/README.txt index 06ad208..a8d9c57 100644 --- a/README.txt +++ b/README.txt @@ -6,7 +6,7 @@ installation, you must certify that your system is Debian based (or at least uses apt-get) and that you have an active Internet connection. It is important to note that you should also have the control commands for the function generator already installed, but you can always install them later (please -refer to the packages "gf2-1.1.tar.gz" or "gf2-1.0.tar.gz" to do so). +refer to the package "gf2-2.0.tar.gz" to do so). A list of the included scripts follows: – install.sh; @@ -15,16 +15,15 @@ A list of the included scripts follows: In order to compile and install GF2 GUI for the first time, all you have to do is to run "install.sh" by invoking "sudo ./install.sh" on a terminal window, after changing your working directory to the current one. This script will -first obtain and install the required "build-essential" and "qt5-default" -packages (if they are not installed yet). Then it will compile the application -and move it to "/usr/local/bin/". +first obtain and install the required "build-essential" and +"qt5-default"/"qtbase5-dev" packages (if they are not installed yet). Then it +will compile the application and move it to "/usr/local/bin/". Conversely, to uninstall, you should run "uninstall.sh" by invoking "sudo ./uninstall.sh", again on a terminal window after making sure that your working directory is this one. This will delete the previously installed -application and source code. However it won't remove the "build-essential" and -"qt5-default" packages, since they could be already installed prior to the -first installation. +application and source code. However it won't remove the packages mentioned +above, since they could be already installed before the first installation. P.S.: Since the GUI was designed having KDE in mind, you should get the best diff --git a/install.sh b/install.sh index 4c2f852..443d9ef 100644 --- a/install.sh +++ b/install.sh @@ -4,20 +4,24 @@ echo Obtaining required packages... apt-get -qq update apt-get -qq install build-essential apt-get -qq install qt5-default +apt-get -qq install qtbase5-dev echo Copying source code files... mkdir -p /usr/local/src/gf2-gui/icons +mkdir -p /usr/local/src/gf2-gui/misc cp -f src/about.cpp /usr/local/src/gf2-gui/. cp -f src/about.h /usr/local/src/gf2-gui/. cp -f src/about.ui /usr/local/src/gf2-gui/. cp -f src/gf2-gui.pro /usr/local/src/gf2-gui/. cp -f src/GPL.txt /usr/local/src/gf2-gui/. cp -f src/icons/active64.png /usr/local/src/gf2-gui/icons/. +cp -f src/icons/gf2-gui.png /usr/local/src/gf2-gui/icons/. cp -f src/icons/greyed64.png /usr/local/src/gf2-gui/icons/. cp -f src/icons/selected64.png /usr/local/src/gf2-gui/icons/. cp -f src/main.cpp /usr/local/src/gf2-gui/. cp -f src/mainwindow.cpp /usr/local/src/gf2-gui/. cp -f src/mainwindow.h /usr/local/src/gf2-gui/. cp -f src/mainwindow.ui /usr/local/src/gf2-gui/. +cp -f src/misc/gf2-gui.desktop /usr/local/src/gf2-gui/misc/. cp -f src/resources.qrc /usr/local/src/gf2-gui/. cp -f src/README.txt /usr/local/src/gf2-gui/. cp -f src/serial.cpp /usr/local/src/gf2-gui/. @@ -26,6 +30,6 @@ cp -f src/serial.ui /usr/local/src/gf2-gui/. echo Building and installing application... cd /usr/local/src/gf2-gui qmake -make all clean -mv -f gf2-gui /usr/local/bin/. +make install clean +rm -f gf2-gui echo Done! diff --git a/src/README.txt b/src/README.txt index a0e2d08..0531d28 100644 --- a/src/README.txt +++ b/src/README.txt @@ -5,24 +5,37 @@ of relevant files follows: – about.ui; – gf2-gui.pro; – icons/active64.png +– icons/gf2-gui.png – icons/greyed64.png – icons/selected64.png – main.cpp; – mainwindow.cpp; – mainwindow.h; – mainwindow.ui; +– misc/gf2-gui.desktop; – resources.qrc; – serial.cpp; – serial.h; – serial.ui. In order to compile successfully, you must have the packages "build-essential" -and "qt5-default" already installed. Given that, if you wish to simply -compile, change your working directory to the current one on a terminal -window, and invoke "qmake", followed by "make" or "make all". Notice that -invoking "qmake" is necessary to generate the Makefile, but only needs to be -done once. +and "qt5-default" (or "qtbase5-dev") already installed. Given that, if you +wish to simply compile, change your working directory to the current one on a +terminal window, and invoke "qmake", followed by "make" or "make all". Notice +that invoking "qmake" is necessary to generate the Makefile, but only needs to +be done once. + +You can also install using make. To do so, after invoking "qmake", you should +simply run "sudo make install". If you wish to force a rebuild before the +installation, then you must invoke "sudo make clean install" instead. It may be necessary to undo any previous operations. Invoking "make clean" will delete all object code generated during earlier compilations. However, -the previously generated binary is preserved. +the previously generated binary is preserved. It is important to note that it +is possible to undo previous installation operations as well, by invoking +"sudo make uninstall". Such approach is not recommended, though. + +P.S.: +Notice that any make operation containing the actions "install" or "uninstall" +(e.g. "make install" or "make uninstall") requires root permissions, or in +other words, must be run with sudo. diff --git a/src/about.cpp b/src/about.cpp index f1a44b6..5d74e23 100644 --- a/src/about.cpp +++ b/src/about.cpp @@ -1,5 +1,5 @@ -/* GF2 GUI - Version 2.0 for Debian Linux - Copyright (c) 2018-2019 Samuel Lourenço +/* GF2 GUI - Version 2.1 for Debian Linux + Copyright (c) 2018-2024 Samuel Lourenço This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free diff --git a/src/about.h b/src/about.h index 8b4da0d..7bad4ba 100644 --- a/src/about.h +++ b/src/about.h @@ -1,5 +1,5 @@ -/* GF2 GUI - Version 2.0 for Debian Linux - Copyright (c) 2018-2019 Samuel Lourenço +/* GF2 GUI - Version 2.1 for Debian Linux + Copyright (c) 2018-2024 Samuel Lourenço This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free diff --git a/src/about.ui b/src/about.ui index fb00eea..880ab5e 100644 --- a/src/about.ui +++ b/src/about.ui @@ -49,7 +49,7 @@ - <html><head/><body><p>GF2 Graphical User Interface - Version 2.0<br/>Copyright © 2018-2019 Samuel Lourenço</p><p>This program is distributed under the terms of the <a href="http://www.gnu.org/licenses/gpl-3.0-standalone.html"><span style=" text-decoration: underline; color:#2980b9;">GNU GPL v3</span></a>.</p></body></html> + <html><head/><body><p>GF2 Graphical User Interface - Version 2.1<br/>Copyright © 2018-2024 Samuel Lourenço</p><p>This program is distributed under the terms of the <a href="http://www.gnu.org/licenses/gpl-3.0-standalone.html"><span style=" text-decoration: underline; color:#2980b9;">GNU GPL v3</span></a>.</p></body></html> Qt::AlignJustify|Qt::AlignTop diff --git a/src/gf2-gui.pro b/src/gf2-gui.pro index 0ca0782..988b3dc 100644 --- a/src/gf2-gui.pro +++ b/src/gf2-gui.pro @@ -8,22 +8,62 @@ QT += core gui xml greaterThan(QT_MAJOR_VERSION, 4): QT += widgets +# Added to provide backwards compatibility (C++11 support) +greaterThan(QT_MAJOR_VERSION, 4) { + CONFIG += c++11 +} else { + QMAKE_CXXFLAGS += -std=c++11 +} + TARGET = gf2-gui TEMPLATE = app +# The following define makes your compiler emit warnings if you use +# any Qt feature that has been marked deprecated (the exact warnings +# depend on your compiler). Please consult the documentation of the +# deprecated API in order to know how to port your code away from it. +DEFINES += QT_DEPRECATED_WARNINGS + +# You can also make your code fail to compile if it uses deprecated APIs. +# In order to do so, uncomment the following line. +# You can also select to disable deprecated APIs only up to a certain version of Qt. +#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0 -SOURCES += main.cpp\ - mainwindow.cpp \ +SOURCES += \ + main.cpp\ + mainwindow.cpp \ serial.cpp \ about.cpp -HEADERS += mainwindow.h \ +HEADERS += \ + mainwindow.h \ serial.h \ about.h -FORMS += mainwindow.ui \ +FORMS += \ + mainwindow.ui \ about.ui \ serial.ui RESOURCES += \ resources.qrc + +# Added installation option +unix { + isEmpty(PREFIX) { + PREFIX = /usr/local + } + target.path = $$PREFIX/bin + icon.files += icons/gf2-gui.png + icon.path = $$PREFIX/share/icons/hicolor/128x128/apps + shortcut.files = misc/gf2-gui.desktop + shortcut.path = $$PREFIX/share/applications + INSTALLS += icon + INSTALLS += shortcut +} + +!isEmpty(target.path): INSTALLS += target + +DISTFILES += \ + icons/gf2-gui.png \ + misc/gf2-gui.desktop diff --git a/src/icons/gf2-gui.png b/src/icons/gf2-gui.png new file mode 100644 index 0000000..e7d87e0 Binary files /dev/null and b/src/icons/gf2-gui.png differ diff --git a/src/main.cpp b/src/main.cpp index dc2606b..4da1885 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1,5 +1,5 @@ -/* GF2 GUI - Version 2.0 for Debian Linux - Copyright (c) 2018-2019 Samuel Lourenço +/* GF2 GUI - Version 2.1 for Debian Linux + Copyright (c) 2018-2024 Samuel Lourenço This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 3d4f440..5511f99 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -1,5 +1,5 @@ -/* GF2 GUI - Version 2.0 for Debian Linux - Copyright (c) 2018-2019 Samuel Lourenço +/* GF2 GUI - Version 2.1 for Debian Linux + Copyright (c) 2018-2024 Samuel Lourenço This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free @@ -55,8 +55,7 @@ void MainWindow::on_actionLoad_triggered() QFile file(filename); if (!file.open(QIODevice::ReadOnly | QIODevice::Text)) { - QMessageBox errorRead; - errorRead.critical(this, tr("Error"), tr("Could not read from %1.\n\nPlease verify that you have read access to this file.").arg(QDir::toNativeSeparators(filename))); + QMessageBox::critical(this, tr("Error"), tr("Could not read from %1.\n\nPlease verify that you have read access to this file.").arg(QDir::toNativeSeparators(filename))); } else { @@ -65,24 +64,21 @@ void MainWindow::on_actionLoad_triggered() file.close(); if (error) { - QMessageBox errorInvalid; - errorInvalid.critical(this, tr("Error"), tr("Invalid XML. The file might be corrupted or incomplete.")); + QMessageBox::critical(this, tr("Error"), tr("Invalid XML. The file might be corrupted or incomplete.")); } else { QDomElement root = document.firstChildElement(); if (root.tagName() != "settings" || root.attribute("target") != "GF2") { - QMessageBox errorNoSettings; - errorNoSettings.critical(this, tr("Error"), tr("The selected file is not a GF2 settings file.")); + QMessageBox::critical(this, tr("Error"), tr("The selected file is not a GF2 settings file.")); } else { int errorcount = implementSettings(root); if (errorcount > 0) { - QMessageBox warningDebug; - warningDebug.warning(this, tr("Warning"), tr("Found %1 setting(s) with invalid attribute values.\n\nPlease check your settings file for out-of-bounds or unsupported attribute values.").arg(errorcount)); + QMessageBox::warning(this, tr("Warning"), tr("Found %1 setting(s) with invalid attribute values.\n\nPlease check your settings file for out-of-bounds or unsupported attribute values.").arg(errorcount)); } filepath_ = filename; } @@ -134,8 +130,7 @@ void MainWindow::on_actionSave_triggered() QFile file(filename); if (!file.open(QIODevice::WriteOnly | QIODevice::Text)) { - QMessageBox errorWrite; - errorWrite.critical(this, tr("Error"), tr("Could not write to %1.\n\nPlease verify that you have write access to this file.").arg(QDir::toNativeSeparators(filename))); + QMessageBox::critical(this, tr("Error"), tr("Could not write to %1.\n\nPlease verify that you have write access to this file.").arg(QDir::toNativeSeparators(filename))); } else { @@ -152,13 +147,13 @@ void MainWindow::on_actionSerial_triggered() { Serial serial; serial.setSerialLineEditText(serialstr_); - if (serial.exec() == QDialog::Accepted) - { + if (serial.exec() == QDialog::Accepted) { + QString title = tr("GF2 Function Generator"); serialstr_ = serial.serialLineEditText(); - if (serialstr_.isEmpty()) - this->setWindowTitle("GF2 Function Generator"); - else - this->setWindowTitle("GF2 Function Generator (S/N: " + serialstr_ + ")"); + if (!serialstr_.isEmpty()) { + title.append(tr(" (S/N: %1)").arg(serialstr_)); + } + this->setWindowTitle(title); } } diff --git a/src/mainwindow.h b/src/mainwindow.h index c078ba5..6ddb17f 100644 --- a/src/mainwindow.h +++ b/src/mainwindow.h @@ -1,5 +1,5 @@ -/* GF2 GUI - Version 2.0 for Debian Linux - Copyright (c) 2018-2019 Samuel Lourenço +/* GF2 GUI - Version 2.1 for Debian Linux + Copyright (c) 2018-2024 Samuel Lourenço This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free diff --git a/src/misc/gf2-gui.desktop b/src/misc/gf2-gui.desktop new file mode 100644 index 0000000..cb588bd --- /dev/null +++ b/src/misc/gf2-gui.desktop @@ -0,0 +1,8 @@ +[Desktop Entry] +Type=Application +Version=1.0 +Name=GF2 GUI +Icon=gf2-gui +Exec=gf2-gui +Terminal=false +Categories=Development;Electronics; diff --git a/src/serial.cpp b/src/serial.cpp index e1513d7..b1f557a 100644 --- a/src/serial.cpp +++ b/src/serial.cpp @@ -1,5 +1,5 @@ -/* GF2 GUI - Version 2.0 for Debian Linux - Copyright (c) 2018 Samuel Lourenço +/* GF2 GUI - Version 2.1 for Debian Linux + Copyright (c) 2018-2024 Samuel Lourenço This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free @@ -20,6 +20,8 @@ // Includes #include +#include +#include #include "serial.h" #include "ui_serial.h" diff --git a/src/serial.h b/src/serial.h index 26974a6..8eca19c 100644 --- a/src/serial.h +++ b/src/serial.h @@ -1,5 +1,5 @@ -/* GF2 GUI - Version 2.0 for Debian Linux - Copyright (c) 2018-2019 Samuel Lourenço +/* GF2 GUI - Version 2.1 for Debian Linux + Copyright (c) 2018-2024 Samuel Lourenço This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free diff --git a/uninstall.sh b/uninstall.sh index 37414cb..735ed0d 100644 --- a/uninstall.sh +++ b/uninstall.sh @@ -1,6 +1,13 @@ #!/bin/sh echo Removing application... +rm -f /usr/local/share/applications/gf2-gui.desktop +rmdir --ignore-fail-on-non-empty /usr/local/share/applications +rm -f /usr/local/share/icons/hicolor/128x128/apps/gf2-gui.png +rmdir --ignore-fail-on-non-empty /usr/local/share/icons/hicolor/128x128/apps +rmdir --ignore-fail-on-non-empty /usr/local/share/icons/hicolor/128x128 +rmdir --ignore-fail-on-non-empty /usr/local/share/icons/hicolor +rmdir --ignore-fail-on-non-empty /usr/local/share/icons rm -f /usr/local/bin/gf2-gui echo Removing source code files... rm -rf /usr/local/src/gf2-gui