def draw(self, build_info): if build_info is None: self.infoLabel.setText( ("Build *{0}* is damaged!").format(Path(self.link).name)) self.launchButton.setText("Delete") self.launchButton.clicked.connect(self.ask_remove_from_drive) self.setEnabled(True) return for i in reversed(range(self.layout.count())): self.layout.itemAt(i).widget().setParent(None) self.build_info = build_info self.branch = self.build_info.branch self.item.date = build_info.commit_time self.icon_favorite = QIcon(":resources/icons/favorite.svg") self.icon_fake = QIcon(":resources/icons/fake.svg") self.icon_delete = QIcon(":resources/icons/delete.svg") self.launchButton = QPushButton("Launch") self.launchButton.setMinimumWidth(75) self.launchButton.setProperty("LaunchButton", True) self.subversionLabel = QLabel() self.branchLabel = QLabel() self.commitTimeLabel = QLabel() self.buildHashLabel = QLabel() self.countButton = QPushButton("0") self.countButton.setEnabled(False) self.countButton.setProperty("Count", True) self.countButton.hide() self.countButton.setFixedSize(24, 24) self.widgetFavorite = QPushButton() self.widgetFavorite.setEnabled(False) self.widgetFavorite.setFixedSize(24, 24) self.widgetFavorite.setIcon(self.icon_fake) self.widgetFavorite.setProperty("Icon", True) self.layout.addWidget(self.launchButton) self.layout.addWidget(self.subversionLabel) self.layout.addWidget(self.branchLabel) self.layout.addWidget(self.commitTimeLabel) self.layout.addWidget(self.buildHashLabel) self.layout.addStretch() self.layout.addWidget(self.countButton) self.layout.addWidget(self.widgetFavorite) self.launchButton.clicked.connect(self.launch) self.subversionLabel.setText(self.build_info.subversion) if self.branch == 'lts': branch_name = "LTS" else: branch_name = self.branch.replace('-', ' ').title() self.branchLabel.setText(branch_name) self.commitTimeLabel.setText(self.build_info.commit_time) self.buildHashLabel.setText(self.build_info.build_hash) # Context menu self.setContextMenuPolicy(Qt.CustomContextMenu) self.customContextMenuRequested.connect(self.context_menu) self.menu = QMenu() self.menu.setFont(self.parent.font) self.menu_extended = QMenu() self.menu_extended.setFont(self.parent.font) self.deleteAction = QAction("Delete From Drive", self) self.deleteAction.setIcon(self.icon_delete) self.deleteAction.triggered.connect(self.ask_remove_from_drive) self.setAsFavoriteAction = QAction("Mark As Favorite", self) self.setAsFavoriteAction.setIcon(self.icon_favorite) self.setAsFavoriteAction.triggered.connect(self.set_favorite) self.registerExtentionAction = QAction("Register Extension") self.registerExtentionAction.triggered.connect(self.register_extension) self.createShortcutAction = QAction("Create Shortcut") self.createShortcutAction.triggered.connect(self.create_shortcut) self.showFolderAction = QAction("Show Folder") self.showFolderAction.triggered.connect(self.show_folder) self.createSymlinkAction = QAction("Create Symlink") self.createSymlinkAction.triggered.connect(self.create_symlink) self.menu.addAction(self.setAsFavoriteAction) if get_platform() == 'Windows': self.menu.addAction(self.registerExtentionAction) self.menu.addAction(self.createShortcutAction) self.menu.addAction(self.createSymlinkAction) self.menu.addAction(self.showFolderAction) self.menu.addAction(self.deleteAction) self.menu_extended.addAction(self.deleteAction) if self.show_new: self.NewItemLabel = QLabel("New") self.NewItemLabel.setAlignment(Qt.AlignRight | Qt.AlignCenter) self.NewItemLabel.setIndent(6) self.layout.addWidget(self.NewItemLabel) if get_mark_as_favorite() == 0: pass elif (get_mark_as_favorite() == 1 and self.branch == "stable"): self.set_favorite() elif (get_mark_as_favorite() == 2 and self.branch == "daily"): self.set_favorite() elif get_mark_as_favorite() == 3: self.set_favorite() elif get_favorite_path() == self.link: self.set_favorite() self.setEnabled(True) self.list_widget.sortItems() self.list_widget.resize_labels( ('subversionLabel', 'branchLabel', 'commitTimeLabel', 'buildHashLabel'))
def __init__(self, parent): super().__init__() self.setWindowFlag(Qt.SubWindow) self.parent = parent self.setupUi(self) self.setWindowTitle("Settings") self.HeaderLayout = QHBoxLayout() self.HeaderLayout.setContentsMargins(36, 1, 1, 0) self.HeaderLayout.setSpacing(0) self.CentralLayout.addLayout(self.HeaderLayout) self.CloseButton = \ QPushButton(QIcon(":resources/icons/close.svg"), "") self.CloseButton.setIconSize(QSize(20, 20)) self.CloseButton.setFixedSize(36, 32) self.CloseButton.setProperty("HeaderButton", True) self.CloseButton.setProperty("CloseButton", True) self.CloseButton.clicked.connect(self.close) self.HeaderLabel = QLabel("Settings") self.HeaderLabel.setAlignment(Qt.AlignCenter) self.HeaderLayout.addWidget(self.HeaderLabel, 1) self.HeaderLayout.addWidget(self.CloseButton, 0, Qt.AlignRight) # Library Folder self.LibraryFolderLineEdit = QLineEdit() self.LibraryFolderLineEdit.setText(str(get_library_folder())) self.LibraryFolderLineEdit.setContextMenuPolicy(Qt.NoContextMenu) self.LibraryFolderLineEdit.setReadOnly(True) self.LibraryFolderLineEdit.setCursorPosition(0) self.SetLibraryFolderButton = \ QPushButton(QIcon(":resources/icons/folder.svg"), "") self.SetLibraryFolderButton.clicked.connect(self.set_library_folder) self.ReloadLibraryFolderContentButton = QPushButton( "Reload Library Folder Content") self.ReloadLibraryFolderContentButton.clicked.connect( lambda: self.parent.draw_library(True)) self.LibraryFolderLayout = QHBoxLayout() self.LibraryFolderLayout.setContentsMargins(0, 0, 0, 0) self.LibraryFolderLayout.setSpacing(0) self.LibraryFolderLayout.addWidget(self.LibraryFolderLineEdit) self.LibraryFolderLayout.addWidget(self.SetLibraryFolderButton) # Launch When System Starts self.LaunchWhenSystemStartsCheckBox = QCheckBox( "Launch When System Starts") self.LaunchWhenSystemStartsCheckBox.setChecked( get_launch_when_system_starts()) self.LaunchWhenSystemStartsCheckBox.clicked.connect( self.toggle_launch_when_system_starts) # Launch Minimized To Tray self.LaunchMinimizedToTrayCheckBox = QCheckBox( "Launch Minimized To Tray") self.LaunchMinimizedToTrayCheckBox.setChecked( get_launch_minimized_to_tray()) self.LaunchMinimizedToTrayCheckBox.clicked.connect( self.toggle_launch_minimized_to_tray) # High Dpi Scaling self.EnableHighDpiScalingCheckBox = \ QCheckBox("Enable High DPI Scaling") self.EnableHighDpiScalingCheckBox.clicked.connect( self.toggle_enable_high_dpi_scaling) self.EnableHighDpiScalingCheckBox.setChecked( get_enable_high_dpi_scaling()) # Taskbar Icon Color self.TaskbarIconColorComboBox = QComboBox() self.TaskbarIconColorComboBox.addItems(taskbar_icon_colors.keys()) self.TaskbarIconColorComboBox.setCurrentIndex( get_taskbar_icon_color()) self.TaskbarIconColorComboBox.activated[str].connect( self.change_taskbar_icon_color) # Default Library Page self.DefaultLibraryPageComboBox = QComboBox() self.DefaultLibraryPageComboBox.addItems(library_pages.keys()) self.DefaultLibraryPageComboBox.setCurrentIndex( get_default_library_page()) self.DefaultLibraryPageComboBox.activated[str].connect( self.change_default_library_page) # Default Downloads Page self.DefaultDownloadsPageComboBox = QComboBox() self.DefaultDownloadsPageComboBox.addItems(downloads_pages.keys()) self.DefaultDownloadsPageComboBox.setCurrentIndex( get_default_downloads_page()) self.DefaultDownloadsPageComboBox.activated[str].connect( self.change_default_downloads_page) # Notifications self.EnableNewBuildsNotifications = QCheckBox( "When New Builds Are Available") self.EnableNewBuildsNotifications.clicked.connect( self.toggle_enable_new_builds_notifications) self.EnableNewBuildsNotifications.setChecked( get_enable_new_builds_notifications()) self.EnableDownloadNotifications = QCheckBox( "When Downloading Is Finished") self.EnableDownloadNotifications.clicked.connect( self.toggle_enable_download_notifications) self.EnableDownloadNotifications.setChecked( get_enable_download_notifications()) # Mark As Favorite self.MarkAsFavorite = QComboBox() self.MarkAsFavorite.addItems(favorite_pages.keys()) self.MarkAsFavorite.setCurrentIndex( get_mark_as_favorite()) self.MarkAsFavorite.activated[str].connect( self.change_mark_as_favorite) # Layout self.SettingsLayout = QFormLayout() self.SettingsLayout.setContentsMargins(6, 6, 6, 6) self.SettingsLayout.setSpacing(6) self.SettingsLayout.setRowWrapPolicy(QFormLayout.DontWrapRows) self.SettingsLayout.setFieldGrowthPolicy( QFormLayout.AllNonFixedFieldsGrow) self.SettingsLayout.setLabelAlignment(Qt.AlignLeft) self.CentralLayout.addLayout(self.SettingsLayout) self.SettingsLayout.addRow(QLabel("Library Folder:")) self.SettingsLayout.addRow(self.LibraryFolderLayout) self.SettingsLayout.addRow( self.ReloadLibraryFolderContentButton) self.SettingsLayout.addRow(QLabel("System:")) if get_platform() == 'Windows': self.SettingsLayout.addRow(self.LaunchWhenSystemStartsCheckBox) self.SettingsLayout.addRow(self.LaunchMinimizedToTrayCheckBox) self.SettingsLayout.addRow(self.EnableHighDpiScalingCheckBox) self.SettingsLayout.addRow(QLabel("Interface:")) self.SettingsLayout.addRow( "Taskbar Icon Color", self.TaskbarIconColorComboBox) self.SettingsLayout.addRow( "Default Library Page", self.DefaultLibraryPageComboBox) self.SettingsLayout.addRow( "Default Downloads Page", self.DefaultDownloadsPageComboBox) self.SettingsLayout.addRow(QLabel("Notifications:")) self.SettingsLayout.addRow(self.EnableNewBuildsNotifications) self.SettingsLayout.addRow(self.EnableDownloadNotifications) self.SettingsLayout.addRow(QLabel("Service:")) self.SettingsLayout.addRow( "Mark New Build As Favorite", self.MarkAsFavorite) self.resize(self.sizeHint()) self.show()