def addProject_(self, sender):
        projectName = self.edtAddProject.stringValue()
        if projectName not in Projects.get() and not re.match("^\s*$", projectName):
                Projects.add(self.edtAddProject.stringValue())
        else:
            # show alert with reason for failure
            alert = NSAlert.alloc().init()
            alert.addButtonWithTitle_('OK')
            alert.setMessageText_('Failed to add new project')
            alert.setInformativeText_('Please ensure the project does not '
                    'already exist and that it contains characters.')
            alert.runModal()

        self.loadProjectsLists()
        self.edtAddProject.setStringValue_('')
    def addProject_(self, sender):
        projectName = self.edtAddProject.stringValue()
        if projectName not in Projects.get() and not re.match(
                "^\s*$", projectName):
            Projects.add(self.edtAddProject.stringValue())
        else:
            # show alert with reason for failure
            alert = NSAlert.alloc().init()
            alert.addButtonWithTitle_('OK')
            alert.setMessageText_('Failed to add new project')
            alert.setInformativeText_(
                'Please ensure the project does not '
                'already exist and that it contains characters.')
            alert.runModal()

        self.loadProjectsLists()
        self.edtAddProject.setStringValue_('')
Esempio n. 3
0
    def projectChange_(self, sender):
        """Project changed event"""
        if self.pbtnProject.titleOfSelectedItem():
            self.cbxInput.removeAllItems()
            self.cbxInput.addItemsWithObjectValues_(Projects.getAutocomleteList(
                    self.pbtnProject.titleOfSelectedItem(),
                    SlackingAutocompletes.get()))

        if sender:
            userPrefs.selectedProject = unicode(
                    self.pbtnProject.titleOfSelectedItem())
            userPrefs.save()
Esempio n. 4
0
    def projectChange_(self, sender):
        """Project changed event"""
        if self.pbtnProject.titleOfSelectedItem():
            self.cbxInput.removeAllItems()
            self.cbxInput.addItemsWithObjectValues_(
                Projects.getAutocomleteList(
                    self.pbtnProject.titleOfSelectedItem(),
                    SlackingAutocompletes.get()))

        if sender:
            userPrefs.selectedProject = unicode(
                self.pbtnProject.titleOfSelectedItem())
            userPrefs.save()
Esempio n. 5
0
    def btnDonePress_(self, sender):
        """On done button press"""
        if self.tasks.dayStarted():
            if self.cbxInput.stringValue().strip():
                taskName = self.cbxInput.stringValue()
                self.appendTask(*fh.formatTaskString(*self.tasks.add(
                    taskName, self.pbtnProject.titleOfSelectedItem())))
                self.readCounters()
                self.cbxInput.setStringValue_("")
                self.scrollToEnd()

                if Tasks.taskType(taskName) == "work":
                    Projects.addAutocomplete(
                        self.pbtnProject.titleOfSelectedItem(), taskName)
                else:
                    SlackingAutocompletes.add(taskName)
                self.cbxInput.addItemWithObjectValue_(taskName)
        else:
            if userPrefs.showHelpMessageOnStart:
                self.showStartHelpMessage()
            taskName = userPrefs.startPlaceholder
            self.appendTask(*fh.formatTaskString(*self.tasks.add(taskName)))
            self.initDoneButton()
Esempio n. 6
0
    def btnDonePress_(self, sender):
        """On done button press"""
        if self.tasks.dayStarted():
            if self.cbxInput.stringValue().strip():
                taskName = self.cbxInput.stringValue()
                self.appendTask(*fh.formatTaskString(
                        *self.tasks.add(taskName,
                            self.pbtnProject.titleOfSelectedItem())))
                self.readCounters()
                self.cbxInput.setStringValue_("")
                self.scrollToEnd()

                if Tasks.taskType(taskName) == "work":
                    Projects.addAutocomplete(
                            self.pbtnProject.titleOfSelectedItem(), taskName)
                else:
                    SlackingAutocompletes.add(taskName)
                self.cbxInput.addItemWithObjectValue_(taskName)
        else:
            if userPrefs.showHelpMessageOnStart:
                self.showStartHelpMessage()
            taskName = userPrefs.startPlaceholder
            self.appendTask(*fh.formatTaskString(*self.tasks.add(taskName)))
            self.initDoneButton()
Esempio n. 7
0
    def initControls(self):
        """Init basic controls"""
        self.outputArea.setString_("")

        self.tasks = Tasks()

        if userPrefs.showWorkTill:
            self.workTillBox.setHidden_(False)
        else:
            self.workTillBox.setHidden_(True)

        self.pbtnProject.removeAllItems()
        self.pbtnProject.addItemsWithTitles_(Projects.get())
        self.pbtnProject.selectItemWithTitle_(userPrefs.selectedProject)

        self.projectChange_(None)

        self.initDoneButton()

        self.fillTasks()
        self.scrollToEnd()
Esempio n. 8
0
    def initControls(self):
        """Init basic controls"""
        self.outputArea.setString_("")

        self.tasks = Tasks()

        if userPrefs.showWorkTill:
            self.workTillBox.setHidden_(False)
        else:
            self.workTillBox.setHidden_(True)

        self.pbtnProject.removeAllItems()
        self.pbtnProject.addItemsWithTitles_(Projects.get())
        self.pbtnProject.selectItemWithTitle_(userPrefs.selectedProject)

        self.projectChange_(None)

        self.initDoneButton()

        self.fillTasks()
        self.scrollToEnd()
Esempio n. 9
0
 def applicationShouldTerminate_(self, sender):
     Projects.sync()
     return True
 def removeProject_(self, sender):
     Projects.remove(self.pbtnRemoveProject.titleOfSelectedItem())
     self.loadProjectsLists()
 def loadProjectsLists(self):
     self.pbtnRemoveProject.removeAllItems()
     self.pbtnRemoveProject.addItemsWithTitles_(Projects.get())
Esempio n. 12
0
 def removeProject_(self, sender):
     Projects.remove(self.pbtnRemoveProject.titleOfSelectedItem())
     self.loadProjectsLists()
Esempio n. 13
0
 def loadProjectsLists(self):
     self.pbtnRemoveProject.removeAllItems()
     self.pbtnRemoveProject.addItemsWithTitles_(Projects.get())