commit 97a63380c6457535293f554727d256d04e35dae9 Author: Sergio Martínez Portela Date: Sat Apr 3 00:16:06 2021 +0200 Initial commit. diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..bee8a64 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +__pycache__ diff --git a/main.py b/main.py new file mode 100755 index 0000000..4f12d2c --- /dev/null +++ b/main.py @@ -0,0 +1,115 @@ +#!/usr/bin/env python3 + +import logging +import os +import sys +import time + +from PySide2.QtCore import QObject, QThread, Signal, Slot +from PySide2.QtWidgets import (QApplication, QDialog, QGroupBox, QHBoxLayout, + QLabel, QLineEdit, QProgressBar, QPushButton, + QScrollArea, QTabBar, QVBoxLayout) + +ORG_PATH = os.environ['ORG_PATH'] + + +class LoadDoneSignal(QObject): + sig = Signal(str) + + +class DocumentLoader(QThread): + def __init__(self, parent = None): + QThread.__init__(self, parent) + self.exiting = False + self.signal = LoadDoneSignal() + + def run(self): + end = time.time() + 3 + while self.exiting==False: + sys.stdout.write('*') + sys.stdout.flush() + time.sleep(1) + now = time.time() + if now >= end: + self.exiting = True + self.signal.sig.emit('OK') + + +class Dialog(QDialog): + def __init__(self): + super(Dialog, self).__init__() + + self.loader = None + + layout = QVBoxLayout() + + # Edit box + self.progressBar = QProgressBar() + self.progressBar.setRange(0, 0) # Make undetermined + layout.addWidget(self.progressBar) + + self.edit = QLineEdit("", placeholderText='Search for notes') + layout.addWidget(self.edit) + + layout.setSpacing(0) + + self.results = QScrollArea() + layout.addWidget(self.results) + + # Options + self.tabBar = QTabBar(shape=QTabBar.RoundedSouth) + + self.tabBar.addTab("Agenda") + self.tabBar.addTab("Notes") + self.tabBar.addTab("Tasks") + self.tabBar.currentChanged.connect(self.update_tab) + + layout.addWidget(self.tabBar) + + self.setLayout(layout) + self.startLoad() + + @Slot() + def update_tab(self): + tabIndex = self.tabBar.currentIndex() + if tabIndex == 0: + self.loadAgenda() + elif tabIndex == 1: + self.loadNotes() + elif tabIndex == 2: + self.loadTasks() + + def startLoad(self): + self.edit.setDisabled(True) + self.tabBar.setDisabled(True) + self.progressBar.setVisible(True) + + self.loader = DocumentLoader() + self.loader.signal.sig.connect(self.longoperationcomplete) + self.loader.start() + + def endLoad(self): + self.edit.setDisabled(False) + self.tabBar.setDisabled(False) + self.progressBar.setVisible(False) + + self.update_tab() + + def longoperationcomplete(self, data): + print("Complete with", data) + self.endLoad() + + def loadAgenda(self): + logging.warning("loadAgenda not yet implemented") + + def loadNotes(self): + logging.warning("loadNotes not yet implemented") + + def loadTasks(self): + logging.warning("loadTasks not yet implemented") + +# Create the Qt Application +app = QApplication(sys.argv) + +dialog = Dialog() +sys.exit(dialog.exec_())