fixed bug with settings. interface and privacy settings added

This commit is contained in:
ingvar1995 2016-03-03 19:44:01 +03:00
parent b9937c13cd
commit 635feb3532
4 changed files with 39 additions and 3 deletions

View file

@ -6,7 +6,7 @@ import sys
from PySide import QtCore, QtGui from PySide import QtCore, QtGui
from callbacks import init_callbacks from callbacks import init_callbacks
from bootstrap import node_generator from bootstrap import node_generator
from util import curr_directory from util import curr_directory, get_style
class login(object): class login(object):
@ -73,6 +73,7 @@ def main():
ms = MainWindow(tox) ms = MainWindow(tox)
ms.show() ms.show()
QtGui.QApplication.setStyle(get_style(settings['theme'])) # set application style
# bootstrap # bootstrap
for data in node_generator(): for data in node_generator():
tox.bootstrap(*data) tox.bootstrap(*data)

View file

@ -1,6 +1,7 @@
from PySide import QtCore, QtGui from PySide import QtCore, QtGui
from settings import Settings from settings import Settings
from profile import Profile from profile import Profile
from util import get_style
class AddContact(QtGui.QWidget): class AddContact(QtGui.QWidget):
@ -214,6 +215,10 @@ class PrivacySettings(QtGui.QWidget):
self.typingNotifications.setObjectName("typingNotifications") self.typingNotifications.setObjectName("typingNotifications")
self.retranslateUi() self.retranslateUi()
settings = Settings()
self.typingNotifications.setChecked(settings['typing_notifications'])
self.fileautoaccept.setChecked(settings['allow_auto_accept'])
self.saveHistory.setChecked(settings['save_history'])
QtCore.QMetaObject.connectSlotsByName(self) QtCore.QMetaObject.connectSlotsByName(self)
def retranslateUi(self): def retranslateUi(self):
@ -222,6 +227,13 @@ class PrivacySettings(QtGui.QWidget):
self.fileautoaccept.setText(QtGui.QApplication.translate("privacySettings", "Allow file autoaccept", None, QtGui.QApplication.UnicodeUTF8)) self.fileautoaccept.setText(QtGui.QApplication.translate("privacySettings", "Allow file autoaccept", None, QtGui.QApplication.UnicodeUTF8))
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):
settings = Settings()
settings['typing_notifications'] = self.typingNotifications.isChecked()
settings['allow_auto_accept'] = self.fileautoaccept.isChecked()
settings['save_history'] = self.saveHistory.isChecked()
settings.save()
class NotificationsSettings(QtGui.QWidget): class NotificationsSettings(QtGui.QWidget):
"""Notifications settings form""" """Notifications settings form"""
@ -293,10 +305,21 @@ class InterfaceSettings(QtGui.QWidget):
font.setPointSize(17) font.setPointSize(17)
self.themeSelect.setFont(font) self.themeSelect.setFont(font)
self.themeSelect.setObjectName("themeSelect") self.themeSelect.setObjectName("themeSelect")
list_of_themes = ['default', 'windows', 'gtk', 'cde', 'plastique', 'motif']
self.themeSelect.addItems(list_of_themes)
theme = Settings()['theme']
index = list_of_themes.index(theme)
self.themeSelect.setCurrentIndex(index)
self.retranslateUi() self.retranslateUi()
QtCore.QMetaObject.connectSlotsByName(self) QtCore.QMetaObject.connectSlotsByName(self)
def retranslateUi(self): def retranslateUi(self):
self.setWindowTitle(QtGui.QApplication.translate("interfaceForm", "Interface settings", None, QtGui.QApplication.UnicodeUTF8)) self.setWindowTitle(QtGui.QApplication.translate("interfaceForm", "Interface settings", None, QtGui.QApplication.UnicodeUTF8))
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):
settings = Settings()
style = str(self.themeSelect.currentText())
settings['theme'] = style
settings.save()
QtGui.QApplication.setStyle(get_style(style))

View file

@ -4,7 +4,7 @@ import os
from util import Singleton from util import Singleton
class Settings(dict, Singleton): class Settings(Singleton, dict):
def __init__(self, name=''): def __init__(self, name=''):
self.path = Settings.get_default_path() + str(name) + '.json' self.path = Settings.get_default_path() + str(name) + '.json'

View file

@ -1,5 +1,7 @@
import os import os
import time import time
from platform import system
program_version = '0.0.1 (alpha)' program_version = '0.0.1 (alpha)'
@ -17,6 +19,16 @@ def curr_time():
return time.strftime("%H:%M") return time.strftime("%H:%M")
def get_style(style):
if style != 'default':
return style
else:
if system() == 'Linux':
return 'gtk'
elif system() == 'Windows':
return 'windows'
class Singleton(object): class Singleton(object):
def __new__(cls, *args): def __new__(cls, *args):