font and closing to tray update

This commit is contained in:
ingvar1995 2016-08-05 15:58:25 +03:00
parent 3a64121d72
commit b0e82dfd08
6 changed files with 72 additions and 31 deletions

View file

@ -23,7 +23,7 @@ class IncomingCallWidget(widgets.CenteredWidget):
self.name = widgets.DataLabel(self) self.name = widgets.DataLabel(self)
self.name.setGeometry(QtCore.QRect(90, 20, 300, 25)) self.name.setGeometry(QtCore.QRect(90, 20, 300, 25))
font = QtGui.QFont() font = QtGui.QFont()
font.setFamily("Times New Roman") font.setFamily(settings.Settings.get_instance['font'])
font.setPointSize(16) font.setPointSize(16)
font.setBold(True) font.setBold(True)
self.name.setFont(font) self.name.setFont(font)

View file

@ -33,7 +33,7 @@ class MessageEdit(QtGui.QTextBrowser):
else: else:
self.setHtml(text) self.setHtml(text)
font = QtGui.QFont() font = QtGui.QFont()
font.setFamily("Times New Roman") font.setFamily(settings.Settings.get_instance()['font'])
font.setPixelSize(settings.Settings.get_instance()['message_font_size']) font.setPixelSize(settings.Settings.get_instance()['message_font_size'])
font.setBold(False) font.setBold(False)
self.setFont(font) self.setFont(font)
@ -130,7 +130,7 @@ class MessageItem(QtGui.QWidget):
self.name.setGeometry(QtCore.QRect(2, 2, 95, 20)) self.name.setGeometry(QtCore.QRect(2, 2, 95, 20))
self.name.setTextFormat(QtCore.Qt.PlainText) self.name.setTextFormat(QtCore.Qt.PlainText)
font = QtGui.QFont() font = QtGui.QFont()
font.setFamily("Times New Roman") font.setFamily(settings.Settings.get_instance()['font'])
font.setPointSize(11) font.setPointSize(11)
font.setBold(True) font.setBold(True)
self.name.setFont(font) self.name.setFont(font)
@ -138,8 +138,6 @@ class MessageItem(QtGui.QWidget):
self.time = QtGui.QLabel(self) self.time = QtGui.QLabel(self)
self.time.setGeometry(QtCore.QRect(parent.width() - 50, 0, 50, 20)) self.time.setGeometry(QtCore.QRect(parent.width() - 50, 0, 50, 20))
font = QtGui.QFont()
font.setFamily("Times New Roman")
font.setPointSize(10) font.setPointSize(10)
font.setBold(False) font.setBold(False)
self.time.setFont(font) self.time.setFont(font)
@ -207,7 +205,7 @@ class ContactItem(QtGui.QWidget):
self.name = DataLabel(self) self.name = DataLabel(self)
self.name.setGeometry(QtCore.QRect(50 if mode else 75, 3 if mode else 10, 150, 15 if mode else 25)) self.name.setGeometry(QtCore.QRect(50 if mode else 75, 3 if mode else 10, 150, 15 if mode else 25))
font = QtGui.QFont() font = QtGui.QFont()
font.setFamily("Times New Roman") font.setFamily(settings.Settings.get_instance()['font'])
font.setPointSize(10 if mode else 12) font.setPointSize(10 if mode else 12)
font.setBold(True) font.setBold(True)
self.name.setFont(font) self.name.setFont(font)
@ -264,7 +262,7 @@ class UnreadMessagesCount(QtGui.QWidget):
self.label.setGeometry(QtCore.QRect(0, 0, 30, 20)) self.label.setGeometry(QtCore.QRect(0, 0, 30, 20))
self.label.setVisible(False) self.label.setVisible(False)
font = QtGui.QFont() font = QtGui.QFont()
font.setFamily("Times New Roman") font.setFamily(settings.Settings.get_instance()['font'])
font.setPointSize(12) font.setPointSize(12)
font.setBold(True) font.setBold(True)
self.label.setFont(font) self.label.setFont(font)
@ -300,7 +298,7 @@ class FileTransferItem(QtGui.QListWidget):
self.name.setGeometry(QtCore.QRect(3, 7, 95, 20)) self.name.setGeometry(QtCore.QRect(3, 7, 95, 20))
self.name.setTextFormat(QtCore.Qt.PlainText) self.name.setTextFormat(QtCore.Qt.PlainText)
font = QtGui.QFont() font = QtGui.QFont()
font.setFamily("Times New Roman") font.setFamily(settings.Settings.get_instance()['font'])
font.setPointSize(11) font.setPointSize(11)
font.setBold(True) font.setBold(True)
self.name.setFont(font) self.name.setFont(font)

View file

@ -239,11 +239,15 @@ class Toxygen:
self.p.show() self.p.show()
def tray_activated(reason): def tray_activated(reason):
if reason == QtGui.QSystemTrayIcon.DoubleClick: if reason == QtGui.QSystemTrayIcon.DoubleClick:
show_window() show_window()
def close_app():
settings.closing = True
self.ms.close()
m.connect(show, QtCore.SIGNAL("triggered()"), show_window) m.connect(show, QtCore.SIGNAL("triggered()"), show_window)
m.connect(exit, QtCore.SIGNAL("triggered()"), lambda: app.exit()) m.connect(exit, QtCore.SIGNAL("triggered()"), close_app)
m.connect(m, QtCore.SIGNAL("aboutToShow()"), lambda: m.aboutToShow()) m.connect(m, QtCore.SIGNAL("aboutToShow()"), lambda: m.aboutToShow())
sub.connect(onl, QtCore.SIGNAL("triggered()"), lambda: m.newStatus(0)) sub.connect(onl, QtCore.SIGNAL("triggered()"), lambda: m.newStatus(0))
sub.connect(away, QtCore.SIGNAL("triggered()"), lambda: m.newStatus(1)) sub.connect(away, QtCore.SIGNAL("triggered()"), lambda: m.newStatus(1))

View file

@ -6,6 +6,7 @@ from list_items import *
from widgets import MultilineEdit, LineEdit from widgets import MultilineEdit, LineEdit
import plugin_support import plugin_support
from mainscreen_widgets import * from mainscreen_widgets import *
import settings
class MainWindow(QtGui.QMainWindow, Singleton): class MainWindow(QtGui.QMainWindow, Singleton):
@ -126,6 +127,7 @@ class MainWindow(QtGui.QMainWindow, Singleton):
self.messageEdit.setObjectName("messageEdit") self.messageEdit.setObjectName("messageEdit")
font = QtGui.QFont() font = QtGui.QFont()
font.setPointSize(10) font.setPointSize(10)
font.setFamily(settings.Settings.get_instance()['font'])
self.messageEdit.setFont(font) self.messageEdit.setFont(font)
self.sendMessageButton = QtGui.QPushButton(Form) self.sendMessageButton = QtGui.QPushButton(Form)
@ -182,7 +184,7 @@ class MainWindow(QtGui.QMainWindow, Singleton):
self.name = Form.name = DataLabel(Form) self.name = Form.name = DataLabel(Form)
Form.name.setGeometry(QtCore.QRect(75, 40, 150, 25)) Form.name.setGeometry(QtCore.QRect(75, 40, 150, 25))
font = QtGui.QFont() font = QtGui.QFont()
font.setFamily("Times New Roman") font.setFamily(settings.Settings.get_instance()['font'])
font.setPointSize(14) font.setPointSize(14)
font.setBold(True) font.setBold(True)
Form.name.setFont(font) Form.name.setFont(font)
@ -210,7 +212,7 @@ class MainWindow(QtGui.QMainWindow, Singleton):
self.account_name.setGeometry(QtCore.QRect(100, 25, 400, 25)) self.account_name.setGeometry(QtCore.QRect(100, 25, 400, 25))
self.account_name.setTextInteractionFlags(QtCore.Qt.LinksAccessibleByMouse) self.account_name.setTextInteractionFlags(QtCore.Qt.LinksAccessibleByMouse)
font = QtGui.QFont() font = QtGui.QFont()
font.setFamily("Times New Roman") font.setFamily(settings.Settings.get_instance()['font'])
font.setPointSize(14) font.setPointSize(14)
font.setBold(True) font.setBold(True)
self.account_name.setFont(font) self.account_name.setFont(font)
@ -322,16 +324,21 @@ class MainWindow(QtGui.QMainWindow, Singleton):
self.retranslateUi() self.retranslateUi()
self.profile = Profile(tox, self) self.profile = Profile(tox, self)
def closeEvent(self, *args, **kwargs): def closeEvent(self, event):
self.profile.save_history() self.profile.save_history()
self.profile.close() self.profile.close()
s = Settings.get_instance() s = Settings.get_instance()
s['x'] = self.geometry().x() if not s['close_to_tray'] or s.closing:
s['y'] = self.geometry().y() s['x'] = self.geometry().x()
s['width'] = self.width() s['y'] = self.geometry().y()
s['height'] = self.height() s['width'] = self.width()
s.save() s['height'] = self.height()
QtGui.QApplication.closeAllWindows() s.save()
QtGui.QApplication.closeAllWindows()
event.accept()
else:
event.ignore()
self.hide()
def resizeEvent(self, *args, **kwargs): def resizeEvent(self, *args, **kwargs):
self.messages.setGeometry(0, 0, self.width() - 270, self.height() - 155) self.messages.setGeometry(0, 0, self.width() - 270, self.height() - 155)

View file

@ -37,6 +37,7 @@ class AddContact(CenteredWidget):
self.error_label = DataLabel(self) self.error_label = DataLabel(self)
self.error_label.setGeometry(QtCore.QRect(120, 10, 420, 20)) self.error_label.setGeometry(QtCore.QRect(120, 10, 420, 20))
font = QtGui.QFont() font = QtGui.QFont()
font.setFamily(Settings.get_instance()['font'])
font.setPointSize(10) font.setPointSize(10)
font.setWeight(30) font.setWeight(30)
self.error_label.setFont(font) self.error_label.setFont(font)
@ -51,7 +52,6 @@ class AddContact(CenteredWidget):
self.message.setObjectName("label_2") self.message.setObjectName("label_2")
self.retranslateUi() self.retranslateUi()
self.message_edit.setText('Hello! Add me to your contact list please') self.message_edit.setText('Hello! Add me to your contact list please')
font = QtGui.QFont()
font.setPointSize(12) font.setPointSize(12)
font.setBold(True) font.setBold(True)
self.label.setFont(font) self.label.setFont(font)
@ -102,6 +102,7 @@ class ProfileSettings(CenteredWidget):
self.label = QtGui.QLabel(self) self.label = QtGui.QLabel(self)
self.label.setGeometry(QtCore.QRect(40, 30, 91, 25)) self.label.setGeometry(QtCore.QRect(40, 30, 91, 25))
font = QtGui.QFont() font = QtGui.QFont()
font.setFamily(Settings.get_instance()['font'])
font.setPointSize(18) font.setPointSize(18)
font.setWeight(75) font.setWeight(75)
font.setBold(True) font.setBold(True)
@ -532,11 +533,12 @@ class NotificationsSettings(CenteredWidget):
self.soundNotifications = QtGui.QCheckBox(self) self.soundNotifications = QtGui.QCheckBox(self)
self.soundNotifications.setGeometry(QtCore.QRect(10, 70, 340, 18)) self.soundNotifications.setGeometry(QtCore.QRect(10, 70, 340, 18))
font = QtGui.QFont() font = QtGui.QFont()
s = Settings.get_instance()
font.setFamily(s['font'])
font.setPointSize(12) font.setPointSize(12)
self.callsSound.setFont(font) self.callsSound.setFont(font)
self.soundNotifications.setFont(font) self.soundNotifications.setFont(font)
self.enableNotifications.setFont(font) self.enableNotifications.setFont(font)
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'])
@ -566,19 +568,20 @@ class InterfaceSettings(CenteredWidget):
def initUI(self): def initUI(self):
self.setObjectName("interfaceForm") self.setObjectName("interfaceForm")
self.setMinimumSize(QtCore.QSize(400, 580)) self.setMinimumSize(QtCore.QSize(400, 650))
self.setMaximumSize(QtCore.QSize(400, 580)) self.setMaximumSize(QtCore.QSize(400, 650))
self.label = QtGui.QLabel(self) self.label = QtGui.QLabel(self)
self.label.setGeometry(QtCore.QRect(30, 10, 370, 20)) self.label.setGeometry(QtCore.QRect(30, 10, 370, 20))
settings = Settings.get_instance()
font = QtGui.QFont() font = QtGui.QFont()
font.setPointSize(14) font.setPointSize(14)
font.setBold(True) font.setBold(True)
font.setFamily(settings['font'])
self.label.setFont(font) self.label.setFont(font)
self.themeSelect = QtGui.QComboBox(self) self.themeSelect = QtGui.QComboBox(self)
self.themeSelect.setGeometry(QtCore.QRect(30, 40, 120, 30)) self.themeSelect.setGeometry(QtCore.QRect(30, 40, 120, 30))
list_of_themes = ['dark'] list_of_themes = ['dark']
self.themeSelect.addItems(list_of_themes) self.themeSelect.addItems(list_of_themes)
settings = Settings.get_instance()
theme = settings['theme'] theme = settings['theme']
if theme in list_of_themes: if theme in list_of_themes:
index = list_of_themes.index(theme) index = list_of_themes.index(theme)
@ -622,23 +625,31 @@ class InterfaceSettings(CenteredWidget):
self.messages_font_size.setCurrentIndex(settings['message_font_size'] - 10) self.messages_font_size.setCurrentIndex(settings['message_font_size'] - 10)
self.unread = QtGui.QPushButton(self) self.unread = QtGui.QPushButton(self)
self.unread.setGeometry(QtCore.QRect(30, 465, 340, 30)) self.unread.setGeometry(QtCore.QRect(30, 470, 340, 30))
self.unread.clicked.connect(self.select_color) self.unread.clicked.connect(self.select_color)
self.compact_mode = QtGui.QCheckBox(self) self.compact_mode = QtGui.QCheckBox(self)
self.compact_mode.setGeometry(QtCore.QRect(30, 380, 370, 20)) self.compact_mode.setGeometry(QtCore.QRect(30, 380, 370, 20))
self.compact_mode.setChecked(settings['compact_mode']) self.compact_mode.setChecked(settings['compact_mode'])
self.close_to_tray = QtGui.QCheckBox(self)
self.close_to_tray.setGeometry(QtCore.QRect(30, 410, 370, 20))
self.close_to_tray.setChecked(settings['close_to_tray'])
self.show_avatars = QtGui.QCheckBox(self) self.show_avatars = QtGui.QCheckBox(self)
self.show_avatars.setGeometry(QtCore.QRect(30, 410, 370, 20)) self.show_avatars.setGeometry(QtCore.QRect(30, 440, 370, 20))
self.show_avatars.setChecked(settings['show_avatars']) self.show_avatars.setChecked(settings['show_avatars'])
self.choose_font = QtGui.QPushButton(self)
self.choose_font.setGeometry(QtCore.QRect(30, 510, 340, 30))
self.choose_font.clicked.connect(self.new_font)
self.import_smileys = QtGui.QPushButton(self) self.import_smileys = QtGui.QPushButton(self)
self.import_smileys.setGeometry(QtCore.QRect(30, 505, 340, 30)) self.import_smileys.setGeometry(QtCore.QRect(30, 550, 340, 30))
self.import_smileys.clicked.connect(self.import_sm) self.import_smileys.clicked.connect(self.import_sm)
self.import_stickers = QtGui.QPushButton(self) self.import_stickers = QtGui.QPushButton(self)
self.import_stickers.setGeometry(QtCore.QRect(30, 545, 340, 30)) self.import_stickers.setGeometry(QtCore.QRect(30, 590, 340, 30))
self.import_stickers.clicked.connect(self.import_st) self.import_stickers.clicked.connect(self.import_st)
self.retranslateUi() self.retranslateUi()
@ -657,6 +668,8 @@ class InterfaceSettings(CenteredWidget):
self.compact_mode.setText(QtGui.QApplication.translate("interfaceForm", "Compact contact list", None, QtGui.QApplication.UnicodeUTF8)) self.compact_mode.setText(QtGui.QApplication.translate("interfaceForm", "Compact contact list", None, QtGui.QApplication.UnicodeUTF8))
self.import_smileys.setText(QtGui.QApplication.translate("interfaceForm", "Import smiley pack", None, QtGui.QApplication.UnicodeUTF8)) self.import_smileys.setText(QtGui.QApplication.translate("interfaceForm", "Import smiley pack", None, QtGui.QApplication.UnicodeUTF8))
self.import_stickers.setText(QtGui.QApplication.translate("interfaceForm", "Import sticker pack", None, QtGui.QApplication.UnicodeUTF8)) self.import_stickers.setText(QtGui.QApplication.translate("interfaceForm", "Import sticker pack", None, QtGui.QApplication.UnicodeUTF8))
self.close_to_tray.setText(QtGui.QApplication.translate("interfaceForm", "Close to tray", None, QtGui.QApplication.UnicodeUTF8))
self.choose_font.setText(QtGui.QApplication.translate("interfaceForm", "Select font", None, QtGui.QApplication.UnicodeUTF8))
def import_st(self): def import_st(self):
directory = QtGui.QFileDialog.getExistingDirectory(self, directory = QtGui.QFileDialog.getExistingDirectory(self,
@ -686,6 +699,20 @@ class InterfaceSettings(CenteredWidget):
dest = curr_directory() + '/smileys/' + os.path.basename(directory) + '/' dest = curr_directory() + '/smileys/' + os.path.basename(directory) + '/'
copy(src, dest) copy(src, dest)
def new_font(self):
settings = Settings.get_instance()
font, ok = QtGui.QFontDialog.getFont(QtGui.QFont(settings['font'], 10), self)
if ok:
settings['font'] = font.family()
settings.save()
msgBox = QtGui.QMessageBox()
text = QtGui.QApplication.translate("interfaceForm", 'Restart app to apply settings', None,
QtGui.QApplication.UnicodeUTF8)
msgBox.setWindowTitle(QtGui.QApplication.translate("interfaceForm", 'Restart required', None,
QtGui.QApplication.UnicodeUTF8))
msgBox.setText(text)
msgBox.exec_()
def select_color(self): def select_color(self):
col = QtGui.QColorDialog.getColor() col = QtGui.QColorDialog.getColor()
@ -710,6 +737,7 @@ class InterfaceSettings(CenteredWidget):
settings['show_avatars'] = self.show_avatars.isChecked() settings['show_avatars'] = self.show_avatars.isChecked()
restart = True restart = True
settings['smiley_pack'] = self.smiley_pack.currentText() settings['smiley_pack'] = self.smiley_pack.currentText()
settings['close_to_tray'] = self.close_to_tray.isChecked()
smileys.SmileyLoader.get_instance().load_pack() smileys.SmileyLoader.get_instance().load_pack()
language = self.lang_choose.currentText() language = self.lang_choose.currentText()
if settings['language'] != language: if settings['language'] != language:
@ -753,9 +781,11 @@ class AudioSettings(CenteredWidget):
self.in_label.setGeometry(QtCore.QRect(25, 5, 350, 20)) self.in_label.setGeometry(QtCore.QRect(25, 5, 350, 20))
self.out_label = QtGui.QLabel(self) self.out_label = QtGui.QLabel(self)
self.out_label.setGeometry(QtCore.QRect(25, 65, 350, 20)) self.out_label.setGeometry(QtCore.QRect(25, 65, 350, 20))
settings = Settings.get_instance()
font = QtGui.QFont() font = QtGui.QFont()
font.setPointSize(16) font.setPointSize(16)
font.setBold(True) font.setBold(True)
font.setFamily(settings['font'])
self.in_label.setFont(font) self.in_label.setFont(font)
self.out_label.setFont(font) self.out_label.setFont(font)
self.input = QtGui.QComboBox(self) self.input = QtGui.QComboBox(self)
@ -763,7 +793,6 @@ class AudioSettings(CenteredWidget):
self.output = QtGui.QComboBox(self) self.output = QtGui.QComboBox(self)
self.output.setGeometry(QtCore.QRect(25, 90, 350, 30)) self.output.setGeometry(QtCore.QRect(25, 90, 350, 30))
p = pyaudio.PyAudio() p = pyaudio.PyAudio()
settings = Settings.get_instance()
self.in_indexes, self.out_indexes = [], [] self.in_indexes, self.out_indexes = [], []
for i in range(p.get_device_count()): for i in range(p.get_device_count()):
device = p.get_device_info_by_index(i) device = p.get_device_info_by_index(i)

View file

@ -34,6 +34,7 @@ class Settings(dict, Singleton):
self.save() self.save()
smileys.SmileyLoader(self) smileys.SmileyLoader(self)
self.locked = False self.locked = False
self.closing = False
p = pyaudio.PyAudio() p = pyaudio.PyAudio()
input_devices = output_devices = 0 input_devices = output_devices = 0
for i in range(p.get_device_count()): for i in range(p.get_device_count()):
@ -134,7 +135,9 @@ class Settings(dict, Singleton):
'unread_color': 'red', 'unread_color': 'red',
'save_unsent_only': False, 'save_unsent_only': False,
'compact_mode': False, 'compact_mode': False,
'show_welcome_screen': True 'show_welcome_screen': True,
'close_to_tray': False,
'font': 'Times New Roman'
} }
@staticmethod @staticmethod