示例#1
0
 def alert(self, repo):
     if Settings().show_msg:
         repo_name = QtCore.QFileInfo(repo).fileName()
         self.tray_icon.showMessage(
             repo_name,
             "Remote repository has been updated. It's time to pull!")
     if Settings().play_sound:
         QtMultimedia.QSound.play(':/time2pull/sounds/sonar.wav')
示例#2
0
 def on_pushButtonRemove_clicked(self):
     repo = self.listWidgetRepos.currentItem().text()
     answer = QtWidgets.QMessageBox.question(
         self, 'Remove repository',
         'Are you sure you want to remove repository: %s?' % repo)
     if answer == QtWidgets.QMessageBox.Yes:
         self.listWidgetRepos.takeItem(self.listWidgetRepos.currentRow())
         settings = Settings()
         repos = settings.repositories
         try:
             repos.remove(repo)
         except ValueError:
             pass
         settings.repositories = repos
示例#3
0
 def closeEvent(self, event):
     if not self._quitting:
         if (not self._user_warned_about_tray and
                 not Settings().hide_on_startup):
             QtWidgets.QMessageBox.information(
                 self, "Time2Pull",
                 "The program will keep running in the system tray.\n"
                 "To terminate the program, choose Quit in the context menu"
                 " of the system tray entry.")
             self._user_warned_about_tray = True
         self.hide()
         event.ignore()
     # save geometry and state
     s = Settings()
     s.geometry = self.saveGeometry()
     s.state = self.saveState()
示例#4
0
文件: app.py 项目: rrosajp/Time2Pull
def main():
    global app, win
    app = QtWidgets.QApplication(sys.argv)
    win = MainWindow()
    if not Settings().hide_on_startup:
        win.show()
    app.exec_()
示例#5
0
def get_tray_icon(is_behind):
    if is_behind:
        return QtGui.QIcon(':/time2pull/icons/Download.png')
    else:
        icons = {
            TrayIconType.light: ':/time2pull/icons/Download-light.png',
            TrayIconType.dark: ':/time2pull/icons/Download-dark.png'
        }
        return QtGui.QIcon(icons[Settings().tray_icon_type])
示例#6
0
 def load_repo_from_settings(self):
     self.listWidgetRepos.clear()
     self.listWidgetRepos.setIconSize(QtCore.QSize(64, 64))
     settings = Settings()
     for file in settings.repositories:
         item = QtWidgets.QListWidgetItem()
         item.setText(file)
         item.setIcon(get_status_icon())
         item.setData(QtCore.Qt.UserRole, (False, RemoteStatus.up_to_date))
         self.listWidgetRepos.addItem(item)
示例#7
0
 def on_pushButtonAdd_clicked(self):
     path = QtWidgets.QFileDialog.getExistingDirectory(
         self, 'Select a repository')
     settings = Settings()
     if path and path not in settings.repositories:
         if os.path.exists(os.path.join(path, '.git')):
             repos = settings.repositories
             repos.append(path)
             settings.repositories = repos
             item = QtWidgets.QListWidgetItem()
             item.setText(path)
             item.setIcon(get_status_icon())
             item.setData(QtCore.Qt.UserRole, (False, RemoteStatus.up_to_date))
             self.listWidgetRepos.addItem(item)
             self.on_refresh_requested()
         else:
             QtWidgets.QMessageBox.warning(
                 self, 'Not a git repository',
                 'The chosen directory is not a git repository')
示例#8
0
    def setup_tray_icon_mnu(self):
        self.tray_icon_menu = QtWidgets.QMenu(self)
        self.tray_icon_menu.addAction(self.actionRestore)
        self.tray_icon_menu.addSeparator()
        self.tray_icon_menu.addAction(self.actionAdd)
        self.actionAdd.triggered.connect(self.on_pushButtonAdd_clicked)
        self.tray_icon_menu.addAction(self.actionRefresh)
        self.actionRefresh.triggered.connect(self.on_refresh_requested)
        self.tray_icon_menu.addSeparator()
        # Preferences
        preferences = QtWidgets.QMenu('Preferences', self)
        self.actionIconGroup = QtWidgets.QActionGroup(self)
        self.actionIconGroup.triggered.connect(
            self.on_tray_icon_style_triggered)
        for title in ['Light icon', 'Dark icon']:
            action = QtWidgets.QAction(title, self)
            action.setCheckable(True)
            self.actionIconGroup.addAction(action)
        self.actionIconGroup.actions()[int(TrayIconType.light)].setChecked(
            Settings().tray_icon_type == TrayIconType.light)
        self.actionIconGroup.actions()[int(TrayIconType.dark)].setChecked(
            Settings().tray_icon_type == TrayIconType.dark)
        mnu = QtWidgets.QMenu(self)
        mnu.setTitle('Tray icon')
        mnu.addActions(self.actionIconGroup.actions())
        preferences.addMenu(mnu)
        preferences.addAction(self.actionHide_on_startup)
        self.actionHide_on_startup.setChecked(Settings().hide_on_startup)
        self.tray_icon_menu.addMenu(preferences)
        preferences.addAction(self.actionPlay_alert_sound)
        preferences.addAction(self.actionShow_message)
        self.actionShow_message.setChecked(Settings().show_msg)
        self.actionPlay_alert_sound.setChecked(Settings().play_sound)
        self.tray_icon_menu.addSeparator()

        self.tray_icon_menu.addAction(self.actionHelp)
        self.tray_icon_menu.addAction(self.actionAbout)
        self.actionHelp.setShortcut(QtGui.QKeySequence.HelpContents)
        self.tray_icon_menu.addSeparator()
        self.tray_icon_menu.addAction(self.actionQuit)
        self.actionQuit.setShortcut(QtGui.QKeySequence.Quit)
示例#9
0
 def restore_geometry_and_state(self):
     s = Settings()
     if s.geometry:
         self.restoreGeometry(s.geometry)
     if s.state:
         self.restoreState(s.state)
示例#10
0
 def on_actionShow_message_triggered(self):
     Settings().show_msg = self.actionShow_message.isChecked()
示例#11
0
 def on_actionPlay_alert_sound_triggered(self):
     Settings().play_sound = self.actionPlay_alert_sound.isChecked()
示例#12
0
 def on_actionHide_on_startup_toggled(self, checked):
     Settings().hide_on_startup = checked
示例#13
0
 def on_tray_icon_style_triggered(self, action):
     ltext = action.text().lower()
     settings = Settings()
     settings.tray_icon_type = (
         TrayIconType.dark if 'dark' in ltext else TrayIconType.light)
     self.update_tray_icon()
示例#14
0
 def _get_repositories_to_refresh(self):
     # maybe only the selected if there is a selection ? not sure it would
     # be useful.
     return Settings().repositories