Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
cmake_minimum_required(VERSION 3.11)
project(qtdmm VERSION "1.0.0" HOMEPAGE_URL "https://github.com/tuxmaster/QtDMM/" LANGUAGES CXX)
project(qtdmm VERSION "0.0.0" HOMEPAGE_URL "https://github.com/tuxmaster/QtDMM/" LANGUAGES CXX)

## main settings
set(CMAKE_CXX_STANDARD 17)
Expand All @@ -11,6 +11,7 @@ set(APP_NAME "QtDMM")
set(APP_ORGANIZATION "QtDMM")
set(QT_COMPONENTS Widgets SerialPort PrintSupport Test LinguistTools Network)

include( cmake/git_version.cmake )

## get files
file(GLOB TRANSLATIONS CONFIGURE_DEPENDS assets/translations/${PROJECT_NAME}_*.ts)
Expand Down
2 changes: 1 addition & 1 deletion QtDMM.spec
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Name: qtdmm
Version: 1.0.0
Version: 1.0.0-alpha.1+dc7490a
Release: 1%{?dist}
Summary: DMM Readout Software Including a Configurable Recorder.

Expand Down
39 changes: 27 additions & 12 deletions assets/translations/qtdmm_de.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,24 +4,24 @@
<context>
<name>ConfigDlg</name>
<message>
<location filename="../../src/configdlg.cpp" line="56"/>
<location filename="../../src/configdlg.cpp" line="81"/>
<location filename="../../src/configdlg.cpp" line="102"/>
<location filename="../../src/configdlg.cpp" line="54"/>
<location filename="../../src/configdlg.cpp" line="79"/>
<location filename="../../src/configdlg.cpp" line="100"/>
<source>QtDMM: Welcome!</source>
<translation>QtDMM: Willkommen!</translation>
</message>
<message>
<location filename="../../src/configdlg.cpp" line="57"/>
<location filename="../../src/configdlg.cpp" line="55"/>
<source>&lt;font size=+2&gt;&lt;b&gt;Welcome!&lt;/b&gt;&lt;/font&gt;&lt;p&gt;This seems to be your first invocation of QtDMM (Or you have deleted its configuration file).&lt;p&gt;QtDMM has created the file %1 in your home directory to save its settings.</source>
<translation>&lt;font size+2&gt;&lt;b&gt;Willkommen!&lt;/b&gt;&lt;/font&gt;&lt;p&gt;Dies scheint der erste Aufruf von QtDMM zu sein, bzw. die Konfigurstion wurde gelöscht.&lt;p&gt;QtDMM hate eine neue Datei unter dem Pfad %1 angelegt.</translation>
</message>
<message>
<location filename="../../src/configdlg.cpp" line="82"/>
<location filename="../../src/configdlg.cpp" line="80"/>
<source>&lt;font size=+2&gt;&lt;b&gt;Welcome!&lt;/b&gt;&lt;/font&gt;&lt;p&gt;You seem to have upgraded &lt;b&gt;QtDMM&lt;/b&gt; from a version prior to 0.8.4. Please check your configuration. There are some new parameters to be configured.&lt;p&gt;Thank you for choosing &lt;b&gt;QtDMM&lt;/b&gt;.&lt;p&gt;&lt;i&gt;Matthias Toussaint&lt;/i&gt;</source>
<translation>&lt;font size=+2&gt;&lt;b&gt;Willkommen!&lt;/b&gt;&lt;p&gt;Wie es ausschaut, wurde &lt;b&gt;QtDMM&lt;/b&gt; von einer Version vor 0.8.4 aktualisiert. Bitte überprüfen Sie die Konfiguration. Es gibt einige neue Parameter.&lt;p&gt;Danke das Sie &lt;b&gt;QtDMM&lt;/b&gt; benutzen.&lt;p&gt;&lt;i&gt;Matthias Toussaint&lt;/i&gt;</translation>
</message>
<message>
<location filename="../../src/configdlg.cpp" line="103"/>
<location filename="../../src/configdlg.cpp" line="101"/>
<source>Your config file has been converted to the new format.
Please check your color settings, because they couldn&apos;t be converted automatically.
Your old config ~/.qtdmmrc was renamed to ~/.qtdmmrc.old.</source>
Expand All @@ -34,8 +34,8 @@ Die Datei ~/.qtdmmtc wurden zu ~/.qtdmmrc.old umbenannt.</translation>
<translation type="vanished">&lt;font size+2&gt;&lt;b&gt;Willkommen!&lt;/b&gt;&lt;/font&gt;&lt;p&gt;Dies scheint der erste Aufruf von QtDMM zu sein, bzw. die Konfigurstion wurde gelöscht.&lt;p&gt;QtDMM hate eine neue Datei unter dem Pfad %1 angelegt.</translation>
</message>
<message>
<location filename="../../src/configdlg.cpp" line="69"/>
<location filename="../../src/configdlg.cpp" line="94"/>
<location filename="../../src/configdlg.cpp" line="67"/>
<location filename="../../src/configdlg.cpp" line="92"/>
<source>Continue</source>
<translation>Fortsetzen</translation>
</message>
Expand Down Expand Up @@ -488,12 +488,12 @@ Ist das DMM angeschlossen und eingeschaltet?</translation>
<context>
<name>MainWin</name>
<message>
<location filename="../../src/mainwin.cpp" line="166"/>
<location filename="../../src/mainwin.cpp" line="173"/>
<source>QtDMM: Welcome!</source>
<translation>QtDMM: Willkommen!</translation>
</message>
<message>
<location filename="../../src/mainwin.cpp" line="166"/>
<location filename="../../src/mainwin.cpp" line="173"/>
<source>&lt;h1&gt;QtDMM %1&lt;/h1&gt;&lt;hr&gt;&lt;div align=right&gt;&lt;i&gt;A simple recorder for DMM&apos;s&lt;/i&gt;&lt;/div&gt;&lt;p&gt;&lt;div align=justify&gt;A simple display software for a variety of digital multimeter. Currently confirmed are:&lt;table&gt;%2&lt;/table&gt;Other compatible models may work also.&lt;p&gt;QtDMM features min/max memory and a configurable recorder with import/export and printing function. Sampling may be started manually, at a given time or triggered by a measured threshold. Additionally an external program may be started when given thresholds are reached.&lt;/div&gt;&lt;div align=justify&gt;&lt;b&gt;QtDMM&lt;/b&gt; uses the platform independent toolkit &lt;b&gt;Qt&lt;/b&gt; version %3 and is licensed under &lt;b&gt;GPL 3&lt;/b&gt; (Versions prior to v0.9.0 where licensed under GPL 2)&lt;/div&gt;&lt;br&gt;&amp;copy; 2001-2014 Matthias Toussaint &amp;nbsp;-&amp;nbsp;&amp;nbsp;&lt;font color=blue&gt;&lt;u&gt;&lt;a href=&apos;mailto:qtdmm@mtoussaint.de&apos;&gt;qtdmm@mtoussaint.de&lt;/a&gt;&lt;/u&gt;&lt;/font&gt;&lt;p&gt;&lt;br&gt;The icons (except the DMM icon) have been taken from the KDE project.&lt;p&gt;</source>
<translation>&lt;h1&gt;QtDMM %1&lt;/h1&gt;&lt;hr&gt;&lt;div align=right&gt;&lt;i&gt;Ein einfacher Datenrekorder für DMM&lt;/i&gt;&lt;/div&gt;&lt;p&gt;&lt;div align=justify&gt;Ein einfaches Anzeigeprogramm für eine Vielzahl von DMM&apos;s. Aktuell bestätigt sind:&lt;table&gt;%2&lt;/table&gt;Andere kompatible Modelle sollten ebenfalls funktionieren.&lt;p&gt;QtDMM stellt die Funktionen Min/Max Werte halten, ein konfigurierbaren Datenrekorder mit Daten im/export Funktion sowie ein Druckfunktion zur Verfügung. Die Datenaufzeichnung kann manuell, durch einen Grenzwert oder durch eine Zeitfunktion ausgelöst werden. Desweiteren kann ein externes Programm beim erreichen eines Grenzwertes gestartet werden.&lt;/div&gt;&lt;div align=justify&gt;&lt;b&gt;QtDMM&lt;/b&gt; wurde mit der Platformunabhängigen &lt;b&gt;Qt&lt;/b&gt; Bibliothek in der Version %3 welche unter der &lt;b&gt;GPLv3&lt;/b&gt; lizensiert ist erstellt.(Versionen vor 0.9.0 wurden unter der GPLv2 Lizenz veröffentlicht)&lt;/div&gt;&lt;br&gt;&amp;copy; 2001-2014 Matthias Toussaint &amp;nbsp;-&amp;nbsp;&amp;nbsp;&lt;font color=blue&gt;&lt;u&gt;&lt;a href=&apos;mailto:qtdmm@mtoussaint.de&apos;&gt;qtdmm@mtoussaint.de&lt;/a&gt;&lt;/u&gt;&lt;/font&gt;&lt;p&gt;&lt;br&gt;Die Symbole (bis auf das DMM Symbol) stammen von dem KDE Projekt.&lt;p&gt;</translation>
</message>
Expand Down Expand Up @@ -527,12 +527,27 @@ Ist das DMM angeschlossen und eingeschaltet?</translation>
<context>
<name>QObject</name>
<message>
<location filename="../../src/main.cpp" line="140"/>
<location filename="../../src/main.cpp" line="125"/>
<source>protocol debugging information</source>
<translation>Protokol debugging Informationen</translation>
</message>
<message>
<location filename="../../src/main.cpp" line="126"/>
<source>sets directory where config files are located</source>
<translation>setzt das Verzeichnis wo die Konfiguration sich befindet</translation>
</message>
<message>
<location filename="../../src/main.cpp" line="127"/>
<source>sets &lt;config-id&gt;</source>
<translation type="unfinished">setzt die &lt;config-id&gt;</translation>
</message>
<message>
<location filename="../../src/main.cpp" line="61"/>
<source>Missing Permission</source>
<translation>Berechtigung fehlt</translation>
</message>
<message>
<location filename="../../src/main.cpp" line="141"/>
<location filename="../../src/main.cpp" line="62"/>
<source>The current user is not a member of the &apos;dialout&apos; group.
Please add the user with the following command:

Expand Down
49 changes: 49 additions & 0 deletions cmake/git_version.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
# get version
function(get_version_from_git)
find_package(Git QUIET)
if(NOT Git_FOUND)
message(WARNING "Git not found")
return()
endif()

execute_process(
COMMAND ${GIT_EXECUTABLE} describe --tags --always
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
OUTPUT_VARIABLE GIT_TAG
OUTPUT_STRIP_TRAILING_WHITESPACE
RESULT_VARIABLE GIT_RESULT
)

if(NOT GIT_RESULT EQUAL 0)
message(WARNING "Failed to get git tag")
return()
endif()

execute_process(
COMMAND ${GIT_EXECUTABLE} rev-parse --short=7 HEAD
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
OUTPUT_VARIABLE GIT_COMMIT_SHORT_HASH
OUTPUT_STRIP_TRAILING_WHITESPACE
)

string(REGEX REPLACE "^v" "" CLEAN_TAG "${GIT_TAG}")
if(CLEAN_TAG MATCHES "^([0-9]+)\\.([0-9]+)\\.([0-9]+)(-.*)?$")

set(PROJECT_VERSION_MAJOR ${CMAKE_MATCH_1})
set(PROJECT_VERSION_MAJOR ${PROJECT_VERSION_MAJOR} PARENT_SCOPE)
set(PROJECT_VERSION_MINOR ${CMAKE_MATCH_2})
set(PROJECT_VERSION_MINOR ${PROJECT_VERSION_MINOR} PARENT_SCOPE)
set(PROJECT_VERSION_PATCH "${CMAKE_MATCH_3}${CMAKE_MATCH_4}+${GIT_COMMIT_SHORT_HASH}")
set(PROJECT_VERSION_PATCH "${PROJECT_VERSION_PATCH}" PARENT_SCOPE)

set(FULL_VERSION "${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}.${PROJECT_VERSION_PATCH}" )
set(FULL_VERSION "${FULL_VERSION}" PARENT_SCOPE)
set(PROJECT_VERSION "${FULL_VERSION}")
set(PROJECT_VERSION "${FULL_VERSION}" PARENT_SCOPE)
message( STATUS "QtDMM version: ${FULL_VERSION}" )
else()
message(WARNING "Tag '${CLEAN_TAG}' does not match semver format")
endif()
endfunction()

get_version_from_git()
6 changes: 2 additions & 4 deletions src/configdlg.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,14 +39,12 @@
#include <iostream>


ConfigDlg::ConfigDlg(QWidget *parent) : QDialog(parent)
ConfigDlg::ConfigDlg(QString session_id, QString config_path, QWidget *parent) : QDialog(parent)
{
m_buttonBox_OK = false;
setupUi(this);

QString path = QString("%1/.qtdmmrc").arg(QDir::homePath());

m_settings = new Settings(this, path);
m_settings = new Settings(this, session_id, config_path);

// Check if configuration file exists. If not welcome user

Expand Down
2 changes: 1 addition & 1 deletion src/configdlg.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ class ConfigDlg : public QDialog, private Ui::UIConfigDlg
NumItems,
};

ConfigDlg(QWidget *parent = Q_NULLPTR);
ConfigDlg(QString session_id, QString config_path, QWidget *parent = Q_NULLPTR);
Settings *getSettings() { return m_settings; }
QString device() const;
int speed() const;
Expand Down
85 changes: 38 additions & 47 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,23 +28,23 @@

#include "mainwin.h"

#ifdef Q_OS_LINUX
bool userInGroup(const char* groupname)
void checkUserInDailOutGroup()
{
#ifdef Q_OS_LINUX
const char* groupname = "dialout";
struct passwd* pw = getpwuid(geteuid());
if (!pw) return false;
if (!pw) return; // check not applicable

gid_t* groups;
int ngroups = 0;

// Erste Abfrage, um die Anzahl der Gruppen zu bekommen
getgrouplist(pw->pw_name, pw->pw_gid, nullptr, &ngroups);

groups = new gid_t[ngroups];
if (getgrouplist(pw->pw_name, pw->pw_gid, groups, &ngroups) == -1)
{
delete[] groups;
return false;
return; // cannot get groups
}

for (int i = 0; i < ngroups; ++i)
Expand All @@ -53,16 +53,22 @@ bool userInGroup(const char* groupname)
if (gr && strcmp(gr->gr_name, groupname) == 0)
{
delete[] groups;
return true;
return; // ok
}
}

delete[] groups;
return false;
}
QMessageBox::critical(nullptr, QObject::tr("Missing Permission"),
QObject::tr("The current user is not a member of the 'dialout' group.\n"
"Please add the user with the following command:\n\n"
"sudo usermod -aG dialout $USER\n\n"
"You need to log out and back in for the changes to take effect."));

#endif
}


void myMessageOutput(QtMsgType type, const QMessageLogContext &, const QString &msg)
void qtdmmMessageOutput(QtMsgType type, const QMessageLogContext &, const QString &msg)
{
switch (type)
{
Expand All @@ -88,62 +94,47 @@ void myMessageOutput(QtMsgType type, const QMessageLogContext &, const QString &
}
}

void printHelp()

void initTranslation(QApplication *app,QTranslator *QtTranslation, QTranslator *AppTranslation)
{
std::cerr << "Usage: qtdmm [--help|--debug|--print]" << std::endl;
std::cerr << " --help : print this message" << std::endl;
std::cerr << " --debug : protocoll debugging information" << std::endl;
std::cerr << " --print : send DMM reading to standard output" << std::endl;
exit(0);
}
if (QtTranslation->load(QString("qt_%1").arg(QLocale::system().name()), QLibraryInfo::path(QLibraryInfo::TranslationsPath)))
app->installTranslator(QtTranslation);
else
qWarning() << "Could not load Qt translation!";

if (AppTranslation->load(QString("%1").arg(QLocale::system().name()), ":/Translations")) //
app->installTranslator(AppTranslation);
else
qWarning() << "Could not load App translation!";
}

int main(int argc, char **argv)
{
qInstallMessageHandler(myMessageOutput);
qInstallMessageHandler(qtdmmMessageOutput);
QApplication app(argc, argv);
QTranslator QtTranslation;
QTranslator AppTranslation;
QCommandLineParser parser;

app.setApplicationName(APP_NAME);
app.setApplicationVersion(APP_VERSION);
app.setOrganizationName(APP_ORGANIZATION);

// translation
QTranslator QtTranslation;
if (QtTranslation.load(QString("qt_%1").arg(QLocale::system().name()), QLibraryInfo::path(QLibraryInfo::TranslationsPath)))
app.installTranslator(&QtTranslation);
else
qWarning() << "Could not load Qt translation!";

QTranslator AppTranslation;
if (AppTranslation.load(QString("%1").arg(QLocale::system().name()), ":/Translations")) //
app.installTranslator(&AppTranslation);
else
qWarning() << "Could not load App translation!";

MainWin mainWin;
initTranslation(&app,&QtTranslation,&AppTranslation);

QCommandLineParser parser;
parser.addOption(QCommandLineOption("debug"));
parser.addOption(QCommandLineOption("help"));
parser.addOption(QCommandLineOption("print"));
parser.addOption({"debug", QObject::tr("protocol debugging information")});
parser.addOption({"config-dir",QObject::tr("sets directory where config files are located"), "config-dir"});
parser.addOption({"config-id",QObject::tr("sets <config-id>"), "config-id"});
parser.addHelpOption();
parser.addVersionOption();
parser.process(app);

if (parser.isSet("debug"))
mainWin.setConsoleLogging(true);

MainWin mainWin(parser);

mainWin.show();
mainWin.move(100, 100);

#ifdef Q_OS_LINUX
if (!userInGroup("dialout")) {
QMessageBox::critical(nullptr, QObject::tr("Missing Permission"),
QObject::tr("The current user is not a member of the 'dialout' group.\n"
"Please add the user with the following command:\n\n"
"sudo usermod -aG dialout $USER\n\n"
"You need to log out and back in for the changes to take effect."));
}
#endif
checkUserInDailOutGroup();

return app.exec();
}
4 changes: 2 additions & 2 deletions src/mainwid.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
#include "displaywid.h"
#include "tipdlg.h"

MainWid::MainWid(QWidget *parent) : QFrame(parent),
MainWid::MainWid(QString session_id, QString config_path, QWidget *parent) : QFrame(parent),
m_display(0),
m_tipDlg(0)
{
Expand All @@ -42,7 +42,7 @@ MainWid::MainWid(QWidget *parent) : QFrame(parent),
m_dmm = new DMM(this);
m_external = new QProcess(this);

m_configDlg = new ConfigDlg(this);
m_configDlg = new ConfigDlg(session_id, config_path, this);
m_configDlg->hide();

m_configDlg->readPrinter(&m_printer);
Expand Down
2 changes: 1 addition & 1 deletion src/mainwid.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ class MainWid : public QFrame, private Ui::UIMainWid
{
Q_OBJECT
public:
MainWid(QWidget *parent = Q_NULLPTR);
MainWid(QString session_id, QString config_path, QWidget *parent = Q_NULLPTR);
bool closeWin();
QRect winRect() const;
bool saveWindowPosition() const;
Expand Down
13 changes: 10 additions & 3 deletions src/mainwin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
#include "displaywid.h"


MainWin::MainWin(QWidget *parent)
MainWin::MainWin(QCommandLineParser &parser, QWidget *parent)
: QMainWindow(parent)
, m_running(false)
, m_menu(Q_NULLPTR)
Expand All @@ -42,17 +42,24 @@ MainWin::MainWin(QWidget *parent)
spacer->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred);
this->toolBarMenu->addWidget(spacer);
this->toolBarMenu->addAction(this->action_Menu);
QString config_id = parser.value("config-id");
QString version = APP_VERSION;
int plusIndex = version.indexOf('+');
if (plusIndex != -1)
version = version.left(plusIndex);

m_wid = new MainWid(this);

m_wid = new MainWid(config_id, parser.value("config-dir"), this);
setCentralWidget(m_wid);
setConsoleLogging(parser.isSet("debug"));

createActions();

m_display = new DisplayWid(this);
toolBarDisplay->addWidget(m_display);
m_wid->setDisplay(m_display);

setWindowTitle(QString("%1 %2").arg(APP_NAME).arg(APP_VERSION));
setWindowTitle(QString("%1 %2 %3").arg(APP_NAME).arg(version).arg(config_id));

connect(m_wid, SIGNAL(running(bool)), this, SLOT(runningSLOT(bool)));

Expand Down
Loading
Loading