diff --git a/bulk_reminders/oauth.py b/bulk_reminders/oauth.py new file mode 100644 index 0000000..a3bd48f --- /dev/null +++ b/bulk_reminders/oauth.py @@ -0,0 +1,28 @@ +from typing import Callable, Optional + +from PyQt5.QtCore import Qt +from PyQt5.QtWidgets import QDialog + +from bulk_reminders.oauth_base import Ui_Dialog + +class OAuthDialog(QDialog, Ui_Dialog): + def __init__(self, *args, callback: Optional[Callable] = None, **kwargs): + super(QDialog, self).__init__(*args, **kwargs) + self._closable = False + self.setupUi(self) + self.show() + + if callback is not None: + callback() + self.accept() + else: + self.reject() + self._closable = True + + def closeEvent(self, evnt): + if self.closable: + super(QDialog, self).closeEvent(evnt) + else: + evnt.ignore() + self.setWindowState(Qt.WindowMinimized) + diff --git a/bulk_reminders/oauth.ui b/bulk_reminders/oauth.ui new file mode 100644 index 0000000..381280c --- /dev/null +++ b/bulk_reminders/oauth.ui @@ -0,0 +1,105 @@ + + + Dialog + + + Qt::NonModal + + + + 0 + 0 + 297 + 153 + + + + Dialog + + + false + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + 0 + 0 + + + + + 300 + 16777215 + + + + No token file was found. +A browser tab has been opened, please sign in to complete the authentication process. + + + Qt::AlignCenter + + + true + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + + diff --git a/bulk_reminders/oauth_base.py b/bulk_reminders/oauth_base.py new file mode 100644 index 0000000..0aac40b --- /dev/null +++ b/bulk_reminders/oauth_base.py @@ -0,0 +1,45 @@ +# -*- coding: utf-8 -*- + +# Form implementation generated from reading ui file 'oauth.ui' +# +# Created by: PyQt5 UI code generator 5.15.4 +# +# WARNING: Any manual changes made to this file will be lost when pyuic5 is +# run again. Do not edit this file unless you know what you are doing. + + +from PyQt5 import QtCore, QtWidgets + + +class Ui_Dialog(object): + def setupUi(self, Dialog): + Dialog.setObjectName("Dialog") + Dialog.setWindowModality(QtCore.Qt.NonModal) + Dialog.resize(297, 153) + Dialog.setSizeGripEnabled(False) + self.gridLayout = QtWidgets.QGridLayout(Dialog) + self.gridLayout.setObjectName("gridLayout") + spacerItem = QtWidgets.QSpacerItem(20, 40, QtWidgets.QSizePolicy.Minimum, QtWidgets.QSizePolicy.Expanding) + self.gridLayout.addItem(spacerItem, 3, 1, 1, 1) + spacerItem1 = QtWidgets.QSpacerItem(40, 20, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Minimum) + self.gridLayout.addItem(spacerItem1, 2, 2, 1, 1) + spacerItem2 = QtWidgets.QSpacerItem(40, 20, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Minimum) + self.gridLayout.addItem(spacerItem2, 2, 0, 1, 1) + self.label = QtWidgets.QLabel(Dialog) + self.label.setMinimumSize(QtCore.QSize(0, 0)) + self.label.setMaximumSize(QtCore.QSize(300, 16777215)) + self.label.setAlignment(QtCore.Qt.AlignCenter) + self.label.setWordWrap(True) + self.label.setObjectName("label") + self.gridLayout.addWidget(self.label, 2, 1, 1, 1) + spacerItem3 = QtWidgets.QSpacerItem(20, 40, QtWidgets.QSizePolicy.Minimum, QtWidgets.QSizePolicy.Expanding) + self.gridLayout.addItem(spacerItem3, 1, 1, 1, 1) + + self.retranslateUi(Dialog) + QtCore.QMetaObject.connectSlotsByName(Dialog) + + def retranslateUi(self, Dialog): + _translate = QtCore.QCoreApplication.translate + Dialog.setWindowTitle(_translate("Dialog", "Dialog")) + self.label.setText(_translate("Dialog", "No token file was found.\n" + "A browser tab has been opened, please sign in to complete the authentication process.")) diff --git a/bulk_reminders/requirements.txt b/bulk_reminders/requirements.txt new file mode 100644 index 0000000..a41c9df --- /dev/null +++ b/bulk_reminders/requirements.txt @@ -0,0 +1,4 @@ +PyQt5 +google-api-python-client +google-auth-httplib2 +google-auth-oauthlib