class RecordingWidget(QWidget): """Widget containing main recording UI for Freeseer""" def __init__(self, parent=None): QWidget.__init__(self, parent) icon = QIcon() icon.addPixmap(QPixmap(":/freeseer/logo.png"), QIcon.Normal, QIcon.Off) self.setWindowIcon(icon) self.resize(400, 400) self.mainLayout = QVBoxLayout() self.setLayout(self.mainLayout) boldFont = QFont() boldFont.setBold(True) # Control bar self.controlRow = QHBoxLayout() self.mainLayout.addLayout(self.controlRow) self.standbyIcon = QIcon.fromTheme("system-shutdown") recordFallbackIcon = QIcon(":/multimedia/record.png") self.recordIcon = QIcon.fromTheme("media-record", recordFallbackIcon) stopFallbackIcon = QIcon(":/multimedia/stop.png") self.stopIcon = QIcon.fromTheme("media-playback-stop", stopFallbackIcon) self.pauseIcon = QIcon.fromTheme("media-playback-pause") self.resumeIcon = QIcon.fromTheme("media-playback-start") self.headphoneIcon = QIcon() self.headphoneIcon.addPixmap(QPixmap(":/multimedia/headphones.png"), QIcon.Normal, QIcon.Off) self.standbyPushButton = QPushButton("Standby") self.standbyPushButton.setToolTip("Standby") self.standbyPushButton.setMinimumSize(QSize(0, 40)) self.standbyPushButton.setSizePolicy(QSizePolicy.Minimum, QSizePolicy.Fixed) self.standbyPushButton.setIcon(self.standbyIcon) self.standbyPushButton.setCheckable(True) self.standbyPushButton.setObjectName("standbyButton") self.controlRow.addWidget(self.standbyPushButton) self.recordPushButton = QPushButton("Record") self.recordPushButton.setToolTip("Record") self.recordPushButton.setMinimumSize(QSize(0, 40)) self.recordPushButton.setSizePolicy(QSizePolicy.Minimum, QSizePolicy.Fixed) self.recordPushButton.setIcon(self.recordIcon) self.recordPushButton.setHidden(True) self.recordPushButton.setEnabled(False) self.recordPushButton.setCheckable(True) self.recordPushButton.setObjectName("recordButton") self.controlRow.addWidget(self.recordPushButton) self.connect(self.recordPushButton, SIGNAL("toggled(bool)"), self.setRecordIcon) self.pauseToolButton = QToolButton() self.pauseToolButton.setText("Pause") self.pauseToolButton.setToolTip("Pause") self.pauseToolButton.setIcon(self.pauseIcon) self.pauseToolButton.setMinimumSize(QSize(40, 40)) self.pauseToolButton.setSizePolicy(QSizePolicy.Maximum, QSizePolicy.Fixed) self.pauseToolButton.setHidden(True) self.pauseToolButton.setEnabled(False) self.pauseToolButton.setCheckable(True) self.controlRow.addWidget(self.pauseToolButton) self.connect(self.pauseToolButton, SIGNAL("toggled(bool)"), self.setPauseIcon) playbackIcon = QIcon.fromTheme("video-x-generic") self.playPushButton = QPushButton() self.playPushButton.setText("Play Video") self.playPushButton.setToolTip("Play last recorded Video") self.playPushButton.setIcon(playbackIcon) self.playPushButton.setMinimumSize(QSize(40, 40)) self.playPushButton.setMaximumSize(QSize(120, 40)) self.playPushButton.setHidden(True) self.playPushButton.setEnabled(False) self.playPushButton.setCheckable(True) self.controlRow.addWidget(self.playPushButton) # Filter bar self.filterBarLayout = QVBoxLayout() self.mainLayout.addLayout(self.filterBarLayout) self.filterBarLayoutRow_1 = QHBoxLayout() self.filterBarLayout.addLayout(self.filterBarLayoutRow_1) self.eventLabel = QLabel("Event") self.eventLabel.setSizePolicy(QSizePolicy.Maximum, QSizePolicy.Fixed) self.eventComboBox = QComboBox() self.eventLabel.setBuddy(self.eventComboBox) self.roomLabel = QLabel("Room") self.roomLabel.setSizePolicy(QSizePolicy.Maximum, QSizePolicy.Fixed) self.roomComboBox = QComboBox() self.roomLabel.setBuddy(self.roomComboBox) self.dateLabel = QLabel("Date") self.dateLabel.setSizePolicy(QSizePolicy.Maximum, QSizePolicy.Fixed) self.dateComboBox = QComboBox() self.dateLabel.setBuddy(self.dateComboBox) self.filterBarLayoutRow_1.addWidget(self.eventLabel) self.filterBarLayoutRow_1.addWidget(self.eventComboBox) self.filterBarLayoutRow_1.addWidget(self.roomLabel) self.filterBarLayoutRow_1.addWidget(self.roomComboBox) self.filterBarLayoutRow_1.addWidget(self.dateLabel) self.filterBarLayoutRow_1.addWidget(self.dateComboBox) self.filterBarLayoutRow_2 = QHBoxLayout() self.filterBarLayout.addLayout(self.filterBarLayoutRow_2) self.talkLabel = QLabel("Talk ") self.talkLabel.setSizePolicy(QSizePolicy.Maximum, QSizePolicy.Fixed) self.talkComboBox = QComboBox() self.talkComboBox.setFont(boldFont) self.talkComboBox.setSizePolicy(QSizePolicy.Minimum, QSizePolicy.Maximum) self.talkComboBox.setSizeAdjustPolicy(QComboBox.AdjustToMinimumContentsLength) self.filterBarLayoutRow_2.addWidget(self.talkLabel) self.filterBarLayoutRow_2.addWidget(self.talkComboBox) # Preview Layout self.previewLayout = QHBoxLayout() self.mainLayout.addLayout(self.previewLayout) self.previewWidget = QWidget() self.audioSlider = QSlider() self.audioSlider.setSizePolicy(QSizePolicy.Fixed, QSizePolicy.Expanding) self.audioSlider.setEnabled(False) self.previewLayout.addWidget(self.previewWidget) self.previewLayout.addWidget(self.audioSlider) self.statusLabel = QLabel() self.mainLayout.addWidget(self.statusLabel) # Audio Feedback Checkbox self.audioFeedbackCheckbox = QCheckBox() self.audioFeedbackCheckbox.setLayoutDirection(Qt.RightToLeft) self.audioFeedbackCheckbox.setIcon(self.headphoneIcon) self.audioFeedbackCheckbox.setToolTip("Enable Audio Feedback") self.mainLayout.addWidget(self.audioFeedbackCheckbox) def setRecordIcon(self, state): if state: self.recordPushButton.setIcon(self.stopIcon) else: self.recordPushButton.setIcon(self.recordIcon) def setPauseIcon(self, state): if state: self.pauseToolButton.setIcon(self.resumeIcon) else: self.pauseToolButton.setIcon(self.pauseIcon)
class RecordingWidget(QWidgetWithDpi): """Widget containing main recording UI for Freeseer""" def __init__(self, parent=None): super(RecordingWidget, self).__init__(parent) icon = QIcon() icon.addPixmap(QPixmap(":/freeseer/logo.png"), QIcon.Normal, QIcon.Off) self.setWindowIcon(icon) self.resize(400, 400) self.mainLayout = QVBoxLayout() self.setLayout(self.mainLayout) self.setStyleSheet( """ QToolButton { background-color: #D1D1D1; border-style: solid; border-width: 1px; border-radius: 10px; border-color: #969696; padding: 6px; } QToolButton:pressed { background-color: #A3A2A2; border-width: 2px; border-color: #707070; } QToolButton:checked { background-color: #A3A2A2; border-width: 2px; border-color: #707070; } QToolButton:disabled { background-color: #EDEDED; border-color: #BFBDBD; } QToolButton:hover { border-width: 2px; } """ ) boldFont = QFont() boldFont.setBold(True) fontSize = self.font().pixelSize() fontUnit = "px" if fontSize == -1: # Font is set as points, not pixels. fontUnit = "pt" fontSize = self.font().pointSize() # Control bar self.controlRow = QHBoxLayout() self.mainLayout.addLayout(self.controlRow) self.recordIcon = QIcon(":/multimedia/record.png") self.stopIcon = QIcon(":/multimedia/stop.png") pauseIcon = QIcon(":/multimedia/pause.png") playIcon = QIcon(":/multimedia/play.png") self.headphoneIcon = QIcon() self.headphoneIcon.addPixmap(QPixmap(":/multimedia/headphones.png"), QIcon.Normal, QIcon.Off) self.is_recording = False self.recordButton = QToolButtonWithDpi() self.recordButton.setToolTip("Record") self.recordButton.setFixedSize(QSize(60, 40)) self.recordButton.setSizePolicy(QSizePolicy.Fixed, QSizePolicy.Fixed) self.recordButton.setIcon(self.recordIcon) self.recordButton.setEnabled(False) self.recordButton.setObjectName("recordButton") self.controlRow.addWidget(self.recordButton, 0, Qt.AlignLeft) self.connect(self.recordButton, SIGNAL("clicked()"), self.setRecordIcon) self.playButton = QToolButtonWithDpi() self.playButton.setToolTip("Play last recorded Video") self.playButton.setFixedSize(QSize(60, 40)) self.playButton.setSizePolicy(QSizePolicy.Fixed, QSizePolicy.Fixed) self.playButton.setIcon(playIcon) self.playButton.setEnabled(False) self.controlRow.addWidget(self.playButton, 0, Qt.AlignLeft) self.pauseButton = QToolButtonWithDpi() self.pauseButton.setToolTip("Pause") self.pauseButton.setIcon(pauseIcon) self.pauseButton.setFixedSize(QSize(60, 40)) self.pauseButton.setSizePolicy(QSizePolicy.Fixed, QSizePolicy.Fixed) self.pauseButton.setEnabled(False) self.pauseButton.setCheckable(True) self.controlRow.addWidget(self.pauseButton, 0, Qt.AlignLeft) self.controlRow.addSpacerItem(self.qspacer_item_with_dpi(30, 40)) self.controlRow.addStretch(1) self.standbyButton = QPushButtonWithDpi("Standby") self.standbyButton.setStyleSheet( """ QPushButton {{ color: white; background-color: #47a447; border-style: solid; border-width: 0px; border-radius: 10px; border-color: #398439; font: bold {}{}; padding: 6px; }} QPushButton:pressed {{ background-color: #3E8A3E; border-color: #327532; }} QPushButton:hover {{ border-width: 2px; }} """.format( fontSize + 3, fontUnit ) ) self.standbyButton.setToolTip("Standby") self.standbyButton.setFixedSize(QSize(180, 40)) self.standbyButton.setSizePolicy(QSizePolicy.Fixed, QSizePolicy.Fixed) self.standbyButton.setCheckable(True) self.standbyButton.setObjectName("standbyButton") self.controlRow.addWidget(self.standbyButton) self.disengageButton = QPushButtonWithDpi("Leave record-mode") self.disengageButton.setStyleSheet( """ QPushButton {{ color: white; background-color: #D14343; border-style: solid; border-width: 0px; border-radius: 10px; border-color: #B02C2C; font: bold {}{}; padding: 6px; }} QPushButton:pressed {{ background-color: #AD2B2B; border-color: #8C2929; }} QPushButton:hover {{ border-width: 2px; }} QPushButton:disabled {{ background-color: #B89E9E; }} """.format( fontSize + 3, fontUnit ) ) self.disengageButton.setToolTip("Leave record-mode") self.disengageButton.setFixedSize(QSize(180, 40)) self.disengageButton.setSizePolicy(QSizePolicy.Fixed, QSizePolicy.Fixed) self.disengageButton.setHidden(True) self.disengageButton.setObjectName("disengageButton") self.controlRow.addWidget(self.disengageButton) # Filter bar self.filterBarLayout = QVBoxLayout() self.mainLayout.addLayout(self.filterBarLayout) self.filterBarLayoutRow_1 = QHBoxLayout() self.filterBarLayout.addLayout(self.filterBarLayoutRow_1) self.eventLabel = QLabel("Event") self.eventLabel.setSizePolicy(QSizePolicy.Maximum, QSizePolicy.Fixed) self.eventComboBox = QComboBox() self.eventLabel.setBuddy(self.eventComboBox) self.roomLabel = QLabel("Room") self.roomLabel.setSizePolicy(QSizePolicy.Maximum, QSizePolicy.Fixed) self.roomComboBox = QComboBox() self.roomLabel.setBuddy(self.roomComboBox) self.dateLabel = QLabel("Date") self.dateLabel.setSizePolicy(QSizePolicy.Maximum, QSizePolicy.Fixed) self.dateComboBox = QComboBox() self.dateLabel.setBuddy(self.dateComboBox) self.filterBarLayoutRow_1.addWidget(self.eventLabel) self.filterBarLayoutRow_1.addWidget(self.eventComboBox) self.filterBarLayoutRow_1.addWidget(self.roomLabel) self.filterBarLayoutRow_1.addWidget(self.roomComboBox) self.filterBarLayoutRow_1.addWidget(self.dateLabel) self.filterBarLayoutRow_1.addWidget(self.dateComboBox) self.filterBarLayoutRow_2 = QHBoxLayout() self.filterBarLayout.addLayout(self.filterBarLayoutRow_2) self.talkLabel = QLabel("Talk ") self.talkLabel.setSizePolicy(QSizePolicy.Maximum, QSizePolicy.Fixed) self.talkComboBox = QComboBox() self.talkComboBox.setFont(boldFont) self.talkComboBox.setSizePolicy(QSizePolicy.Minimum, QSizePolicy.Maximum) self.talkComboBox.setSizeAdjustPolicy(QComboBox.AdjustToMinimumContentsLength) self.filterBarLayoutRow_2.addWidget(self.talkLabel) self.filterBarLayoutRow_2.addWidget(self.talkComboBox) # Preview Layout self.previewLayout = QHBoxLayout() self.mainLayout.addLayout(self.previewLayout) self.previewWidget = QWidget() self.audioSlider = QSlider() self.audioSlider.setSizePolicy(QSizePolicy.Fixed, QSizePolicy.Expanding) self.audioSlider.setEnabled(False) self.previewLayout.addWidget(self.previewWidget) self.previewLayout.addWidget(self.audioSlider) self.statusLabel = QLabel() self.mainLayout.addWidget(self.statusLabel) # Audio Feedback Checkbox self.audioFeedbackCheckbox = QCheckBox() self.audioFeedbackCheckbox.setLayoutDirection(Qt.RightToLeft) self.audioFeedbackCheckbox.setIcon(self.headphoneIcon) self.audioFeedbackCheckbox.setToolTip("Enable Audio Feedback") self.mainLayout.addWidget(self.audioFeedbackCheckbox) def setRecordIcon(self): self.is_recording = not self.is_recording if self.is_recording: self.recordButton.setIcon(self.stopIcon) else: self.recordButton.setIcon(self.recordIcon)
class LoginForm(QMainWindow): def __init__(self, parent=None): super(LoginForm, self).__init__(parent) self.width, self.height = 800, 650 self.crear_interfaz(self.width, self.height) self.checkbox_rememberme.clicked.connect(self.remember_me) self.button_login.clicked.connect(self.logging) # self.div_create.setVisible(False) self.database = Database() """self.label_rememberme.mousePressEvent = self.do_remember def do_remember(self, event): # TDE FIXME: Create another remember_me method for remember me label self.remember_me(event) """ def loading(self): print "loading..." def logging(self): self.valid_fields() def valid_fields(self): username = self.username.text() password = self.password.text() if username == '': self.username.setFocus(True) elif password == '': self.password.setFocus(True) else: self.loading() self.username.setEnabled(False) self.password.setEnabled(False) print "Logging validation username" if self.database.login(username, password): print "Bienvenido %s" % username else: print "Datos incorrectos!" # return True in end of statement def anim_left(self): animation = QPropertyAnimation(self.label_icon, "geometry") animation.setDuration(250) animation.setStartValue(QRect(0, 0, 20, 20)) animation.setEndValue(QRect(20, 0, 20, 20)) animation.start() self.animation = animation def anim_right(self): animation = QPropertyAnimation(self.label_icon, "geometry") animation.setDuration(250) animation.setStartValue(QRect(20, 0, 20, 20)) animation.setEndValue(QRect(0, 0, 20, 20)) animation.start() self.animation = animation def remember_me(self): if self.checkbox_rememberme.isChecked(): self.anim_left() self.label_icon.setGeometry(20, 0, 20, 20) else: self.anim_right() self.label_icon.setGeometry(0, 0, 20, 20) def crear_interfaz(self, width, height): self.setMinimumSize(width, height) self.setMaximumSize(width, height) self.setWindowTitle('I n i c i a s e s i ó n | SN') self.setObjectName('login_form_window') self.container = QWidget(self) self.container.setMinimumSize(width, height) self.container.setMaximumSize(width, height) self.container.setObjectName('login_container') self.title = QLabel(self) self.title.setText('I N I C I A S E S I Ó N G R Á T I S') self.title.setGeometry(210, 130, 400, 40) self.title.setAlignment(Qt.AlignHCenter | Qt.AlignVCenter) self.title.setObjectName('login_title') self.username = QLineEdit(self) self.username.setPlaceholderText('N O M B R E D E U S U A R I O') self.username.setGeometry(260, 230, 300, 40) self.username.setObjectName('login_username') self.username.setAcceptDrops(False) self.password = QLineEdit(self) self.password.setPlaceholderText('C O N T R A S E Ñ A') self.password.setGeometry(260, 290, 300, 40) self.password.setObjectName('login_password') self.password.setEchoMode(QLineEdit.Password) self.checkbox_rememberme = QCheckBox(self) self.checkbox_rememberme.setLayoutDirection(Qt.RightToLeft) self.checkbox_rememberme.setGeometry(260, 360, 40, 20) self.checkbox_rememberme.setObjectName("login_rememberme") self.checkbox_rememberme.setCursor(QCursor(Qt.PointingHandCursor)) self.label_icon = QLabel(self.checkbox_rememberme) self.label_icon.setGeometry(0, 0, 20, 20) self.label_icon.setObjectName("label_icon") self.label_rememberme = QLabel(self) self.label_rememberme.setText("R E C U É R D A M E") self.label_rememberme.setGeometry(310, 360, 165, 20) self.label_rememberme.setObjectName("label_rememberme") self.button_login = QPushButton(self) self.button_login.setGeometry(315, 420, 200, 40) self.button_login.setText("I N I C I A R S E S I Ó N") self.button_login.setObjectName("button_login") self.layout = QGridLayout(self.container)
class RecordingWidget(QWidget): """Widget containing main recording UI for Freeseer""" def __init__(self, parent=None): QWidget.__init__(self, parent) icon = QIcon() icon.addPixmap(QPixmap(":/freeseer/logo.png"), QIcon.Normal, QIcon.Off) self.setWindowIcon(icon) self.resize(400, 400) self.mainLayout = QVBoxLayout() self.setLayout(self.mainLayout) boldFont = QFont() boldFont.setBold(True) # Control bar self.controlRow = QHBoxLayout() self.mainLayout.addLayout(self.controlRow) self.standbyIcon = QIcon.fromTheme("system-shutdown") recordFallbackIcon = QIcon(":/multimedia/record.png") self.recordIcon = QIcon.fromTheme("media-record", recordFallbackIcon) stopFallbackIcon = QIcon(":/multimedia/stop.png") self.stopIcon = QIcon.fromTheme("media-playback-stop", stopFallbackIcon) self.pauseIcon = QIcon.fromTheme("media-playback-pause") self.resumeIcon = QIcon.fromTheme("media-playback-start") self.headphoneIcon = QIcon() self.headphoneIcon.addPixmap(QPixmap(":/multimedia/headphones.png"), QIcon.Normal, QIcon.Off) self.standbyPushButton = QPushButton("Standby") self.standbyPushButton.setToolTip("Standby") self.standbyPushButton.setMinimumSize(QSize(0, 40)) self.standbyPushButton.setSizePolicy(QSizePolicy.Minimum, QSizePolicy.Fixed) self.standbyPushButton.setIcon(self.standbyIcon) self.standbyPushButton.setCheckable(True) self.standbyPushButton.setObjectName("standbyButton") self.controlRow.addWidget(self.standbyPushButton) self.autoRecordPushButton = QPushButton("Auto Record") self.autoRecordPushButton.setToolTip("Automated Recording") self.autoRecordPushButton.setMinimumSize(QSize(40, 40)) self.autoRecordPushButton.setMaximumSize(QSize(120, 40)) self.autoRecordPushButton.setCheckable(True) self.autoRecordPushButton.setObjectName("autoRecordButton") self.controlRow.addWidget(self.autoRecordPushButton) self.recordPushButton = QPushButton("Record") self.recordPushButton.setToolTip("Record") self.recordPushButton.setMinimumSize(QSize(0, 40)) self.recordPushButton.setSizePolicy(QSizePolicy.Minimum, QSizePolicy.Fixed) self.recordPushButton.setIcon(self.recordIcon) self.recordPushButton.setHidden(True) self.recordPushButton.setEnabled(False) self.recordPushButton.setCheckable(True) self.recordPushButton.setObjectName("recordButton") self.controlRow.addWidget(self.recordPushButton) self.connect(self.recordPushButton, SIGNAL("toggled(bool)"), self.setRecordIcon) self.pauseToolButton = QToolButton() self.pauseToolButton.setText("Pause") self.pauseToolButton.setToolTip("Pause") self.pauseToolButton.setIcon(self.pauseIcon) self.pauseToolButton.setMinimumSize(QSize(40, 40)) self.pauseToolButton.setSizePolicy(QSizePolicy.Maximum, QSizePolicy.Fixed) self.pauseToolButton.setHidden(True) self.pauseToolButton.setEnabled(False) self.pauseToolButton.setCheckable(True) self.controlRow.addWidget(self.pauseToolButton) self.connect(self.pauseToolButton, SIGNAL("toggled(bool)"), self.setPauseIcon) playbackIcon = QIcon.fromTheme("video-x-generic") self.playPushButton = QPushButton() self.playPushButton.setText("Play Video") self.playPushButton.setToolTip("Play last recorded Video") self.playPushButton.setIcon(playbackIcon) self.playPushButton.setMinimumSize(QSize(40, 40)) self.playPushButton.setMaximumSize(QSize(120, 40)) self.playPushButton.setHidden(True) self.playPushButton.setEnabled(False) self.playPushButton.setCheckable(True) self.controlRow.addWidget(self.playPushButton) # Filter bar self.filterBarLayout = QVBoxLayout() self.mainLayout.addLayout(self.filterBarLayout) self.filterBarLayoutRow_1 = QHBoxLayout() self.filterBarLayout.addLayout(self.filterBarLayoutRow_1) self.eventLabel = QLabel("Event") self.eventLabel.setSizePolicy(QSizePolicy.Maximum, QSizePolicy.Fixed) self.eventComboBox = QComboBox() self.eventLabel.setBuddy(self.eventComboBox) self.roomLabel = QLabel("Room") self.roomLabel.setSizePolicy(QSizePolicy.Maximum, QSizePolicy.Fixed) self.roomComboBox = QComboBox() self.roomLabel.setBuddy(self.roomComboBox) self.dateLabel = QLabel("Date") self.dateLabel.setSizePolicy(QSizePolicy.Maximum, QSizePolicy.Fixed) self.dateComboBox = QComboBox() self.dateLabel.setBuddy(self.dateComboBox) self.filterBarLayoutRow_1.addWidget(self.eventLabel) self.filterBarLayoutRow_1.addWidget(self.eventComboBox) self.filterBarLayoutRow_1.addWidget(self.roomLabel) self.filterBarLayoutRow_1.addWidget(self.roomComboBox) self.filterBarLayoutRow_1.addWidget(self.dateLabel) self.filterBarLayoutRow_1.addWidget(self.dateComboBox) self.filterBarLayoutRow_2 = QHBoxLayout() self.filterBarLayout.addLayout(self.filterBarLayoutRow_2) self.talkLabel = QLabel("Talk ") self.talkLabel.setSizePolicy(QSizePolicy.Maximum, QSizePolicy.Fixed) self.talkComboBox = QComboBox() self.talkComboBox.setFont(boldFont) self.talkComboBox.setSizePolicy(QSizePolicy.Minimum, QSizePolicy.Maximum) self.talkComboBox.setSizeAdjustPolicy( QComboBox.AdjustToMinimumContentsLength) self.filterBarLayoutRow_2.addWidget(self.talkLabel) self.filterBarLayoutRow_2.addWidget(self.talkComboBox) # Preview Layout self.previewLayout = QHBoxLayout() self.mainLayout.addLayout(self.previewLayout) self.previewWidget = QWidget() self.audioSlider = QSlider() self.audioSlider.setSizePolicy(QSizePolicy.Fixed, QSizePolicy.Expanding) self.audioSlider.setEnabled(False) self.previewLayout.addWidget(self.previewWidget) self.previewLayout.addWidget(self.audioSlider) self.statusLabel = QLabel() self.mainLayout.addWidget(self.statusLabel) # Audio Feedback Checkbox self.audioFeedbackCheckbox = QCheckBox() self.audioFeedbackCheckbox.setLayoutDirection(Qt.RightToLeft) self.audioFeedbackCheckbox.setIcon(self.headphoneIcon) self.audioFeedbackCheckbox.setToolTip("Enable Audio Feedback") self.mainLayout.addWidget(self.audioFeedbackCheckbox) def setRecordIcon(self, state): if state: self.recordPushButton.setIcon(self.stopIcon) else: self.recordPushButton.setIcon(self.recordIcon) def setPauseIcon(self, state): if state: self.pauseToolButton.setIcon(self.resumeIcon) else: self.pauseToolButton.setIcon(self.pauseIcon)
class RecordingWidget(QWidgetWithDpi): """Widget containing main recording UI for Freeseer""" def __init__(self, parent=None): super(RecordingWidget, self).__init__(parent) icon = QIcon() icon.addPixmap(QPixmap(":/freeseer/logo.png"), QIcon.Normal, QIcon.Off) self.setWindowIcon(icon) self.resize(400, 400) self.mainLayout = QVBoxLayout() self.setLayout(self.mainLayout) self.setStyleSheet(""" QToolButton { background-color: #D1D1D1; border-style: solid; border-width: 1px; border-radius: 10px; border-color: #969696; padding: 6px; } QToolButton:pressed { background-color: #A3A2A2; border-width: 2px; border-color: #707070; } QToolButton:checked { background-color: #A3A2A2; border-width: 2px; border-color: #707070; } QToolButton:disabled { background-color: #EDEDED; border-color: #BFBDBD; } QToolButton:hover { border-width: 2px; } """) boldFont = QFont() boldFont.setBold(True) fontSize = self.font().pixelSize() fontUnit = "px" if fontSize == -1: # Font is set as points, not pixels. fontUnit = "pt" fontSize = self.font().pointSize() # Control bar self.controlRow = QHBoxLayout() self.mainLayout.addLayout(self.controlRow) self.recordIcon = QIcon(":/multimedia/record.png") self.stopIcon = QIcon(":/multimedia/stop.png") pauseIcon = QIcon(":/multimedia/pause.png") playIcon = QIcon(":/multimedia/play.png") self.headphoneIcon = QIcon() self.headphoneIcon.addPixmap(QPixmap(":/multimedia/headphones.png"), QIcon.Normal, QIcon.Off) self.is_recording = False self.recordButton = QToolButtonWithDpi() self.recordButton.setToolTip("Record") self.recordButton.setFixedSize(QSize(60, 40)) self.recordButton.setSizePolicy(QSizePolicy.Fixed, QSizePolicy.Fixed) self.recordButton.setIcon(self.recordIcon) self.recordButton.setEnabled(False) self.recordButton.setObjectName("recordButton") self.controlRow.addWidget(self.recordButton, 0, Qt.AlignLeft) self.connect(self.recordButton, SIGNAL("clicked()"), self.setRecordIcon) self.playButton = QToolButtonWithDpi() self.playButton.setToolTip("Play last recorded Video") self.playButton.setFixedSize(QSize(60, 40)) self.playButton.setSizePolicy(QSizePolicy.Fixed, QSizePolicy.Fixed) self.playButton.setIcon(playIcon) self.playButton.setEnabled(False) self.controlRow.addWidget(self.playButton, 0, Qt.AlignLeft) self.pauseButton = QToolButtonWithDpi() self.pauseButton.setToolTip("Pause") self.pauseButton.setIcon(pauseIcon) self.pauseButton.setFixedSize(QSize(60, 40)) self.pauseButton.setSizePolicy(QSizePolicy.Fixed, QSizePolicy.Fixed) self.pauseButton.setEnabled(False) self.pauseButton.setCheckable(True) self.controlRow.addWidget(self.pauseButton, 0, Qt.AlignLeft) self.controlRow.addSpacerItem(self.qspacer_item_with_dpi(30, 40)) self.controlRow.addStretch(1) self.standbyButton = QPushButtonWithDpi("Standby") self.standbyButton.setStyleSheet(""" QPushButton {{ color: white; background-color: #47a447; border-style: solid; border-width: 0px; border-radius: 10px; border-color: #398439; font: bold {}{}; padding: 6px; }} QPushButton:pressed {{ background-color: #3E8A3E; border-color: #327532; }} QPushButton:hover {{ border-width: 2px; }} """.format(fontSize + 3, fontUnit)) self.standbyButton.setToolTip("Standby") self.standbyButton.setFixedSize(QSize(180, 40)) self.standbyButton.setSizePolicy(QSizePolicy.Fixed, QSizePolicy.Fixed) self.standbyButton.setCheckable(True) self.standbyButton.setObjectName("standbyButton") self.controlRow.addWidget(self.standbyButton) self.disengageButton = QPushButtonWithDpi("Leave record-mode") self.disengageButton.setStyleSheet(""" QPushButton {{ color: white; background-color: #D14343; border-style: solid; border-width: 0px; border-radius: 10px; border-color: #B02C2C; font: bold {}{}; padding: 6px; }} QPushButton:pressed {{ background-color: #AD2B2B; border-color: #8C2929; }} QPushButton:hover {{ border-width: 2px; }} QPushButton:disabled {{ background-color: #B89E9E; }} """.format(fontSize + 3, fontUnit)) self.disengageButton.setToolTip("Leave record-mode") self.disengageButton.setFixedSize(QSize(180, 40)) self.disengageButton.setSizePolicy(QSizePolicy.Fixed, QSizePolicy.Fixed) self.disengageButton.setHidden(True) self.disengageButton.setObjectName("disengageButton") self.controlRow.addWidget(self.disengageButton) # Filter bar self.filterBarLayout = QVBoxLayout() self.mainLayout.addLayout(self.filterBarLayout) self.filterBarLayoutRow_1 = QHBoxLayout() self.filterBarLayout.addLayout(self.filterBarLayoutRow_1) self.eventLabel = QLabel("Event") self.eventLabel.setSizePolicy(QSizePolicy.Maximum, QSizePolicy.Fixed) self.eventComboBox = QComboBox() self.eventLabel.setBuddy(self.eventComboBox) self.roomLabel = QLabel("Room") self.roomLabel.setSizePolicy(QSizePolicy.Maximum, QSizePolicy.Fixed) self.roomComboBox = QComboBox() self.roomLabel.setBuddy(self.roomComboBox) self.dateLabel = QLabel("Date") self.dateLabel.setSizePolicy(QSizePolicy.Maximum, QSizePolicy.Fixed) self.dateComboBox = QComboBox() self.dateLabel.setBuddy(self.dateComboBox) self.filterBarLayoutRow_1.addWidget(self.eventLabel) self.filterBarLayoutRow_1.addWidget(self.eventComboBox) self.filterBarLayoutRow_1.addWidget(self.roomLabel) self.filterBarLayoutRow_1.addWidget(self.roomComboBox) self.filterBarLayoutRow_1.addWidget(self.dateLabel) self.filterBarLayoutRow_1.addWidget(self.dateComboBox) self.filterBarLayoutRow_2 = QHBoxLayout() self.filterBarLayout.addLayout(self.filterBarLayoutRow_2) self.talkLabel = QLabel("Talk ") self.talkLabel.setSizePolicy(QSizePolicy.Maximum, QSizePolicy.Fixed) self.talkComboBox = QComboBox() self.talkComboBox.setFont(boldFont) self.talkComboBox.setSizePolicy(QSizePolicy.Minimum, QSizePolicy.Maximum) self.talkComboBox.setSizeAdjustPolicy(QComboBox.AdjustToMinimumContentsLength) self.filterBarLayoutRow_2.addWidget(self.talkLabel) self.filterBarLayoutRow_2.addWidget(self.talkComboBox) # Preview Layout self.previewLayout = QHBoxLayout() self.mainLayout.addLayout(self.previewLayout) self.previewWidget = QWidget() self.audioSlider = QSlider() self.audioSlider.setSizePolicy(QSizePolicy.Fixed, QSizePolicy.Expanding) self.audioSlider.setEnabled(False) self.previewLayout.addWidget(self.previewWidget) self.previewLayout.addWidget(self.audioSlider) self.statusLabel = QLabel() self.mainLayout.addWidget(self.statusLabel) # Audio Feedback Checkbox self.audioFeedbackCheckbox = QCheckBox() self.audioFeedbackCheckbox.setLayoutDirection(Qt.RightToLeft) self.audioFeedbackCheckbox.setIcon(self.headphoneIcon) self.audioFeedbackCheckbox.setToolTip("Enable Audio Feedback") self.mainLayout.addWidget(self.audioFeedbackCheckbox) def setRecordIcon(self): self.is_recording = not self.is_recording if self.is_recording: self.recordButton.setIcon(self.stopIcon) else: self.recordButton.setIcon(self.recordIcon)
class GUI(QWidget): def __init__(self, parent=None): global f f = open(filename, "a") f.write("Widget init.\n") f.close() QWidget.__init__(self, parent, Qt.WindowStaysOnTopHint) self.__setup_gui__(self) self._flag = False self._change = False f = open(filename, "a") f.write("End of widget init.\n") f.close() def closeEvent(self, event): reply = QMessageBox.question(self, "Confirm", "Are you sure You want to quit?", QMessageBox.Yes | QMessageBox.No, QMessageBox.No) if reply == QMessageBox.Yes: event.accept() else: event.ignore() def __setup_gui__(self, Dialog): global f f = open(filename, "a") f.write("Setup of gui.\n") f.close() Dialog.setObjectName("Dialog") Dialog.resize(270, 145) self.setWindowTitle("Map Layer") screen = QDesktopWidget().screenGeometry() size = self.geometry() self.move((screen.width() - size.width()) / 2, (screen.height() - size.height()) / 2) self.Render = QPushButton("Render", Dialog) self.Render.setGeometry(QRect(85, 90, 100, 25)) self.Render.setObjectName("Render") self.comboBox = QComboBox(Dialog) self.comboBox.setGeometry(QRect(100, 34, 115, 18)) self.comboBox.setEditable(False) self.comboBox.setMaxVisibleItems(11) self.comboBox.setInsertPolicy(QComboBox.InsertAtBottom) self.comboBox.setObjectName("comboBox") self.comboBox.addItems([ "Google Roadmap", "Google Terrain", "Google Satellite", "Google Hybrid", "Yahoo Roadmap", "Yahoo Satellite", "Yahoo Hybrid", "Bing Roadmap", "Bing Satellite", "Bing Hybrid", "Open Street Maps" ]) self.comboBox.setCurrentIndex(10) self.label1 = QLabel("Source:", Dialog) self.label1.setGeometry(QRect(55, 35, 35, 16)) self.label1.setObjectName("label1") self.slider = QSlider(Dialog) self.slider.setOrientation(Qt.Horizontal) self.slider.setMinimum(1) self.slider.setMaximum(12) self.slider.setValue(4) self.slider.setGeometry(QRect(110, 61, 114, 16)) self.label2 = QLabel("Quality: " + str(self.slider.value()), Dialog) self.label2.setGeometry(QRect(47, 61, 54, 16)) self.label2.setObjectName("label2") self.doubleSpinBox = QDoubleSpinBox(Dialog) self.doubleSpinBox.setGeometry(QRect(160, 5, 40, 20)) self.doubleSpinBox.setDecimals(0) self.doubleSpinBox.setObjectName("doubleSpinBox") self.doubleSpinBox.setMinimum(10.0) self.doubleSpinBox.setValue(20.0) self.doubleSpinBox.setEnabled(False) self.checkBox = QCheckBox("Auto refresh", Dialog) self.checkBox.setGeometry(QRect(50, 6, 100, 20)) self.checkBox.setLayoutDirection(Qt.RightToLeft) self.checkBox.setObjectName("checkBox") self.progressBar = QProgressBar(Dialog) self.progressBar.setGeometry(QRect(5, 130, 260, 10)) self.progressBar.setProperty("value", 0) self.progressBar.setTextVisible(False) self.progressBar.setObjectName("progressBar") self.progressBar.setVisible(False) QObject.connect(self.Render, SIGNAL("clicked()"), Dialog.__repaint__) QMetaObject.connectSlotsByName(Dialog) QObject.connect(self.slider, SIGNAL("valueChanged(int)"), self.__update_slider_label__) QObject.connect(self.comboBox, SIGNAL("activated(int)"), self.__combobox_changed__) self.timerRepaint = QTimer() QObject.connect(self.checkBox, SIGNAL("clicked()"), self.__activate_timer__) QObject.connect(self.timerRepaint, SIGNAL("timeout()"), self.__on_timer__) f = open(filename, "a") f.write("End of setup of gui.\n") f.close() def __combobox_changed__(self): self._change = True def __activate_timer__(self): self.doubleSpinBox.setEnabled(self.checkBox.isChecked()) if self.checkBox.isChecked(): self.timerRepaint.start(self.doubleSpinBox.value() * 1000) self.Render.setEnabled(False) if _progress == 0: self.__repaint__() else: self.timerRepaint.stop() self.Render.setEnabled(True) def __get_net_size__(self): global f f = open(filename, "a") f.write("Geting net size...\n") f.close() if not os.path.exists(Paths["Screenshot"]): Visum.Graphic.Screenshot(Paths["Screenshot"]) size = Image.open(Paths["Screenshot"]).size f = open(filename, "a") f.write("Read net size:" + str(size) + ".\n") f.close() return size def __on_timer__(self): global _paramGlobal self._flag = False Visum.Graphic.MaximizeNetWindow() param = _paramGlobal _paramGlobal = Visum.Graphic.GetWindow() shift = abs((param[0] - _paramGlobal[0]) / (param[2] - param[0])) zoom = abs((param[2] - param[0]) / (_paramGlobal[2] - _paramGlobal[0]) - 1) print _windowSizeGlobal if _windowSizeGlobal[2:4] != Visum.Graphic.GetMainWindowPos()[2:4]: self.__get_net_size__() self._flag = True elif shift > 0.4 or zoom > 0.2: self._flag = True if self._flag or self._change and _progress == 0: self.__repaint__() self._change = False def __update_slider_label__(self, value): self.label2.setText("Quality: " + str(value)) self._change = True def __update_progress_bar__(self): if _progress != 0: self.progressBar.setVisible(True) self.progressBar.setValue(_progress) else: self.progressBar.setVisible(False) def __rebuild_paths__(self): global Paths Paths["Images"] = [] list = os.listdir(Paths["ScriptFolder"]) imageList = [] for i in range(len(list)): if list[i][-3:] == "png": imageList.append(list[i]) for i in range(len(imageList)): try: Visum.Graphic.Backgrounds.ItemByKey(imageList[i]) Paths["Images"].append(Paths["ScriptFolder"] + "\\" + imageList[i]) except: pass def __repaint__(self): global _progress, f if len(Visum.Graphic.Backgrounds.GetAll) != len(Paths["Images"]): self.__rebuild_paths__() if _progress == 0: f = open(filename, "a") f.write("Doing repaint...\n") f.close() QWebSettings.clearMemoryCaches() timer = QTimer() timer.start(100) QObject.connect(timer, SIGNAL("timeout()"), self.__update_progress_bar__) Main(self.comboBox.currentIndex(), Visum.Graphic.GetWindow(), self.slider.value() / 4.0, self.__get_net_size__()) Visum.Graphic.Draw() self.__update_progress_bar__() _progress = 0 QTimer().singleShot(1500, self.__update_progress_bar__) f = open(filename, "a") f.write("End of doing repaint.\n") f.close()