Ejemplo n.º 1
0
    def __init__(self, chum, initiated, mainwindow, parent=None):
        QtGui.QFrame.__init__(self, parent)
        self.setAttribute(QtCore.Qt.WA_QuitOnClose, False)
        self.setObjectName(chum.handle)
        self.setFocusPolicy(QtCore.Qt.ClickFocus)
        self.chum = chum
        self.mainwindow = mainwindow
        theme = self.mainwindow.theme
        self.resize(*theme["convo/size"])
        self.setStyleSheet("QFrame#%s { %s }" % (chum.handle, theme["convo/style"]))
        self.setWindowIcon(self.icon())
        self.setWindowTitle(self.title())

        t = Template(self.mainwindow.theme["convo/chumlabel/text"])
        
        self.chumLabel = QtGui.QLabel(t.safe_substitute(handle=chum.handle), self)
        self.chumLabel.setStyleSheet(self.mainwindow.theme["convo/chumlabel/style"])
        self.chumLabel.setAlignment(self.aligndict["h"][self.mainwindow.theme["convo/chumlabel/align/h"]] | self.aligndict["v"][self.mainwindow.theme["convo/chumlabel/align/v"]])
        self.chumLabel.setMaximumHeight(self.mainwindow.theme["convo/chumlabel/maxheight"])
        self.chumLabel.setMinimumHeight(self.mainwindow.theme["convo/chumlabel/minheight"])
        self.chumLabel.setSizePolicy(QtGui.QSizePolicy(QtGui.QSizePolicy.MinimumExpanding, QtGui.QSizePolicy.MinimumExpanding))
        self.textArea = PesterText(self.mainwindow.theme, self)
        self.textInput = PesterInput(self.mainwindow.theme, self)
        self.textInput.setFocus()

        self.connect(self.textInput, QtCore.SIGNAL('returnPressed()'),
                     self, QtCore.SLOT('sentMessage()'))

        self.layout = QtGui.QVBoxLayout()
        self.layout.addWidget(self.chumLabel)
        self.layout.addWidget(self.textArea)
        self.layout.addWidget(self.textInput)
        self.layout.setSpacing(0)
        margins = self.mainwindow.theme["convo/margins"]
        self.layout.setContentsMargins(margins["left"], margins["top"],
                                      margins["right"], margins["bottom"])
        
        self.setLayout(self.layout)

        self.optionsMenu = QtGui.QMenu(self)
        self.optionsMenu.setStyleSheet(self.mainwindow.theme["main/defaultwindow/style"])
        self.addChumAction = QtGui.QAction(self.mainwindow.theme["main/menus/rclickchumlist/addchum"], self)
        self.connect(self.addChumAction, QtCore.SIGNAL('triggered()'),
                     self, QtCore.SLOT('addThisChum()'))
        self.blockAction = QtGui.QAction(self.mainwindow.theme["main/menus/rclickchumlist/blockchum"], self)
        self.connect(self.blockAction, QtCore.SIGNAL('triggered()'),
                     self, QtCore.SLOT('blockThisChum()'))
        self.quirksOff = QtGui.QAction(self.mainwindow.theme["main/menus/rclickchumlist/quirksoff"], self)
        self.quirksOff.setCheckable(True)
        self.connect(self.quirksOff, QtCore.SIGNAL('toggled(bool)'),
                     self, QtCore.SLOT('toggleQuirks(bool)'))
        self.unblockchum = QtGui.QAction(self.mainwindow.theme["main/menus/rclickchumlist/unblockchum"], self)
        self.connect(self.unblockchum, QtCore.SIGNAL('triggered()'),
                     self, QtCore.SLOT('unblockChumSlot()'))

        self.optionsMenu.addAction(self.quirksOff)
        self.optionsMenu.addAction(self.addChumAction)
        self.optionsMenu.addAction(self.blockAction)

        self.chumopen = False
        self.applyquirks = True

        if parent:
            parent.addChat(self)
        if initiated:
            msg = self.mainwindow.profile().pestermsg(self.chum, QtGui.QColor(self.mainwindow.theme["convo/systemMsgColor"]), self.mainwindow.theme["convo/text/beganpester"])
            self.setChumOpen(True)
            self.textArea.append(convertTags(msg))
            self.mainwindow.chatlog.log(self.title(), msg)
        self.newmessage = False
        self.history = PesterHistory()
Ejemplo n.º 2
0
    def __init__(self, chum, initiated, mainwindow, parent=None):
        super(PesterConvo, self).__init__(parent)
        self.setAttribute(QtCore.Qt.WA_QuitOnClose, False)
        self.setObjectName(chum.handle)
        self.setFocusPolicy(QtCore.Qt.ClickFocus)
        self.chum = chum
        self.mainwindow = mainwindow
        theme = self.mainwindow.theme
        self.resize(*theme["convo/size"])
        self.setStyleSheet("QFrame#%s { %s }" %
                           (chum.handle, theme["convo/style"]))
        self.setWindowIcon(self.icon())
        self.setWindowTitle(self.title())

        t = Template(self.mainwindow.theme["convo/chumlabel/text"])

        self.chumLabel = QtGui.QLabel(t.safe_substitute(handle=chum.handle),
                                      self)
        self.chumLabel.setStyleSheet(
            self.mainwindow.theme["convo/chumlabel/style"])
        self.chumLabel.setAlignment(
            self.aligndict["h"][
                self.mainwindow.theme["convo/chumlabel/align/h"]]
            | self.aligndict["v"][
                self.mainwindow.theme["convo/chumlabel/align/v"]])
        self.chumLabel.setMaximumHeight(
            self.mainwindow.theme["convo/chumlabel/maxheight"])
        self.chumLabel.setMinimumHeight(
            self.mainwindow.theme["convo/chumlabel/minheight"])
        self.chumLabel.setSizePolicy(
            QtGui.QSizePolicy(QtGui.QSizePolicy.MinimumExpanding,
                              QtGui.QSizePolicy.MinimumExpanding))
        self.textArea = PesterText(self.mainwindow.theme, self)
        self.textInput = PesterInput(self.mainwindow.theme, self)
        self.textInput.setFocus()

        self.connect(self.textInput, QtCore.SIGNAL('returnPressed()'), self,
                     QtCore.SLOT('sentMessage()'))

        self.layout = QtGui.QVBoxLayout()
        self.layout.addWidget(self.chumLabel)
        self.layout.addWidget(self.textArea)
        self.layout.addWidget(self.textInput)
        self.layout.setSpacing(0)
        margins = self.mainwindow.theme["convo/margins"]
        self.layout.setContentsMargins(margins["left"], margins["top"],
                                       margins["right"], margins["bottom"])

        self.setLayout(self.layout)

        self.optionsMenu = QtGui.QMenu(self)
        self.optionsMenu.setStyleSheet(
            self.mainwindow.theme["main/defaultwindow/style"])
        self.addChumAction = QtGui.QAction(
            self.mainwindow.theme["main/menus/rclickchumlist/addchum"], self)
        self.connect(self.addChumAction, QtCore.SIGNAL('triggered()'), self,
                     QtCore.SLOT('addThisChum()'))
        self.blockAction = QtGui.QAction(
            self.mainwindow.theme["main/menus/rclickchumlist/blockchum"], self)
        self.connect(self.blockAction, QtCore.SIGNAL('triggered()'), self,
                     QtCore.SLOT('blockThisChum()'))
        self.quirksOff = QtGui.QAction(
            self.mainwindow.theme["main/menus/rclickchumlist/quirksoff"], self)
        self.quirksOff.setCheckable(True)
        self.connect(self.quirksOff, QtCore.SIGNAL('toggled(bool)'), self,
                     QtCore.SLOT('toggleQuirks(bool)'))
        self.oocToggle = QtGui.QAction(
            self.mainwindow.theme["main/menus/rclickchumlist/ooc"], self)
        self.oocToggle.setCheckable(True)
        self.connect(self.oocToggle, QtCore.SIGNAL('toggled(bool)'), self,
                     QtCore.SLOT('toggleOOC(bool)'))
        self.unblockchum = QtGui.QAction(
            self.mainwindow.theme["main/menus/rclickchumlist/unblockchum"],
            self)
        self.connect(self.unblockchum, QtCore.SIGNAL('triggered()'), self,
                     QtCore.SLOT('unblockChumSlot()'))
        self.reportchum = QtGui.QAction(
            self.mainwindow.theme["main/menus/rclickchumlist/report"], self)
        self.connect(self.reportchum, QtCore.SIGNAL('triggered()'), self,
                     QtCore.SLOT('reportThisChum()'))
        self.logchum = QtGui.QAction(
            self.mainwindow.theme["main/menus/rclickchumlist/viewlog"], self)
        self.connect(self.logchum, QtCore.SIGNAL('triggered()'), self,
                     QtCore.SLOT('openChumLogs()'))

        # For this, we'll want to use setChecked to toggle these so they match
        # the user's setting. Alternately (better), use a tristate checkbox, so
        # that they start semi-checked?
        # Easiest solution: Implement a 'Mute' option that overrides all
        # notifications for that window, save for mentions.
        # TODO: Look into setting up theme support here.
        self._beepToggle = QtGui.QAction("Beep on Message", self)
        self._beepToggle.setCheckable(True)
        self.connect(self._beepToggle, QtCore.SIGNAL('toggled(bool)'), self,
                     QtCore.SLOT('toggleBeep(bool)'))

        self._flashToggle = QtGui.QAction("Flash on Message", self)
        self._flashToggle.setCheckable(True)
        self.connect(self._flashToggle, QtCore.SIGNAL('toggled(bool)'), self,
                     QtCore.SLOT('toggleFlash(bool)'))

        self._muteToggle = QtGui.QAction("Mute Notifications", self)
        self._muteToggle.setCheckable(True)
        self.connect(self._muteToggle, QtCore.SIGNAL('toggled(bool)'), self,
                     QtCore.SLOT('toggleMute(bool)'))

        self.optionsMenu.addAction(self.quirksOff)
        self.optionsMenu.addAction(self.oocToggle)

        self.optionsMenu.addAction(self._beepToggle)
        self.optionsMenu.addAction(self._flashToggle)
        self.optionsMenu.addAction(self._muteToggle)

        self.optionsMenu.addAction(self.logchum)
        self.optionsMenu.addAction(self.addChumAction)
        self.optionsMenu.addAction(self.blockAction)
        self.optionsMenu.addAction(self.reportchum)

        self.chumopen = False
        self.applyquirks = True
        self.ooc = False

        self.always_beep = False
        self.always_flash = False
        self.notifications_muted = False

        if parent:
            parent.addChat(self)
        if initiated:
            msg = self.mainwindow.profile().pestermsg(
                self.chum,
                QtGui.QColor(self.mainwindow.theme["convo/systemMsgColor"]),
                self.mainwindow.theme["convo/text/beganpester"])
            self.setChumOpen(True)
            self.textArea.append(convertTags(msg))
            self.mainwindow.chatlog.log(self.title(), msg)
        self.newmessage = False
        self.history = PesterHistory()
Ejemplo n.º 3
0
    def __init__(self, channel, timestr, mainwindow, parent=None):
        QtGui.QFrame.__init__(self, parent)
        self.setAttribute(QtCore.Qt.WA_QuitOnClose, False)
        self.channel = channel
        self.setObjectName(self.channel)
        self.mainwindow = mainwindow
        self.time = TimeTracker(txt2delta(timestr))
        self.setWindowTitle(channel)
        self.channelLabel = QtGui.QLabel(self)
        self.channelLabel.setSizePolicy(QtGui.QSizePolicy(QtGui.QSizePolicy.MinimumExpanding, QtGui.QSizePolicy.Expanding))

        self.textArea = MemoText(self.mainwindow.theme, self)
        self.textInput = MemoInput(self.mainwindow.theme, self)
        self.textInput.setFocus()

        self.userlist = RightClickList(self)
        self.userlist.setSizePolicy(QtGui.QSizePolicy(QtGui.QSizePolicy.Fixed, QtGui.QSizePolicy.Expanding))
        self.userlist.optionsMenu = QtGui.QMenu(self)
        self.addchumAction = QtGui.QAction(self.mainwindow.theme["main/menus/rclickchumlist/addchum"], self)
        self.connect(self.addchumAction, QtCore.SIGNAL('triggered()'),
                     self, QtCore.SLOT('addChumSlot()'))
        self.banuserAction = QtGui.QAction(self.mainwindow.theme["main/menus/rclickchumlist/banuser"], self)
        self.connect(self.banuserAction, QtCore.SIGNAL('triggered()'),
                     self, QtCore.SLOT('banSelectedUser()'))
        self.opAction = QtGui.QAction(self.mainwindow.theme["main/menus/rclickchumlist/opuser"], self)
        self.connect(self.opAction, QtCore.SIGNAL('triggered()'),
                     self, QtCore.SLOT('opSelectedUser()'))
        self.userlist.optionsMenu.addAction(self.addchumAction)
        # ban & op list added if we are op

        self.optionsMenu = QtGui.QMenu(self)
        self.quirksOff = QtGui.QAction(self.mainwindow.theme["main/menus/rclickchumlist/quirksoff"], self)
        self.quirksOff.setCheckable(True)
        self.connect(self.quirksOff, QtCore.SIGNAL('toggled(bool)'),
                     self, QtCore.SLOT('toggleQuirks(bool)'))
        self.optionsMenu.addAction(self.quirksOff)

        self.timeslider = TimeSlider(QtCore.Qt.Horizontal, self)
        self.timeinput = TimeInput(self.timeslider, self)
        self.timeinput.setText(timestr)
        self.timeinput.setSlider()
        self.timetravel = QtGui.QPushButton("GO", self)
        self.timeclose = QtGui.QPushButton("CLOSE", self)
        self.timeswitchl = QtGui.QPushButton(self)
        self.timeswitchr = QtGui.QPushButton(self)

        self.connect(self.timetravel, QtCore.SIGNAL('clicked()'),
                     self, QtCore.SLOT('sendtime()'))
        self.connect(self.timeclose, QtCore.SIGNAL('clicked()'),
                     self, QtCore.SLOT('smashclock()'))
        self.connect(self.timeswitchl, QtCore.SIGNAL('clicked()'),
                     self, QtCore.SLOT('prevtime()'))
        self.connect(self.timeswitchr, QtCore.SIGNAL('clicked()'),
                     self, QtCore.SLOT('nexttime()'))

        self.times = {}

        self.initTheme(self.mainwindow.theme)

        # connect
        self.connect(self.textInput, QtCore.SIGNAL('returnPressed()'),
                     self, QtCore.SLOT('sentMessage()'))

        layout_0 = QtGui.QVBoxLayout()
        layout_0.addWidget(self.textArea)
        layout_0.addWidget(self.textInput)

        layout_1 = QtGui.QHBoxLayout()
        layout_1.addLayout(layout_0)
        layout_1.addWidget(self.userlist)

#        layout_1 = QtGui.QGridLayout()
#        layout_1.addWidget(self.timeslider, 0, 1, QtCore.Qt.AlignHCenter)
#        layout_1.addWidget(self.timeinput, 1, 0, 1, 3)
        layout_2 = QtGui.QHBoxLayout()
        layout_2.addWidget(self.timeslider)
        layout_2.addWidget(self.timeinput)
        layout_2.addWidget(self.timetravel)
        layout_2.addWidget(self.timeclose)
        layout_2.addWidget(self.timeswitchl)
        layout_2.addWidget(self.timeswitchr)
        self.layout = QtGui.QVBoxLayout()

        self.layout.addWidget(self.channelLabel)
        self.layout.addLayout(layout_1)
        self.layout.addLayout(layout_2)
        self.layout.setSpacing(0)
        margins = self.mainwindow.theme["memos/margins"]
        self.layout.setContentsMargins(margins["left"], margins["top"],
                                  margins["right"], margins["bottom"])
        
        self.setLayout(self.layout)

        if parent:
            parent.addChat(self)

        p = self.mainwindow.profile()
        timeGrammar = self.time.getGrammar()
        systemColor = QtGui.QColor(self.mainwindow.theme["memos/systemMsgColor"])
        msg = p.memoopenmsg(systemColor, self.time.getTime(), timeGrammar, self.mainwindow.theme["convo/text/openmemo"], self.channel)
        self.time.openCurrentTime()
        self.textArea.append(convertTags(msg))
        self.mainwindow.chatlog.log(self.channel, msg)

        self.op = False
        self.newmessage = False
        self.history = PesterHistory()
        self.applyquirks = True