mirror of
https://github.com/JimmXinu/FanFicFare.git
synced 2025-12-06 17:02:43 +01:00
Add Ctrl-Enter to AddDialog, consolidating code with INIEdit
This commit is contained in:
parent
3b8d0f63d4
commit
11d3f601c9
1 changed files with 27 additions and 20 deletions
|
|
@ -189,12 +189,32 @@ class DroppableQTextEdit(QTextEdit):
|
||||||
else:
|
else:
|
||||||
return QTextEdit.insertFromMimeData(self, mime_data)
|
return QTextEdit.insertFromMimeData(self, mime_data)
|
||||||
|
|
||||||
class AddNewDialog(SizePersistedDialog):
|
class HotKeyedSizePersistedDialog(SizePersistedDialog):
|
||||||
|
|
||||||
|
def __init__(self, gui, save_size_name):
|
||||||
|
super(HotKeyedSizePersistedDialog,self).__init__(gui, save_size_name)
|
||||||
|
self.keys=dict()
|
||||||
|
|
||||||
|
def addCtrlKeyPress(self,key,func):
|
||||||
|
# print("addKeyPress: key(0x%x)"%key)
|
||||||
|
# print("control: 0x%x"%QtCore.Qt.ControlModifier)
|
||||||
|
self.keys[key]=func
|
||||||
|
|
||||||
|
def keyPressEvent(self, event):
|
||||||
|
# print("event: key(0x%x) modifiers(0x%x)"%(event.key(),event.modifiers()))
|
||||||
|
if (event.modifiers() & QtCore.Qt.ControlModifier) and event.key() in self.keys:
|
||||||
|
func = self.keys[event.key()]
|
||||||
|
return func()
|
||||||
|
else:
|
||||||
|
return super(HotKeyedSizePersistedDialog,self).keyPressEvent(event)
|
||||||
|
|
||||||
|
class AddNewDialog(HotKeyedSizePersistedDialog):
|
||||||
|
|
||||||
go_signal = pyqtSignal(object, object, object, object)
|
go_signal = pyqtSignal(object, object, object, object)
|
||||||
|
|
||||||
def __init__(self, gui, prefs, icon):
|
def __init__(self, gui, prefs, icon):
|
||||||
SizePersistedDialog.__init__(self, gui, 'fff:add new dialog')
|
super(AddNewDialog,self).__init__(gui, 'fff:add new dialog')
|
||||||
|
|
||||||
self.prefs = prefs
|
self.prefs = prefs
|
||||||
|
|
||||||
self.setMinimumWidth(300)
|
self.setMinimumWidth(300)
|
||||||
|
|
@ -333,6 +353,9 @@ class AddNewDialog(SizePersistedDialog):
|
||||||
self.button_box.rejected.connect(self.reject)
|
self.button_box.rejected.connect(self.reject)
|
||||||
self.l.addWidget(self.button_box)
|
self.l.addWidget(self.button_box)
|
||||||
|
|
||||||
|
self.addCtrlKeyPress(QtCore.Qt.Key_Return,self.ok_clicked)
|
||||||
|
self.addCtrlKeyPress(QtCore.Qt.Key_Enter,self.ok_clicked) # num pad
|
||||||
|
|
||||||
def click_show_download_options(self,x):
|
def click_show_download_options(self,x):
|
||||||
self.gbf.setVisible(x)
|
self.gbf.setVisible(x)
|
||||||
gprefs[show_download_options] = x
|
gprefs[show_download_options] = x
|
||||||
|
|
@ -498,7 +521,6 @@ class AddNewDialog(SizePersistedDialog):
|
||||||
def get_urlstext(self):
|
def get_urlstext(self):
|
||||||
return unicode(self.url.toPlainText())
|
return unicode(self.url.toPlainText())
|
||||||
|
|
||||||
|
|
||||||
class FakeLineEdit():
|
class FakeLineEdit():
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
pass
|
pass
|
||||||
|
|
@ -1374,7 +1396,7 @@ class QTextEditPlainPaste(QTextEdit):
|
||||||
else:
|
else:
|
||||||
QTextEdit.insertFromMimeData(self, mimeData)
|
QTextEdit.insertFromMimeData(self, mimeData)
|
||||||
|
|
||||||
class IniTextDialog(SizePersistedDialog):
|
class IniTextDialog(HotKeyedSizePersistedDialog):
|
||||||
|
|
||||||
def __init__(self, parent, text,
|
def __init__(self, parent, text,
|
||||||
icon=None, title=None, label=None,
|
icon=None, title=None, label=None,
|
||||||
|
|
@ -1382,9 +1404,7 @@ class IniTextDialog(SizePersistedDialog):
|
||||||
read_only=False,
|
read_only=False,
|
||||||
save_size_name='fff:ini text dialog',
|
save_size_name='fff:ini text dialog',
|
||||||
):
|
):
|
||||||
SizePersistedDialog.__init__(self, parent, save_size_name)
|
super(IniTextDialog,self).__init__(parent, save_size_name)
|
||||||
|
|
||||||
self.keys=dict()
|
|
||||||
|
|
||||||
self.l = QVBoxLayout()
|
self.l = QVBoxLayout()
|
||||||
self.setLayout(self.l)
|
self.setLayout(self.l)
|
||||||
|
|
@ -1485,19 +1505,6 @@ class IniTextDialog(SizePersistedDialog):
|
||||||
# print("call parent accept")
|
# print("call parent accept")
|
||||||
return SizePersistedDialog.accept(self)
|
return SizePersistedDialog.accept(self)
|
||||||
|
|
||||||
def addCtrlKeyPress(self,key,func):
|
|
||||||
# print("addKeyPress: key(0x%x)"%key)
|
|
||||||
# print("control: 0x%x"%QtCore.Qt.ControlModifier)
|
|
||||||
self.keys[key]=func
|
|
||||||
|
|
||||||
def keyPressEvent(self, event):
|
|
||||||
# print("event: key(0x%x) modifiers(0x%x)"%(event.key(),event.modifiers()))
|
|
||||||
if (event.modifiers() & QtCore.Qt.ControlModifier) and event.key() in self.keys:
|
|
||||||
func = self.keys[event.key()]
|
|
||||||
return func()
|
|
||||||
else:
|
|
||||||
return SizePersistedDialog.keyPressEvent(self, event)
|
|
||||||
|
|
||||||
def get_plain_text(self):
|
def get_plain_text(self):
|
||||||
return unicode(self.textedit.toPlainText())
|
return unicode(self.textedit.toPlainText())
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue