Exemplo n.º 1
0
    def __init__(self):
        if (FontManager.instance is None):
            FontManager.instance = self

        self.fonts = {}

        for font_name in ConfigManager.getOptions('interface', 'Fonts'):
            tmp = ConfigManager.getVal('interface', 'Fonts', font_name)
            path, family = tuple(map(str.strip, tmp.split('||')))

            QFontDatabase.addApplicationFont('resources/fonts/' + path)

            self.fonts[font_name] = QFont(family)
Exemplo n.º 2
0
    def __init__(self):
        if (FontManager.instance is None):
            FontManager.instance = self
        
        self.fonts = {}
        
        for font_name in ConfigManager.getOptions('interface','Fonts'):
            tmp = ConfigManager.getVal('interface','Fonts',font_name)
            path, family = tuple(map(str.strip,tmp.split('||'))) 

            QFontDatabase.addApplicationFont('resources/fonts/' + path)

            self.fonts[font_name] = QFont(family)
Exemplo n.º 3
0
    def load_fonts(self, lrf, load_substitutions=True):
        font_map = {}

        for font in lrf.font_map:
            fdata = QByteArray(lrf.font_map[font].data)
            id = QFontDatabase.addApplicationFontFromData(fdata)
            if id != -1:
                font_map[font] = [str(i) for i in QFontDatabase.applicationFontFamilies(id)][0]

        if load_substitutions:
            base = P("fonts/liberation/*.ttf")
            for f in glob.glob(base):
                QFontDatabase.addApplicationFont(f)

        self.font_loader = FontLoader(font_map, self.dpi)
Exemplo n.º 4
0
    def load_fonts(self, lrf, load_substitutions=True):
        font_map = {}

        for font in lrf.font_map:
            fdata = QByteArray(lrf.font_map[font].data)
            id = QFontDatabase.addApplicationFontFromData(fdata)
            if id != -1:
                font_map[font] = [
                    str(i) for i in QFontDatabase.applicationFontFamilies(id)
                ][0]

        if load_substitutions:
            base = P('fonts/liberation/*.ttf')
            for f in glob.glob(base):
                QFontDatabase.addApplicationFont(f)

        self.font_loader = FontLoader(font_map, self.dpi)
Exemplo n.º 5
0
 def __init__(self, verify=True):
     from PyQt4.QtGui import QFontDatabase
     mainURL = 'https://api.themoviedb.org/3/genre/movie/list'
     params = {'api_key': tmdb_apiKey}
     response = requests.get(mainURL, params=params, verify=verify)
     data = response.json()
     genres_tup = data['genres']
     self._genres = {
         genre_row['name']: genre_row['id']
         for genre_row in genres_tup
     }
     self._genres_rev = {
         genre_row['id']: genre_row['name']
         for genre_row in genres_tup
     }
     self._genres['ALL'] = -1
     self._genres_rev[-1] = 'ALL'
     #
     ## now load in the fonts
     for fontFile in glob.glob(
             os.path.join(mainDir, 'resources', '*.ttf')):
         QFontDatabase.addApplicationFont(fontFile)
Exemplo n.º 6
0
 def addFont(self):
     '''
     @note::
         成功或者失败
     '''
     font_path = self.font_path
     fontId = QFontDatabase.addApplicationFont(font_path)
     if(fontId != -1):
         fontInfoList = QFontDatabase.applicationFontFamilies(fontId)
         fontFamily = fontInfoList[0]
         self.__font.setFamily(fontFamily)
         log.info("添加字体成功")
         return True
     else:
         log.warning("添加字体失败")
         return False
Exemplo n.º 7
0
 def addFont(self):
     '''
     @note::
         成功或者失败
     '''
     font_path = self.font_path
     fontId = QFontDatabase.addApplicationFont(font_path)
     if (fontId != -1):
         fontInfoList = QFontDatabase.applicationFontFamilies(fontId)
         fontFamily = fontInfoList[0]
         self.__font.setFamily(fontFamily)
         log.info("添加字体成功")
         return True
     else:
         log.warning("添加字体失败")
         return False
Exemplo n.º 8
0
# -*- coding: utf-8 -*-
'''
Created on 13 abr. 2017

@author: javit
'''

from PyQt4.QtGui import QSplashScreen, QFontDatabase, QFont, QLabel, QProgressBar

QFontDatabase.addApplicationFont("./fonts/EXO2REGULAR.TTF")


class SplashScreen(QSplashScreen):
    ''' Splash con logos mostrado al inicio de la aplicacion '''
    def __init__(self, pixmap):
        super(SplashScreen, self).__init__(pixmap)

        self._title = QLabel(self)
        self._title.setGeometry(50 * self.width() / 100,
                                20 * self.height() / 100,
                                50 * self.width() / 100,
                                11 * self.height() / 100)
        self._title.setStyleSheet('QLabel { color : rgb(191,180,110); }')
        font = QFont('Exo 2')
        font.setPixelSize(36)
        font.setBold(True)
        font.setItalic(True)
        self._title.setFont(font)

        font = QFont('Exo 2')
        font.setPixelSize(16)
Exemplo n.º 9
0
 def loadCustomFonts(self):
     for font in FONTS_DICT.values():
         # 0 ~ font name, 1 ~ extension
         QFontDatabase.addApplicationFont(RES + FONTS + font[0] + '.' + font[1])
Exemplo n.º 10
0
lm_name = QString(u'Liberation Mono')
qfdb = QFontDatabase()
qf = qfdb.font(lm_name, QString(u'Regular'), 12)
if qf.family() == lm_name:
    # Lib. Mono is installed in this system, good to go
    IMC.defaultFontFamily = lm_name
else:
    # Let's try to install Lib. Mono. Was it bundled with us?
    fpath = os.path.join(base, u"fonts")
    if os.path.exists(fpath):
        # It was; add each .ttf in it to the Qt font database
        # We are *assuming* that what's in fonts is Liberation Mono Regular
        # for sure, and optionally other variants like bold.
        for fname in os.listdir(fpath):
            if fname.endswith(u'.ttf'):
                qfdb.addApplicationFont(QString(os.path.join(fpath, fname)))
        IMC.defaultFontFamily = lm_name
    else:
        # OK, no fonts bundled with us (or they've been removed?)
        IMC.defaultFontFamily = QString(u'Courier New')
IMC.fontFamily = IMC.defaultFontFamily  # pqMain may override
# Make the application default be that which we just set
# app.setFont(pqMsgs.getMonoFont()) -- do NOT as it is a bad
# idea to have monospaced menus, titles, etc!

# Import each submodule and stick a reference to IMC into it.

import pqLists  # implements ordered lists of words for quick lookup

pqLists.IMC = IMC
# instantiate all our lists empty
Exemplo n.º 11
0
    def populateUi(self):
        """
		Die Graphische Oberfläche wird bevölkert.
		"""

        ## Die Icons werden hier definiert, da der Pfad zur ressourcen-DAtei nicht stimmt, wenn pyside-uic über die ui-Datei marschiert ist.
        self.ui.pushButton_previous.setIcon(
            QIcon(":/icons/images/actions/1leftarrow.png"))
        self.ui.pushButton_next.setIcon(
            QIcon(":/icons/images/actions/1rightarrow.png"))
        self.ui.actionNew.setIcon(QIcon(":/icons/images/actions/filenew.png"))
        self.ui.actionOpen.setIcon(
            QIcon(":/icons/images/actions/fileopen.png"))
        self.ui.actionSave.setIcon(
            QIcon(":/icons/images/actions/filesave.png"))
        self.ui.actionExport.setIcon(
            QIcon(":/icons/images/actions/fileexport.png"))
        self.ui.actionPrint.setIcon(
            QIcon(":/icons/images/actions/agt_print.png"))
        self.ui.actionSettings.setIcon(
            QIcon(":/icons/images/actions/exec.png"))
        self.ui.actionQuit.setIcon(QIcon(":/icons/images/actions/exit.png"))

        self.info = InfoWidget(self.__storage, self.__character, self)
        self.ui.layout_info.addWidget(self.info)

        attributes = AttributeWidget(self.__storage, self.__character, self)
        self.ui.layout_attributes.addWidget(attributes)

        skills = SkillWidget(self.__storage, self.__character, self)
        self.ui.layout_skills.addWidget(skills)

        #specialties = Specialties( self.__storage.traits["Skill"], self )
        specialties = SpecialtiesWidget(self.__storage.traits["Skill"], self)
        self.ui.layout_specialties.addWidget(specialties)

        merits = MeritWidget(self.__storage, self.__character, self)
        self.ui.layout_merits.addWidget(merits)

        morality = MoralityWidget(self.__storage, self.__character, self)
        self.ui.layout_morality.addWidget(morality)

        self.template = TemplateWidget(self.__storage, self.__character, self)
        self.ui.layout_template.addWidget(self.template)

        if "Power" in self.__storage.traits.keys():
            powers = PowerWidget(self.__storage, self.__character, self)
            self.ui.layout_powers.addWidget(powers)

            subPowers = SubPowerWidget(self.__storage, self.__character, self)
            self.ui.layout_subPowers.addWidget(subPowers)

        flaws = FlawWidget(self.__storage, self.__character, self)
        self.ui.layout_flaws.addWidget(flaws)

        self.__advantages = AdvantagesWidget(self.__storage, self.__character,
                                             self)
        self.ui.layout_advantages.addWidget(self.__advantages)

        items = ItemWidget(self.__storage, self.__character, self)
        self.ui.layout_items.addWidget(items)

        speciesSpecials = SpecialsWidget(self.__storage, self.__character,
                                         self)
        self.ui.layout_specials.addWidget(speciesSpecials)

        ## Wenn sich der Name im InfoWidget ändert, soll sich auch die Titelzeile des Programms ändern
        self.info.nameChanged.connect(self.setTitle)

        ### Wird eine neue Seite angewählt, muß das Info-Widget den Beschreibungstext speichern.
        #self.pageChanged.connect(self.info.saveDescription)

        # Die Spezialisierungen einer Fertigkeit sollen angezeigt werden.
        skills.specialtiesActivated.connect(specialties.showSpecialties)

        # Menschen haben keine übernatürlichen Kräfte, also zeige ich sie auch nicht an.
        self.__character.speciesChanged.connect(
            self.ui.selectWidget_select.disableItems)

        # Hintergrundbild ändert sich je nach Spezies
        self.__character.speciesChanged.connect(self.showBackround)

        ## Sämtliche Schriften in das System laden, damit ich sie auch benutzen kann.
        resourceFontDir = QDir(":/fonts/fonts")
        fontsList = resourceFontDir.entryList()
        for font in fontsList:
            QFontDatabase.addApplicationFont(resourceFontDir.filePath(font))
Exemplo n.º 12
0
    def __init__(self, debug=False):
        self.app = QApplication(['Turpial'] + sys.argv)

        Base.__init__(self)
        QWidget.__init__(self)

        self.debug = debug

        for font_path in self.fonts:
            QFontDatabase.addApplicationFont(font_path)

        #database = QFontDatabase()
        #for f in database.families():
        #    print f

        self.templates_path = os.path.realpath(
            os.path.join(os.path.dirname(__file__), 'templates'))

        self.setWindowTitle('Turpial')
        self.app.setApplicationName('Turpial')
        self.setWindowIcon(QIcon(self.get_image_path('turpial.svg')))
        self.resize(320, 480)
        self.center_on_screen()

        self.ignore_quit = True
        self.showed = True
        self.core_ready = False
        self.timers = {}
        self.extra_friends = []

        self.update_box = UpdateBox(self)
        self.profile_dialog = ProfileDialog(self)
        self.profile_dialog.options_clicked.connect(self.show_profile_menu)
        self.image_view = ImageView(self)
        self.queue_dialog = QueueDialog(self)

        self.core = CoreWorker()
        self.core.ready.connect(self.after_core_initialized)
        self.core.status_updated.connect(self.after_update_status)
        self.core.status_broadcasted.connect(self.after_broadcast_status)
        self.core.status_repeated.connect(self.after_repeat_status)
        self.core.status_deleted.connect(self.after_delete_status)
        self.core.message_deleted.connect(self.after_delete_message)
        self.core.message_sent.connect(self.after_send_message)
        self.core.column_updated.connect(self.after_update_column)
        self.core.account_saved.connect(self.after_save_account)
        self.core.account_loaded.connect(self.after_load_account)
        self.core.account_deleted.connect(self.after_delete_account)
        self.core.column_saved.connect(self.after_save_column)
        self.core.column_deleted.connect(self.after_delete_column)
        self.core.status_marked_as_favorite.connect(
            self.after_marking_status_as_favorite)
        self.core.status_unmarked_as_favorite.connect(
            self.after_unmarking_status_as_favorite)
        self.core.fetched_user_profile.connect(self.after_get_user_profile)
        self.core.urls_shorted.connect(self.update_box.after_short_url)
        self.core.media_uploaded.connect(self.update_box.after_upload_media)
        self.core.friends_list_updated.connect(
            self.update_box.update_friends_list)
        self.core.user_muted.connect(self.after_mute_user)
        self.core.user_unmuted.connect(self.after_unmute_user)
        self.core.user_blocked.connect(self.after_block_user)
        self.core.user_reported_as_spam.connect(self.after_report_user_as_spam)
        self.core.user_followed.connect(self.after_follow_user)
        self.core.user_unfollowed.connect(self.after_unfollow_user)
        self.core.status_from_conversation.connect(
            self.after_get_status_from_conversation)
        self.core.fetched_profile_image.connect(self.after_get_profile_image)
        self.core.fetched_avatar.connect(self.update_profile_avatar)
        self.core.fetched_image_preview.connect(self.after_get_image_preview)
        self.core.status_pushed_to_queue.connect(
            self.after_push_status_to_queue)
        self.core.status_poped_from_queue.connect(
            self.after_pop_status_from_queue)
        self.core.status_posted_from_queue.connect(
            self.after_post_status_from_queue)
        self.core.status_deleted_from_queue.connect(
            self.after_delete_status_from_queue)
        self.core.queue_cleared.connect(self.after_clear_queue)
        self.core.exception_raised.connect(self.on_exception)

        self.core.start()

        self._container = Container(self)

        self.os_notifications = OSNotificationSystem(self.images_path)
        self.sounds = SoundSystem(self.sounds_path)

        self.dock = Dock(self)

        self.dock.accounts_clicked.connect(self.show_accounts_dialog)
        self.dock.columns_clicked.connect(self.show_column_menu)
        self.dock.search_clicked.connect(self.show_search_dialog)
        self.dock.updates_clicked.connect(self.show_update_box)
        self.dock.messages_clicked.connect(
            self.show_friends_dialog_for_direct_message)
        self.dock.queue_clicked.connect(self.show_queue_dialog)
        #self.dock.filters_clicked.connect(self.show_filters_dialog)
        self.dock.preferences_clicked.connect(self.show_preferences_dialog)

        self.tray = TrayIcon(self)
        self.tray.toggled.connect(self.toggle_tray_icon)
        self.tray.updates_clicked.connect(self.show_update_box)
        self.tray.messages_clicked.connect(
            self.show_friends_dialog_for_direct_message)
        self.tray.settings_clicked.connect(self.show_preferences_dialog)

        layout = QVBoxLayout()
        layout.setSpacing(0)
        layout.setMargin(0)
        layout.setContentsMargins(0, 0, 0, 0)
        layout.addLayout(self._container, 1)
        layout.addWidget(self.dock)

        self.setLayout(layout)
Exemplo n.º 13
0
	def populateUi(self):
		"""
		Die Graphische Oberfläche wird bevölkert.
		"""

		## Die Icons werden hier definiert, da der Pfad zur ressourcen-DAtei nicht stimmt, wenn pyside-uic über die ui-Datei marschiert ist.
		self.ui.pushButton_previous.setIcon(QIcon(":/icons/images/actions/1leftarrow.png"))
		self.ui.pushButton_next.setIcon(QIcon(":/icons/images/actions/1rightarrow.png"))
		self.ui.actionNew.setIcon(QIcon(":/icons/images/actions/filenew.png"))
		self.ui.actionOpen.setIcon(QIcon(":/icons/images/actions/fileopen.png"))
		self.ui.actionSave.setIcon(QIcon(":/icons/images/actions/filesave.png"))
		self.ui.actionExport.setIcon(QIcon(":/icons/images/actions/fileexport.png"))
		self.ui.actionPrint.setIcon(QIcon(":/icons/images/actions/agt_print.png"))
		self.ui.actionSettings.setIcon(QIcon(":/icons/images/actions/exec.png"))
		self.ui.actionQuit.setIcon(QIcon(":/icons/images/actions/exit.png"))

		self.info = InfoWidget(self.__storage, self.__character, self)
		self.ui.layout_info.addWidget( self.info )

		attributes = AttributeWidget( self.__storage, self.__character, self )
		self.ui.layout_attributes.addWidget( attributes )

		skills = SkillWidget( self.__storage, self.__character, self )
		self.ui.layout_skills.addWidget( skills )

		#specialties = Specialties( self.__storage.traits["Skill"], self )
		specialties = SpecialtiesWidget( self.__storage.traits["Skill"], self )
		self.ui.layout_specialties.addWidget( specialties )

		merits = MeritWidget( self.__storage, self.__character, self )
		self.ui.layout_merits.addWidget( merits )

		morality = MoralityWidget( self.__storage, self.__character, self )
		self.ui.layout_morality.addWidget( morality )

		self.template = TemplateWidget(self.__storage, self.__character, self)
		self.ui.layout_template.addWidget( self.template )

		if "Power" in self.__storage.traits.keys():
			powers = PowerWidget( self.__storage, self.__character, self )
			self.ui.layout_powers.addWidget( powers )

			subPowers = SubPowerWidget( self.__storage, self.__character, self )
			self.ui.layout_subPowers.addWidget( subPowers )

		flaws = FlawWidget( self.__storage, self.__character, self )
		self.ui.layout_flaws.addWidget( flaws )

		self.__advantages = AdvantagesWidget( self.__storage, self.__character, self )
		self.ui.layout_advantages.addWidget( self.__advantages )

		items = ItemWidget( self.__storage, self.__character, self )
		self.ui.layout_items.addWidget( items )

		speciesSpecials = SpecialsWidget(self.__storage, self.__character, self)
		self.ui.layout_specials.addWidget( speciesSpecials )

		## Wenn sich der Name im InfoWidget ändert, soll sich auch die Titelzeile des Programms ändern
		self.info.nameChanged.connect(self.setTitle)

		### Wird eine neue Seite angewählt, muß das Info-Widget den Beschreibungstext speichern.
		#self.pageChanged.connect(self.info.saveDescription)

		# Die Spezialisierungen einer Fertigkeit sollen angezeigt werden.
		skills.specialtiesActivated.connect(specialties.showSpecialties)

		# Menschen haben keine übernatürlichen Kräfte, also zeige ich sie auch nicht an.
		self.__character.speciesChanged.connect(self.ui.selectWidget_select.disableItems)

		# Hintergrundbild ändert sich je nach Spezies
		self.__character.speciesChanged.connect(self.showBackround)

		## Sämtliche Schriften in das System laden, damit ich sie auch benutzen kann.
		resourceFontDir = QDir(":/fonts/fonts")
		fontsList = resourceFontDir.entryList()
		for font in fontsList:
			QFontDatabase.addApplicationFont(resourceFontDir.filePath(font))
Exemplo n.º 14
0
                elif col+1 in schedule.employees[row].free_days:
                    item.setBackground(FREE_GREEN)
                table_widget.setItem(row, col, item)

    def _set_month_label(self, label_widget, year, month):
        label_widget.setText(unicode(year) + '. ' + calendar.month_name[month])

    def about(self):
        """Show about dialog."""
        about = AboutDialog(self)
        about.exec_()

    def help(self):
        """Show help dialog."""
        help = HelpDialog(self)
        help.show()

    def notimplemented(self):
        QMessageBox.information(self, u'Not implemented',
                                u'This function is not implemented!\n'
                                u'If you need it, you can hire me for developing it.\n'
                                u'Check About menu!')


if __name__ == "__main__":
    app = QApplication(sys.argv)
    QFontDatabase.addApplicationFont(':/font/general_foundicons.ttf')
    form = MainWindow()
    form.show()
    sys.exit(app.exec_())
Exemplo n.º 15
0
lm_name = QString(u'Liberation Mono')
qfdb = QFontDatabase()
qf = qfdb.font(lm_name,QString(u'Regular'),12)
if qf.family() == lm_name :
    # Lib. Mono is installed in this system, good to go
    IMC.defaultFontFamily = lm_name
else:
    # Let's try to install Lib. Mono. Was it bundled with us?
    fpath = os.path.join(base,u"fonts")
    if os.path.exists(fpath) :
        # It was; add each .ttf in it to the Qt font database
        # We are *assuming* that what's in fonts is Liberation Mono Regular
        # for sure, and optionally other variants like bold.
        for fname in os.listdir(fpath) :
            if fname.endswith(u'.ttf') :
                qfdb.addApplicationFont(QString(os.path.join(fpath,fname)))
        IMC.defaultFontFamily = lm_name
    else :
        # OK, no fonts bundled with us (or they've been removed?)
        IMC.defaultFontFamily = QString(u'Courier New')
IMC.fontFamily = IMC.defaultFontFamily # pqMain may override
# Make the application default be that which we just set
# app.setFont(pqMsgs.getMonoFont()) -- do NOT as it is a bad
# idea to have monospaced menus, titles, etc!

# Import each submodule and stick a reference to IMC into it.

import pqLists # implements ordered lists of words for quick lookup
pqLists.IMC = IMC
# instantiate all our lists empty
IMC.scannoList = pqLists.wordList()
Exemplo n.º 16
0
    def __init__(self, debug=False):
        self.app = QApplication(["Turpial"] + sys.argv)

        Base.__init__(self)
        QWidget.__init__(self)

        self.debug = debug

        for font_path in self.fonts:
            QFontDatabase.addApplicationFont(font_path)

        # database = QFontDatabase()
        # for f in database.families():
        #    print f

        self.templates_path = os.path.realpath(os.path.join(os.path.dirname(__file__), "templates"))

        self.setWindowTitle("Turpial")
        self.app.setApplicationName("Turpial")
        self.setWindowIcon(QIcon(self.get_image_path("turpial.svg")))
        self.resize(320, 480)
        self.center_on_screen()

        self.ignore_quit = True
        self.showed = True
        self.core_ready = False
        self.timers = {}
        self.extra_friends = []

        self.update_box = UpdateBox(self)
        self.profile_dialog = ProfileDialog(self)
        self.profile_dialog.options_clicked.connect(self.show_profile_menu)
        self.image_view = ImageView(self)
        self.queue_dialog = QueueDialog(self)

        self.core = CoreWorker()
        self.core.ready.connect(self.after_core_initialized)
        self.core.status_updated.connect(self.after_update_status)
        self.core.status_broadcasted.connect(self.after_broadcast_status)
        self.core.status_repeated.connect(self.after_repeat_status)
        self.core.status_deleted.connect(self.after_delete_status)
        self.core.message_deleted.connect(self.after_delete_message)
        self.core.message_sent.connect(self.after_send_message)
        self.core.column_updated.connect(self.after_update_column)
        self.core.account_saved.connect(self.after_save_account)
        self.core.account_loaded.connect(self.after_load_account)
        self.core.account_deleted.connect(self.after_delete_account)
        self.core.column_saved.connect(self.after_save_column)
        self.core.column_deleted.connect(self.after_delete_column)
        self.core.status_marked_as_favorite.connect(self.after_marking_status_as_favorite)
        self.core.status_unmarked_as_favorite.connect(self.after_unmarking_status_as_favorite)
        self.core.fetched_user_profile.connect(self.after_get_user_profile)
        self.core.urls_shorted.connect(self.update_box.after_short_url)
        self.core.media_uploaded.connect(self.update_box.after_upload_media)
        self.core.friends_list_updated.connect(self.update_box.update_friends_list)
        self.core.user_muted.connect(self.after_mute_user)
        self.core.user_unmuted.connect(self.after_unmute_user)
        self.core.user_blocked.connect(self.after_block_user)
        self.core.user_reported_as_spam.connect(self.after_report_user_as_spam)
        self.core.user_followed.connect(self.after_follow_user)
        self.core.user_unfollowed.connect(self.after_unfollow_user)
        self.core.status_from_conversation.connect(self.after_get_status_from_conversation)
        self.core.fetched_profile_image.connect(self.after_get_profile_image)
        self.core.fetched_avatar.connect(self.update_profile_avatar)
        self.core.fetched_image_preview.connect(self.after_get_image_preview)
        self.core.status_pushed_to_queue.connect(self.after_push_status_to_queue)
        self.core.status_poped_from_queue.connect(self.after_pop_status_from_queue)
        self.core.status_posted_from_queue.connect(self.after_post_status_from_queue)
        self.core.status_deleted_from_queue.connect(self.after_delete_status_from_queue)
        self.core.queue_cleared.connect(self.after_clear_queue)
        self.core.exception_raised.connect(self.on_exception)

        self.core.start()

        self._container = Container(self)

        self.os_notifications = OSNotificationSystem(self.images_path)
        self.sounds = SoundSystem(self.sounds_path)

        self.dock = Dock(self)

        self.dock.accounts_clicked.connect(self.show_accounts_dialog)
        self.dock.columns_clicked.connect(self.show_column_menu)
        self.dock.search_clicked.connect(self.show_search_dialog)
        self.dock.updates_clicked.connect(self.show_update_box)
        self.dock.messages_clicked.connect(self.show_friends_dialog_for_direct_message)
        self.dock.queue_clicked.connect(self.show_queue_dialog)
        # self.dock.filters_clicked.connect(self.show_filters_dialog)
        self.dock.preferences_clicked.connect(self.show_preferences_dialog)

        self.tray = TrayIcon(self)
        self.tray.toggled.connect(self.toggle_tray_icon)
        self.tray.updates_clicked.connect(self.show_update_box)
        self.tray.messages_clicked.connect(self.show_friends_dialog_for_direct_message)
        self.tray.settings_clicked.connect(self.show_preferences_dialog)

        layout = QVBoxLayout()
        layout.setSpacing(0)
        layout.setMargin(0)
        layout.setContentsMargins(0, 0, 0, 0)
        layout.addLayout(self._container, 1)
        layout.addWidget(self.dock)

        self.setLayout(layout)
Exemplo n.º 17
0
    def load_font(self, prefix, ttf_filename, charmap_filename, directory=None):
        """Loads a font file and the associated charmap.

        If ``directory`` is None, the files will be looked for in ``./fonts/``.

        Parameters
        ----------
        prefix: str
            Prefix string to be used when accessing a given font set
        ttf_filename: str
            Ttf font filename
        charmap_filename: str
            Charmap filename
        directory: str or None, optional
            Directory for font and charmap files
        """

        def hook(obj):
            result = {}
            for key in obj:
                result[key] = unichr(int(obj[key], 16))
            return result

        if directory is None:
            directory = os.path.join(
                os.path.dirname(os.path.realpath(__file__)), 'fonts')

        # Load font
        if QApplication.instance() is not None:
            id_ = QFontDatabase.addApplicationFont(os.path.join(directory,
                                                                ttf_filename))
            loadedFontFamilies = QFontDatabase.applicationFontFamilies(id_)
            if(loadedFontFamilies):
                self.fontname[prefix] = loadedFontFamilies[0]
            else:
                raise FontError(u"Font at '{0}' appears to be empty. "
                                "If you are on Windows 10, please read "
                                "https://support.microsoft.com/"
                                "en-us/kb/3053676 "
                                "to know how to prevent Windows from blocking "
                                "the fonts that come with QtAwesome.".format(
                                        os.path.join(directory, ttf_filename)))

            with open(os.path.join(directory, charmap_filename), 'r') as codes:
                self.charmap[prefix] = json.load(codes, object_hook=hook)

            # Verify that vendorized fonts are not corrupt
            if not SYSTEM_FONTS:
                md5_hashes = {'fontawesome-webfont.ttf':
                              'b06871f281fee6b241d60582ae9369b9',
                              'elusiveicons-webfont.ttf':
                              '207966b04c032d5b873fd595a211582e'}
                ttf_hash = md5_hashes.get(ttf_filename, None)
                if ttf_hash is not None:
                    hasher = hashlib.md5()
                    with open(os.path.join(directory, ttf_filename),
                              'rb') as f:
                        content = f.read()
                        hasher.update(content)
                    ttf_calculated_hash_code = hasher.hexdigest()
                    if ttf_calculated_hash_code != ttf_hash:
                        raise FontError(u"Font is corrupt at: '{0}'".format(
                                        os.path.join(directory, ttf_filename)))