diff options
| -rw-r--r-- | calendar_gui.py | 108 |
1 files changed, 53 insertions, 55 deletions
diff --git a/calendar_gui.py b/calendar_gui.py index 1c9efe7..422b851 100644 --- a/calendar_gui.py +++ b/calendar_gui.py @@ -2,7 +2,7 @@ import sys from PyQt5.QtWidgets import (QApplication, QMainWindow, QWidget, QVBoxLayout, QHBoxLayout,
QLabel, QPushButton, QDateEdit, QTableWidget,
QTableWidgetItem, QHeaderView, QDialog, QFormLayout, QComboBox,
- QMessageBox, QSpinBox, QAction, QFileDialog, QTextEdit,
+ QMessageBox, QSpinBox, QFileDialog, QTextEdit,
QAbstractItemView, QToolButton)
from PyQt5.QtWidgets import QStyle
from PyQt5.QtCore import Qt, QDate, QLocale
@@ -200,59 +200,6 @@ class CalendarManagerGUI(QMainWindow): )
self.init_ui()
- self.create_menus()
-
- def create_menus(self):
- # Create menu bar
- menubar = self.menuBar()
- menubar.setFont(self.app_font)
- menubar.setStyleSheet(
- "QMenuBar { background: #ffffff; color: #333; }"
- " QMenuBar::item:selected { background: #f0f3fa; }"
- " QMenu { background: #ffffff; color: #333; border: 1px solid #e1e4ee; }"
- " QMenu::item:selected { background: #e6f0ff; }"
- )
-
- # File menu
- file_menu = menubar.addMenu('Start')
-
- # Load action
- load_action = QAction('Laden', self)
- load_action.setShortcut('Ctrl+L')
- load_action.setIcon(self.style().standardIcon(QStyle.SP_DialogOpenButton))
- load_action.triggered.connect(self.load_file)
- file_menu.addAction(load_action)
-
- # Save action
- save_action = QAction('Speichern', self)
- save_action.setShortcut('Ctrl+S')
- save_action.setIcon(self.style().standardIcon(QStyle.SP_DialogSaveButton))
- save_action.triggered.connect(self.save_file)
- file_menu.addAction(save_action)
-
- # Export PDF action
- export_pdf_action = QAction('Als PDF exportieren', self)
- export_pdf_action.setShortcut('Ctrl+E')
- # Fallback icon; SP_DialogPrintButton may not exist in some Qt styles
- export_pdf_action.setIcon(self.style().standardIcon(QStyle.SP_FileIcon))
- export_pdf_action.triggered.connect(self.export_pdf)
- file_menu.addAction(export_pdf_action)
-
- # Note: Saving/Loading now operate on complete prediction state
-
- # Clear action
- clear_action = QAction('Einträge löschen', self)
- clear_action.setShortcut('Ctrl+N')
- clear_action.setIcon(self.style().standardIcon(QStyle.SP_DialogDiscardButton))
- clear_action.triggered.connect(self.clear_entries)
- file_menu.addAction(clear_action)
-
- # Exit action
- exit_action = QAction('Beenden', self)
- exit_action.setShortcut('Ctrl+Q')
- exit_action.setIcon(self.style().standardIcon(QStyle.SP_DialogCloseButton))
- exit_action.triggered.connect(self.close)
- file_menu.addAction(exit_action)
def init_ui(self):
central_widget = QWidget()
@@ -274,6 +221,47 @@ class CalendarManagerGUI(QMainWindow): " QToolButton { border: none; }"
)
+ # Button bar at the top
+ button_bar = QHBoxLayout()
+ button_bar.setSpacing(10)
+
+ # Load button
+ load_button = QPushButton("Laden")
+ load_button.setFont(self.app_font)
+ load_button.setIcon(self.style().standardIcon(QStyle.SP_DialogOpenButton))
+ load_button.setShortcut('Ctrl+L')
+ load_button.clicked.connect(self.load_file)
+ button_bar.addWidget(load_button)
+
+ # Save button
+ save_button = QPushButton("Speichern")
+ save_button.setFont(self.app_font)
+ save_button.setIcon(self.style().standardIcon(QStyle.SP_DialogSaveButton))
+ save_button.setShortcut('Ctrl+S')
+ save_button.clicked.connect(self.save_file)
+ button_bar.addWidget(save_button)
+
+ # PDF export button
+ export_pdf_button = QPushButton("PDF exportieren")
+ export_pdf_button.setFont(self.app_font)
+ export_pdf_button.setIcon(self.style().standardIcon(QStyle.SP_FileIcon))
+ export_pdf_button.setShortcut('Ctrl+E')
+ export_pdf_button.clicked.connect(self.export_pdf)
+ button_bar.addWidget(export_pdf_button)
+
+ # Clear entries button
+ clear_button = QPushButton("Einträge löschen")
+ clear_button.setFont(self.app_font)
+ clear_button.setIcon(self.style().standardIcon(QStyle.SP_DialogDiscardButton))
+ clear_button.setShortcut('Ctrl+N')
+ clear_button.clicked.connect(self.clear_entries)
+ button_bar.addWidget(clear_button)
+
+ # Add stretch to push buttons to the left
+ button_bar.addStretch()
+
+ main_layout.addLayout(button_bar)
+
top_layout = QHBoxLayout()
top_layout.setSpacing(18)
@@ -589,7 +577,17 @@ class CalendarManagerGUI(QMainWindow): # Re-render to revert combo to valid value
self.update_events_table()
return
- modified = self.calendar_manager.modify_entry(event_id, keyword=new_keyword)
+ # Auto-adjust end date if keyword enforces a fixed duration (e.g., EZ pauschal)
+ new_end_iso = None
+ if EventTypeHandler.should_hide_end_date_input(new_keyword):
+ start_dt = entry.start_date
+ end_dt = EventTypeHandler.get_duration_for_type(new_keyword, start_dt)
+ new_end_iso = DateService.format_date_for_iso(end_dt)
+ modified = self.calendar_manager.modify_entry(
+ event_id,
+ end_date=new_end_iso if new_end_iso else None,
+ keyword=new_keyword
+ )
if modified is None:
QMessageBox.critical(self, "Fehler", "Eintrag konnte nicht aktualisiert werden.")
self.update_events_table()
|
