def __init__(self, parent=None): super(self.__class__, self).__init__(parent=parent) # load user interface layout from .ui file uic.loadUi(UNLINK_DIALOG_PATH, self) self.setModal(True) self.setWindowFlags(QtCore.Qt.Sheet) self.buttonBox.buttons()[0].setText("Unlink") self.titleLabel.setFont(get_scaled_font(bold=True)) self.infoLabel.setFont(get_scaled_font(scaling=0.9)) icon = QtGui.QIcon(APP_ICON_PATH) pixmap = icon_to_pixmap(icon, self.iconLabel.width(), self.iconLabel.height()) self.iconLabel.setPixmap(pixmap)
def __init__(self, reason=EXPIRED, parent=None): super(self.__class__, self).__init__(parent=parent) # load user interface layout from .ui file uic.loadUi(RELINK_DIALOG_PATH, self) self.setModal(True) self.setWindowFlags(Qt.WindowTitleHint | Qt.CustomizeWindowHint) assert reason in (self.EXPIRED, self.REVOKED) # format text labels if reason is self.EXPIRED: self.titleLabel.setText("Dropbox Access expired") formatted_text = self.infoLabel.text().format( "has expired", self.auth_session.get_auth_url()) else: self.titleLabel.setText("Dropbox Access revoked") formatted_text = self.infoLabel.text().format( "has been revoked", self.auth_session.get_auth_url()) self.infoLabel.setText(formatted_text) self.titleLabel.setFont(get_scaled_font(bold=True)) self.infoLabel.setFont(get_scaled_font(scaling=0.9)) # add app icon icon = QtGui.QIcon(APP_ICON_PATH) pixmap = icon_to_pixmap(icon, self.iconLabel.width(), self.iconLabel.height()) self.iconLabel.setPixmap(pixmap) # format progress indicator self._layout = QtWidgets.QHBoxLayout() self._layout.setContentsMargins(0, 0, 3, 0) self._layout.setAlignment(Qt.AlignRight | Qt.AlignVCenter) self.lineEditAuthCode.setLayout(self._layout) self.progressIndicator = QProgressIndicator(self.lineEditAuthCode) self._layout.addWidget(self.progressIndicator) # format line edit self.lineEditAuthCode.setTextMargins(3, 0, 0, 0) # connect callbacks self.lineEditAuthCode.textChanged.connect(self._set_text_style) self.pushButtonCancel.clicked.connect(self.quit) self.pushButtonUnlink.clicked.connect(self.delete_creds_and_quit) self.pushButtonLink.clicked.connect(self.on_link_clicked) # other self.pushButtonCancel.setFocus() self.adjustSize()
def update_dark_mode(self): # update style sheet with new colors line_rgb = LINE_COLOR_DARK if isDarkWindow() else LINE_COLOR_LIGHT bg_color = self.palette().color(QtGui.QPalette.Base) bg_color_rgb = [bg_color.red(), bg_color.green(), bg_color.blue()] self.frame.setStyleSheet(""" .QFrame {{ border: 1px solid rgb({0},{1},{2}); background-color: rgb({3},{4},{5}); border-radius: 7px; }}""".format(*line_rgb, *bg_color_rgb)) # update item icons (the system may supply different icons in dark mode) icon = get_native_item_icon(self.sync_err["local_path"]) pixmap = icon_to_pixmap(icon, self.iconLabel.width(), self.iconLabel.height()) self.iconLabel.setPixmap(pixmap)
def __init__(self, parent, reason=EXPIRED): super(self.__class__, self).__init__(parent=None) uic.loadUi(RELINK_DIALOG_PATH, self) # import OAuth2Session here because of ~40 MB memory footprint from maestral.sync.oauth import OAuth2Session self._parent = parent self.auth_session = OAuth2Session(self._parent.mdbx.config_name) self.setModal(True) self.setWindowFlags(Qt.WindowTitleHint | Qt.CustomizeWindowHint) # format text labels if reason is self.EXPIRED: self.titleLabel.setText("Dropbox Access Expired") formatted_text = self.infoLabel.text().format( "has expired", self.auth_session.get_auth_url()) elif reason is self.REVOKED: self.titleLabel.setText("Dropbox Access Revoked") formatted_text = self.infoLabel.text().format( "has been revoked", self.auth_session.get_auth_url()) else: raise ValueError("'reason' must be RelinkDialog.EXPIRED or " "RelinkDialog.REVOKED.") self.infoLabel.setText(formatted_text) self.titleLabel.setFont(get_scaled_font(bold=True)) self.infoLabel.setFont(get_scaled_font(scaling=0.9)) # add app icon icon = QtGui.QIcon(APP_ICON_PATH) pixmap = icon_to_pixmap(icon, self.iconLabel.width(), self.iconLabel.height()) self.iconLabel.setPixmap(pixmap) # format line edit self.lineEditAuthCode.setTextMargins(3, 0, 0, 0) # connect callbacks self.lineEditAuthCode.textChanged.connect(self._set_text_style) self.pushButtonCancel.clicked.connect(self._parent.quit) self.pushButtonUnlink.clicked.connect(self.delete_creds_and_quit) self.pushButtonLink.clicked.connect(self.on_link_clicked) # other self.pushButtonCancel.setFocus() self.adjustSize()
def __init__(self, pending_link=True, parent=None): super(self.__class__, self).__init__(parent=parent) # load user interface layout from .ui file uic.loadUi(SETUP_DIALOG_PATH, self) self.app_icon = QtGui.QIcon(APP_ICON_PATH) self.labelIcon_0.setPixmap(icon_to_pixmap(self.app_icon, 170)) self.labelIcon_1.setPixmap(icon_to_pixmap(self.app_icon, 70)) self.labelIcon_2.setPixmap(icon_to_pixmap(self.app_icon, 70)) self.labelIcon_3.setPixmap(icon_to_pixmap(self.app_icon, 100)) self.mdbx = None self.folder_items = [] # resize dialog buttons width = self.pushButtonAuthPageCancel.width() * 1.1 for b in (self.pushButtonAuthPageLink, self.pussButtonDropboxPathUnlink, self.pussButtonDropboxPathSelect, self.pushButtonFolderSelectionBack, self.pushButtonFolderSelectionSelect, self.pushButtonAuthPageCancel, self.pussButtonDropboxPathCalcel, self.pushButtonClose): b.setMinimumWidth(width) b.setMaximumWidth(width) # set up combobox self.dropbox_location = osp.dirname(CONF.get( "main", "path")) or get_home_dir() relative_path = self.rel_path(self.dropbox_location) folder_icon = get_native_item_icon(self.dropbox_location) self.comboBoxDropboxPath.addItem(folder_icon, relative_path) self.comboBoxDropboxPath.insertSeparator(1) self.comboBoxDropboxPath.addItem(QtGui.QIcon(), "Other...") self.comboBoxDropboxPath.currentIndexChanged.connect(self.on_combobox) self.dropbox_folder_dialog = QtWidgets.QFileDialog(self) self.dropbox_folder_dialog.setAcceptMode( QtWidgets.QFileDialog.AcceptOpen) self.dropbox_folder_dialog.setFileMode(QtWidgets.QFileDialog.Directory) self.dropbox_folder_dialog.setOption( QtWidgets.QFileDialog.ShowDirsOnly, True) self.dropbox_folder_dialog.fileSelected.connect(self.on_new_dbx_folder) self.dropbox_folder_dialog.rejected.connect( lambda: self.comboBoxDropboxPath.setCurrentIndex(0)) # connect buttons to callbacks self.setAttribute(QtCore.Qt.WA_DeleteOnClose) self.pushButtonLink.clicked.connect(self.on_link) self.pushButtonAuthPageCancel.clicked.connect(self.abort) self.pushButtonAuthPageLink.clicked.connect(self.on_auth_clicked) self.pussButtonDropboxPathCalcel.clicked.connect(self.abort) self.pussButtonDropboxPathSelect.clicked.connect( self.on_dropbox_location_selected) self.pussButtonDropboxPathUnlink.clicked.connect( self.unlink_and_go_to_start) self.pushButtonFolderSelectionBack.clicked.connect( self.stackedWidget.slideInPrev) self.pushButtonFolderSelectionSelect.clicked.connect( self.on_folders_selected) self.pushButtonClose.clicked.connect(self.accept) self.listWidgetFolders.itemChanged.connect( self.update_select_all_checkbox) self.selectAllCheckBox.clicked.connect(self.on_select_all_clicked) self.labelDropboxPath.setText(self.labelDropboxPath.text().format( CONF.get("main", "default_dir_name"))) # check if we are already authenticated, skip authentication if yes if not pending_link: self.labelDropboxPath.setText(""" <html><head/><body> <p align="left"> Your Dropbox folder has been moved or deleted from its original location. Maestral will not work properly until you move it back. It used to be located at: </p><p align="left">{0}</p> <p align="left"> To move it back, click "Quit" below, move the Dropbox folder back to its original location, and launch Maestral again. </p> <p align="left"> To re-download your Dropbox, please select a location for your Dropbox folder below. Maestral will create a new folder named "{1}" in the selected location.</p> <p align="left"> To unlink your Dropbox account from Maestral, click "Unlink" below.</p> </body></html> """.format(CONF.get("main", "path"), CONF.get("main", "default_dir_name"))) self.pussButtonDropboxPathCalcel.setText("Quit") self.stackedWidget.setCurrentIndex(2) self.stackedWidgetButtons.setCurrentIndex(2) self.mdbx = Maestral(run=False) self.mdbx.client.get_account_info() else: self.stackedWidget.setCurrentIndex(0) self.stackedWidgetButtons.setCurrentIndex(0)