mirror of
				https://github.com/arsenetar/dupeguru.git
				synced 2025-09-11 17:58:17 +00:00 
			
		
		
		
	Pushed some logic for fairware from gui layers to hscommon.
This commit is contained in:
		
							parent
							
								
									9fac97c147
								
							
						
					
					
						commit
						9a7a20472d
					
				| @ -166,7 +166,7 @@ http://www.hardcoded.net/licenses/bsd_license | ||||
|         [[self resultWindow] restoreColumnsPosition:columnsOrder widths:columnsWidth]; | ||||
|     else | ||||
|         [[self resultWindow] resetColumnsToDefault:nil]; | ||||
|     [HSFairwareReminder showNagWithApp:[self py]]; | ||||
|     [py initialRegistrationSetup]; | ||||
|     [py loadSession]; | ||||
| } | ||||
| 
 | ||||
| @ -227,4 +227,14 @@ http://www.hardcoded.net/licenses/bsd_license | ||||
| { | ||||
|     [Dialogs showMessage:msg]; | ||||
| } | ||||
| 
 | ||||
| - (void)setupAsRegistered | ||||
| { | ||||
|     // Nothing to do. | ||||
| } | ||||
| 
 | ||||
| - (void)showFairwareNag | ||||
| { | ||||
|     [HSFairwareReminder showNagWithApp:[self py]]; | ||||
| } | ||||
| @end | ||||
|  | ||||
| @ -2,11 +2,10 @@ import logging | ||||
| 
 | ||||
| from jobprogress import job | ||||
| from hscommon import cocoa | ||||
| from hscommon.cocoa import install_exception_hook, pythonify | ||||
| from hscommon.cocoa import install_exception_hook | ||||
| from hscommon.cocoa.inter import signature, PyFairware | ||||
| from hscommon.cocoa.objcmin import (NSNotificationCenter, NSUserDefaults, | ||||
|     NSSearchPathForDirectoriesInDomains, NSApplicationSupportDirectory, NSUserDomainMask, | ||||
|     NSWorkspace) | ||||
| from hscommon.cocoa.objcmin import (NSNotificationCenter, NSSearchPathForDirectoriesInDomains, | ||||
|     NSApplicationSupportDirectory, NSUserDomainMask, NSWorkspace) | ||||
| from hscommon.trans import tr | ||||
| 
 | ||||
| from core.app import JobType | ||||
| @ -188,14 +187,6 @@ class PyDupeGuruBase(PyFairware): | ||||
|             ud = {'desc': JOBID2TITLE[jobid], 'jobid':jobid} | ||||
|             NSNotificationCenter.defaultCenter().postNotificationName_object_userInfo_('JobStarted', self, ud) | ||||
|      | ||||
|     def get_default(self, key_name): | ||||
|         raw = NSUserDefaults.standardUserDefaults().objectForKey_(key_name) | ||||
|         result = pythonify(raw) | ||||
|         return result | ||||
|      | ||||
|     def set_default(self, key_name, value): | ||||
|         NSUserDefaults.standardUserDefaults().setObject_forKey_(value, key_name) | ||||
|      | ||||
|     def show_extra_fairware_reminder(self): | ||||
|         self.cocoa.showExtraFairwareReminder() | ||||
|      | ||||
|  | ||||
| @ -79,17 +79,14 @@ class DupeGuru(RegistrableApplication, Broadcaster): | ||||
|     # open_path(path) | ||||
|     # reveal_path(path) | ||||
|     # start_job(jobid, func, args=()) ( func(j, *args) ) | ||||
|     # get_default(key_name, fallback_value=None) | ||||
|     # set_default(key_name, value) | ||||
|     # show_extra_fairware_reminder() | ||||
|     # show_message(msg) | ||||
|      | ||||
|     def __init__(self, view, appdata): | ||||
|         self.view = view | ||||
|         if self.get_default(DEBUG_MODE_PREFERENCE, False): | ||||
|         if view.get_default(DEBUG_MODE_PREFERENCE): | ||||
|             logging.getLogger().setLevel(logging.DEBUG) | ||||
|             logging.debug("Debug mode enabled") | ||||
|         RegistrableApplication.__init__(self, appid=1) | ||||
|         RegistrableApplication.__init__(self, view, appid=1) | ||||
|         Broadcaster.__init__(self) | ||||
|         self.is_first_run = not self.get_default(HAD_FIRST_LAUNCH_PREFERENCE, False) | ||||
|         if self.is_first_run: | ||||
|  | ||||
| @ -82,9 +82,7 @@ class DupeGuru(QObject): | ||||
|         self.problemDialog = ProblemDialog(parent=self.resultWindow, app=self) | ||||
|         self.preferences_dialog = self._create_preferences_dialog(self.resultWindow) | ||||
|         self.about_box = AboutBox(self.resultWindow, self) | ||||
|          | ||||
|          | ||||
|         self.model.set_registration(self.prefs.registration_code, self.prefs.registration_email) | ||||
|                  | ||||
|         self.directories_dialog.show() | ||||
|         self.model.load() | ||||
|          | ||||
| @ -113,13 +111,6 @@ class DupeGuru(QObject): | ||||
|         if ISLINUX: | ||||
|             self.actionCheckForUpdate.setVisible(False) # This only works on Windows | ||||
|      | ||||
|     def _setup_as_registered(self): | ||||
|         self.prefs.registration_code = self.registration_code | ||||
|         self.prefs.registration_email = self.registration_email | ||||
|         self.actionRegister.setVisible(False) | ||||
|         self.about_box.registerButton.hide() | ||||
|         self.about_box.registeredEmailLabel.setText(self.prefs.registration_email) | ||||
|      | ||||
|     def _update_options(self): | ||||
|         self.model.scanner.mix_file_kind = self.prefs.mix_file_kind | ||||
|         self.model.options['escape_filter_regexp'] = self.prefs.use_regexp | ||||
| @ -198,9 +189,7 @@ class DupeGuru(QObject): | ||||
|      | ||||
|     #--- Events | ||||
|     def finishedLaunching(self): | ||||
|         if self.model.should_show_fairware_reminder: | ||||
|             reg = Registration(self.model) | ||||
|             reg.show_nag() | ||||
|         self.model.initial_registration_setup() | ||||
|      | ||||
|     def application_will_terminate(self): | ||||
|         self.willSavePrefs.emit() | ||||
| @ -282,6 +271,15 @@ class DupeGuru(QObject): | ||||
|     def set_default(self, key, value): | ||||
|         self.prefs.set_value(key, value) | ||||
|      | ||||
|     def setup_as_registered(self): | ||||
|         self.actionRegister.setVisible(False) | ||||
|         self.about_box.registerButton.hide() | ||||
|         self.about_box.registeredEmailLabel.setText(self.model.registration_email) | ||||
|      | ||||
|     def show_fairware_nag(self): | ||||
|         reg = Registration(self.model) | ||||
|         reg.show_nag() | ||||
|      | ||||
|     def show_extra_fairware_reminder(self): | ||||
|         dialog = ExtraFairwareReminder(self.directories_dialog, self) | ||||
|         dialog.exec() | ||||
|  | ||||
| @ -49,8 +49,6 @@ class Preferences(PreferencesBase): | ||||
|         self.recentResults = get('RecentResults', self.recentResults) | ||||
|         self.recentFolders = get('RecentFolders', self.recentFolders) | ||||
|          | ||||
|         self.registration_code = get('RegistrationCode', self.registration_code) | ||||
|         self.registration_email = get('RegistrationEmail', self.registration_email) | ||||
|         self._load_specific(settings) | ||||
|      | ||||
|     def _reset_specific(self): | ||||
| @ -76,8 +74,6 @@ class Preferences(PreferencesBase): | ||||
|         self.recentResults = [] | ||||
|         self.recentFolders = [] | ||||
|          | ||||
|         self.registration_code = '' | ||||
|         self.registration_email = '' | ||||
|         self._reset_specific() | ||||
|      | ||||
|     def reset_columns(self): | ||||
| @ -110,7 +106,5 @@ class Preferences(PreferencesBase): | ||||
|         set_('RecentResults', self.recentResults) | ||||
|         set_('RecentFolders', self.recentFolders) | ||||
|          | ||||
|         set_('RegistrationCode', self.registration_code) | ||||
|         set_('RegistrationEmail', self.registration_email) | ||||
|         self._save_specific(settings) | ||||
|      | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user