Example #1
0
class Login(QDialog, Ui_Dialog):
    """User validation"""

    def __init__(self, parent=None):
        super(Login, self).__init__(parent)
        self.setupUi(self)
        self.btnBoxLogin.button(QDialogButtonBox.Cancel).setText("Cancelar")
        self.btnBoxLogin.button(QDialogButtonBox.Cancel).clicked.connect(self.close)
        self.btnBoxLogin.button(QDialogButtonBox.Ok).clicked.connect(self.ok_clicked)
        self.load_icon = QMovie(":icons/loading.gif")
        sql_statement = """SELECT username, password, access FROM users WHERE
                      users.username=:username AND users.password=:password"""
        self._validate_job = Db_Query_Thread(name="validation", query=sql_statement)
        self._validate_job.query_finished.connect(self.validate_login)
        self._user_logged = False
        self._username = None
        self._access = None

    def set_loading_icon(self, frame=None):
        self.btnBoxLogin.button(QDialogButtonBox.Ok).setIcon(QIcon(self.load_icon.currentPixmap()))

    def ok_clicked(self):
        """Calls validation methods"""
        self.btnBoxLogin.button(QDialogButtonBox.Ok).setEnabled(False)
        self.btnBoxLogin.button(QDialogButtonBox.Ok).setText("")
        self.load_icon.frameChanged.connect(self.set_loading_icon)
        self.load_icon.start()
        username = self.editUsername.text()
        password = self.editPassword.text()
        parameters = [["str", "username", username],["str","password",password]]
        self._validate_job.set_params(parameters)
        self._validate_job.start()

    def validate_login(self, db_result, error=None):
        self._validate_job.exit()
        if db_result:
            # correct username and password
            self._user_logged = True
            self._username = db_result[0].value(0)
            self._access = db_result[0].value(2)
            self.accept()
        else:
            if error == 'connError':
                message = unicode("Erro de autenticação\n\n""Banco de dados indisponível".decode('utf-8'))
            else:
                message = unicode("Erro de autenticação\n\n""Usuário e/ou Senha inválido(s)".decode('utf-8'))
            QMessageBox.critical(self, "Seareiros - Login", message)
            self.btnBoxLogin.button(QDialogButtonBox.Ok).setText("&OK")
            self.load_icon.frameChanged.disconnect(self.set_loading_icon)
            self.load_icon.stop()
            self.btnBoxLogin.button(QDialogButtonBox.Ok).setIcon(QIcon())
            self.btnBoxLogin.button(QDialogButtonBox.Ok).setEnabled(True)
            self.editUsername.setFocus()
            self.editUsername.selectAll()

    def get_user_data(self):
        if self._user_logged:
            return [self._username, self._access]
        else:
            return None
Example #2
0
    def __init__(self, parent=None, statusBarService=None):
        """
        Creates a QProgressBar and adds it to the given status bar (for
        threads that can provide accurate progress information).

        Note: The status bar can either be a QStatusBar or the StatusBarService. In the default
        BioPARKIN use, it is the StatusBarService instance.

        @todo: A throbber is created and also added to the status bar (for
        threads that can only provide start/stop information).
        """
        #        super(ProgressBarService, self).__init__(parent)   # done in __new__

        if statusBarService is not None:
            self.statusBarService = statusBarService
            self.progressBar = QProgressBar(None)  # used for showing progress
            self.progressBarMutex = QMutex()
            self.progressBar.hide()
            self.statusBarService.addPermanentWidget(self.progressBar)
            self.progressRunning = False

            self.throbber = QLabel()
            self.throbberRunning = False
            self.throbberMutex = QMutex()
            self.statusBarService.addPermanentWidget(self.throbber)
            self.throbber.show()
            self.throbber.hide()

            throbberImage = QMovie(":/images/Spinning_wheel_throbber.gif", parent=self.throbber)
            throbberImage.setScaledSize(QSize(24, 24))
            throbberImage.setCacheMode(QMovie.CacheAll)
            throbberImage.start()
            self.throbber.setMovie(throbberImage)
            self.throbber.setFixedSize(24, 24)
Example #3
0
    def __init__(self, parent=None, statusBarService=None):
        """
        Creates a QProgressBar and adds it to the given status bar (for
        threads that can provide accurate progress information).

        Note: The status bar can either be a QStatusBar or the StatusBarService. In the default
        BioPARKIN use, it is the StatusBarService instance.

        @todo: A throbber is created and also added to the status bar (for
        threads that can only provide start/stop information).
        """
        #        super(ProgressBarService, self).__init__(parent)   # done in __new__

        if statusBarService is not None:
            self.statusBarService = statusBarService
            self.progressBar = QProgressBar(None)  # used for showing progress
            self.progressBarMutex = QMutex()
            self.progressBar.hide()
            self.statusBarService.addPermanentWidget(self.progressBar)
            self.progressRunning = False

            self.throbber = QLabel()
            self.throbberRunning = False
            self.throbberMutex = QMutex()
            self.statusBarService.addPermanentWidget(self.throbber)
            self.throbber.show()
            self.throbber.hide()

            throbberImage = QMovie(":/images/Spinning_wheel_throbber.gif",
                                   parent=self.throbber)
            throbberImage.setScaledSize(QSize(24, 24))
            throbberImage.setCacheMode(QMovie.CacheAll)
            throbberImage.start()
            self.throbber.setMovie(throbberImage)
            self.throbber.setFixedSize(24, 24)
 def update(self):
     self.my_rank = 0
     for class_id in self.img_wdg.keys():
         if class_id != '8':
             r = self.wdg_pos[class_id][0]
             c = self.wdg_pos[class_id][1]
             t_min = round(self.pose_time[class_id] / 60)
             t_sec = self.pose_time[class_id] - t_min * 60
             self.cellWidget(r, c * 3 + 2).setText('%02d:%02d' %
                                                   (t_min, t_sec))
             self.cellWidget(r, c * 3 + 2).update()
             if t_sec > 0 or t_min > 0:
                 if not os.path.isdir('tmp'):
                     os.mkdir('tmp')
                 gif_output = imageio.get_writer('tmp/%s.gif' % class_id,
                                                 mode='I',
                                                 fps=2)
                 for img in self.correctFrames[class_id]:
                     #pimg=cv2.rectangle(img,(0,0),(256,256),(0,255,0),3)
                     gif_output.append_data(img[:, :, (2, 1, 0)])
                 gif_output.close()
                 print 'load gif'
                 lblMov = QtGui.QLabel('', self)
                 gif_anim = QMovie('tmp/%s.gif' % class_id, parent=self)
                 gif_anim.setCacheMode(QMovie.CacheAll)
                 gif_anim.setSpeed(200)
                 lblMov.setMovie(gif_anim)
                 gif_anim.start()
                 self.setCellWidget(r, c * 3 + 1, lblMov)
                 self.cellWidget(
                     r, c * 3).setStyleSheet('background-color: green;')
                 self.my_rank += 1
                 #self.cellWidget(r,c*3+1).setImage(self.correctFrames[class_id][0])
                 #self.cellWidget(r,c*3+1).update()
             else:
                 lblMov = QtGui.QLabel('', self)
                 gif_anim = QMovie('examples/%s.gif' % class_id,
                                   parent=self)
                 gif_anim.setCacheMode(QMovie.CacheAll)
                 gif_anim.setSpeed(300)
                 gif_anim.setScaledSize(QtCore.QSize(150, 150))
                 lblMov.setMovie(gif_anim)
                 gif_anim.start()
                 self.setCellWidget(r, c * 3 + 1, lblMov)
             print '%02d:%02d' % (t_min, t_sec)
Example #5
0
        class SpinnerDialog(SpinnerDialogType, BaseType):
            def __init__(self, parent=None):
                SpinnerDialogType.__init__(self, parent)
                BaseType.__init__(self, parent)
                self.setupUi(self)
                self.setWindowFlags(Qt.Dialog | Qt.FramelessWindowHint
                                    | Qt.WindowTitleHint)

                spinner_filename = os.path.join(
                    SubmitWindowController._get_self_dir(),
                    SPINNER_GIF_FILE_NAME)
                self.spinner_movie = QMovie(spinner_filename)
                self.spinner_movie.setScaledSize(QSize(40, 40))
                self.spinner_label.setMovie(self.spinner_movie)

            def show(self):
                super(SpinnerDialog, self).show()
                self.spinner_movie.start()
Example #6
0
    def __init__(self, parent=None):
        super(PowerNotificationDialog, self).__init__(parent)
        self.setWindowFlags(Qt.Dialog | Qt.FramelessWindowHint)

        layout = QGridLayout()

        spinBox = QLabel()
        spinner = QMovie(":icons/spinner")
        spinner.start()
        spinBox.setMovie(spinner)
        layout.addWidget(spinBox, 0, 0)

        self.textBox = QLabel()

        layout.addWidget(self.textBox, 0, 1, 1, 3)

        btnOK = ExpandingButton()
        btnOK.setText("OK")
        btnOK.clicked.connect(self.accept)
        layout.addWidget(btnOK, 1, 1, 1, 2)

        self.setLayout(layout)
Example #7
0
    def __init__(self, parent=None):
        super(PowerNotificationDialog, self).__init__(parent)
        self.setWindowFlags(Qt.Dialog | Qt.FramelessWindowHint)

        layout = QGridLayout()

        spinBox = QLabel()
        spinner = QMovie(":icons/spinner")
        spinner.start()
        spinBox.setMovie(spinner)
        layout.addWidget(spinBox, 0, 0)

        self.textBox = QLabel()

        layout.addWidget(self.textBox, 0, 1, 1, 3)

        btnOK = ExpandingButton()
        btnOK.setText("OK")
        btnOK.clicked.connect(self.accept)
        layout.addWidget(btnOK, 1, 1, 1, 2)

        self.setLayout(layout)
class LoadingWidget(QWidget):
  """A widget with a little animation for showing progress.
    Call setMessage to change the secondary message and emit
    the finished signal with an appropriate string to set as the
    primary message when done.
  """
  finished = Signal(str)
  animation_finished = Signal()
  
  def __init__(self, loadIcon="loading_bar", primaryMessage="Please, Wait", message='', parent=None):
    super(LoadingWidget, self).__init__(parent)
    self.finished.connect(self._updateUI)
    self.setStyleSheet("""
      QWidget {
        background-color: #ffffff
      }
    """)
    self._icon_load = loadIcon
    self._primary_message = primaryMessage
    self._label_message = QLabel(message)
    self._label_message.setWordWrap(True)
    self._label_message.setAlignment(Qt.AlignCenter)
    self._label_primary_message = QLabel(self._primary_message)
    self._label_primary_message.setStyleSheet("""
      QLabel {
        font-size: 20px;
        font-weight:bold;
        color: rgb(65,65,65);
      }
    """)
    self._label_primary_message.setAlignment(Qt.AlignCenter)
    self._label_movie = QLabel()
    self._label_movie.setAlignment(Qt.AlignCenter)
    self._movie = QMovie(self._icon_load)
    self._label_movie.setMovie(self._movie)
    self._movie.start()
    layout = QVBoxLayout()
    layout.addWidget(self._label_primary_message)
    layout.addSpacing(5)
    layout.addWidget(self._label_message)
    layout.addSpacing(5)
    layout.addWidget(self._label_movie)
    layout.addStretch()
    #self._setupAnimation() # this should be done after showing everything to get correct geometries
    self.setLayout(layout)
  
  def _setupAnimation(self):
    self._load_animation = QPropertyAnimation(self._label_movie, "geometry")
    # since the opacity is failing, make it run out of the area!
    anim_label_geom = self._label_movie.geometry()
    self._load_animation.setStartValue(anim_label_geom)
    target_anim_geom = QRect(anim_label_geom)
    target_anim_geom.moveTop(self.height())
    # make the animation target a rectangle that's directly under it but shifted downwards outside of parent
    self._load_animation.setEndValue(target_anim_geom)
    self._load_animation.setEasingCurve(QEasingCurve.InBack)
    self._load_animation.setDuration(1000)
    self._load_animation.finished.connect(self.animation_finished)
    self._load_animation.finished.connect(self._hideAnimLabel)
  
  def setMessage(self, message):
    self._label_message.setText(message)
    
  def _updateUI(self, message=''):
    if not message:
      message = "All Done!"
    self._label_primary_message.setText(message)
    self._label_message.setText('')
    self._movie.stop()
    self._setupAnimation()
    self.layout().removeWidget(self._label_movie)
    self._label_movie.setGeometry(self._load_animation.startValue())
    self._load_animation.start()
    
  def _hideAnimLabel(self):
    self._label_movie.hide()
    
Example #9
0
class LoadingWidget(QWidget):
    """A widget with a little animation for showing progress.
    Call setMessage to change the secondary message and emit
    the finished signal with an appropriate string to set as the
    primary message when done.
  """
    finished = Signal(str)
    animation_finished = Signal()

    def __init__(self,
                 loadIcon="loading_bar",
                 primaryMessage="Please, Wait",
                 message='',
                 parent=None):
        super(LoadingWidget, self).__init__(parent)
        self.finished.connect(self._updateUI)
        self.setStyleSheet("""
      QWidget {
        background-color: #ffffff
      }
    """)
        self._icon_load = loadIcon
        self._primary_message = primaryMessage
        self._label_message = QLabel(message)
        self._label_message.setWordWrap(True)
        self._label_message.setAlignment(Qt.AlignCenter)
        self._label_primary_message = QLabel(self._primary_message)
        self._label_primary_message.setStyleSheet("""
      QLabel {
        font-size: 20px;
        font-weight:bold;
        color: rgb(65,65,65);
      }
    """)
        self._label_primary_message.setAlignment(Qt.AlignCenter)
        self._label_movie = QLabel()
        self._label_movie.setAlignment(Qt.AlignCenter)
        self._movie = QMovie(self._icon_load)
        self._label_movie.setMovie(self._movie)
        self._movie.start()
        layout = QVBoxLayout()
        layout.addWidget(self._label_primary_message)
        layout.addSpacing(5)
        layout.addWidget(self._label_message)
        layout.addSpacing(5)
        layout.addWidget(self._label_movie)
        layout.addStretch()
        #self._setupAnimation() # this should be done after showing everything to get correct geometries
        self.setLayout(layout)

    def _setupAnimation(self):
        self._load_animation = QPropertyAnimation(self._label_movie,
                                                  "geometry")
        # since the opacity is failing, make it run out of the area!
        anim_label_geom = self._label_movie.geometry()
        self._load_animation.setStartValue(anim_label_geom)
        target_anim_geom = QRect(anim_label_geom)
        target_anim_geom.moveTop(self.height())
        # make the animation target a rectangle that's directly under it but shifted downwards outside of parent
        self._load_animation.setEndValue(target_anim_geom)
        self._load_animation.setEasingCurve(QEasingCurve.InBack)
        self._load_animation.setDuration(1000)
        self._load_animation.finished.connect(self.animation_finished)
        self._load_animation.finished.connect(self._hideAnimLabel)

    def setMessage(self, message):
        self._label_message.setText(message)

    def _updateUI(self, message=''):
        if not message:
            message = "All Done!"
        self._label_primary_message.setText(message)
        self._label_message.setText('')
        self._movie.stop()
        self._setupAnimation()
        self.layout().removeWidget(self._label_movie)
        self._label_movie.setGeometry(self._load_animation.startValue())
        self._load_animation.start()

    def _hideAnimLabel(self):
        self._label_movie.hide()
Example #10
0
class Status(QWidget, Ui_Status):
    def __init__(self, parent=None):
        super(Status, self).__init__(parent)
        self.setupUi(self)
        self.base = parent

        self.wait_anim = QMovie(":/stuff/wait.gif")
        self.anim_lbl.setMovie(self.wait_anim)
        self.anim_lbl.hide()

        self.show_menu = QMenu(self)
        for i in [
                self.act_page, self.act_date, self.act_text, self.act_comment
        ]:
            self.show_menu.addAction(i)
            # noinspection PyUnresolvedReferences
            i.triggered.connect(self.on_show_items)
            i.setChecked(True)

        sort_menu = QMenu(self)
        ico_sort = QIcon(":/stuff/sort.png")
        group = QActionGroup(self)

        action = QAction(_("Date"), sort_menu)
        action.setCheckable(True)
        action.setChecked(not self.base.high_by_page)
        action.triggered.connect(self.base.set_highlight_sort)
        action.setData(False)
        group.addAction(action)
        sort_menu.addAction(action)

        action = QAction(_("Page"), sort_menu)
        action.setCheckable(True)
        action.setChecked(self.base.high_by_page)
        action.triggered.connect(self.base.set_highlight_sort)
        action.setData(True)
        group.addAction(action)
        sort_menu.addAction(action)

        sort_menu.setIcon(ico_sort)
        sort_menu.setTitle(_("Sort by"))
        self.show_menu.addMenu(sort_menu)

        self.show_items_btn.setMenu(self.show_menu)

    def on_show_items(self):
        """ Show/Hide elements of the highlight info
        """
        try:
            idx = self.base.file_table.selectionModel().selectedRows()[-1]
        except IndexError:  # nothing selected
            return
        item = self.base.file_table.item(idx.row(), 0)
        self.base.on_file_table_itemClicked(item)

    def animation(self, run):
        """ Creates or deletes temporary files and folders

        :type run: bool
        :param run: Start/stop animation
        """
        # if action == "start":
        if run:
            self.anim_lbl.show()
            self.wait_anim.start()
        else:
            self.anim_lbl.hide()
            self.wait_anim.stop()