예제 #1
0
 def delete(self):
     print("Deleting from contacts:", self.user_email)
     s.deleteContact(self.user_email)
     message = "Deleted " + self.user_email + " from contacts"
     msg = QMessageBox()
     msg.setText(message)
     msg.setWindowTitle("Deleted Contact")
     msg.setStyleSheet(
         'background-color: darkSlateGray; color: white; font: Courier')
     msg.setIcon(QMessageBox.Information)
     msg.exec_()
     #self.hide()
     for widget in self.win.contWidget:  #show all widgets with contact deleted from it
         widget.hide()  #show all the contacts widgets
     contacts = s.addContact(None, None, None)
     self.win.contWidget = []
     #have to update the contacts widget so that when we add a new contact or delete contacts
     #old ones dont reappear
     for name in contacts:
         user_email = contacts[
             name]  #accessing email from dictionary of contacts
         item = contactsWidget(
             name, user_email, self.win
         )  #make a project widget with the name of the current project
         #and with the list with file_id and project_id
         self.win.controlsLayout.insertWidget(0, item)
         self.win.contWidget.append(
             item)  #append it to our list of widgets of projects
     for widget in self.win.contWidget:  #show all widgets with contact deleted from it
         widget.show()  #show all the contacts widgets
     self.win.currentWindow = self.win.contWidget
예제 #2
0
 def collaborateProj(self):
     contacts = s.addContact(None, None, None)
     contact_selected, ok = QInputDialog.getItem(self,
                                                 "Collaborate on Project",
                                                 "Contacts", contacts, 0,
                                                 False)
     if ok and contact_selected:
         user_email = contacts[contact_selected]
         try:
             s.shareProject(service, self.project_id, user_email)
             message = "Project shared with " + contact_selected + ": " + contacts[
                 contact_selected]
             print(message)
             msg = QMessageBox()
             msg.setText(message)
             msg.setWindowTitle("Shared Project")
             msg.setIcon(QMessageBox.Information)
             msg.setStyleSheet(
                 'background-color: darkSlateGray; color: white; font: Courier'
             )
             msg.exec_()
         except:
             message = "Unable to share project with " + (user_email)
             msg = QMessageBox()
             msg.setText(message)
             msg.setWindowTitle("Share Project Error")
             message = "Please ensure " + user_email + " is a valid email address"
             msg.setInformativeText(message)
             msg.setIcon(QMessageBox.Warning)
             msg.setStyleSheet(
                 'background-color: darkSlateGray; color: white; font: Courier'
             )
             msg.exec_()
예제 #3
0
 def addNew(self):
     contacts = s.addContact(None, None, None)  #refresh the contacts list
     loop = True  #loop around until they either create a new contact successfully or decide to not create one
     while loop == True:
         name_in, ok = QInputDialog.getText(self, 'New Contact',
                                            'Contact Name:')
         if (ok):  #if okay button pressed for name
             contact_name = str(name_in)  #convert to string
             email_in, ok = QInputDialog.getText(self, 'New Contact',
                                                 'Contact Email:')
             contact_email = str(email_in)  #convert to string
             if (ok) & (
                     contact_name != contact_email
             ):  #if okay button pressed for email, and theyre not the same
                 s.addContact(contact_name, contact_email, contacts)
                 for widget in self.contWidget:  #hide all the widgets
                     widget.hide()
                 item = contactsWidget(
                     contact_name, contact_email, self
                 )  #make a project widget with the name of the current project
                 self.controlsLayout.insertWidget(
                     0, item)  #insert it at the top of the list
                 self.contWidget.append(
                     item)  #append it to our list of widgets of projects
                 for widget in self.contWidget:  #show all widgets with new contacts appended to it
                     widget.show()  #show all the contacts widgets
                 loop = False
             elif (contact_name == contact_email):
                 msg_box = QtWidgets.QMessageBox(self)
                 msg_box.setWindowTitle("New Contact Error")
                 msg_box.setText(
                     "Contact name and email address can't be the same")
                 msg_box.setStyleSheet(
                     'background-color: darkSlateGray; color: white; font: Courier'
                 )
                 msg_box.exec_(
                 )  #they cant be the same, ask them to enter new details
         else:  #break from loop as we chose not to add a new contact
             loop = False
     self.currentWindow = self.contWidget
예제 #4
0
 def contactsView(self):
     for widget in self.projWidget:
         widget.hide()  #hide all the projects widgets
     for widget in self.fileWidget:
         widget.hide()  #hide all the file widgets
     for widget in self.contWidget:
         widget.hide()  #show all the contacts widgets
     self.contacts.hide()  #hide view contacts button
     self.NewContact.show()  #show add new contacts button
     #this will to take us to scrollable contacts view
     self.contWidget = []  #empty list of contact widgets
     contacts = s.addContact(None, None, None)  #get the list of contacts
     for name in contacts:
         user_email = contacts[
             name]  #accessing email from dictionary of contacts
         item = contactsWidget(
             name, user_email, self
         )  #make a project widget with the name of the current project
         #and with the list with file_id and project_id
         self.controlsLayout.insertWidget(0, item)
         self.contWidget.append(
             item)  #append it to our list of widgets of projects
     self.currentWindow = self.contWidget
예제 #5
0
    def __init__(self, *args, **kwargs):
        super().__init__()
        #Create our 4 main buttons, the add contacts button will only be visible
        #on the contacts screen
        self.setStyleSheet(
            'background-color: #242424; color: white; font-size: 14pt;'
            'font: Courier;')
        self.create = QtWidgets.QPushButton(self)
        self.create.setText("Create Project")
        # padding: 6px;')
        self.create.setStyleSheet(
            "QPushButton{background-color : darkSlateGray;}"
            "QPushButton::pressed{background-color : #242424;}")
        self.create.setCursor(QCursor(QtCore.Qt.PointingHandCursor))
        self.create.clicked.connect(self.createProj)

        self.view = QtWidgets.QPushButton(self)
        self.view.setText("View All Projects")
        self.view.setStyleSheet(
            "QPushButton{background-color : darkSlateGray;}"
            "QPushButton::pressed{background-color : #242424;}")
        self.view.setCursor(QCursor(QtCore.Qt.PointingHandCursor))
        self.view.clicked.connect(self.projView)

        self.contacts = QtWidgets.QPushButton(self)
        self.contacts.setText("Contacts")
        self.contacts.setStyleSheet(
            "QPushButton{background-color : darkSlateGray;}"
            "QPushButton::pressed{background-color : #242424;}")
        self.contacts.setCursor(QCursor(QtCore.Qt.PointingHandCursor))
        self.contacts.clicked.connect(self.contactsView)

        #This button is hidden and only made visible on contacts screen
        self.NewContact = QtWidgets.QPushButton(self)
        self.NewContact.setText("Add New Contact")
        self.NewContact.clicked.connect(self.addNew)
        self.NewContact.setStyleSheet(
            "QPushButton{background-color : darkSlateGray;}"
            "QPushButton::pressed{background-color : #242424;}")
        self.NewContact.setCursor(QCursor(QtCore.Qt.PointingHandCursor))
        self.NewContact.hide()

        self.controls = QWidget()  #Controls container widget.
        self.controlsLayout = QVBoxLayout()  #Controls container layout.

        # List of names, widgets are stored in a dictionary by these keys.
        self.projWidget = []
        project_dict = s.listProjects(folder_id, service)
        #Iterating through all the projects, creating a widget
        #for each one with their own buttons
        for name in project_dict:
            project_id = project_dict[name]
            #print("adding",name, "to widget:", project_id, "ProjectWindow")
            item = ProjectWidget(
                name, project_id, self
            )  #make a project widget with the name of the current project
            self.controlsLayout.insertWidget(
                0, item
            )  #^^^ we pass self so we can hide it from the widgets inside it
            self.projWidget.append(
                item)  #append it to our list of widgets of projects

        self.contWidget = []  #empty list of contact widgets
        contacts = s.addContact(None, None, None)  #get the list of contacts

        for name in contacts:
            user_email = contacts[
                name]  #accessing email from dictionary of contacts
            item = contactsWidget(
                name, user_email, self
            )  #make a project widget with the name of the current project
            #and with the list with file_id and project_id
            self.controlsLayout.insertWidget(0, item)
            self.contWidget.append(
                item)  #append it to our list of widgets of projects

        #Hide the contacts until the contact view is opened
        for widget in self.contWidget:
            widget.hide()

        self.fileWidget = [
        ]  #declaring this for later use in viewing the files in a project

        #Hide the project view widgets until a project is clicked
        for widget in self.fileWidget:
            widget.hide()

        spacer = QSpacerItem(1, 1, QSizePolicy.Minimum, QSizePolicy.Expanding)
        self.controlsLayout.addItem(spacer)
        self.controls.setLayout(self.controlsLayout)

        # Scroll Area Properties.
        self.scroll = QScrollArea()
        self.scroll.setVerticalScrollBarPolicy(Qt.ScrollBarAlwaysOn)
        self.scroll.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOff)
        self.scroll.setWidgetResizable(True)
        self.scroll.setWidget(self.controls)

        # Search bar.
        self.searchbar = QLineEdit()
        self.searchbar.setStyleSheet(
            'background-color: white; color: black; font: Courier; padding: 6px;'
            'border-style: outset;'
            'border-width: 2px; border-radius: 6px;'
            'border-color: beige;')
        self.searchbar.textChanged.connect(self.update_display)

        # Adding Completer.
        self.completer = QCompleter(project_dict)
        self.completer.setCaseSensitivity(Qt.CaseInsensitive)
        self.searchbar.setCompleter(self.completer)

        #Add the items to VBoxLayout (applied to container widget)
        #which encompasses the whole window.
        container = QWidget()
        containerLayout = QVBoxLayout()
        containerLayout.addWidget(self.create)
        containerLayout.addWidget(self.view)
        containerLayout.addWidget(self.contacts)
        containerLayout.addWidget(self.NewContact)
        containerLayout.addWidget(self.searchbar)
        containerLayout.addWidget(self.scroll)

        container.setLayout(containerLayout)
        self.setCentralWidget(container)

        self.showMaximized()
        self.setWindowTitle('StudioHub')

        #when we initialise this is the current window
        #We will keep track of this and hide all other results outside of it
        self.currentWindow = self.projWidget