示例#1
0
    def __init__(self, flags, *args, **kwargs):
        super(BackupDialog, self).__init__(flags=flags, *args)

        if 'palette' in kwargs:
            self.setPalette(kwargs.get('palette'))
        if 'font' in kwargs:
            self.setFont(kwargs.get('font'))
        self.setWindowFlags(Qt.Dialog)

        self.spinner = WaitingSpinner()

        self.thread_pool = QThreadPool()

        self.calendar = kwargs.get('calendar', None)
        if self.calendar is None:
            raise RuntimeError('BackupDialog: calendar is not set')

        self.storage = kwargs.get('storage', Storage())
        self.cloud = kwargs.get('cloud_storage', CloudStorage())

        self.setFixedSize(500, 320)
        self.setWindowTitle(self.tr('Backup and Restore'))

        self.backups_pool = []

        self.settings = Settings()

        self.backup_file_input = QLineEdit()
        self.restore_file_input = QLineEdit()

        self.backup_file_button = PushButton('', 40, 30, self.get_folder_path)
        self.restore_file_button = PushButton('', 40, 30, self.get_file_path)

        self.launch_restore_button = PushButton(self.tr('Start'), 120, 35,
                                                self.launch_restore_local)
        self.launch_backup_button = PushButton(self.tr('Start'), 120, 35,
                                               self.launch_backup_local)

        self.backups_cloud_list_widget = QListWidget()

        self.upload_backup_button = PushButton(' {}'.format(self.tr('Upload')),
                                               120, 35,
                                               self.upload_backup_cloud)
        self.download_backup_button = PushButton(
            ' {}'.format(self.tr('Download')),
            150 if self.settings.app_lang == 'uk_UA' else 120, 35,
            self.download_backup_cloud)
        self.delete_backup_button = PushButton(' {}'.format(self.tr('Delete')),
                                               120, 35,
                                               self.delete_backup_cloud)

        self.setup_ui()

        self.layout().addWidget(self.spinner)
示例#2
0
	def __init__(self, **kwargs):
		self.settings = Settings()
		super().__init__(None, Qt.WindowFlags())

		self.window().setWindowTitle(APP_NAME)
		self.resize(self.settings.app_size)
		self.move(self.settings.app_pos)
		self.setWindowIcon(self.settings.app_icon())
		self.setMinimumWidth(APP_MIN_WIDTH)
		self.setMinimumHeight(APP_MIN_HEIGHT)

		self.events_list = EventListWidget(**{
			'parent': self,
		})

		# noinspection PyUnresolvedReferences
		self.events_list.itemSelectionChanged.connect(self.events_list_selection_changed)

		self.calendar = self.init_calendar()

		self.btn_new_event = PushButton(self.tr('New'), 90, 30, self.calendar.open_details_event)
		self.btn_edit = PushButton(self.tr('Details'), 90, 30, self.calendar.edit_event_click)
		self.btn_delete = PushButton(self.tr('Delete'), 90, 30, self.calendar.delete_event_click)
		events_widget = self.init_events_widget()

		main_layout = QHBoxLayout()

		# noinspection PyArgumentList
		main_layout.addWidget(self.calendar)
		main_layout.addWidget(events_widget, alignment=Qt.AlignRight)

		central_widget = QWidget(flags=self.windowFlags())
		central_widget.setLayout(main_layout)

		self.setCentralWidget(central_widget)

		# noinspection PyUnresolvedReferences
		self.calendar.selectionChanged.connect(self.date_selection_changed)

		self.setup_navigation_menu()
		self.setFont(QFont('SansSerif', self.settings.app_font))

		self.open_action = QAction('{} {}'.format(self.tr('Open'), APP_NAME), self)
		self.hide_action = QAction(self.tr('Minimize To Tray'), self)
		if self.settings.start_in_tray:
			self.hide_action.setEnabled(False)
		self.close_action = QAction('{} {}'.format(self.tr('Quit'), APP_NAME), self)

		self.tray_icon = self.init_tray(kwargs.get('app'))
		self.tray_icon.show()

		self.setPalette(self.settings.app_theme)
示例#3
0
    def __init__(self, parent, **kwargs):
        super().__init__(parent=parent)
        self.parent = parent

        self.setGeometry(0, 0, kwargs['width'], kwargs['height'])
        self.setGridVisible(True)

        # noinspection PyUnresolvedReferences
        self.clicked[QDate].connect(self.load_events)

        self.setContentsMargins(0, 0, 0, 0)

        self.events_list = kwargs.get('events_list', None)
        if self.events_list is None:
            raise RuntimeError('CalendarWidget: events list is not set')

        self.storage = Storage()

        self.thread_pool = QThreadPool()

        self.settings = Settings()
        font = QFont('SansSerif', self.settings.app_font)
        self.setFont(font)
        self.setPalette(self.settings.app_theme)

        self.cloud_storage = CloudStorage()

        params = {
            'font': font,
            'calendar': self,
            'flags': self.parent.windowFlags(),
            'palette': self.settings.app_theme,
            'parent': self
        }

        self.event_details_dialog = EventDetailsDialog(storage=self.storage,
                                                       **params)
        self.settings_dialog = SettingsDialog(cloud_storage=self.cloud_storage,
                                              **params)
        self.backup_dialog = BackupDialog(storage=self.storage,
                                          cloud_storage=self.cloud_storage,
                                          **params)

        self.dialogs = [
            self.event_details_dialog, self.settings_dialog, self.backup_dialog
        ]

        self.marked_dates = []
        self.past_events = []

        self.update()
示例#4
0
	def restore_from_dict(self, data):
		err_template = 'Restore failure: {}.'
		for key in ['digest', 'timestamp', 'backup']:
			if key not in data:
				raise DatabaseException(err_template.format('invalid backup file'))
		if datetime.now() < datetime.strptime(data['timestamp'], EventModel.TIMESTAMP_FORMAT):
			raise DatabaseException(err_template.format('incorrect timestamp'))
		backup_decoded = base64.b64decode(data['backup'])
		if sha512(backup_decoded).hexdigest() != data['digest']:
			raise DatabaseException(err_template.format('backup is broken'))
		backup = json.loads(backup_decoded.decode('utf8'))
		if 'db' not in backup:
			raise DatabaseException(err_template.format('invalid backup data'))
		self.__cursor.execute(QUERY_DELETE_ALL_EVENTS)
		self.from_array(backup['db'])
		if 'settings' in backup:
			Settings().from_dict(backup['settings'])
示例#5
0
    def __init__(self, flags, *args, **kwargs):
        super(AboutDialog, self).__init__(flags=flags, *args)
        if 'palette' in kwargs:
            self.setPalette(kwargs.get('palette'))
        self.setFixedSize(500, 250)
        self.setWindowTitle('Legal Information')
        self.setWindowFlags(Qt.Popup | Qt.FramelessWindowHint)

        self.calendar = kwargs.get('calendar', None)
        if self.calendar is None:
            raise RuntimeError('AboutDialog: calendar is not set')

        self.settings = Settings()
        self.user = None
        self.thread_pool = QThreadPool()
        self.data_section = QVBoxLayout()
        self.setup_ui()
示例#6
0
def main():
    app = QApplication(sys.argv)

    app.setStyle('Fusion')

    settings = Settings()

    translator = QTranslator()
    translator.load(':/lang/{}.qm'.format(settings.app_lang))
    app.installTranslator(translator)

    window = MainWindow(app=app)

    ReminderService(window, window.calendar).start()

    if not settings.start_in_tray:
        window.show()

    sys.exit(app.exec_())
示例#7
0
    def __init__(self, flags, *args, **kwargs):
        super(AccountDialog, self).__init__(flags=flags, *args)

        if 'palette' in kwargs:
            self.setPalette(kwargs.get('palette'))
        if 'font' in kwargs:
            self.setFont(kwargs.get('font'))

        self.calendar = kwargs.get('calendar', None)
        if self.calendar is None:
            raise RuntimeError('AccountDialog: calendar is not set')

        self.setFixedSize(550, 280)
        self.setWindowTitle(self.tr('Account'))
        self.setWindowFlags(Qt.Dialog)

        self.settings = Settings()
        self.spinner = WaitingSpinner()
        self.thread_pool = QThreadPool()
        self.cloud = kwargs.get('cloud_storage', CloudStorage())

        self.username_signup_input = QLineEdit()
        self.email_signup_input = QLineEdit()

        self.username_login_input = QLineEdit()
        self.password_login_input = QLineEdit()
        self.remember_login_check_box = QCheckBox(self.tr('Remember me'))

        self.login_menu = None
        self.account_info_menu = None

        self.v_layout = QVBoxLayout()
        self.tabs = QTabWidget(self)

        self.setup_ui()

        self.layout().addWidget(self.spinner)
示例#8
0
	def prepare_backup_data(events_array, timestamp, include_settings, username=None, settings=Settings().to_dict()):
		data = {
			'db': events_array
		}
		if include_settings:
			data['settings'] = settings
		if username is not None:
			data['username'] = username
		data = json.dumps(data).encode('utf8')
		encoded_data = base64.b64encode(data)
		return {
			'digest': sha512(data).hexdigest(),
			'timestamp': timestamp,
			'backup': encoded_data,
			'backup_size': Storage.count_str_size(encoded_data),
			'events_count': len(events_array),
			'contains_settings': include_settings
		}
示例#9
0
	def __init__(self, parent, calendar):
		super().__init__(parent=parent)
		self.__calendar = calendar
		self.__settings = Settings()
		self.__storage = Storage()