def __init__(self):
        super().__init__()
        self.show()

        self.updating_gui_bool = False
        self.rest_actions_qbg = QtWidgets.QButtonGroup()
        vbox_l2 = QtWidgets.QVBoxLayout()
        self.setLayout(vbox_l2)
        vbox_l2.addStretch(1)

        # Main area
        self.main_area_qgb = QtWidgets.QGroupBox("Rest")
        vbox_l2.addWidget(self.main_area_qgb)

        vbox_l3 = QtWidgets.QVBoxLayout()
        self.main_area_qgb.setLayout(vbox_l3)

        self.title_qll = QtWidgets.QLabel()
        vbox_l3.addWidget(self.title_qll)
        self.image_qll = QtWidgets.QLabel()
        vbox_l3.addWidget(self.image_qll)
        self.image_qll.setScaledContents(True)
        self.image_qll.setMinimumWidth(IMAGE_GOAL_WIDTH_INT)
        self.image_qll.setMinimumHeight(IMAGE_GOAL_HEIGHT_INT)

        hbox_l4 = QtWidgets.QHBoxLayout()
        vbox_l3.addLayout(hbox_l4)
        self.wait_qpb = QtWidgets.QPushButton("Wait")
        hbox_l4.addWidget(self.wait_qpb)
        self.wait_qpb.clicked.connect(self.on_wait_clicked)
        self.wait_qpb.setFont(mc_global.get_font_xlarge())
        hbox_l4.addWidget(QtWidgets.QLabel("for"))
        self.wait_qsb = QtWidgets.QSpinBox()
        self.wait_qsb.setMinimum(1)
        self.wait_qsb.setFont(mc_global.get_font_xlarge())
        hbox_l4.addWidget(self.wait_qsb)
        hbox_l4.addWidget(QtWidgets.QLabel("minutes"))
        hbox_l4.addStretch(1)

        hbox_l4 = QtWidgets.QHBoxLayout()
        vbox_l3.addLayout(hbox_l4)
        self.close_qpb = QtWidgets.QPushButton("Close")
        hbox_l4.addWidget(self.close_qpb)
        self.close_qpb.clicked.connect(self.on_close_button_clicked)
        self.close_qpb.setFont(mc_global.get_font_xlarge())
        hbox_l4.addWidget(QtWidgets.QLabel("and disable reminders"))
        hbox_l4.addStretch(1)

        vbox_l2.addStretch(1)

        # Breathe
        vbox_l2.addWidget(QtWidgets.QLabel("After taking a break:"))
        self.close_and_breathe_qpb = QtWidgets.QPushButton("Breathe")
        vbox_l2.addWidget(self.close_and_breathe_qpb)
        self.close_and_breathe_qpb.clicked.connect(
            self.on_close_and_breathe_button_clicked)
        self.close_and_breathe_qpb.setFont(
            mc_global.get_font_xlarge(i_bold=False))
    def update_gui(self):
        self.updating_gui_bool = True

        # Buttons and shortcut descriptions
        if mc_global.breathing_state == mc_global.BreathingState.inactive:
            self.ib_toggle_qpb.setEnabled(False)
            self.ob_toggle_qpb.setEnabled(False)
            self.start_pause_qpb.setText("Start")
            self.start_pause_qpb.setFont(mc_global.get_font_medium(i_bold=True))

            # self.start_stop_shortcut_qll.setText("Press and hold shift key to start")
            # self.iob_shortcut_qll.setText("")
        else:
            self.ib_toggle_qpb.setEnabled(True)
            self.ob_toggle_qpb.setEnabled(True)
            self.start_pause_qpb.setText("Pause")
            self.start_pause_qpb.setFont(mc_global.get_font_medium())

            # self.start_stop_shortcut_qll.setText("shortcut")

            if mc_global.breathing_state == mc_global.BreathingState.breathing_in:
                # self.iob_toggle_qpb.setText("Breathing In")
                self.ib_toggle_qpb.setChecked(True)
                self.ob_toggle_qpb.setChecked(False)
                # self.iob_shortcut_qll.setText("Press and hold shift to breathe in")

            elif mc_global.breathing_state == mc_global.BreathingState.breathing_out:
                # self.iob_toggle_qpb.setText("Breathing Out")
                self.ib_toggle_qpb.setChecked(False)
                self.ob_toggle_qpb.setChecked(True)
                # self.iob_shortcut_qll.setText("Release the shift key to breathe out")

        if mc_global.active_phrase_id_it != mc_global.NO_PHRASE_SELECTED_INT:
            self.help_text_qll.hide()

            active_phrase = model.PhrasesM.get(mc_global.active_phrase_id_it)

            ib_formatted_str = active_phrase.ib_str
            ob_formatted_str = active_phrase.ob_str
            if mc_global.breathing_state == mc_global.BreathingState.breathing_in:
                # ib_formatted_str += " ←"
                self.bi_text_qll.setFont(mc_global.get_font_xlarge(i_underscore=True))
                self.bo_text_qll.setFont(mc_global.get_font_xlarge())
            elif mc_global.breathing_state == mc_global.BreathingState.breathing_out:
                # ob_formatted_str += " ←"
                self.bi_text_qll.setFont(mc_global.get_font_xlarge())
                self.bo_text_qll.setFont(mc_global.get_font_xlarge(i_underscore=True))
            elif mc_global.breathing_state == mc_global.BreathingState.inactive:
                self.bi_text_qll.setFont(mc_global.get_font_xlarge())
                self.bo_text_qll.setFont(mc_global.get_font_xlarge())
            self.bi_text_qll.setText(ib_formatted_str)
            self.bo_text_qll.setText(ob_formatted_str)
            if ob_formatted_str:
                self.bo_text_qll.show()
            else:
                self.bo_text_qll.hide()

        self.updating_gui_bool = False
Пример #3
0
    def update_gui(self):
        self.updating_gui_bool = True
        if mc_global.active_rest_action_id_it == mc_global.NO_REST_ACTION_SELECTED_INT:
            pass
        else:
            rest_action = model.RestActionsM.get(
                mc_global.active_rest_action_id_it)
            if rest_action.image_path_str and os.path.isfile(
                    rest_action.image_path_str):
                self.image_qll.show()
                self.image_qll.setPixmap(
                    QtGui.QPixmap(rest_action.image_path_str))
                self.resize_image()
            else:
                self.image_qll.hide()
                self.image_qll.clear()

            self.title_qll.setText(rest_action.title_str)
            self.title_qll.setFont(mc_global.get_font_xlarge())
            self.title_qll.setWordWrap(True)

            self.updating_gui_bool = False
    def __init__(self):
        super().__init__()
        self.show()
        self.setMinimumHeight(270)
        self.setMinimumWidth(400)

        self.ib_qtimer = None
        self.ob_qtimer = None
        self.updating_gui_bool = False
        self.breathing_rest_counter_int = 0
        self.breath_counter_int = 0

        self.in_breath_graphics_qgri_list = []
        self.out_breath_graphics_qgri_list = []

        vbox_l2 = QtWidgets.QVBoxLayout()
        self.setLayout(vbox_l2)

        self.help_text_qll = QtWidgets.QLabel(
            "Please select a breathing phrase from the list to the left")
        vbox_l2.addWidget(self.help_text_qll)
        self.help_text_qll.setFont(mc_global.get_font_large(i_italics=True))

        self.bi_text_qll = CustomLabel(mc_global.BreathingState.breathing_in)
        self.bo_text_qll = CustomLabel(mc_global.BreathingState.breathing_out)
        vbox_l2.addWidget(self.bi_text_qll)
        vbox_l2.addWidget(self.bo_text_qll)
        self.bi_text_qll.setFont(mc_global.get_font_xlarge())
        self.bo_text_qll.setFont(mc_global.get_font_xlarge())
        self.bi_text_qll.setWordWrap(True)
        self.bo_text_qll.setWordWrap(True)
        self.bi_text_qll.widget_entered_signal.connect(
            self.on_io_widget_entered)
        self.bo_text_qll.widget_entered_signal.connect(
            self.on_io_widget_entered)

        hbox_l3 = QtWidgets.QHBoxLayout()
        vbox_l2.addLayout(hbox_l3)

        sps_qgb = QtWidgets.QGroupBox()
        hbox_l3.addWidget(sps_qgb)
        vbox_l4 = QtWidgets.QVBoxLayout()
        sps_qgb.setLayout(vbox_l4)
        self.start_pause_qpb = QtWidgets.QPushButton("Start")
        vbox_l4.addWidget(self.start_pause_qpb)
        # TODO: Change font
        self.start_pause_qpb.clicked.connect(self.on_start_pause_clicked)
        self.stop_qpb = QtWidgets.QPushButton("Stop/Clear")
        vbox_l4.addWidget(self.stop_qpb)
        self.stop_qpb.clicked.connect(self.on_stop_button_clicked)

        io_qgb = QtWidgets.QGroupBox()
        hbox_l3.addWidget(io_qgb)
        hbox_l4 = QtWidgets.QHBoxLayout()
        io_qgb.setLayout(hbox_l4)

        vbox_l5 = QtWidgets.QVBoxLayout()
        hbox_l4.addLayout(vbox_l5)
        # self.btn_descr_qll = QtWidgets.QLabel("In")
        self.ib_toggle_qpb = QtWidgets.QPushButton("In")
        vbox_l5.addWidget(self.ib_toggle_qpb)
        self.ib_toggle_qpb.setCheckable(True)
        self.ib_toggle_qpb.toggled.connect(self.on_ib_toggled)
        self.ob_toggle_qpb = QtWidgets.QPushButton("Out")
        vbox_l5.addWidget(self.ob_toggle_qpb)
        self.ob_toggle_qpb.setCheckable(True)
        self.ob_toggle_qpb.toggled.connect(self.on_ob_toggled)

        vbox_l5 = QtWidgets.QVBoxLayout()
        hbox_l4.addLayout(vbox_l5)
        self.ib_icon_cqll = CustomLabel(
            mc_global.BreathingState.breathing_in,
            mc_global.get_icon_path("arrow-circle-top-4x.png"))
        vbox_l5.addWidget(self.ib_icon_cqll)
        self.ib_icon_cqll.widget_entered_signal.connect(
            self.on_io_widget_entered)
        self.ob_icon_cqll = CustomLabel(
            mc_global.BreathingState.breathing_out,
            mc_global.get_icon_path("arrow-circle-bottom-4x.png"))
        vbox_l5.addWidget(self.ob_icon_cqll)
        self.ob_icon_cqll.widget_entered_signal.connect(
            self.on_io_widget_entered)
        """
        start_stop_vbox = QtWidgets.QVBoxLayout()
        hbox.addLayout(start_stop_vbox)
        start_stop_vbox.addWidget(self.start_pause_qpb)
        self.start_stop_shortcut_qll = QtWidgets.QLabel()
        start_stop_vbox.addWidget(self.start_stop_shortcut_qll)
        """

        self.breathing_graphicsview = QtWidgets.QGraphicsView(
        )  # QGraphicsScene
        vbox_l2.addWidget(self.breathing_graphicsview)
        self.breathing_graphicsscene = QtWidgets.QGraphicsScene()
        self.breathing_graphicsview.setScene(self.breathing_graphicsscene)
        # self.breathing_graphicsview.centerOn(QtCore.Qt.AlignRight)
        # alignment can be set with "setAlignment"
        self.breathing_graphicsview.setDragMode(
            QtWidgets.QGraphicsView.ScrollHandDrag)

        self.update_gui()
Пример #5
0
    def __init__(self):
        super().__init__()
        self.show()

        self.updating_gui_bool = False

        self.rest_actions_qbg = QtWidgets.QButtonGroup()

        # self.setWindowTitle("Please take care of yourself")
        # self.setWindowIcon(QtGui.QIcon(mc.mc_global.get_app_icon_path()))
        # self.setMinimumWidth(IMAGE_GOAL_WIDTH_INT * 2)
        # self.setMinimumHeight(IMAGE_GOAL_WIDTH_INT)
        # self.setSizePolicy(asdf)

        vbox_l2 = QtWidgets.QVBoxLayout()
        self.setLayout(vbox_l2)

        # Help text
        self.help_text_qll = QtWidgets.QLabel(
            "Please select a rest action from the list to the left")
        vbox_l2.addWidget(self.help_text_qll)
        self.help_text_qll.setFont(mc_global.get_font_xlarge(i_italics=True))

        # Main area

        self.title_qll = QtWidgets.QLabel()
        vbox_l2.addWidget(self.title_qll)

        # Image (or text if image is missing)
        self.image_qll = QtWidgets.QLabel()
        vbox_l2.addWidget(self.image_qll)
        self.image_qll.setScaledContents(True)
        self.image_qll.setMinimumWidth(IMAGE_GOAL_WIDTH_INT)
        self.image_qll.setMinimumHeight(IMAGE_GOAL_HEIGHT_INT)

        # TODO: Quote here?

        # self.image_qll.setPixmap(QtGui.QPixmap(mc_global.active_rest_image_full_path_str))
        # self.resize_image()
        """
        self.qpb = QtWidgets.QProgressBar()
        vbox_l2.addWidget(self.qpb)
        self.qpb.setMinimum(0)
        self.qpb.setMaximum(0)
        """

        vbox_l2.addStretch(1)
        self.title_qll = QtWidgets.QLabel("Please take good care of yourself")
        self.title_qll.setFont(mc_global.get_font_xlarge())
        vbox_l2.addWidget(self.title_qll)
        vbox_l2.addStretch(1)

        # TODO: Wait interface here to indicate that the user should take a break
        # For example we could use a progressbar "without end" (it's possible to set this)

        # Line of buttons (and widgets) at the bottom of the widget
        hbox_l3 = QtWidgets.QHBoxLayout()
        vbox_l2.addLayout(hbox_l3)

        # TODO: Reset timer and .. close / breathe

        close_qgb = QtWidgets.QGroupBox()
        hbox_l3.addWidget(close_qgb)
        hbox_l4 = QtWidgets.QHBoxLayout()
        close_qgb.setLayout(hbox_l4)

        self.close_and_breathe_qpb = QtWidgets.QPushButton("Breathe")
        hbox_l4.addWidget(self.close_and_breathe_qpb)
        self.close_and_breathe_qpb.clicked.connect(
            self.on_close_and_breathe_button_clicked)
        self.close_and_breathe_qpb.setFont(
            mc_global.get_font_xlarge(i_bold=True))

        hbox_l4.addStretch(1)

        self.wait_qpb = QtWidgets.QPushButton("Wait")
        hbox_l4.addWidget(self.wait_qpb)
        self.wait_qpb.clicked.connect(self.on_wait_clicked)
        self.wait_qpb.setFont(mc_global.get_font_xlarge())
        hbox_l4.addWidget(QtWidgets.QLabel("for"))
        self.wait_qsb = QtWidgets.QSpinBox()
        self.wait_qsb.setMinimum(1)
        self.wait_qsb.setFont(mc_global.get_font_xlarge())
        hbox_l4.addWidget(self.wait_qsb)
        hbox_l4.addWidget(QtWidgets.QLabel("minutes"))

        hbox_l4.addStretch(1)

        self.close_qpb = QtWidgets.QPushButton("Close")
        hbox_l4.addWidget(self.close_qpb)
        self.close_qpb.clicked.connect(self.on_close_button_clicked)
        self.close_qpb.setFont(mc_global.get_font_xlarge())