Beispiel #1
0
class TopTab1(Widget):

    key = 'TopTab1'
    tasks = []

    def __init__(self, buttonManager, parent=None):
        super(TopTab1, self).__init__(parent)

        self.buttonManager = buttonManager
        self.parent = parent

        self.layout = GridLayout()
        self.buildUI()
        self.setLayout(self.layout)

    def buildUI(self):

        self.prjButtons  = self.buttonManager.projectButtonsGroupBox(self.parent)
        self.taskButtons = self.buttonManager.taskButtonsGroupBox(self.parent)
        self.teamButtons = self.buttonManager.teamButtonsGroupBox(self.parent)

        self.update_tasks()

        self.prjGrp      = GroupBox("Project", self.prjButtons, "BtnGrid")
        self.taskGrp     = GroupBox("Task", self.taskButtons, "BtnGrid")
        self.teamGrp     = GroupBox('Team', self.teamButtons, 'BtnGrid')
        self.tabFilter   = TopTap1Filter()
        self.tabFilter.overduedCB.stateChanged.connect(self.overdue)
        self.tabFilter.urgentCB.stateChanged.connect(self.urgent)
        self.tabFilter.safetyCB.stateChanged.connect(self.safety)

        self.layout.addWidget(self.prjGrp, 5, 0, 2, 2)
        self.layout.addWidget(self.taskGrp, 5, 2, 2, 2)
        self.layout.addWidget(self.teamGrp, 5, 4, 2, 2)
        self.layout.addWidget(self.tabFilter, 5, 6, 2, 3)

    def update_tasks(self):
        try:
            self.layout.removeItem(self.taskLayout)
        except AttributeError:
            self.taskLayout = HBoxLayout()
        else:
            for w in self.taskLayout.children():
                self.taskLayout.removeWidget(w)
            self.taskLayout = HBoxLayout()

        tasks = get_file_path(TASK_DIR)

        for t in tasks:
            task = TaskInfo(t)
            self.taskLayout.addWidget(task)
            self.tasks.append(task)
        self.layout.addLayout(self.taskLayout, 1, 0, 3, 9)

    def overdue(self, bool):
        for task in self.tasks:
            if task.task.status == 'Overdued':
                task.setVisible(bool)

    def urgent(self, bool):
        for task in self.tasks:
            if task.task.status == 'Urgent':
                task.setVisible(bool)

    def safety(self, bool):
        for task in self.tasks:
            if task.task.status not in ['Overdued, Urgent']:
                task.setVisible(bool)
Beispiel #2
0
class Screenshot(Widget):

    key = 'ScreenShot'

    def __init__(self, parent=None):
        super(Screenshot, self).__init__(parent)
        self.setWindowIcon(AppIcon(32, "Screenshot"))
        self.resize(960, 540)

        self.layout = GridLayout()
        self.buildUI()
        self.setLayout(self.layout)

        self.shootScreen()
        self.delaySpinBox.setValue(5)

    def buildUI(self):
        self.screenshotLabel = Label({
            'alg': 'center',
            'sizePolicy': ['expanding', 'expanding'],
            'smin': [240, 160]
        })

        self.createOptionsGroupBox()
        self.createButtonsLayout()

        self.layout.addWidget(self.screenshotLabel, 0, 0, 9, 16)
        self.layout.addWidget(self.optionsGroupBox, 10, 0, 1, 16)
        self.layout.addLayout(self.buttonsLayout, 11, 0, 1, 16)

    def resizeEvent(self, event):
        scaledSize = self.originalPixmap.size()
        scaledSize.scale(self.screenshotLabel.size(), keepARM)
        if not self.screenshotLabel.pixmap(
        ) or scaledSize != self.screenshotLabel.pixmap().size():
            self.updateScreenshotLabel()

    def newScreenshot(self):
        if self.hideThisWindowCheckBox.isChecked():
            self.hide()

        self.newScreenshotButton.setDisabled(True)

        QTimer.singleShot(self.delaySpinBox.value() * 1000, self.shootScreen)

    def saveScreenshot(self):
        format = 'png'
        initialPath = QDir.currentPath() + "/untitled." + format

        fileName, _ = QFileDialog.getSaveFileName(
            self, "Save As", initialPath,
            "%s Files (*.%s);;All Files (*)" % (format.upper(), format))

        if fileName:
            self.originalPixmap.save(fileName, format)

    def shootScreen(self):
        if self.delaySpinBox.value() != 0:
            QApplication.instance().beep()

        screen = QApplication.primaryScreen()
        if screen is not None:
            self.originalPixmap = screen.grabWindow(0)
        else:
            self.originalPixmap = QPixmap()

        self.updateScreenshotLabel()

        self.newScreenshotButton.setDisabled(False)
        if self.hideThisWindowCheckBox.isChecked():
            self.show()

    def updateCheckBox(self):
        if self.delaySpinBox.value() == 0:
            self.hideThisWindowCheckBox.setDisabled(True)
        else:
            self.hideThisWindowCheckBox.setDisabled(False)

    def createOptionsGroupBox(self):
        self.optionsGroupBox = QGroupBox("Options")

        self.delaySpinBox = QSpinBox()
        self.delaySpinBox.setSuffix(" s")
        self.delaySpinBox.setMaximum(60)
        self.delaySpinBox.valueChanged.connect(self.updateCheckBox)

        self.delaySpinBoxLabel = QLabel("Screenshot Delay:")

        self.hideThisWindowCheckBox = QCheckBox("Hide This Window")

        optionsGroupBoxLayout = QGridLayout()
        optionsGroupBoxLayout.addWidget(self.delaySpinBoxLabel, 0, 0)
        optionsGroupBoxLayout.addWidget(self.delaySpinBox, 0, 1)
        optionsGroupBoxLayout.addWidget(self.hideThisWindowCheckBox, 1, 0, 1,
                                        2)
        self.optionsGroupBox.setLayout(optionsGroupBoxLayout)

    def createButtonsLayout(self):
        self.newScreenshotButton = Button({
            'txt': "New Screenshot",
            'cl': self.newScreenshot
        })
        self.saveScreenshotButton = Button({
            'txt': "Save Screenshot",
            'cl': self.saveScreenshot
        })
        self.quitScreenshotButton = Button({
            'txt':
            "Quit",
            'cl':
            partial(self.signals.showLayout.emit, self.key, 'hide')
        })

        self.buttonsLayout = HBoxLayout({
            'addWidget': [
                self.newScreenshotButton, self.saveScreenshotButton,
                self.quitScreenshotButton
            ]
        })
        self.buttonsLayout.addStretch()
        # self.buttonsLayout.addWidget(self.newScreenshotButton)
        # self.buttonsLayout.addWidget(self.saveScreenshotButton)
        # self.buttonsLayout.addWidget(self.quitScreenshotButton)

    def updateScreenshotLabel(self):
        self.screenshotLabel.setPixmap(
            self.originalPixmap.scaled(self.screenshotLabel.size(),
                                       Qt.KeepAspectRatio,
                                       Qt.SmoothTransformation))