Exemplo n.º 1
0
 def createStatementsImportMenu(self):
     for i, source in enumerate(self.statements.sources):
         if 'icon' in source:
             source_icon = load_icon(source['icon'])
             action = QAction(source_icon, source['name'], self)
         else:
             action = QAction(source['name'], self)
         action.setData(i)
         self.menuStatement.addAction(action)
         self.statementGroup.addAction(action)
Exemplo n.º 2
0
    def refreshMenusButtonsStatusBar(self, reset: bool = False) -> None:
        if not self._database:
            self.statusLabel.setText('No database opened')
        else:
            protein = f'{self._database.proteins_count} protein{"s" if self._database.proteins_count > 1 else ""}'
            sequence = f'{self._database.sequences_count} sequence{"s" if self._database.sequences_count > 1 else ""}'
            self.statusLabel.setText(', '.join(
                (str(self._database.path), protein, sequence)))

        if reset:
            self.proteinsSearchLineEdit.setText('')
            self.proteinsTableWidget.setRowCount(0)

        database_opened = bool(self._database)
        digestions_available = database_opened and bool(
            self._database.available_digestions)
        database_is_coherent = database_opened and bool(
            self._database.is_coherent_with_enzymes_collection)
        self.mainSplitter.setEnabled(database_opened)
        self.mainSplitterBottomWidget.setVisible(digestions_available)
        self.databaseMenu.setEnabled(database_opened and database_is_coherent)
        self.workingDigestionMenu.setEnabled(digestions_available)

        if digestions_available:
            if self._working_digestion_action_group.actions():
                current_digestion_settings = self._working_digestion_action_group.checkedAction(
                ).data()
            else:
                current_digestion_settings = None

            new_digestion_settings = None

            for action in self._working_digestion_action_group.actions():
                self._working_digestion_action_group.removeAction(action)
                action.deleteLater()

            for i, digestion in enumerate(self.database.available_digestions):
                action_title = (
                    f'{digestion.enzyme} - {digestion.missed_cleavages} missed cleavage'
                    f'{"s" if digestion.missed_cleavages > 1 else ""}')

                # Adding action to working digestion menu
                action = QAction(action_title,
                                 self._working_digestion_action_group)
                action.setCheckable(True)
                action.setData(digestion)
                self.workingDigestionMenu.addAction(action)

                if digestion == current_digestion_settings or not i:
                    new_digestion_settings = digestion
                    action.setChecked(True)

            # Refreshing if needed
            if current_digestion_settings != new_digestion_settings:
                self.refreshPeptidesTableWidget()
Exemplo n.º 3
0
 def createStatementsImportMenu(self):
     for i, statement in enumerate(self.statements.items):
         statement_name = statement['name'].replace('&', '&&')  # & -> && to prevent shortcut creation
         if statement['icon']:
             statement_icon = load_icon(statement['icon'])
             action = QAction(statement_icon, statement_name, self)
         else:
             action = QAction(statement_name, self)
         action.setData(i)
         self.menuStatement.addAction(action)
         self.statementGroup.addAction(action)
Exemplo n.º 4
0
    def createLanguageMenu(self):
        langPath = get_app_path() + Setup.LANG_PATH + os.sep

        langDirectory = QDir(langPath)
        for language_file in langDirectory.entryList(['*.qm']):
            language_code = language_file.split('.')[0]
            language = QLocale.languageToString(QLocale(language_code).language())
            language_icon = QIcon(langPath + language_code + '.png')
            action = QAction(language_icon, language, self)
            action.setCheckable(True)
            action.setData(language_code)
            self.menuLanguage.addAction(action)
            self.langGroup.addAction(action)
Exemplo n.º 5
0
    def constructContextMenu(self, position):
        globalPosition = self.mapToGlobal(position)

        menu = QMenu()

        optionsEntry = QAction('Options', menu)
        optionsEntry.setData(self.openOptions)

        def rotate():
            mousePosition = QCursor.pos()

            self.rotate(mousePosition)

        rotateEntry = QAction('Rotate', menu)
        rotateEntry.setData(rotate)

        aboutEntry = QAction('About', menu)
        aboutEntry.setData(self.openAbout)

        quitEntry = QAction('Close', menu)
        quitEntry.setData(self.quit)

        menu.addAction(optionsEntry)
        menu.addAction(rotateEntry)
        menu.addAction(aboutEntry)
        menu.addAction(quitEntry)

        selectedItem = menu.exec_(globalPosition)
        """:type : QAction"""

        if selectedItem:
            selectedItem.data()()
Exemplo n.º 6
0
 def createReportsMenu(self):
     for i, report in enumerate(self.reports.items):
         action = QAction(report['name'].replace('&', '&&'), self)  # & -> && to prevent shortcut creation
         action.setData(i)
         self.menuReports.addAction(action)
         self.reportsGroup.addAction(action)