Skip to content

Commit

Permalink
Merge pull request #1024 from virusMac/PICARD-1325
Browse files Browse the repository at this point in the history
PICARD-1325: Allow disabling new version update checking for packagers
  • Loading branch information
phw committed Nov 5, 2018
2 parents 21a4581 + ff0df0a commit 985c56c
Show file tree
Hide file tree
Showing 6 changed files with 41 additions and 32 deletions.
5 changes: 3 additions & 2 deletions picard/tagger.py
Expand Up @@ -146,7 +146,7 @@ def __init__(self, picard_args, unparsed_args, localedir, autoupdate):
)

self._cmdline_files = picard_args.FILE
self._autoupdate = autoupdate
self.autoupdate_enabled = autoupdate
self._no_restore = picard_args.no_restore
self._no_plugins = picard_args.no_plugins

Expand Down Expand Up @@ -251,7 +251,8 @@ def __init__(self, picard_args, unparsed_args, localedir, autoupdate):
self.stopping = False

# Load release version information
self.updatecheckmanager = UpdateCheckManager(parent=self.window)
if self.autoupdate_enabled:
self.updatecheckmanager = UpdateCheckManager(parent=self.window)

def register_cleanup(self, func):
self.exit_cleanup.append(func)
Expand Down
13 changes: 8 additions & 5 deletions picard/ui/mainwindow.py
Expand Up @@ -189,7 +189,8 @@ def keyPressEvent(self, event):
def show(self):
self.restoreWindowState()
super().show()
self.auto_update_check()
if self.tagger.autoupdate_enabled:
self.auto_update_check()
self.metadata_box.restore_state()

def closeEvent(self, event):
Expand Down Expand Up @@ -556,8 +557,9 @@ def create_actions(self):
self.open_folder_action.setEnabled(False)
self.open_folder_action.triggered.connect(self.open_folder)

self.check_update_action = QtWidgets.QAction(_("&Check for Update"), self)
self.check_update_action.triggered.connect(self.do_update_check)
if self.tagger.autoupdate_enabled:
self.check_update_action = QtWidgets.QAction(_("&Check for Update"), self)
self.check_update_action.triggered.connect(self.do_update_check)

def toggle_rename_files(self, checked):
config.setting["rename_files"] = checked
Expand Down Expand Up @@ -634,8 +636,9 @@ def create_menus(self):
menu.addSeparator()
menu.addAction(self.view_history_action)
menu.addSeparator()
menu.addAction(self.check_update_action)
menu.addSeparator()
if self.tagger.autoupdate_enabled:
menu.addAction(self.check_update_action)
menu.addSeparator()
menu.addAction(self.support_forum_action)
menu.addAction(self.report_bug_action)
menu.addAction(self.view_log_action)
Expand Down
22 changes: 13 additions & 9 deletions picard/ui/options/general.py
Expand Up @@ -74,21 +74,25 @@ def load(self):
self.ui.server_port.setValue(config.setting["server_port"])
self.ui.analyze_new_files.setChecked(config.setting["analyze_new_files"])
self.ui.ignore_file_mbids.setChecked(config.setting["ignore_file_mbids"])
self.ui.check_for_updates.setChecked(config.setting["check_for_updates"])
self.ui.update_level.clear()
for level, description in PROGRAM_UPDATE_LEVELS.items():
self.ui.update_level.addItem(_(description['title']), level)
self.ui.update_level.setCurrentIndex(self.ui.update_level.findData(config.setting["update_level"]))
self.ui.update_check_days.setValue(config.setting["update_check_days"])
if self.tagger.autoupdate_enabled:
self.ui.check_for_updates.setChecked(config.setting["check_for_updates"])
self.ui.update_level.clear()
for level, description in PROGRAM_UPDATE_LEVELS.items():
self.ui.update_level.addItem(_(description['title']), level)
self.ui.update_level.setCurrentIndex(self.ui.update_level.findData(config.setting["update_level"]))
self.ui.update_check_days.setValue(config.setting["update_check_days"])
else:
self.ui.update_check_groupbox.hide()

def save(self):
config.setting["server_host"] = self.ui.server_host.currentText().strip()
config.setting["server_port"] = self.ui.server_port.value()
config.setting["analyze_new_files"] = self.ui.analyze_new_files.isChecked()
config.setting["ignore_file_mbids"] = self.ui.ignore_file_mbids.isChecked()
config.setting["check_for_updates"] = self.ui.check_for_updates.isChecked()
config.setting["update_level"] = self.ui.update_level.currentData(QtCore.Qt.UserRole)
config.setting["update_check_days"] = self.ui.update_check_days.value()
if self.tagger.autoupdate_enabled:
config.setting["check_for_updates"] = self.ui.check_for_updates.isChecked()
config.setting["update_level"] = self.ui.update_level.currentData(QtCore.Qt.UserRole)
config.setting["update_check_days"] = self.ui.update_check_days.value()

def update_login_logout(self):
if self.tagger.webservice.oauth_manager.is_logged_in():
Expand Down
27 changes: 14 additions & 13 deletions picard/ui/ui_options_general.py
Expand Up @@ -67,31 +67,31 @@ def setupUi(self, GeneralOptionsPage):
self.ignore_file_mbids.setObjectName("ignore_file_mbids")
self.verticalLayout.addWidget(self.ignore_file_mbids)
self.vboxlayout.addWidget(self.groupBox_2)
self.groupBox_3 = QtWidgets.QGroupBox(GeneralOptionsPage)
self.groupBox_3.setEnabled(True)
self.update_check_groupbox = QtWidgets.QGroupBox(GeneralOptionsPage)
self.update_check_groupbox.setEnabled(True)
sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Preferred, QtWidgets.QSizePolicy.Preferred)
sizePolicy.setHorizontalStretch(0)
sizePolicy.setVerticalStretch(0)
sizePolicy.setHeightForWidth(self.groupBox_3.sizePolicy().hasHeightForWidth())
self.groupBox_3.setSizePolicy(sizePolicy)
self.groupBox_3.setObjectName("groupBox_3")
self.verticalLayout_2 = QtWidgets.QVBoxLayout(self.groupBox_3)
sizePolicy.setHeightForWidth(self.update_check_groupbox.sizePolicy().hasHeightForWidth())
self.update_check_groupbox.setSizePolicy(sizePolicy)
self.update_check_groupbox.setObjectName("update_check_groupbox")
self.verticalLayout_2 = QtWidgets.QVBoxLayout(self.update_check_groupbox)
self.verticalLayout_2.setObjectName("verticalLayout_2")
self.check_for_updates = QtWidgets.QCheckBox(self.groupBox_3)
self.check_for_updates = QtWidgets.QCheckBox(self.update_check_groupbox)
self.check_for_updates.setObjectName("check_for_updates")
self.verticalLayout_2.addWidget(self.check_for_updates)
self.gridLayout = QtWidgets.QGridLayout()
self.gridLayout.setContentsMargins(-1, -1, -1, 0)
self.gridLayout.setObjectName("gridLayout")
self.label_2 = QtWidgets.QLabel(self.groupBox_3)
self.label_2 = QtWidgets.QLabel(self.update_check_groupbox)
sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.MinimumExpanding, QtWidgets.QSizePolicy.Preferred)
sizePolicy.setHorizontalStretch(0)
sizePolicy.setVerticalStretch(0)
sizePolicy.setHeightForWidth(self.label_2.sizePolicy().hasHeightForWidth())
self.label_2.setSizePolicy(sizePolicy)
self.label_2.setObjectName("label_2")
self.gridLayout.addWidget(self.label_2, 0, 0, 1, 1)
self.update_check_days = QtWidgets.QSpinBox(self.groupBox_3)
self.update_check_days = QtWidgets.QSpinBox(self.update_check_groupbox)
sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Fixed, QtWidgets.QSizePolicy.Fixed)
sizePolicy.setHorizontalStretch(0)
sizePolicy.setVerticalStretch(0)
Expand All @@ -105,10 +105,10 @@ def setupUi(self, GeneralOptionsPage):
self.gridLayout_2 = QtWidgets.QGridLayout()
self.gridLayout_2.setContentsMargins(-1, -1, -1, 0)
self.gridLayout_2.setObjectName("gridLayout_2")
self.label_3 = QtWidgets.QLabel(self.groupBox_3)
self.label_3 = QtWidgets.QLabel(self.update_check_groupbox)
self.label_3.setObjectName("label_3")
self.gridLayout_2.addWidget(self.label_3, 0, 0, 1, 1)
self.update_level = QtWidgets.QComboBox(self.groupBox_3)
self.update_level = QtWidgets.QComboBox(self.update_check_groupbox)
sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.MinimumExpanding, QtWidgets.QSizePolicy.Fixed)
sizePolicy.setHorizontalStretch(0)
sizePolicy.setVerticalStretch(0)
Expand All @@ -118,7 +118,8 @@ def setupUi(self, GeneralOptionsPage):
self.update_level.setObjectName("update_level")
self.gridLayout_2.addWidget(self.update_level, 0, 1, 1, 1)
self.verticalLayout_2.addLayout(self.gridLayout_2)
self.vboxlayout.addWidget(self.groupBox_3)
self.vboxlayout.addWidget(self.update_check_groupbox)

spacerItem1 = QtWidgets.QSpacerItem(181, 21, QtWidgets.QSizePolicy.Minimum, QtWidgets.QSizePolicy.Expanding)
self.vboxlayout.addItem(spacerItem1)

Expand All @@ -137,7 +138,7 @@ def retranslateUi(self, GeneralOptionsPage):
self.groupBox_2.setTitle(_("General"))
self.analyze_new_files.setText(_("Automatically scan all new files"))
self.ignore_file_mbids.setText(_("Ignore MBIDs when loading new files"))
self.groupBox_3.setTitle(_("Update Checking"))
self.update_check_groupbox.setTitle(_("Update Checking"))
self.check_for_updates.setText(_("Check for updates during start-up"))
self.label_2.setText(_("Days between checks:"))
self.label_3.setText(_("Updates to check:"))
Expand Down
4 changes: 2 additions & 2 deletions setup.py
Expand Up @@ -144,7 +144,7 @@ class picard_install(install):
('install-locales=', None,
"installation directory for locales"),
('localedir=', None, ''),
('disable-autoupdate', None, ''),
('disable-autoupdate', None, 'disable update checking and hide settings for it'),
('disable-locales', None, ''),
]

Expand Down Expand Up @@ -181,7 +181,7 @@ class picard_build(build):
user_options = build.user_options + [
('build-locales=', 'd', "build directory for locale files"),
('localedir=', None, ''),
('disable-autoupdate', None, ''),
('disable-autoupdate', None, 'disable update checking and hide settings for it'),
('disable-locales', None, ''),
]

Expand Down
2 changes: 1 addition & 1 deletion ui/options_general.ui
Expand Up @@ -133,7 +133,7 @@
</widget>
</item>
<item>
<widget class="QGroupBox" name="groupBox_3">
<widget class="QGroupBox" name="update_check_groupbox">
<property name="enabled">
<bool>true</bool>
</property>
Expand Down

0 comments on commit 985c56c

Please sign in to comment.