Made CTRL+PGUP/PGDN switch tabs.
This commit is contained in:
parent
8336efbab7
commit
51cc7abc12
2 changed files with 91 additions and 7 deletions
11
TODO.mkdn
11
TODO.mkdn
|
@ -31,8 +31,8 @@ Features
|
||||||
* Redo text processing in general
|
* Redo text processing in general
|
||||||
* Redo quirk processing (use pieces from Textsub if needed)
|
* Redo quirk processing (use pieces from Textsub if needed)
|
||||||
* LET PEOPLE TURN OFF HONKING - people already rename the soundfile and such to do this manually
|
* LET PEOPLE TURN OFF HONKING - people already rename the soundfile and such to do this manually
|
||||||
* Make CTRL+PGUP/PGDN switch memo/pester tabs
|
|
||||||
* Set up a simple function to display a traceback instead of silently moving on!
|
* Set up a simple function to display a traceback instead of silently moving on!
|
||||||
|
* Pare down the PesterMemo object so it inherits more things from PesterConvo *implicitly*
|
||||||
|
|
||||||
* SOONER OR LATER: Redo internal chum storage, centralize data into widely accessible manager objects, etc.
|
* SOONER OR LATER: Redo internal chum storage, centralize data into widely accessible manager objects, etc.
|
||||||
* Also: Overhaul settings storage. Bring it more in line with the system Textsub used (if feeling masochistic), but simpler.
|
* Also: Overhaul settings storage. Bring it more in line with the system Textsub used (if feeling masochistic), but simpler.
|
||||||
|
@ -58,10 +58,17 @@ Features
|
||||||
|
|
||||||
* Finish creating the sound wrapper. Just make it check what the type of sound needed is upon creation, and instantiate a private class based off of that.
|
* Finish creating the sound wrapper. Just make it check what the type of sound needed is upon creation, and instantiate a private class based off of that.
|
||||||
* There is basically no good way to do this without moving to Qt5. I might try that myself later, but that's a long-term goal.
|
* There is basically no good way to do this without moving to Qt5. I might try that myself later, but that's a long-term goal.
|
||||||
* Toggle individual tab flash / alert sounds (from the same right-click memo that lets us toggle OOC)
|
|
||||||
* Make it possible to test quirk things and such without connecting? This'd be hard to separate out, but useful.
|
* Make it possible to test quirk things and such without connecting? This'd be hard to separate out, but useful.
|
||||||
* Right-click Time entry field to see those used? (Replace left/right buttons?)
|
* Right-click Time entry field to see those used? (Replace left/right buttons?)
|
||||||
|
|
||||||
|
Todo/Done
|
||||||
|
----
|
||||||
|
* Fix parser text-loss bug that plagues everyone (especially Chumdroid users)
|
||||||
|
* Make /me messages that cut continue into more /me messages
|
||||||
|
* Make sound work on Windows through QSound (disables volume control)
|
||||||
|
* Toggle individual tab flash / alert sounds (from the same right-click memo that lets us toggle OOC)
|
||||||
|
* Make CTRL+PGUP/PGDN switch memo/pester tabs
|
||||||
|
|
||||||
Debugging
|
Debugging
|
||||||
----
|
----
|
||||||
* Make small, simplistic windows that allow the viewing of internal variables pertaining to things like set quirks, users present, etc.
|
* Make small, simplistic windows that allow the viewing of internal variables pertaining to things like set quirks, users present, etc.
|
||||||
|
|
87
convo.py
87
convo.py
|
@ -79,6 +79,7 @@ class PesterTabWindow(QtGui.QFrame):
|
||||||
return True
|
return True
|
||||||
|
|
||||||
def keyPressEvent(self, event):
|
def keyPressEvent(self, event):
|
||||||
|
# TODO: Clean this up. Our text areas now call this.
|
||||||
keypress = event.key()
|
keypress = event.key()
|
||||||
mods = event.modifiers()
|
mods = event.modifiers()
|
||||||
if ((mods & QtCore.Qt.ControlModifier) and
|
if ((mods & QtCore.Qt.ControlModifier) and
|
||||||
|
@ -92,6 +93,37 @@ class PesterTabWindow(QtGui.QFrame):
|
||||||
nexti = (self.tabIndices[self.currentConvo.title()] + 1) % self.tabs.count()
|
nexti = (self.tabIndices[self.currentConvo.title()] + 1) % self.tabs.count()
|
||||||
self.tabs.setCurrentIndex(nexti)
|
self.tabs.setCurrentIndex(nexti)
|
||||||
|
|
||||||
|
elif (mods == QtCore.Qt.ControlModifier and
|
||||||
|
keypress in (QtCore.Qt.Key_PageUp, QtCore.Qt.Key_PageDown)):
|
||||||
|
if keypress == QtCore.Qt.Key_PageUp:
|
||||||
|
direction = 1
|
||||||
|
elif keypress == QtCore.Qt.Key_PageDown:
|
||||||
|
direction = -1
|
||||||
|
# ...Processing...
|
||||||
|
tabs = self.tabs
|
||||||
|
# Pick our new index by sliding up or down the tab range.
|
||||||
|
# NOTE: This feels like it could error. In fact, it /will/ if
|
||||||
|
# there are no tabs, but...that shouldn't happen, should it?
|
||||||
|
# There are probably other scenarios, too, so we'll have to
|
||||||
|
# check on this later.
|
||||||
|
#
|
||||||
|
# Calculate the new index.
|
||||||
|
ct = tabs.count()
|
||||||
|
cind = tabs.currentIndex()
|
||||||
|
nind = cind + direction
|
||||||
|
if nind > (ct - 1):
|
||||||
|
# The new index would be higher than the maximum; loop.
|
||||||
|
nind = nind % ct
|
||||||
|
# Otherwise, negative syntax should get it for us.
|
||||||
|
nind = range(ct)[nind]
|
||||||
|
# Change to the selected tab.
|
||||||
|
# Note that this will send out the usual callbacks that handle
|
||||||
|
# focusing and such.
|
||||||
|
tabs.setCurrentIndex(nind)
|
||||||
|
# Ensure this doesn't fall through normally.
|
||||||
|
# (Not an issue here, but this used to be on a TextArea.)
|
||||||
|
return
|
||||||
|
|
||||||
def closeSoft(self):
|
def closeSoft(self):
|
||||||
self.softclose = True
|
self.softclose = True
|
||||||
self.close()
|
self.close()
|
||||||
|
@ -391,11 +423,51 @@ class PesterText(QtGui.QTextEdit):
|
||||||
QtGui.QTextEdit.focusInEvent(self, event)
|
QtGui.QTextEdit.focusInEvent(self, event)
|
||||||
|
|
||||||
def keyPressEvent(self, event):
|
def keyPressEvent(self, event):
|
||||||
if hasattr(self.parent(), 'textInput'):
|
# First parent is the PesterConvo containing this.
|
||||||
if event.key() not in [QtCore.Qt.Key_PageUp, QtCore.Qt.Key_PageDown, \
|
# Second parent is the PesterTabWindow containing *it*.
|
||||||
QtCore.Qt.Key_Up, QtCore.Qt.Key_Down]:
|
pass_to_super = (QtCore.Qt.Key_PageUp, QtCore.Qt.Key_PageDown,
|
||||||
self.parent().textInput.keyPressEvent(event)
|
QtCore.Qt.Key_Up, QtCore.Qt.Key_Down)
|
||||||
QtGui.QTextEdit.keyPressEvent(self, event)
|
parent = self.parent()
|
||||||
|
key = event.key()
|
||||||
|
keymods = event.modifiers()
|
||||||
|
if hasattr(parent, 'textInput') and key not in pass_to_super:
|
||||||
|
parent.textInput.keyPressEvent(event)
|
||||||
|
|
||||||
|
#~# Check if we can switch tabs here.
|
||||||
|
#~tabwindow = parent.parent()
|
||||||
|
#~if tabwindow and keymods == QtCore.Qt.ControlModifier:
|
||||||
|
#~ direction = 0
|
||||||
|
#~ if key == QtCore.Qt.Key_PageUp:
|
||||||
|
#~ direction = 1
|
||||||
|
#~ elif key == QtCore.Qt.Key_PageDown:
|
||||||
|
#~ direction = -1
|
||||||
|
#~ if direction:
|
||||||
|
#~ # ...Processing...
|
||||||
|
#~ tabs = tabwindow.tabs
|
||||||
|
#~ # Pick our new index by sliding up or down the tab range.
|
||||||
|
#~ # NOTE: This feels like it could error. In fact, it /will/ if
|
||||||
|
#~ # there are no tabs, but...that shouldn't happen, should it?
|
||||||
|
#~ # There are probably other scenarios, too, so we'll have to
|
||||||
|
#~ # check on this later.
|
||||||
|
#~ #
|
||||||
|
#~ # Calculate the new index.
|
||||||
|
#~ ct = tabs.count()
|
||||||
|
#~ cind = tabs.currentIndex()
|
||||||
|
#~ nind = cind + direction
|
||||||
|
#~ if nind > (ct - 1):
|
||||||
|
#~ # The new index would be higher than the maximum; loop.
|
||||||
|
#~ nind = nind % ct
|
||||||
|
#~ # Otherwise, negative syntax should get it for us.
|
||||||
|
#~ nind = range(ct)[nind]
|
||||||
|
#~ # Change to the selected tab.
|
||||||
|
#~ # Note that this will send out the usual callbacks that handle
|
||||||
|
#~ # focusing and such.
|
||||||
|
#~ tabs.setCurrentIndex(nind)
|
||||||
|
#~ # Ensure this doesn't fall through normally.
|
||||||
|
#~ return
|
||||||
|
|
||||||
|
# Pass to the normal handler.
|
||||||
|
super(QtGui.QTextEdit, self).keyPressEvent(event)
|
||||||
|
|
||||||
def mousePressEvent(self, event):
|
def mousePressEvent(self, event):
|
||||||
if event.button() == QtCore.Qt.LeftButton:
|
if event.button() == QtCore.Qt.LeftButton:
|
||||||
|
@ -469,6 +541,11 @@ class PesterText(QtGui.QTextEdit):
|
||||||
del self.sending
|
del self.sending
|
||||||
|
|
||||||
class PesterInput(QtGui.QLineEdit):
|
class PesterInput(QtGui.QLineEdit):
|
||||||
|
# NOTE: I have ABSOLUTELY NO IDEA HOW, but using super() here breaks this
|
||||||
|
# class's keyPressEvent so that no input can be provided. I am *very*
|
||||||
|
# confused.
|
||||||
|
# For the sake of safety, I've avoided it here until I know what's going
|
||||||
|
# on.
|
||||||
def __init__(self, theme, parent=None):
|
def __init__(self, theme, parent=None):
|
||||||
QtGui.QLineEdit.__init__(self, parent)
|
QtGui.QLineEdit.__init__(self, parent)
|
||||||
self.setStyleSheet(theme["convo/input/style"])
|
self.setStyleSheet(theme["convo/input/style"])
|
||||||
|
|
Loading…
Reference in a new issue