Initial commit
This commit is contained in:
parent
4d4ea94522
commit
2407aa35e7
5 changed files with 294 additions and 0 deletions
71
.gitignore
vendored
Normal file
71
.gitignore
vendored
Normal file
|
|
@ -0,0 +1,71 @@
|
||||||
|
# Betriebssystem-spezifische Dateien
|
||||||
|
.DS_Store
|
||||||
|
Thumbs.db
|
||||||
|
|
||||||
|
# Qt Creator spezifisch
|
||||||
|
*.pro.user
|
||||||
|
*.pro.user.*
|
||||||
|
*.qbs.user
|
||||||
|
*.qbs.user.*
|
||||||
|
*.qmlproject.user
|
||||||
|
*.qmlproject.user.*
|
||||||
|
*.autosave
|
||||||
|
|
||||||
|
# Build-Verzeichnisse
|
||||||
|
build*/
|
||||||
|
*.o
|
||||||
|
*.obj
|
||||||
|
*.lo
|
||||||
|
*.la
|
||||||
|
*.lai
|
||||||
|
*.a
|
||||||
|
*.lib
|
||||||
|
*.so
|
||||||
|
*.dylib
|
||||||
|
*.dll
|
||||||
|
*.exe
|
||||||
|
*.out
|
||||||
|
|
||||||
|
# Kompilierte Bibliotheken und temporäre Dateien
|
||||||
|
*.moc
|
||||||
|
*.qrc
|
||||||
|
*.cmi
|
||||||
|
*.rcc
|
||||||
|
|
||||||
|
# Qt spezifische Dateien
|
||||||
|
Makefile
|
||||||
|
Makefile.*
|
||||||
|
.qmake.stash
|
||||||
|
qrc_*.cpp
|
||||||
|
moc_*.cpp
|
||||||
|
ui_*.h
|
||||||
|
|
||||||
|
# CMake spezifisch
|
||||||
|
CMakeLists.txt.user
|
||||||
|
CMakeCache.txt
|
||||||
|
CMakeFiles/
|
||||||
|
cmake_install.cmake
|
||||||
|
CTestTestfile.cmake
|
||||||
|
|
||||||
|
# Logs und temporäre Dateien
|
||||||
|
*.log
|
||||||
|
*.tmp
|
||||||
|
*.bak
|
||||||
|
*.swp
|
||||||
|
*.tags
|
||||||
|
*.gz
|
||||||
|
|
||||||
|
# Debugger-Symbole
|
||||||
|
*.dSYM/
|
||||||
|
*.ipdb
|
||||||
|
*.pdb
|
||||||
|
*.pch
|
||||||
|
|
||||||
|
# MinGW spezifisch
|
||||||
|
*.a
|
||||||
|
*.d
|
||||||
|
*.map
|
||||||
|
*.obj
|
||||||
|
|
||||||
|
# VSCode spezifisch (falls du es verwendest)
|
||||||
|
.vscode/
|
||||||
23
CMakeLists.txt
Normal file
23
CMakeLists.txt
Normal file
|
|
@ -0,0 +1,23 @@
|
||||||
|
cmake_minimum_required(VERSION 3.16)
|
||||||
|
|
||||||
|
# Projektname und Standards
|
||||||
|
project(ArbeitszeitRechner)
|
||||||
|
set(CMAKE_CXX_STANDARD 17)
|
||||||
|
|
||||||
|
# Automatische Qt-Prozesse aktivieren
|
||||||
|
set(CMAKE_AUTOMOC ON)
|
||||||
|
set(CMAKE_AUTOUIC ON)
|
||||||
|
set(CMAKE_AUTORCC ON)
|
||||||
|
|
||||||
|
# Qt6 einbinden
|
||||||
|
find_package(Qt6 REQUIRED COMPONENTS Widgets)
|
||||||
|
|
||||||
|
# Quellen-Dateien
|
||||||
|
add_executable(ArbeitszeitRechner
|
||||||
|
main.cpp
|
||||||
|
WorkTimeCalculator.cpp
|
||||||
|
WorkTimeCalculator.h
|
||||||
|
)
|
||||||
|
|
||||||
|
# Qt6-Widgets verlinken
|
||||||
|
target_link_libraries(ArbeitszeitRechner Qt6::Widgets)
|
||||||
147
WorkTimeCalculator.cpp
Normal file
147
WorkTimeCalculator.cpp
Normal file
|
|
@ -0,0 +1,147 @@
|
||||||
|
#include "WorkTimeCalculator.h"
|
||||||
|
#include <QVBoxLayout>
|
||||||
|
#include <QHBoxLayout>
|
||||||
|
#include <QApplication>
|
||||||
|
#include <QInputDialog>
|
||||||
|
#include <QSettings>
|
||||||
|
#include <QMessageBox>
|
||||||
|
#include <QStyleFactory>
|
||||||
|
|
||||||
|
WorkTimeCalculator::WorkTimeCalculator() {
|
||||||
|
// Hauptlayout
|
||||||
|
QWidget *mainWidget = new QWidget;
|
||||||
|
QVBoxLayout *layout = new QVBoxLayout(mainWidget);
|
||||||
|
mainWidget->setLayout(layout); // Setze das Layout für das Widget
|
||||||
|
|
||||||
|
// Einstempelzeit
|
||||||
|
QLabel *startTimeLabel = new QLabel("Einstempelzeit:");
|
||||||
|
startTimeEdit = new QTimeEdit;
|
||||||
|
startTimeEdit->setTime(QTime::currentTime());
|
||||||
|
layout->addWidget(startTimeLabel);
|
||||||
|
layout->addWidget(startTimeEdit);
|
||||||
|
|
||||||
|
// Pausenzeiten
|
||||||
|
QLabel *breaksLabel = new QLabel("Pausenzeiten (Minuten):");
|
||||||
|
layout->addWidget(breaksLabel);
|
||||||
|
|
||||||
|
addBreakButton = new QPushButton("Pause hinzufügen");
|
||||||
|
layout->addWidget(addBreakButton);
|
||||||
|
|
||||||
|
breakList = new QListWidget;
|
||||||
|
layout->addWidget(breakList);
|
||||||
|
|
||||||
|
connect(addBreakButton, &QPushButton::clicked, this, &WorkTimeCalculator::addBreak);
|
||||||
|
|
||||||
|
// Ausstempelzeit (optional)
|
||||||
|
includeEndTimeCheckbox = new QCheckBox("Ausstempelzeit angeben");
|
||||||
|
endTimeEdit = new QTimeEdit;
|
||||||
|
endTimeEdit->setTime(QTime::currentTime());
|
||||||
|
endTimeEdit->setVisible(false);
|
||||||
|
layout->addWidget(includeEndTimeCheckbox);
|
||||||
|
layout->addWidget(endTimeEdit);
|
||||||
|
|
||||||
|
connect(includeEndTimeCheckbox, &QCheckBox::toggled, endTimeEdit, &QTimeEdit::setVisible);
|
||||||
|
|
||||||
|
// Regelarbeitszeit
|
||||||
|
QLabel *workTimeLabel = new QLabel("Regelarbeitszeit (Std:Min):");
|
||||||
|
layout->addWidget(workTimeLabel);
|
||||||
|
|
||||||
|
dailyHoursSpin = new QSpinBox;
|
||||||
|
dailyHoursSpin->setRange(0, 24);
|
||||||
|
dailyMinutesSpin = new QSpinBox;
|
||||||
|
dailyMinutesSpin->setRange(0, 59);
|
||||||
|
|
||||||
|
QHBoxLayout *workTimeLayout = new QHBoxLayout();
|
||||||
|
workTimeLayout->addWidget(dailyHoursSpin);
|
||||||
|
workTimeLayout->addWidget(dailyMinutesSpin);
|
||||||
|
layout->addLayout(workTimeLayout);
|
||||||
|
|
||||||
|
// Berechnung starten
|
||||||
|
calculateButton = new QPushButton("Berechnung starten");
|
||||||
|
layout->addWidget(calculateButton);
|
||||||
|
|
||||||
|
resultLabel = new QLabel;
|
||||||
|
layout->addWidget(resultLabel);
|
||||||
|
|
||||||
|
connect(calculateButton, &QPushButton::clicked, this, &WorkTimeCalculator::calculateWorkTime);
|
||||||
|
|
||||||
|
// Dark Mode
|
||||||
|
qApp->setStyle(QStyleFactory::create("Fusion"));
|
||||||
|
QPalette darkPalette;
|
||||||
|
darkPalette.setColor(QPalette::Window, QColor(53, 53, 53));
|
||||||
|
darkPalette.setColor(QPalette::WindowText, Qt::white);
|
||||||
|
darkPalette.setColor(QPalette::Base, QColor(25, 25, 25));
|
||||||
|
darkPalette.setColor(QPalette::AlternateBase, QColor(53, 53, 53));
|
||||||
|
darkPalette.setColor(QPalette::Text, Qt::white);
|
||||||
|
darkPalette.setColor(QPalette::Button, QColor(53, 53, 53));
|
||||||
|
darkPalette.setColor(QPalette::ButtonText, Qt::white);
|
||||||
|
|
||||||
|
qApp->setPalette(darkPalette);
|
||||||
|
|
||||||
|
setCentralWidget(mainWidget);
|
||||||
|
setWindowTitle("Arbeitszeitrechner");
|
||||||
|
|
||||||
|
loadSettings();
|
||||||
|
}
|
||||||
|
|
||||||
|
WorkTimeCalculator::~WorkTimeCalculator() {
|
||||||
|
saveSettings();
|
||||||
|
}
|
||||||
|
|
||||||
|
void WorkTimeCalculator::addBreak() {
|
||||||
|
bool ok;
|
||||||
|
int breakTime = QInputDialog::getInt(this, "Pause hinzufügen", "Pause (Minuten):", 0, 0, 1440, 1, &ok);
|
||||||
|
if (ok && breakTime > 0) {
|
||||||
|
breakList->addItem(QString::number(breakTime) + " Minuten");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void WorkTimeCalculator::calculateWorkTime() {
|
||||||
|
QTime startTime = startTimeEdit->time();
|
||||||
|
int totalBreakMinutes = 0;
|
||||||
|
|
||||||
|
for (int i = 0; i < breakList->count(); ++i) {
|
||||||
|
totalBreakMinutes += breakList->item(i)->text().split(" ")[0].toInt();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Gesamte Pausenzeit anzeigen
|
||||||
|
QString breakTimeMessage = QString("Gesamte Pausenzeit: %1 Minuten").arg(totalBreakMinutes);
|
||||||
|
|
||||||
|
QTime endTime;
|
||||||
|
if (includeEndTimeCheckbox->isChecked()) {
|
||||||
|
endTime = endTimeEdit->time();
|
||||||
|
} else {
|
||||||
|
// Ausstempelzeit berechnen, wenn nicht angegeben
|
||||||
|
int dailyMinutes = dailyHoursSpin->value() * 60 + dailyMinutesSpin->value();
|
||||||
|
endTime = startTime.addSecs((dailyMinutes + totalBreakMinutes) * 60);
|
||||||
|
}
|
||||||
|
|
||||||
|
int workedMinutes = startTime.secsTo(endTime) / 60 - totalBreakMinutes;
|
||||||
|
|
||||||
|
int dailyMinutes = dailyHoursSpin->value() * 60 + dailyMinutesSpin->value();
|
||||||
|
int balanceMinutes = workedMinutes - dailyMinutes;
|
||||||
|
|
||||||
|
QString result = QString("Netto-Arbeitszeit: %1 Stunden %2 Minuten\n")
|
||||||
|
.arg(workedMinutes / 60)
|
||||||
|
.arg(workedMinutes % 60);
|
||||||
|
result += QString("Zeitkonto: %1 Minuten\n").arg(balanceMinutes);
|
||||||
|
result += breakTimeMessage; // Gesamte Pausenzeit hinzufügen
|
||||||
|
|
||||||
|
if (!includeEndTimeCheckbox->isChecked()) {
|
||||||
|
result += QString("\nVorgeschlagene Ausstempelzeit: %1").arg(endTime.toString("hh:mm"));
|
||||||
|
}
|
||||||
|
|
||||||
|
resultLabel->setText(result);
|
||||||
|
}
|
||||||
|
|
||||||
|
void WorkTimeCalculator::loadSettings() {
|
||||||
|
QSettings settings("ArbeitszeitRechner", "Settings");
|
||||||
|
dailyHoursSpin->setValue(settings.value("dailyHours", 8).toInt());
|
||||||
|
dailyMinutesSpin->setValue(settings.value("dailyMinutes", 0).toInt());
|
||||||
|
}
|
||||||
|
|
||||||
|
void WorkTimeCalculator::saveSettings() {
|
||||||
|
QSettings settings("ArbeitszeitRechner", "Settings");
|
||||||
|
settings.setValue("dailyHours", dailyHoursSpin->value());
|
||||||
|
settings.setValue("dailyMinutes", dailyMinutesSpin->value());
|
||||||
|
}
|
||||||
42
WorkTimeCalculator.h
Normal file
42
WorkTimeCalculator.h
Normal file
|
|
@ -0,0 +1,42 @@
|
||||||
|
#ifndef WORKTIMECALCULATOR_H
|
||||||
|
#define WORKTIMECALCULATOR_H
|
||||||
|
|
||||||
|
#include <QMainWindow> // Basis-Klasse für das Hauptfenster
|
||||||
|
#include <QTimeEdit> // Widget zur Eingabe von Uhrzeiten
|
||||||
|
#include <QPushButton> // Button-Widget
|
||||||
|
#include <QCheckBox> // Checkbox-Widget
|
||||||
|
#include <QListWidget> // Widget zur Anzeige der Pausenzeiten
|
||||||
|
#include <QSpinBox> // Eingabe für numerische Werte (z. B. Stunden/Minuten)
|
||||||
|
#include <QLabel> // Widget zur Anzeige von Text
|
||||||
|
|
||||||
|
class WorkTimeCalculator : public QMainWindow {
|
||||||
|
Q_OBJECT // Erforderlich für Qt-Signal- und Slot-Mechanismus
|
||||||
|
|
||||||
|
public:
|
||||||
|
// Konstruktor und Destruktor
|
||||||
|
WorkTimeCalculator(); // Initialisiert das GUI und die Logik
|
||||||
|
~WorkTimeCalculator(); // Speichert Einstellungen beim Schließen
|
||||||
|
|
||||||
|
private slots:
|
||||||
|
// Slots für Benutzeraktionen
|
||||||
|
void addBreak(); // Hinzufügen einer neuen Pause
|
||||||
|
void calculateWorkTime(); // Berechnet die Netto-Arbeitszeit
|
||||||
|
|
||||||
|
private:
|
||||||
|
// Hilfsfunktionen
|
||||||
|
void loadSettings(); // Lädt gespeicherte Einstellungen
|
||||||
|
void saveSettings(); // Speichert aktuelle Einstellungen
|
||||||
|
|
||||||
|
// GUI-Komponenten
|
||||||
|
QTimeEdit *startTimeEdit; // Widget für die Einstempelzeit
|
||||||
|
QTimeEdit *endTimeEdit; // Widget für die Ausstempelzeit (optional)
|
||||||
|
QPushButton *addBreakButton; // Button, um eine Pause hinzuzufügen
|
||||||
|
QPushButton *calculateButton; // Button, um die Arbeitszeit zu berechnen
|
||||||
|
QCheckBox *includeEndTimeCheckbox; // Checkbox zur Aktivierung der Ausstempelzeit
|
||||||
|
QListWidget *breakList; // Liste der eingegebenen Pausenzeiten
|
||||||
|
QSpinBox *dailyHoursSpin; // Eingabe für tägliche Sollarbeitszeit (Stunden)
|
||||||
|
QSpinBox *dailyMinutesSpin; // Eingabe für tägliche Sollarbeitszeit (Minuten)
|
||||||
|
QLabel *resultLabel; // Anzeige für das Ergebnis der Berechnung
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // WORKTIMECALCULATOR_H
|
||||||
11
main.cpp
Normal file
11
main.cpp
Normal file
|
|
@ -0,0 +1,11 @@
|
||||||
|
#include <QApplication>
|
||||||
|
#include "WorkTimeCalculator.h"
|
||||||
|
|
||||||
|
int main(int argc, char *argv[]) {
|
||||||
|
QApplication app(argc, argv);
|
||||||
|
|
||||||
|
WorkTimeCalculator calculator;
|
||||||
|
calculator.show();
|
||||||
|
|
||||||
|
return app.exec();
|
||||||
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue