Пример #1
0
class Startup(QDialog):
    def __init__(self, parent=None):
        QDialog.__init__(self)
        self.setFixedSize(500, 600)
        self.setWindowTitle("RecoveryContable")
        self.setStyleSheet(backgroundStartup)

        self.initModel()

    def initModel(self):

        self.buttonInit = QPushButton(self)
        self.buttonInit.setGeometry(QRect(0, 0, 200, 60))
        self.buttonInit.move(150, 450)
        self.buttonInit.setText("INICIO")
        self.buttonInit.setStyleSheet(buttonStartup)
        self.buttonInit.setFont(QtGui.QFont("Roboto", 17, QtGui.QFont.Bold))
        self.shadow = QGraphicsDropShadowEffect()
        self.shadow.setBlurRadius(22)
        self.buttonInit.setGraphicsEffect(self.shadow)
        self.buttonInit.clicked.connect(self.openMain)

    def openMain(self):
        self.interfaceMain = mainWindow()
        self.interfaceMain.show()
        self.close()
Пример #2
0
    def uiDefinitions(self):
        # Remove Title Bar
        self.setWindowFlag(QtCore.Qt.FramelessWindowHint)
        self.setAttribute(QtCore.Qt.WA_TranslucentBackground)

        # Set Drop Shadow Window
        self.shadow = QGraphicsDropShadowEffect(self)
        self.shadow.setBlurRadius(20)
        self.shadow.setXOffset(0)
        self.shadow.setYOffset(0)
        self.shadow.setColor(QColor(0, 0, 0, 100))

        # Apply Drop Shadow Frame
        self.ui.frame_background.setGraphicsEffect(self.shadow)

        # Maximize / Restore
        self.ui.btn_maximize.clicked.connect(lambda: self.maximize_restore())

        # Minimize
        self.ui.btn_minimize.clicked.connect(lambda: self.showMinimized())

        # Close
        self.ui.btn_close.clicked.connect(lambda: self.close())

        # Create size grip to resize window
        self.sizegrip = QSizeGrip(self.ui.frame_grip)
        self.sizegrip.setStyleSheet(
            "QSizeGrip { width: 10px; height: 10px; margin: 5px } QSizeGrip:hover { background-color: rgb(50, 42, 94) }"
        )
Пример #3
0
    def __init__(self, m=TMsgEntry(),no=-1,):
        super(TMsgLabel, self).__init__()
        self.no = no #在LabelList中的序号
        self.on_events = False  #正在响应事件
        self.MsgEntry=m

        left, top = self.MsgEntry.left, self.MsgEntry.top + (self.no * settings["labelFontSize"] * 6)
        self.move(left,top)
        self.setScaledContents = True  #自动拉伸
        self.setWordWrap = True
        self.setFont(QFont(font_path[settings["lang"]]))
        self.setTextFormat(Qt.MarkdownText)
        self.setText(font_path[settings["lang"]])
        if self.MsgEntry.style_str != "":
            #将html标签形式的font包装成text
            l= re.findall(r"<([a-zA-Z0-9\-_]*)([a-zA-Z0-9\-_#= ]*)>",self.MsgEntry.style_str)
            self.setText(self.MsgEntry.style_str + self.MsgEntry.text + ''.join(["</" + i[0] + ">" for i in l]))
        # 添加阴影
        self.effect_shadow = QGraphicsDropShadowEffect(self)
        text_color = re.search(r"color=(#[0-9A-F]*)", self.text())
        text_color = RGB2Hex((8,8,160,127)) if text_color == None else text_color.group(1)
        self.effect_shadow.setOffset(0,0)  # 偏移
        self.effect_shadow.setColor(QColor(text_color))  # 阴影颜色
        self.effect_shadow.setBlurRadius(10)  # 阴影半径
        self.setGraphicsEffect(self.effect_shadow)  # 将设置套用到widget窗口中
Пример #4
0
    def __init__(self):
        QMainWindow.__init__(self)
        self.ui = Ui_SplashScreen()
        self.ui.setupUi(self)

        self.setWindowFlags(QtCore.Qt.FramelessWindowHint)
        self.setAttribute(QtCore.Qt.WA_TranslucentBackground)
        self.shadow = QGraphicsDropShadowEffect(self)
        self.shadow.setBlurRadius(20)
        self.shadow.setXOffset(0)
        self.shadow.setYOffset(0)
        self.shadow.setColor(QColor(0, 0, 0, 60))
        self.ui.dropShadowFrame.setGraphicsEffect(self.shadow)
        self.timer = QtCore.QTimer()
        self.timer.timeout.connect(self.progress)
        self.timer.start(35)

        self.ui.label_description.setText(
            "<strong>Welcome</strong> to  my Application")

        QtCore.QTimer.singleShot(
            1500, lambda: self.ui.label_description.setText(
                "<strong>Loading</strong> Database"))
        QtCore.QTimer.singleShot(
            3000, lambda: self.ui.label_description.setText(
                "<strong>Loading</strong> User Interface"))
        QtCore.QTimer.singleShot

        self.show()
Пример #5
0
 def __init__(self, workspace_name, is_owner, creator, files, shared_with=None, *args, **kwargs):
     super().__init__(*args, **kwargs)
     self.setupUi(self)
     self.is_owner = is_owner
     self.creator = creator
     self.shared_with = shared_with or []
     self.name = workspace_name
     if not len(files):
         self.label_empty.show()
         self.widget_files.hide()
     else:
         for i, (f, is_dir) in enumerate(files.items(), 1):
             if i > 4:
                 break
             label = getattr(self, "line_edit_file{}".format(i))
             label.clicked.connect(self.open_clicked_file)
             label.setText(f)
             label.setIsDir(is_dir)
             label.setCursorPosition(0)
         self.label_empty.hide()
     effect = QGraphicsDropShadowEffect(self)
     effect.setColor(QColor(164, 164, 164))
     effect.setBlurRadius(10)
     effect.setXOffset(4)
     effect.setYOffset(4)
     self.setGraphicsEffect(effect)
     self.button_details.clicked.connect(self.button_details_clicked)
     self.button_share.clicked.connect(self.button_share_clicked)
     self.button_delete.clicked.connect(self.button_delete_clicked)
     self.button_rename.clicked.connect(self.button_rename_clicked)
     if not self.is_owner:
         self.label_owner.hide()
     if not self.shared_with:
         self.label_shared.hide()
Пример #6
0
def shadow() -> QGraphicsDropShadowEffect:
    s = QGraphicsDropShadowEffect()
    s.setBlurRadius(10)
    s.setXOffset(2)
    s.setYOffset(2)
    s.setColor(QColor(200, 200, 200))
    return s
Пример #7
0
class SubToolTip(QWidget):
    """ 自定义圆角提示气泡子窗口 """

    def __init__(self,text='',parent=None):
        super().__init__(parent)

        # 换行标志位
        self.isWordWrap = False
        
        # 实例化小部件
        self.timer = QTimer(self)
        self.label = QLabel(text, self)
        self.all_h_layout = QHBoxLayout()
        self.dropShadowEffect = QGraphicsDropShadowEffect(self)
        # 初始化小部件
        self.initLayout()
        self.initWidget()
        self.setText(text)

    def initWidget(self):
        """ 初始化小部件 """
        self.setMaximumSize(400,60)
        self.setAttribute(Qt.WA_TranslucentBackground)
        self.label.setStyleSheet(""" QLabel{font:15px "Microsoft YaHei";
                                            background:transparent} """)
        # 设置阴影
        self.dropShadowEffect.setBlurRadius(40)
        self.dropShadowEffect.setOffset(0,5)
        self.setGraphicsEffect(self.dropShadowEffect)

    def initLayout(self):
        """ 初始化布局 """
        self.all_h_layout.addWidget(self.label, 0, Qt.AlignCenter)
        self.all_h_layout.setContentsMargins(9, 9, 9, 9)
        # 根据布局的内小部件大小调整窗体大小
        self.all_h_layout.setSizeConstraint(QHBoxLayout.SetFixedSize)
        self.setLayout(self.all_h_layout)

    def setText(self,text:str):
        """ 设置提示文字 """
        newText, self.isWordWrap = autoWrap(text, 48)
        self.label.setText(newText)
        # 如果有换行发生就调整宽度
        if self.isWordWrap:
            self.setMaximumHeight(60)
        else:
            self.setMaximumHeight(38)
        
    def paintEvent(self, e):
        """ 绘制圆角背景 """
        pen = QPen(QColor(204, 204, 204))
        painter = QPainter(self)
        # 反锯齿
        painter.setRenderHint(QPainter.Antialiasing)
        # 绘制边框
        painter.setPen(pen)
        # 绘制背景
        brush = QBrush(QColor(242, 242, 242))
        painter.setBrush(brush)
        painter.drawRoundedRect(self.rect(), 7, 7)
Пример #8
0
 def on_btn_stickie_clicked(self):
     if self.ui.btn_stickie.isChecked():
         self.ui.btn_stickie.setStyleSheet(
             'background-color: qlineargradient(x1:0, y1:0, x2:1, y2:1,'
             'stop:0 #489DCF, stop:1 #62D5FF);')
         self.ui.btn_stickie.setGraphicsEffect(None)
         self.ui.btn_stickieAfter.setGraphicsEffect(None)
         self.setWindowFlags(Qt.WindowStaysOnTopHint)
         self.show()
         print(self.windowFlags())
     else:
         self.ui.btn_stickie.setStyleSheet(
             '''background-color: qlineargradient(x1:0, y1:0, x2:1, y2:1,
                                           stop:0 #5BC6FF, stop:1 #4DA7DB);
                                           QPushButton:hover {
                                           background: #55b9f3;
                                           }''')
         self.ui.btn_stickie.setGraphicsEffect(
             QGraphicsDropShadowEffect(blurRadius=5,
                                       offset=QPointF(3, 3),
                                       color=QColor('#489DCF')))
         self.ui.btn_stickieAfter.setGraphicsEffect(
             QGraphicsDropShadowEffect(blurRadius=5,
                                       offset=QPointF(-3, -3),
                                       color=QColor('#62D5FF')))
         self.setWindowFlags(self.windowFlags() & ~Qt.WindowStaysOnTopHint)
         self.show()
Пример #9
0
    def start(self):
        self.clockface = QLabel(self.block)
        self.clockface.setObjectName("clockface")
        self.clockrect = self.block.frameRect()
        self.clockface.setGeometry(self.clockrect)
        dcolor = QColor(self.config.color).darker(0).name()
        lcolor = QColor(self.config.color).lighter(120).name()
        extraAttributes = ''
        if 'extra-font-attributes' in self.config:
            extraAttributes = self.config['extra-font-attributes']
        self.clockface.setStyleSheet(
            "#clockface { background-color: transparent; " +
            " font-family:sans-serif;" + " font-weight: light; color: " +
            lcolor + "; background-color: transparent; font-size: " +
            self.fontCalc(0.3) + extraAttributes + "}")
        logging.info(self.clockface.styleSheet())
        self.clockface.setAlignment(Qt.AlignCenter)
        self.clockface.setGeometry(self.clockrect)
        self.glow = QGraphicsDropShadowEffect()
        self.glow.setOffset(0)
        self.glow.setBlurRadius(50)
        self.glow.setColor(QColor(dcolor))
        self.clockface.setGraphicsEffect(self.glow)
        self.lasttimestr = ""

        self.ctimer = QTimer()
        self.ctimer.timeout.connect(self.tick)
        self.ctimer.start(1000)
Пример #10
0
def dropShadowUp():
    effect = QGraphicsDropShadowEffect()
    effect.setBlurRadius(10)
    effect.setXOffset(0)
    effect.setYOffset(-3)
    effect.setColor(QColor(0, 0, 0, 25))
    return effect
Пример #11
0
    def __init__(self, parent=None):

        # Se invoca el constructor padre.
        super(PantallaInicio_Aplicacion, self).__init__(parent)
        # Se crea una instancia de nuestra ventana diseñada.
        self.uiVentana = ven_Inicio()
        # Se llama al método "setupUi" que esta en la clase "ven_Inicio" del archivo "inicioUi.py".
        self.uiVentana.setupUi(self)
        # Se indica el tamaño de la ventana para que no se pueda modificar su tamaño.
        self.setFixedSize(837, 601)
        # Se elimina la barra de titulo y la botonera.
        self.setWindowFlag(QtCore.Qt.FramelessWindowHint)
        # Se elimina el fondo de la ventana para que sólo muestre la imagen.
        self.setAttribute(QtCore.Qt.WA_TranslucentBackground)
        # Se crea un efecto de sombreado para la ventana.
        self.shadow = QGraphicsDropShadowEffect(self)
        self.shadow.setBlurRadius(20)
        self.shadow.setXOffset(0)
        self.shadow.setYOffset(0)
        self.shadow.setColor(QColor(98, 97, 98, 150))
        # Se aplica el efecto sombreado al QWidget centralwidget.
        self.uiVentana.centralwidget.setGraphicsEffect(self.shadow)

        # Se crea una variable global para almacenar el valor de la barra de progreso.
        self.w_valor_barra_progreso = 0
        # Se crea un objeto de tipo Timer para ejecutar la barra de desplazamiento.
        self.w_timer = QtCore.QTimer()
        # Se indica el método que se lanza cuando se ejecute el timer.
        self.w_timer.timeout.connect(self.pro_barra_progreso)
        # Se indica el intervalo del timer que serán 100 milisegundos para que vaya avanzando la barra de progreso.
        self.w_timer.start(100)

        # Se muestra la pantalla.
        self.show()
Пример #12
0
def dropShadow():
    effect = QGraphicsDropShadowEffect()
    effect.setBlurRadius(15)
    effect.setXOffset(0)
    effect.setYOffset(3)
    effect.setColor(QColor(0, 0, 0, 30))
    return effect
Пример #13
0
 def __init__(self, user_name, is_current_user, is_admin, certified_on,
              is_revoked, current_user_is_admin):
     super().__init__()
     self.setupUi(self)
     self.current_user_is_admin = current_user_is_admin
     self.is_admin = is_admin
     self.is_revoked = is_revoked
     self._is_revoked = is_revoked
     self.certified_on = certified_on
     self.is_current_user = is_current_user
     self.user_name = user_name
     self.label_username.setText(user_name)
     self.user_icon.apply_style()
     self.setContextMenuPolicy(Qt.CustomContextMenu)
     self.customContextMenuRequested.connect(self.show_context_menu)
     self.label_created_on.setText(
         format_datetime(self.certified_on, full=True))
     self.label_role.setText(
         _("TEXT_USER_ROLE_ADMIN") if self.
         is_admin else _("TEXT_USER_ROLE_CONTRIBUTOR"))
     if self.is_current_user:
         self.label_user_is_current.setText("({})".format(
             _("TEXT_USER_IS_CURRENT")))
     effect = QGraphicsDropShadowEffect(self)
     effect.setColor(QColor(0x99, 0x99, 0x99))
     effect.setBlurRadius(10)
     effect.setXOffset(2)
     effect.setYOffset(2)
     self.setGraphicsEffect(effect)
Пример #14
0
 def _init_bloom_effect(self, radius=32):
     """Create a bloom effect"""
     self.bloom = QGraphicsDropShadowEffect()
     self.bloom.setBlurRadius(radius)
     self.bloom.setXOffset(0)
     self.bloom.setYOffset(0)
     self.setGraphicsEffect(self.bloom)
Пример #15
0
class VolumeSlider(QWidget):
    """ 音量滑动条 """

    # 静音状态改变信号
    muteStateChanged = pyqtSignal(bool)
    volumeLevelChanged = pyqtSignal(int)

    def __init__(self, parent=None):
        super().__init__(parent)
        self.volumeButton = VolumeButton(self)
        self.volumeSlider = Slider(Qt.Horizontal, self)
        # 初始化
        self.__initWidget()

    def __initWidget(self):
        """ 初始化小部件 """
        self.setFixedSize(345, 78)
        self.volumeButton.move(25, 15)
        self.volumeSlider.move(108, 25)
        self.volumeSlider.setSingleStep(1)
        self.volumeSlider.setRange(0, 100)
        self.setWindowFlags(
            Qt.FramelessWindowHint | Qt.Popup | Qt.NoDropShadowWindowHint
        )
        self.setAttribute(Qt.WA_TranslucentBackground)
        self.__setQss()
        # self.__setShadowEffect()
        # 信号连接到槽
        self.volumeButton.muteStateChanged.connect(
            lambda muteState: self.muteStateChanged.emit(muteState)
        )
        self.volumeButton.volumeLevelChanged.connect(
            lambda volumeLevel: self.volumeLevelChanged.emit(volumeLevel)
        )
        self.volumeSlider.valueChanged.connect(self.volumeButton.setVolumeLevel)

    def __setQss(self):
        """ 设置层叠样式 """
        with open(r"app\resource\css\volume_slider.qss", encoding="utf-8") as f:
            self.setStyleSheet(f.read())

    def __setShadowEffect(self):
        """ 添加阴影 """
        self.shadowEffect = QGraphicsDropShadowEffect(self)
        self.shadowEffect.setBlurRadius(40)
        self.shadowEffect.setOffset(0, 2)
        self.setGraphicsEffect(self.shadowEffect)

    def paintEvent(self, e):
        """ 绘制背景 """
        painter = QPainter(self)
        painter.setRenderHints(QPainter.Antialiasing | QPainter.SmoothPixmapTransform)
        painter.setPen(QPen(QColor(190, 190, 190, 150)))
        painter.setBrush(QBrush(QColor(227, 227, 227)))
        painter.drawRoundedRect(self.rect(), 8, 8)

    def setValue(self, value):
        """ 设置音量 """
        self.volumeSlider.setValue(value)
        self.volumeButton.setVolumeLevel(value)
Пример #16
0
    def __init__(self):
        QWidget.__init__(self)
        threading.Thread.__init__(self)

        self.setFixedSize(480, 500)
        self.setStyleSheet("background-color:#000000")
        self.label_animation = QLabel(self)

        self.movie = QMovie('jarvis.gif')
        self.label_animation.setMovie(self.movie)

        self.time = QLabel(self)
        self.time.setAlignment(Qt.AlignCenter)
        self.time.resize(350, 250)
        self.time.setStyleSheet(
            "color: #00BFFF;background-color:transparent;font:80px;font-weight: bold"
        )
        self.time.move(70, 280)

        self.shadow_effect = QGraphicsDropShadowEffect()
        self.shadow_effect.setColor(QColor("#ffffff"))
        self.shadow_effect.setOffset(1, 1)

        self.time.setGraphicsEffect(self.shadow_effect)

        self.timer = QTimer(self)
        self.timer.timeout.connect(self.show_time)
        self.timer.start(1000)

        self.movie.start()
        self.show()

        self.show_time()
Пример #17
0
    def __init__(self, parent=None, line=None, **kwargs):
        Annotation.__init__(self, parent, **kwargs)
        self.setFlag(QGraphicsItem.ItemIsMovable)
        self.setFlag(QGraphicsItem.ItemIsSelectable)

        self.setFocusPolicy(Qt.ClickFocus)

        if line is None:
            line = QLineF(0, 0, 20, 0)

        self.__line = line
        self.__color = QColor(Qt.red)
        self.__arrowItem = ArrowItem(self)
        self.__arrowItem.setLine(line)
        self.__arrowItem.setBrush(self.__color)
        self.__arrowItem.setPen(QPen(Qt.NoPen))
        self.__arrowItem.setArrowStyle(ArrowItem.Concave)
        self.__arrowItem.setLineWidth(5)

        self.__shadow = QGraphicsDropShadowEffect(
            blurRadius=5,
            offset=QPointF(1.0, 2.0),
        )

        self.__arrowItem.setGraphicsEffect(self.__shadow)
        self.__shadow.setEnabled(True)

        self.__autoAdjustGeometry = True
    def uiDefinitions(self):

        # REMOVE TITLE BAR
        self.setWindowFlag(QtCore.Qt.FramelessWindowHint)
        self.setAttribute(QtCore.Qt.WA_TranslucentBackground)

        # SET DROPSHADOW WINDOW
        self.shadow = QGraphicsDropShadowEffect(self)
        self.shadow.setBlurRadius(20)
        self.shadow.setXOffset(0)
        self.shadow.setYOffset(0)
        self.shadow.setColor(QColor(0, 0, 0, 100))

        # APPLY DROPSHADOW TO FRAME
        self.ui.drop_shadow_frame.setGraphicsEffect(self.shadow)

        # MAXIMIZE / RESTORE
        self.ui.btn_maximize.clicked.connect(
            lambda: UIFunctions.maximize_restore(self))

        # MINIMIZE
        self.ui.btn_minimize.clicked.connect(lambda: self.showMinimized())

        # CLOSE
        self.ui.btn_close.clicked.connect(lambda: self.close())
Пример #19
0
 def __init__(self, *args, **kwargs):
     super().__init__(*args, **kwargs)
     effect = QGraphicsDropShadowEffect(self)
     effect.setColor(QColor(164, 164, 164))
     effect.setBlurRadius(4)
     effect.setXOffset(2)
     effect.setYOffset(2)
     self.setGraphicsEffect(effect)
Пример #20
0
    def __init__(self, parent):
        QGraphicsDropShadowEffect.__init__(self, parent)

        self.m_fakeParent = None

        self.setBlurRadius(20)
        self.setColor(canvas.theme.box_shadow)
        self.setOffset(0, 0)
Пример #21
0
 def _frame(self):
     # 边框
     self.setWindowFlags(Qt.FramelessWindowHint)
     self.setAttribute(Qt.WA_TranslucentBackground, True)
     # 阴影
     effect = QGraphicsDropShadowEffect(blurRadius=12, xOffset=0, yOffset=0)
     effect.setColor(QColor(25, 25, 25, 170))
     self.mainFrame.setGraphicsEffect(effect)
Пример #22
0
    def __init__(self):
        super().__init__()
        self.setWindowTitle("Login")
        self.setGeometry(350, 45, 771, 681)

        vLayout = QVBoxLayout()
        self.vWidgetLayout = QVBoxLayout()

        container_widget = QWidget()

        shadow = QGraphicsDropShadowEffect()
        shadow.setBlurRadius(3)
        shadow.setColor(QColor("#010101"))
        shadow.setXOffset(3)
        shadow.setYOffset(3)

        username_label = QLabel("Username")
        username_label.setStyleSheet("border: none; font-size: 15px;")

        username_input = QLineEdit()
        username_input.setStyleSheet(
            "background: none; border-top: none; border-left: none; border-right: none; border-bottom: 1px solid #010101; font-size: 14px;"
        )
        username_input.setFixedWidth(200)

        password_label = QLabel("Password")
        password_label.setStyleSheet("border: none; font-size: 15px;")

        password_input = QLineEdit()
        password_input.setEchoMode(QLineEdit.Password)
        password_input.setStyleSheet(
            "border-top: none; border-left: none; border-right: none; border-bottom: 1px solid #010101; font-size: 14px;"
        )
        password_input.setFixedWidth(200)

        self.login_btn = QPushButton("Login")
        self.login_btn.setStyleSheet(
            "QPushButton { border-radius: 3px; font-size: 12px; }"
            "QPushButton:pressed { background: black; color: white; }")
        self.login_btn.setFixedWidth(50)
        self.login_btn.setFixedHeight(25)

        self._addWidgets(username_label, username_input, password_label,
                         password_input, self.login_btn)

        container_widget.setStyleSheet(
            "background: white; border: 0.5px solid #010101; border-radius: 10px; font-family: Lucida Console, Monaco, monospace; font-weight: bold;"
        )
        container_widget.setLayout(self.vWidgetLayout)
        container_widget.setFixedHeight(200)
        container_widget.setFixedWidth(300)
        container_widget.setGraphicsEffect(shadow)
        self.vWidgetLayout.setSpacing(20)
        self.vWidgetLayout.setAlignment(Qt.AlignCenter)

        vLayout.addWidget(container_widget)
        vLayout.setAlignment(Qt.AlignCenter)
        self.setLayout(vLayout)
Пример #23
0
    def __init__(self, core_config, *args, **kwargs):
        super().__init__(*args, **kwargs)
        self.setupUi(self)

        self.menu = MenuWidget(parent=self)
        self.widget_menu.layout().addWidget(self.menu)

        self.mount_widget = MountWidget(parent=self)
        self.mount_widget.reset_taskbar.connect(self.reset_taskbar)
        self.widget_central.layout().insertWidget(0, self.mount_widget)
        self.users_widget = UsersWidget(parent=self)
        self.widget_central.layout().insertWidget(0, self.users_widget)
        self.devices_widget = DevicesWidget(parent=self)
        self.widget_central.layout().insertWidget(0, self.devices_widget)
        self.settings_widget = SettingsWidget(core_config=core_config,
                                              parent=self)
        self.widget_central.layout().insertWidget(0, self.settings_widget)
        self.notification_center = NotificationCenterWidget(parent=self)
        self.button_notif = TaskbarButton(
            icon_path=":/icons/images/icons/menu_settings.png")

        self.widget_notif.layout().addWidget(self.notification_center)
        self.notification_center.hide()

        effect = QGraphicsDropShadowEffect(self)
        effect.setColor(QColor(100, 100, 100))
        effect.setBlurRadius(4)
        effect.setXOffset(-2)
        effect.setYOffset(2)
        self.widget_notif.setGraphicsEffect(effect)

        self.menu.button_files.clicked.connect(self.show_mount_widget)
        self.menu.button_users.clicked.connect(self.show_users_widget)
        self.menu.button_settings.clicked.connect(self.show_settings_widget)
        self.menu.button_devices.clicked.connect(self.show_devices_widget)
        self.menu.button_logout.clicked.connect(self.logout_requested.emit)
        self.button_notif.clicked.connect(self.show_notification_center)
        self.connection_state_changed.connect(
            self._on_connection_state_changed)
        self.notification_center.close_requested.connect(
            self.close_notification_center)

        # self.notification_center.add_notification(
        #     "ERROR", "An error message to test how it looks like."
        # )
        # self.notification_center.add_notification(
        #     "WARNING", "Another message but this time its a warning."
        # )
        # self.notification_center.add_notification(
        #     "INFO", "An information message, because we gotta test them all."
        # )
        # self.notification_center.add_notification(
        #     "ERROR",
        #     "And another error message, but this one will be a little bit longer just "
        #     "to see if the GUI can handle it.",
        # )

        self.reset()
Пример #24
0
    def __init__(self, parent=None):
        super(Child_Playbutton, self).__init__(parent)
        self.resize(1400, 600)
        self.Option = parent.getOption()
        self.shadow = QGraphicsDropShadowEffect()
        self.shadow.setBlurRadius(200)
        self.shadow.setColor(QColor(255, 255, 255))
        self.shadow.setXOffset(0)
        self.shadow.setYOffset(0)

        self.setWindowFlags(Qt.FramelessWindowHint | Qt.BypassWindowManagerHint
                            | Qt.Tool | Qt.WindowStaysOnTopHint)
        self.setAttribute(Qt.WA_TranslucentBackground)
        self.wdt = QWidget()
        #self.wdt.setObjectName("tipWaitingWindow_back")
        #self.wdt.setStyleSheet("#tipWaitingWindow_back{background:rgba(0,0,0,0.2)}")
        self.left_widget = QtWidgets.QWidget()  # 创建左侧部件
        self.left_widget.setObjectName('left_widget')
        self.left_layout = QtWidgets.QGridLayout()  # 创建左侧部件的网格布局层
        self.left_widget.setLayout(self.left_layout)  # 设置左侧部件布局为网格

        self.layout = QGridLayout(self)
        self.layout.addWidget(self.wdt, 8, 6, 16, 5)
        self.layout.addWidget(self.left_widget, 0, 6, 16, 5)

        self.layout.setSpacing(100)
        main_layout = QGridLayout()

        self.wdt.setLayout(main_layout)
        # 在main_layout上添加widget就行

        self.Play_button = QPushButton('Play')
        self.Play_button.setFixedSize(120, 70)
        self.Play_button.setStyleSheet(''' 
        
            QPushButton {text-align : center;  
            background-color :rgba(0,0,0,0); 
            border-color: rgba(0,0,0,0); border-width: 2px; border-radius: 10px; 
            height : 60px; border-style: outset; font: Bold 30pt "Pristina"; color: rgb(157,157,157);}
        QPushButton:hover{ font: Bold 30pt "Pristina"; 
        color: rgb(255,255,255);
            border-color: rgb(85, 123, 182);
            border-width: 2px;
            border-radius: 10px; padding: 0px;
                     height : 30px;
                     border-style: outset; background: rgba(0,0,0,0.2)}
         QPushButton:press{ font: Bold 30pt "Pristina"; color: rgb(255,255,255);
            border-color: rgb(85, 123, 182);border-width: 2px;
            border-radius: 10px; padding: 6px;
                     height : 14px;
                     border-style: outset; background: rgba(0,0,0,0.4)}            
                     
                     
                     ''')
        self.Play_button.setGraphicsEffect(self.shadow)
        main_layout.addWidget(self.Play_button, 8, 10, 6, 5)
        self.Play_button.clicked.connect(self.play)
Пример #25
0
    def __init__(self, workspace_fs):
        # Initialize UI
        super().__init__()
        self.setupUi(self)

        # Read-only attributes
        self.workspace_fs = workspace_fs

        # Property inner state
        self._reencrypting = None
        self._reencryption_needs = None

        # Static initialization
        self.switch_button = SwitchButton()
        self.widget_actions.layout().insertWidget(0, self.switch_button)
        self.switch_button.clicked.connect(self._on_switch_clicked)
        self.setCursor(QCursor(Qt.PointingHandCursor))
        self.setContextMenuPolicy(Qt.CustomContextMenu)
        self.customContextMenuRequested.connect(self.show_context_menu)

        if not self.timestamped:
            self.button_delete.hide()
            self.button_reencrypt.hide()
            self.widget_empty.layout().addWidget(EmptyWorkspaceWidget())
        else:
            self.switch_button.setChecked(True)
            self.button_reencrypt.hide()
            self.button_remount_ts.hide()
            self.button_share.hide()
            self.button_rename.hide()
            self.label_shared.hide()
            self.label_owner.hide()
            self.switch_button.hide()
            widget_tmp = TemporaryWorkspaceWidget()
            self.widget_empty.layout().addWidget(widget_tmp)

        effect = QGraphicsDropShadowEffect(self)
        effect.setColor(QColor(0x99, 0x99, 0x99))
        effect.setBlurRadius(10)
        effect.setXOffset(2)
        effect.setYOffset(2)
        self.setGraphicsEffect(effect)
        self.widget_reencryption.hide()
        self.button_share.clicked.connect(self.button_share_clicked)
        self.button_share.apply_style()
        self.button_reencrypt.clicked.connect(self.button_reencrypt_clicked)
        self.button_reencrypt.apply_style()
        self.button_delete.clicked.connect(self.button_delete_clicked)
        self.button_delete.apply_style()
        self.button_rename.clicked.connect(self.button_rename_clicked)
        self.button_rename.apply_style()
        self.button_remount_ts.clicked.connect(self.button_remount_ts_clicked)
        self.button_remount_ts.apply_style()
        self.button_open.clicked.connect(self.button_open_workspace_clicked)
        self.button_open.apply_style()
        self.label_owner.apply_style()
        self.label_shared.apply_style()
Пример #26
0
    def __init__(self, core, jobs_ctx, event_bus, **kwargs):
        super().__init__(**kwargs)
        self.setupUi(self)

        self.jobs_ctx = jobs_ctx
        self.core = core
        self.event_bus = event_bus

        self.menu = MenuWidget(parent=self)
        self.widget_menu.layout().addWidget(self.menu)

        for e in self.NOTIFICATION_EVENTS:
            self.event_bus.connect(e, self.handle_event)

        self.label_mountpoint.setText(str(self.core.config.mountpoint_base_dir))
        self.label_mountpoint.clicked.connect(self.open_mountpoint)
        self.menu.organization = self.core.device.organization_addr.organization_id
        self.menu.username = self.core.device.user_id
        self.menu.device = self.core.device.device_name
        self.menu.organization_url = str(self.core.device.organization_addr)

        self.new_notification.connect(self.on_new_notification)
        self.menu.files_clicked.connect(self.show_mount_widget)
        self.menu.users_clicked.connect(self.show_users_widget)
        self.menu.devices_clicked.connect(self.show_devices_widget)
        self.menu.logout_clicked.connect(self.logout_requested.emit)
        self.connection_state_changed.connect(self._on_connection_state_changed)

        self.widget_title2.hide()
        self.widget_title3.hide()
        self.title2_icon.apply_style()
        self.title3_icon.apply_style()

        self.icon_mountpoint.apply_style()

        effect = QGraphicsDropShadowEffect(self)
        effect.setColor(QColor(100, 100, 100))
        effect.setBlurRadius(4)
        effect.setXOffset(-2)
        effect.setYOffset(2)
        self.widget_notif.setGraphicsEffect(effect)

        self.mount_widget = MountWidget(self.core, self.jobs_ctx, self.event_bus, parent=self)
        self.widget_central.layout().insertWidget(0, self.mount_widget)
        self.mount_widget.folder_changed.connect(self._on_folder_changed)

        self.users_widget = UsersWidget(self.core, self.jobs_ctx, self.event_bus, parent=self)
        self.widget_central.layout().insertWidget(0, self.users_widget)

        self.devices_widget = DevicesWidget(self.core, self.jobs_ctx, self.event_bus, parent=self)
        self.widget_central.layout().insertWidget(0, self.devices_widget)

        self._on_connection_state_changed(
            self.core.backend_conn.status, self.core.backend_conn.status_exc
        )
        self.show_mount_widget()
Пример #27
0
    def __init__(self, lightTheme=False, useAlpha=False):
        super(ColorPicker, self).__init__()

        self.usingAlpha = useAlpha

        # Call UI Builder function
        if useAlpha:
            if lightTheme: self.ui = Ui_Light_Alpha()
            else: self.ui = Ui_Dark_Alpha()
            self.ui.setupUi(self)
        else:
            if lightTheme: self.ui = Ui_Light()
            else: self.ui = Ui_Dark()
            self.ui.setupUi(self)


        # Make Frameless
        self.setWindowFlags(Qt.FramelessWindowHint)
        self.setAttribute(Qt.WA_TranslucentBackground)
        self.setWindowTitle("Color Picker")

        # Add DropShadow
        self.shadow = QGraphicsDropShadowEffect(self)
        self.shadow.setBlurRadius(17)
        self.shadow.setXOffset(0)
        self.shadow.setYOffset(0)
        self.shadow.setColor(QColor(0, 0, 0, 150))
        self.ui.drop_shadow_frame.setGraphicsEffect(self.shadow)

        # Connect update functions
        self.ui.hue.mouseMoveEvent = self.moveHueSelector
        self.ui.red.textEdited.connect(self.rgbChanged)
        self.ui.green.textEdited.connect(self.rgbChanged)
        self.ui.blue.textEdited.connect(self.rgbChanged)
        self.ui.hex.textEdited.connect(self.hexChanged)
        if self.usingAlpha: self.ui.alpha.textEdited.connect(self.alphaChanged)

        # Connect window dragging functions
        self.ui.title_bar.mouseMoveEvent = self.moveWindow
        self.ui.title_bar.mousePressEvent = self.setDragPos
        self.ui.window_title.mouseMoveEvent = self.moveWindow
        self.ui.window_title.mousePressEvent = self.setDragPos

        # Connect selector moving function
        self.ui.black_overlay.mouseMoveEvent = self.moveSVSelector
        self.ui.black_overlay.mousePressEvent = self.moveSVSelector

        # Connect Ok|Cancel Button Box and X Button
        self.ui.buttonBox.accepted.connect(self.accept)
        self.ui.buttonBox.rejected.connect(self.reject)
        self.ui.exit_btn.clicked.connect(self.reject)

        self.lastcolor = (0,0,0)
        self.color = (0,0,0)
        self.alpha = 100
Пример #28
0
 def __init__(self, parent=None):
     super(MyWindow, self).__init__(parent)
     self.mPos = None
     self.setupUi(self)
     self.shadow = QGraphicsDropShadowEffect()
     self.shadow.setBlurRadius(16)
     self.shadow.setColor(QColor(0, 0, 0, 80))
     self.shadow.setOffset(-1, 3)
     self.pushButtonLogin.setGraphicsEffect(self.shadow)
     self.setAttribute(Qt.WA_TranslucentBackground, True)
     self.setWindowFlags(self.windowFlags() | Qt.FramelessWindowHint)
Пример #29
0
    def initModel(self):

        self.buttonInit = QPushButton(self)
        self.buttonInit.setGeometry(QRect(0, 0, 200, 60))
        self.buttonInit.move(150, 450)
        self.buttonInit.setText("INICIO")
        self.buttonInit.setStyleSheet(buttonStartup)
        self.buttonInit.setFont(QtGui.QFont("Roboto", 17, QtGui.QFont.Bold))
        self.shadow = QGraphicsDropShadowEffect()
        self.shadow.setBlurRadius(22)
        self.buttonInit.setGraphicsEffect(self.shadow)
        self.buttonInit.clicked.connect(self.openMain)
Пример #30
0
 def __init__(self, window: QDialog, parent=None):
     super(VideoViewerContainer, self).__init__(parent)
     self.setWindowFlags(QtCore.Qt.FramelessWindowHint)
     self.setAttribute(QtCore.Qt.WA_TranslucentBackground)
     self.resize(1024, 580)
     layout = QVBoxLayout(self)
     layout.addWidget(window)
     layout.setContentsMargins(0, 0, 6, 6)
     self.shadow = QGraphicsDropShadowEffect(self)
     self.shadow.setBlurRadius(50)
     self.shadow.setColor(QColor(138, 145, 140))
     self.shadow.setOffset(8)
     window.setGraphicsEffect(self.shadow)
Пример #31
0
 def initObj(self):
     self.ellipse.setPos(self.posX, self.posY)
     self.ellipse.setPen(QPen(Qt.transparent, 1))
     self.ellipse.setBrush(QBrush(Qt.darkGreen))
     self.ellipse.setZValue(0)
     self.ellipse.setOpacity(1)
     effect = QGraphicsDropShadowEffect(self.parent)
     effect.setBlurRadius(15)
     effect.setColor(Qt.black)
     self.ellipse.setGraphicsEffect(effect)
     self.stand.append(self.sheet.copy(10, 15, 100, 120))
     self.stand.append(self.sheet.copy(130, 15, 100, 120))
     self.stand.append(self.sheet.copy(250, 15, 100, 120))
     self.pix = self.parent.m_scene.addPixmap(self.stand[0])
     self.pix.setPos(self.posX, self.posY)
     self.pix.setOffset(-20, -56)
     self.pix.setZValue(2)
     self.pix.setScale(1)
Пример #32
0
    def setupScene(self):
        self.m_scene.setSceneRect(-300, -200, 600, 460)

        linearGrad = QLinearGradient(QPointF(-100, -100), QPointF(100, 100))
        linearGrad.setColorAt(0, QColor(255, 255, 255))
        linearGrad.setColorAt(1, QColor(192, 192, 255))
        self.setBackgroundBrush(linearGrad)

        radialGrad = QRadialGradient(30, 30, 30)
        radialGrad.setColorAt(0, Qt.yellow)
        radialGrad.setColorAt(0.2, Qt.yellow)
        radialGrad.setColorAt(1, Qt.transparent)

        pixmap = QPixmap(60, 60)
        pixmap.fill(Qt.transparent)

        painter = QPainter(pixmap)
        painter.setPen(Qt.NoPen)
        painter.setBrush(radialGrad)
        painter.drawEllipse(0, 0, 60, 60)
        painter.end()

        self.m_lightSource = self.m_scene.addPixmap(pixmap)
        self.m_lightSource.setZValue(2)

        for i in range(-2, 3):
            for j in range(-2, 3):
                if (i + j) & 1:
                    item = QGraphicsEllipseItem(0, 0, 50, 50)
                else:
                    item = QGraphicsRectItem(0, 0, 50, 50)

                item.setPen(QPen(Qt.black, 1))
                item.setBrush(QBrush(Qt.white))

                effect = QGraphicsDropShadowEffect(self)
                effect.setBlurRadius(8)
                item.setGraphicsEffect(effect)
                item.setZValue(1)
                item.setPos(i * 80, j * 80)
                self.m_scene.addItem(item)
                self.m_items.append(item)
Пример #33
0
def get_shadow():
    """
    Returns shadow effect.
    """

    shadow = QGraphicsDropShadowEffect()
    shadow.setBlurRadius(10)
    shadow.setXOffset(0)
    shadow.setYOffset(0)
    return shadow
Пример #34
0
    def __init__(self, parent=None):
        QMainWindow.__init__(self, parent)
        self.configOptions, self.checkBoxList, self.configBool = {}, {}, None
        # Check for root privileges
        if geteuid() != 0:
            msg = ("{} is not root. You need to run with root priviliges\n"
                   "Please use kdesudo, gksu or sudo/sux.").format(getuser())
            QMessageBox.critical(self, __doc__ + "- Error", msg)
            sys.exit(1)
        else:
            msg = "This tool is running with root priviliges."
            QMessageBox.warning(self, __doc__ + "- Warning", msg)
        # title, icon and sizes
        self.setWindowTitle(__doc__)
        self.setMinimumSize(400, 400)
        self.setMaximumSize(2048, 2048)
        self.resize(600, 600)
        self.setWindowIcon(QIcon.fromTheme("preferences-system"))
        self.menuBar().addMenu("&File").addAction("Exit", exit)
        QShortcut("Ctrl+q", self, activated=lambda: self.close())
        # main group
        main_group = QGroupBox("Module configuration")
        self.setCentralWidget(main_group)
        self.layout = QVBoxLayout(main_group)
        # scrollarea widgets
        self.scrollArea, self.window = QScrollArea(), QWidget()
        self.layout.addWidget(self.scrollArea)
        self.vbox = QVBoxLayout(self.window)
        # Graphic effect
        glow = QGraphicsDropShadowEffect(self)
        glow.setOffset(0)
        glow.setBlurRadius(99)
        glow.setColor(QColor(99, 255, 255))
        self.scrollArea.setGraphicsEffect(glow)
        glow.setEnabled(True)
        # config loading stuff
        self.findConfig(CONFIG_DIR)
        for eachOption in tuple(self.configOptions.keys()):

            self.readConfig(eachOption, self.configOptions)
            self.subLayout = QHBoxLayout()

            self.checkBoxName = "checkBox_" + eachOption
            checkBoxList = QCheckBox(self.checkBoxName, self)
            self.checkBoxList[self.checkBoxName] = checkBoxList
            checkBoxList.setObjectName(self.checkBoxName)
            checkBoxList.setText("Enable module {}".format(eachOption))

            if self.tooltip is not '':
                checkBoxList.setToolTip(self.tooltip)
            else:
                tooltip = "Configuration settings for {}".format(eachOption)
                checkBoxList.setToolTip(tooltip)

            if self.configBool:
                checkBoxList.setChecked(True)

            self.subLayout.addWidget(checkBoxList)
            self.vbox.addLayout(self.subLayout)
        self.scrollArea.setWidget(self.window)

        # Bottom Buttons Bar
        self.pushButtonSleep = QPushButton("Sleep")
        self.pushButtonSleep.setToolTip("Trigger Suspend to RAM aka Sleep")
        self.pushButtonSleep.clicked.connect(self.sleep)
        self.pushButtonHibernate = QPushButton("Hibernate")
        self.pushButtonHibernate.setToolTip("Trigger Suspend to Disk Hibernate")
        self.pushButtonHibernate.clicked.connect(self.hibernate)
        self.buttonBox = QDialogButtonBox()
        self.buttonBox.setStandardButtons(
            QDialogButtonBox.Ok | QDialogButtonBox.Close |
            QDialogButtonBox.Help)
        self.buttonBox.addButton(self.pushButtonHibernate,
                                 QDialogButtonBox.ActionRole)
        self.buttonBox.addButton(self.pushButtonSleep,
                                 QDialogButtonBox.ActionRole)
        self.layout.addWidget(self.buttonBox)
        self.buttonBox.rejected.connect(exit)
        self.buttonBox.accepted.connect(self.writeConfig)
        self.buttonBox.helpRequested.connect(lambda: open_new_tab(WEBPAGE_URL))
Пример #35
0
 def __init__(self, parent=None):
     """Init class."""
     super(MainWindow, self).__init__()
     self.setWindowTitle(__doc__.strip().capitalize())
     self.statusBar().showMessage(" Choose one App and move the sliders !")
     self.setMinimumSize(480, 240)
     self.setMaximumSize(640, 2048)
     self.setWindowIcon(QIcon.fromTheme("preferences-system"))
     self.center()
     QShortcut("Ctrl+q", self, activated=lambda: self.close())
     self.menuBar().addMenu("&File").addAction("Exit", exit)
     windowMenu = self.menuBar().addMenu("&Window")
     windowMenu.addAction("Minimize", lambda: self.showMinimized())
     windowMenu.addAction("Maximize", lambda: self.showMaximized())
     windowMenu.addAction("Restore", lambda: self.showNormal())
     windowMenu.addAction("FullScreen", lambda: self.showFullScreen())
     windowMenu.addAction("Center", lambda: self.center())
     windowMenu.addAction("Top-Left", lambda: self.move(0, 0))
     windowMenu.addAction("To Mouse", lambda: self.move_to_mouse_position())
     windowMenu.addSeparator()
     windowMenu.addAction(
         "Increase size", lambda:
         self.resize(self.size().width() * 1.4, self.size().height() * 1.4))
     windowMenu.addAction("Decrease size", lambda: self.resize(
         self.size().width() // 1.4, self.size().height() // 1.4))
     windowMenu.addAction("Minimum size", lambda:
                          self.resize(self.minimumSize()))
     windowMenu.addAction("Maximum size", lambda:
                          self.resize(self.maximumSize()))
     windowMenu.addAction("Horizontal Wide", lambda: self.resize(
         self.maximumSize().width(), self.minimumSize().height()))
     windowMenu.addAction("Vertical Tall", lambda: self.resize(
         self.minimumSize().width(), self.maximumSize().height()))
     windowMenu.addSeparator()
     windowMenu.addAction("Disable Resize", lambda:
                          self.setFixedSize(self.size()))
     windowMenu.addAction("Set Interface Font...", lambda:
                          self.setFont(QFontDialog.getFont()[0]))
     helpMenu = self.menuBar().addMenu("&Help")
     helpMenu.addAction("About Qt 5", lambda: QMessageBox.aboutQt(self))
     helpMenu.addAction("About Python 3",
                        lambda: open_new_tab('https://www.python.org'))
     helpMenu.addAction("About" + __doc__,
                        lambda: QMessageBox.about(self, __doc__, HELP))
     helpMenu.addSeparator()
     helpMenu.addAction(
         "Keyboard Shortcut",
         lambda: QMessageBox.information(self, __doc__, "<b>Quit = CTRL+Q"))
     helpMenu.addAction("View Source Code",
                        lambda: call('xdg-open ' + __file__, shell=True))
     helpMenu.addAction("View GitHub Repo", lambda: open_new_tab(__url__))
     helpMenu.addAction("Report Bugs", lambda: open_new_tab(
         'https://github.com/juancarlospaco/pyority/issues?state=open'))
     helpMenu.addAction("Check Updates", lambda: Downloader(self))
     container, child_container = QWidget(), QWidget()
     container_layout = QVBoxLayout(container)
     child_layout = QHBoxLayout(child_container)
     self.setCentralWidget(container)
     # widgets
     group0 = QGroupBox("My Apps")
     group1, group2 = QGroupBox("CPU Priority"), QGroupBox("HDD Priority")
     child_layout.addWidget(group0)
     child_layout.addWidget(group1)
     child_layout.addWidget(group2)
     container_layout.addWidget(child_container)
     # table
     self.table = QTableWidget()
     self.table.setColumnCount(1)
     self.table.verticalHeader().setVisible(True)
     self.table.horizontalHeader().setVisible(False)
     self.table.setShowGrid(False)
     self.table.setAlternatingRowColors(True)
     self.table.setIconSize(QSize(64, 64))
     self.table.setSelectionMode(QAbstractItemView.SingleSelection)
     self.table.setEditTriggers(QAbstractItemView.NoEditTriggers)
     # Graphic effect
     glow = QGraphicsDropShadowEffect(self)
     glow.setOffset(0)
     glow.setBlurRadius(9)
     glow.setColor(QColor(99, 255, 255))
     self.table.setGraphicsEffect(glow)
     glow.setEnabled(True)
     processes = self.generate_process_list()
     self.table.setRowCount(len(processes))
     for index, process in enumerate(processes):
         item = QTableWidgetItem(
             QIcon.fromTheme(process.name().split()[0].split('/')[0]),
             process.name().split()[0].split('/')[0].strip())
         item.setData(Qt.UserRole, process)
         item.setToolTip("{}, {}, {}, {}".format(
             process.name(), process.nice(),
             process.ionice()[1], process.pid))
         self.table.setItem(index, 0, item)
     self.table.clicked.connect(lambda: self.sliderhdd.setDisabled(False))
     self.table.clicked.connect(lambda: self.slidercpu.setDisabled(False))
     self.table.clicked.connect(lambda: self.slidercpu.setValue(
         int(tuple(self.table.currentItem().toolTip().split(","))[1])))
     self.table.clicked.connect(lambda: self.sliderhdd.setValue(
         int(tuple(self.table.currentItem().toolTip().split(","))[2])))
     self.table.resizeColumnsToContents()
     # self.table.resizeRowsToContents()
     # sliders
     self.slidercpu = QSlider()
     self.slidercpu.setRange(0, 19)
     self.slidercpu.setSingleStep(1)
     self.slidercpu.setTickPosition(3)
     self.slidercpu.setDisabled(True)
     self.slidercpu.setInvertedAppearance(True)
     self.slidercpu.setInvertedControls(True)
     self.slidercpu.valueChanged.connect(self.set_cpu_value)
     self.slidercpu.valueChanged.connect(
         lambda: self.slidercpu.setToolTip(str(self.slidercpu.value())))
     # Timer to start
     self.slidercpu_timer = QTimer(self)
     self.slidercpu_timer.setSingleShot(True)
     self.slidercpu_timer.timeout.connect(self.on_slidercpu_timer_timeout)
     QLabel(self.slidercpu).setPixmap(
         QIcon.fromTheme("list-add").pixmap(16))
     QVBoxLayout(group1).addWidget(self.slidercpu)
     self.sliderhdd = QSlider()
     self.sliderhdd.setRange(0, 7)
     self.sliderhdd.setSingleStep(1)
     self.sliderhdd.setTickPosition(3)
     self.sliderhdd.setDisabled(True)
     self.sliderhdd.setInvertedAppearance(True)
     self.sliderhdd.setInvertedControls(True)
     self.sliderhdd.valueChanged.connect(self.set_hdd_value)
     self.sliderhdd.valueChanged.connect(
         lambda: self.sliderhdd.setToolTip(str(self.sliderhdd.value())))
     # Timer to start
     self.sliderhdd_timer = QTimer(self)
     self.sliderhdd_timer.setSingleShot(True)
     self.sliderhdd_timer.timeout.connect(self.on_sliderhdd_timer_timeout)
     QLabel(self.sliderhdd).setPixmap(
         QIcon.fromTheme("list-add").pixmap(16))
     QVBoxLayout(group2).addWidget(self.sliderhdd)
     QVBoxLayout(group0).addWidget(self.table)
class MainWindow(QMainWindow):

    """Voice Changer main window."""

    def __init__(self, parent=None):
        super(MainWindow, self).__init__()
        self.statusBar().showMessage("Move Dial to Deform Microphone Voice !.")
        self.setWindowTitle(__doc__)
        self.setMinimumSize(240, 240)
        self.setMaximumSize(480, 480)
        self.resize(self.minimumSize())
        self.setWindowIcon(QIcon.fromTheme("audio-input-microphone"))
        self.tray = QSystemTrayIcon(self)
        self.center()
        QShortcut("Ctrl+q", self, activated=lambda: self.close())
        self.menuBar().addMenu("&File").addAction("Quit", lambda: exit())
        self.menuBar().addMenu("Sound").addAction(
            "STOP !", lambda: call('killall rec', shell=True))
        windowMenu = self.menuBar().addMenu("&Window")
        windowMenu.addAction("Hide", lambda: self.hide())
        windowMenu.addAction("Minimize", lambda: self.showMinimized())
        windowMenu.addAction("Maximize", lambda: self.showMaximized())
        windowMenu.addAction("Restore", lambda: self.showNormal())
        windowMenu.addAction("FullScreen", lambda: self.showFullScreen())
        windowMenu.addAction("Center", lambda: self.center())
        windowMenu.addAction("Top-Left", lambda: self.move(0, 0))
        windowMenu.addAction("To Mouse", lambda: self.move_to_mouse_position())
        # widgets
        group0 = QGroupBox("Voice Deformation")
        self.setCentralWidget(group0)
        self.process = QProcess(self)
        self.process.error.connect(
            lambda: self.statusBar().showMessage("Info: Process Killed", 5000))
        self.control = QDial()
        self.control.setRange(-10, 20)
        self.control.setSingleStep(5)
        self.control.setValue(0)
        self.control.setCursor(QCursor(Qt.OpenHandCursor))
        self.control.sliderPressed.connect(
            lambda: self.control.setCursor(QCursor(Qt.ClosedHandCursor)))
        self.control.sliderReleased.connect(
            lambda: self.control.setCursor(QCursor(Qt.OpenHandCursor)))
        self.control.valueChanged.connect(
            lambda: self.control.setToolTip(f"<b>{self.control.value()}"))
        self.control.valueChanged.connect(
            lambda: self.statusBar().showMessage(
                f"Voice deformation: {self.control.value()}", 5000))
        self.control.valueChanged.connect(self.run)
        self.control.valueChanged.connect(lambda: self.process.kill())
        # Graphic effect
        self.glow = QGraphicsDropShadowEffect(self)
        self.glow.setOffset(0)
        self.glow.setBlurRadius(99)
        self.glow.setColor(QColor(99, 255, 255))
        self.control.setGraphicsEffect(self.glow)
        self.glow.setEnabled(False)
        # Timer to start
        self.slider_timer = QTimer(self)
        self.slider_timer.setSingleShot(True)
        self.slider_timer.timeout.connect(self.on_slider_timer_timeout)
        # an icon and set focus
        QLabel(self.control).setPixmap(
            QIcon.fromTheme("audio-input-microphone").pixmap(32))
        self.control.setFocus()
        QVBoxLayout(group0).addWidget(self.control)
        self.menu = QMenu(__doc__)
        self.menu.addAction(__doc__).setDisabled(True)
        self.menu.setIcon(self.windowIcon())
        self.menu.addSeparator()
        self.menu.addAction(
            "Show / Hide",
            lambda: self.hide() if self.isVisible() else self.showNormal())
        self.menu.addAction("STOP !", lambda: call('killall rec', shell=True))
        self.menu.addSeparator()
        self.menu.addAction("Quit", lambda: exit())
        self.tray.setContextMenu(self.menu)
        self.make_trayicon()

    def run(self):
        """Run/Stop the QTimer."""
        if self.slider_timer.isActive():
            self.slider_timer.stop()
        self.glow.setEnabled(True)
        call('killall rec ; killall play', shell=True)
        self.slider_timer.start(3000)

    def on_slider_timer_timeout(self):
        """Run subprocess to deform voice."""
        self.glow.setEnabled(False)
        value = int(self.control.value()) * 100
        command = f'play -q -V0 "|rec -q -V0 -n -d -R riaa bend pitch {value} "'
        print(f"Voice Deformation Value: {value}")
        print(f"Voice Deformation Command: {command}")
        self.process.start(command)
        if self.isVisible():
            self.statusBar().showMessage("Minimizing to System TrayIcon", 3000)
            print("Minimizing Main Window to System TrayIcon now...")
            sleep(3)
            self.hide()

    def center(self):
        """Center Window on the Current Screen,with Multi-Monitor support."""
        window_geometry = self.frameGeometry()
        mousepointer_position = QApplication.desktop().cursor().pos()
        screen = QApplication.desktop().screenNumber(mousepointer_position)
        centerPoint = QApplication.desktop().screenGeometry(screen).center()
        window_geometry.moveCenter(centerPoint)
        self.move(window_geometry.topLeft())

    def move_to_mouse_position(self):
        """Center the Window on the Current Mouse position."""
        window_geometry = self.frameGeometry()
        window_geometry.moveCenter(QApplication.desktop().cursor().pos())
        self.move(window_geometry.topLeft())

    def make_trayicon(self):
        """Make a Tray Icon."""
        if self.windowIcon() and __doc__:
            self.tray.setIcon(self.windowIcon())
            self.tray.setToolTip(__doc__)
            self.tray.activated.connect(
                lambda: self.hide() if self.isVisible()
                else self.showNormal())
            return self.tray.show()
 def __init__(self, parent=None):
     super(MainWindow, self).__init__()
     self.statusBar().showMessage("Move Dial to Deform Microphone Voice !.")
     self.setWindowTitle(__doc__)
     self.setMinimumSize(240, 240)
     self.setMaximumSize(480, 480)
     self.resize(self.minimumSize())
     self.setWindowIcon(QIcon.fromTheme("audio-input-microphone"))
     self.tray = QSystemTrayIcon(self)
     self.center()
     QShortcut("Ctrl+q", self, activated=lambda: self.close())
     self.menuBar().addMenu("&File").addAction("Quit", lambda: exit())
     self.menuBar().addMenu("Sound").addAction(
         "STOP !", lambda: call('killall rec', shell=True))
     windowMenu = self.menuBar().addMenu("&Window")
     windowMenu.addAction("Hide", lambda: self.hide())
     windowMenu.addAction("Minimize", lambda: self.showMinimized())
     windowMenu.addAction("Maximize", lambda: self.showMaximized())
     windowMenu.addAction("Restore", lambda: self.showNormal())
     windowMenu.addAction("FullScreen", lambda: self.showFullScreen())
     windowMenu.addAction("Center", lambda: self.center())
     windowMenu.addAction("Top-Left", lambda: self.move(0, 0))
     windowMenu.addAction("To Mouse", lambda: self.move_to_mouse_position())
     # widgets
     group0 = QGroupBox("Voice Deformation")
     self.setCentralWidget(group0)
     self.process = QProcess(self)
     self.process.error.connect(
         lambda: self.statusBar().showMessage("Info: Process Killed", 5000))
     self.control = QDial()
     self.control.setRange(-10, 20)
     self.control.setSingleStep(5)
     self.control.setValue(0)
     self.control.setCursor(QCursor(Qt.OpenHandCursor))
     self.control.sliderPressed.connect(
         lambda: self.control.setCursor(QCursor(Qt.ClosedHandCursor)))
     self.control.sliderReleased.connect(
         lambda: self.control.setCursor(QCursor(Qt.OpenHandCursor)))
     self.control.valueChanged.connect(
         lambda: self.control.setToolTip(f"<b>{self.control.value()}"))
     self.control.valueChanged.connect(
         lambda: self.statusBar().showMessage(
             f"Voice deformation: {self.control.value()}", 5000))
     self.control.valueChanged.connect(self.run)
     self.control.valueChanged.connect(lambda: self.process.kill())
     # Graphic effect
     self.glow = QGraphicsDropShadowEffect(self)
     self.glow.setOffset(0)
     self.glow.setBlurRadius(99)
     self.glow.setColor(QColor(99, 255, 255))
     self.control.setGraphicsEffect(self.glow)
     self.glow.setEnabled(False)
     # Timer to start
     self.slider_timer = QTimer(self)
     self.slider_timer.setSingleShot(True)
     self.slider_timer.timeout.connect(self.on_slider_timer_timeout)
     # an icon and set focus
     QLabel(self.control).setPixmap(
         QIcon.fromTheme("audio-input-microphone").pixmap(32))
     self.control.setFocus()
     QVBoxLayout(group0).addWidget(self.control)
     self.menu = QMenu(__doc__)
     self.menu.addAction(__doc__).setDisabled(True)
     self.menu.setIcon(self.windowIcon())
     self.menu.addSeparator()
     self.menu.addAction(
         "Show / Hide",
         lambda: self.hide() if self.isVisible() else self.showNormal())
     self.menu.addAction("STOP !", lambda: call('killall rec', shell=True))
     self.menu.addSeparator()
     self.menu.addAction("Quit", lambda: exit())
     self.tray.setContextMenu(self.menu)
     self.make_trayicon()