singleton fix
This commit is contained in:
parent
635feb3532
commit
6c525477d9
3 changed files with 15 additions and 11 deletions
12
src/menu.py
12
src/menu.py
|
@ -215,7 +215,7 @@ class PrivacySettings(QtGui.QWidget):
|
||||||
self.typingNotifications.setObjectName("typingNotifications")
|
self.typingNotifications.setObjectName("typingNotifications")
|
||||||
|
|
||||||
self.retranslateUi()
|
self.retranslateUi()
|
||||||
settings = Settings()
|
settings = Settings.get_instance()
|
||||||
self.typingNotifications.setChecked(settings['typing_notifications'])
|
self.typingNotifications.setChecked(settings['typing_notifications'])
|
||||||
self.fileautoaccept.setChecked(settings['allow_auto_accept'])
|
self.fileautoaccept.setChecked(settings['allow_auto_accept'])
|
||||||
self.saveHistory.setChecked(settings['save_history'])
|
self.saveHistory.setChecked(settings['save_history'])
|
||||||
|
@ -228,7 +228,7 @@ class PrivacySettings(QtGui.QWidget):
|
||||||
self.typingNotifications.setText(QtGui.QApplication.translate("privacySettings", "Send typing notifications", None, QtGui.QApplication.UnicodeUTF8))
|
self.typingNotifications.setText(QtGui.QApplication.translate("privacySettings", "Send typing notifications", None, QtGui.QApplication.UnicodeUTF8))
|
||||||
|
|
||||||
def closeEvent(self, event):
|
def closeEvent(self, event):
|
||||||
settings = Settings()
|
settings = Settings.get_instance()
|
||||||
settings['typing_notifications'] = self.typingNotifications.isChecked()
|
settings['typing_notifications'] = self.typingNotifications.isChecked()
|
||||||
settings['allow_auto_accept'] = self.fileautoaccept.isChecked()
|
settings['allow_auto_accept'] = self.fileautoaccept.isChecked()
|
||||||
settings['save_history'] = self.saveHistory.isChecked()
|
settings['save_history'] = self.saveHistory.isChecked()
|
||||||
|
@ -257,7 +257,7 @@ class NotificationsSettings(QtGui.QWidget):
|
||||||
self.callsSound = QtGui.QCheckBox(self)
|
self.callsSound = QtGui.QCheckBox(self)
|
||||||
self.callsSound.setGeometry(QtCore.QRect(30, 60, 231, 22))
|
self.callsSound.setGeometry(QtCore.QRect(30, 60, 231, 22))
|
||||||
self.callsSound.setObjectName("checkBox_3")
|
self.callsSound.setObjectName("checkBox_3")
|
||||||
s = Settings()
|
s = Settings.get_instance()
|
||||||
self.enableNotifications.setChecked(s['notifications'])
|
self.enableNotifications.setChecked(s['notifications'])
|
||||||
self.soundNotifications.setChecked(s['sound_notifications'])
|
self.soundNotifications.setChecked(s['sound_notifications'])
|
||||||
self.callsSound.setChecked(s['calls_sound'])
|
self.callsSound.setChecked(s['calls_sound'])
|
||||||
|
@ -271,7 +271,7 @@ class NotificationsSettings(QtGui.QWidget):
|
||||||
self.callsSound.setText(QtGui.QApplication.translate("notificationsForm", "Enable sound notifications", None, QtGui.QApplication.UnicodeUTF8))
|
self.callsSound.setText(QtGui.QApplication.translate("notificationsForm", "Enable sound notifications", None, QtGui.QApplication.UnicodeUTF8))
|
||||||
|
|
||||||
def closeEvent(self, *args, **kwargs):
|
def closeEvent(self, *args, **kwargs):
|
||||||
settings = Settings()
|
settings = Settings.get_instance()
|
||||||
settings['notifications'] = self.enableNotifications.isChecked()
|
settings['notifications'] = self.enableNotifications.isChecked()
|
||||||
settings['sound_notifications'] = self.soundNotifications.isChecked()
|
settings['sound_notifications'] = self.soundNotifications.isChecked()
|
||||||
settings['calls_sound'] = self.callsSound.isChecked()
|
settings['calls_sound'] = self.callsSound.isChecked()
|
||||||
|
@ -307,7 +307,7 @@ class InterfaceSettings(QtGui.QWidget):
|
||||||
self.themeSelect.setObjectName("themeSelect")
|
self.themeSelect.setObjectName("themeSelect")
|
||||||
list_of_themes = ['default', 'windows', 'gtk', 'cde', 'plastique', 'motif']
|
list_of_themes = ['default', 'windows', 'gtk', 'cde', 'plastique', 'motif']
|
||||||
self.themeSelect.addItems(list_of_themes)
|
self.themeSelect.addItems(list_of_themes)
|
||||||
theme = Settings()['theme']
|
theme = Settings.get_instance()['theme']
|
||||||
index = list_of_themes.index(theme)
|
index = list_of_themes.index(theme)
|
||||||
self.themeSelect.setCurrentIndex(index)
|
self.themeSelect.setCurrentIndex(index)
|
||||||
self.retranslateUi()
|
self.retranslateUi()
|
||||||
|
@ -318,7 +318,7 @@ class InterfaceSettings(QtGui.QWidget):
|
||||||
self.label.setText(QtGui.QApplication.translate("interfaceForm", "Theme:", None, QtGui.QApplication.UnicodeUTF8))
|
self.label.setText(QtGui.QApplication.translate("interfaceForm", "Theme:", None, QtGui.QApplication.UnicodeUTF8))
|
||||||
|
|
||||||
def closeEvent(self, event):
|
def closeEvent(self, event):
|
||||||
settings = Settings()
|
settings = Settings.get_instance()
|
||||||
style = str(self.themeSelect.currentText())
|
style = str(self.themeSelect.currentText())
|
||||||
settings['theme'] = style
|
settings['theme'] = style
|
||||||
settings.save()
|
settings.save()
|
||||||
|
|
|
@ -141,7 +141,7 @@ class Profile(Contact):
|
||||||
self._name = tox.self_get_name()
|
self._name = tox.self_get_name()
|
||||||
self._status_message = tox.self_get_status_message()
|
self._status_message = tox.self_get_status_message()
|
||||||
self._status = None
|
self._status = None
|
||||||
self.show_online = Settings()['show_online_friends']
|
self.show_online = Settings.get_instance()['show_online_friends']
|
||||||
data = tox.self_get_friend_list()
|
data = tox.self_get_friend_list()
|
||||||
self._friends, num, self._active_friend = [], 0, -1
|
self._friends, num, self._active_friend = [], 0, -1
|
||||||
for i in data:
|
for i in data:
|
||||||
|
|
12
src/util.py
12
src/util.py
|
@ -31,7 +31,11 @@ def get_style(style):
|
||||||
|
|
||||||
class Singleton(object):
|
class Singleton(object):
|
||||||
|
|
||||||
def __new__(cls, *args):
|
def __new__(cls, *args, **kwargs):
|
||||||
if not hasattr(cls, 'instance'):
|
if not hasattr(cls, '_instance'):
|
||||||
cls.instance = super(Singleton, cls,).__new__(cls, *args)
|
cls._instance = super(Singleton, cls).__new__(cls, *args, **kwargs)
|
||||||
return cls.instance
|
return cls._instance
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def get_instance(cls):
|
||||||
|
return cls._instance
|
||||||
|
|
Loading…
Reference in a new issue