Add tiny dialog for OAuth2.0 flow

This commit is contained in:
Xevion
2021-08-25 02:32:05 -05:00
parent 76e79f5116
commit 00223241ea
4 changed files with 182 additions and 0 deletions

28
bulk_reminders/oauth.py Normal file
View File

@@ -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)