@ -0,0 +1,27 @@ | |||
// SPDX-License-Identifier: GPL-3.0-or-later | |||
/* | |||
* Qt mutizone MQTT thermostat | |||
* | |||
* Copyright (C) 2019 Richard Genoud | |||
* | |||
*/ | |||
#ifndef MAINWINDOW_H | |||
#define MAINWINDOW_H | |||
#include <QMainWindow> | |||
#include <QPushButton> | |||
#include <QtWidgets> | |||
class MainWindow : public QMainWindow | |||
{ | |||
Q_OBJECT | |||
public: | |||
explicit MainWindow(QWidget *parent = 0); | |||
~MainWindow(); | |||
}; | |||
#endif // MAINWINDOW_H | |||
/* vim: set tabstop=8 shiftwidth=8 softtabstop=0 noexpandtab: */ |
@ -0,0 +1,26 @@ | |||
// SPDX-License-Identifier: GPL-3.0-or-later | |||
/* | |||
* Qt mutizone MQTT thermostat | |||
* | |||
* Copyright (C) 2019 Richard Genoud | |||
* | |||
*/ | |||
#ifndef ZONEITEM_H | |||
#define ZONEITEM_H | |||
#include <QWidget> | |||
#include <QObject> | |||
class ZoneItem : public QWidget | |||
{ | |||
Q_OBJECT | |||
public: | |||
explicit ZoneItem(QWidget *parent = Q_NULLPTR); | |||
~ZoneItem(); | |||
}; | |||
#endif // ZONEITEM_H | |||
/* vim: set tabstop=8 shiftwidth=8 softtabstop=0 noexpandtab: */ |
@ -0,0 +1,18 @@ | |||
<?xml version="1.0" encoding="utf-8"?> | |||
<!DOCTYPE TS> | |||
<TS version="2.1" language="fr_FR"> | |||
<context> | |||
<name>MainWindow</name> | |||
<message> | |||
<source>Sorico's thermostat</source> | |||
<translation type="unfinished"></translation> | |||
</message> | |||
</context> | |||
<context> | |||
<name>ZoneItem</name> | |||
<message> | |||
<source>Living room</source> | |||
<translation>Salon</translation> | |||
</message> | |||
</context> | |||
</TS> |
@ -0,0 +1,43 @@ | |||
#!/bin/sh | |||
devflag="" | |||
dirtyflag="" | |||
# set the version from tags | |||
tag="$(git describe --exact-match --tags 2>/dev/null)" | |||
if [ -n "$tag" ]; then | |||
# we are exactly on a tag (ex: 2015_09_10_08_51_version_1.6.7) | |||
# so we have just to extract the version | |||
version="$(echo "$tag" | sed "s/^.*_//")" | |||
else | |||
# we are not on a tag. | |||
# In this case, we want to have the previous tag version plus "dev" string | |||
# and the number of commits | |||
# git describe format is tag-x-gsha1 | |||
tag="$(git describe --long --tags 2>/dev/null)" | |||
if [ -n "$tag" ]; then | |||
version="$(echo "$tag" | sed "s/^.*_\(.*\)-[0-9]\+-g[^-]\+$/\1/")" | |||
nbcommit="$(echo "$tag" | sed "s/^.*_.*-\([0-9]\+\)-g[^-]\+$/\1/")" | |||
commit="$(echo "$tag" | sed "s/^.*_.*-[0-9]\+-g\([^-]\+\)$/\1/")" | |||
devflag="-dev" | |||
else | |||
nbcommit=0 | |||
version="$(git log -1 --pretty="format:%h")" | |||
fi | |||
fi | |||
dirtyflag=$(git diff-index --name-only HEAD) | |||
if [ -n "$dirtyflag" ]; then | |||
flag="-dirty" | |||
else | |||
flag="$devflag" | |||
fi | |||
[ "$nbcommit" -eq "$nbcommit" ] 2>/dev/null || nbcommit=0 | |||
printf "%s%s" "${version}" "${flag}" | |||
if [ "$nbcommit" -ne 0 ]; then | |||
printf "%03d_%s" "${nbcommit}" "${commit}" | |||
fi | |||
printf "\n" | |||
# /* vim: set noai ts=8 sw=8: */ |
@ -0,0 +1,42 @@ | |||
// SPDX-License-Identifier: GPL-3.0-or-later | |||
/* | |||
* Qt mutizone MQTT thermostat | |||
* | |||
* Copyright (C) 2019 Richard Genoud | |||
* | |||
*/ | |||
#include <QApplication> | |||
#include <QInputDialog> | |||
#include <QTranslator> | |||
#include "mainwindow.h" | |||
int main(int argc, char *argv[]) | |||
{ | |||
QTranslator qtTranslator; | |||
QTranslator translator; | |||
Q_INIT_RESOURCE(thermostat); | |||
QApplication a(argc, argv); | |||
a.setApplicationVersion(VERSION); | |||
/* | |||
* Init l10n | |||
*/ | |||
if (qtTranslator.load("qt_" + QLocale::system().name(), | |||
QLibraryInfo::location(QLibraryInfo::TranslationsPath))) | |||
a.installTranslator(&qtTranslator); | |||
if (translator.load(":/lang/thermostat_" + QLocale::system().name() + ".qm")) | |||
a.installTranslator(&translator); | |||
MainWindow w; | |||
w.show(); | |||
return a.exec(); | |||
} | |||
/* vim: set tabstop=8 shiftwidth=8 softtabstop=0 noexpandtab: */ |
@ -0,0 +1,48 @@ | |||
// SPDX-License-Identifier: GPL-3.0-or-later | |||
/* | |||
* Qt mutizone MQTT thermostat | |||
* | |||
* Copyright (C) 2019 Richard Genoud | |||
* | |||
*/ | |||
#include <QtWidgets> | |||
#include <QPushButton> | |||
#include <QTime> | |||
#include <QLocale> | |||
#include "zoneitem.h" | |||
#include "mainwindow.h" | |||
MainWindow::MainWindow(QWidget *parent) : | |||
QMainWindow(parent) | |||
{ | |||
/* | |||
* Sensors-related layout | |||
*/ | |||
QGridLayout *mainLayout = new QGridLayout; | |||
mainLayout->addWidget(new ZoneItem(this), 0, 0); | |||
mainLayout->addWidget(new ZoneItem(this), 0, 1); | |||
mainLayout->addWidget(new QPushButton(tr("Menu")), 0, 2); | |||
mainLayout->addWidget(new ZoneItem(this), 1, 0); | |||
mainLayout->addWidget(new ZoneItem(this), 1, 1); | |||
mainLayout->addWidget(new QPushButton(tr("Auto")), 1, 2); | |||
QWidget *mainWidget = new QWidget; | |||
mainWidget->setLayout(mainLayout); | |||
/* | |||
* Top widget | |||
*/ | |||
setCentralWidget(mainWidget); | |||
setWindowTitle(tr("Sorico's thermostat")); | |||
} | |||
MainWindow::~MainWindow() | |||
{ | |||
} | |||
/* vim: set tabstop=8 shiftwidth=8 softtabstop=0 noexpandtab: */ |
@ -0,0 +1,38 @@ | |||
// SPDX-License-Identifier: GPL-3.0-or-later | |||
/* | |||
* Qt mutizone MQTT thermostat | |||
* | |||
* Copyright (C) 2019 Richard Genoud | |||
* | |||
*/ | |||
#include <QPushButton> | |||
#include <QVBoxLayout> | |||
#include <QWidget> | |||
#include <QLocale> | |||
#include <QLabel> | |||
#include "zoneitem.h" | |||
ZoneItem::ZoneItem(QWidget *parent) : | |||
QWidget(parent) | |||
{ | |||
/* | |||
* Layout for the left part of the window | |||
*/ | |||
QVBoxLayout *topLayout = new QVBoxLayout; | |||
QPushButton *btn = new QPushButton; | |||
btn->setText("20°C"); | |||
btn->setFlat(true); | |||
topLayout->addWidget(new QLabel(tr("Living room"))); | |||
topLayout->addWidget(btn); | |||
topLayout->addWidget(new QLabel("45%h")); | |||
this->setLayout(topLayout); | |||
} | |||
ZoneItem::~ZoneItem() | |||
{ | |||
} | |||
/* vim: set tabstop=8 shiftwidth=8 softtabstop=0 noexpandtab: */ |
@ -0,0 +1,67 @@ | |||
QT += core gui | |||
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets | |||
CONFIG += c++11 | |||
TARGET = thermostat | |||
TEMPLATE = app | |||
# The following define makes your compiler emit warnings if you use | |||
# any feature of Qt which as been marked as 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 you use 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 += src/main.cpp \ | |||
src/mainwindow.cpp \ | |||
src/zoneitem.cpp \ | |||
HEADERS += inc/mainwindow.h \ | |||
inc/zoneitem.h \ | |||
RESOURCES += thermostat.qrc | |||
TRANSLATION_DIR = lang | |||
TRANSLATIONS += $$TRANSLATION_DIR/thermostat_fr.ts | |||
# This is not working with Qt5.7 on debian. | |||
CONFIG += lrelease embed_translations | |||
target.path = /usr/bin/ | |||
INSTALLS += target | |||
VERSION = $$system(./scripts/get_tag_version.sh) | |||
QMAKE_CXXFLAGS += -Wall -Werror | |||
QMAKE_CXXFLAGS += -std=c++11 | |||
QMAKE_CXXFLAGS += -DVERSION=\'\"$$VERSION\"\' | |||
QMAKE_CXXFLAGS_DEBUG += -O0 | |||
QMAKE_CXXFLAGS_RELEASE += -Os | |||
unix: CONFIG += link_pkgconfig | |||
INCLUDEPATH += inc/ \ | |||
LUPDATE = $$shell_path($$[QT_INSTALL_BINS]/lupdate) -locations relative -no-ui-lines -no-sort | |||
LRELEASE = $$shell_path($$[QT_INSTALL_BINS]/lrelease) -compress -nounfinished -removeidentical | |||
LCONVERT = $$shell_path($$[QT_INSTALL_BINS]/lconvert) | |||
langupd.command = $$LUPDATE $$shell_path($$_PRO_FILE_) -ts $$_PRO_FILE_PWD_/$$TRANSLATIONS | |||
langrel.depends = langupd | |||
langrel.input = TRANSLATIONS | |||
langrel.output = $$TRANSLATION_DIR/${QMAKE_FILE_BASE}.qm | |||
langrel.commands = $$LRELEASE ${QMAKE_FILE_IN} | |||
langrel.CONFIG += no_link | |||
QMAKE_EXTRA_TARGETS += langupd | |||
QMAKE_EXTRA_COMPILERS += langrel | |||
PRE_TARGETDEPS += langupd compiler_langrel_make_all |
@ -0,0 +1,6 @@ | |||
<!DOCTYPE RCC> | |||
<RCC version="1.0"> | |||
<qresource prefix="/"> | |||
<file>lang/thermostat_fr.qm</file> | |||
</qresource> | |||
</RCC> |