Skip to content

Commit

Permalink
Removing useless buttons in the Qt4 GUI and implemented enter shortcut
Browse files Browse the repository at this point in the history
Signed-off-by: Dario Freddi <drf54321@gmail.com>
  • Loading branch information
drf committed Oct 9, 2008
1 parent 44c83cd commit d2648ed
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 49 deletions.
32 changes: 1 addition & 31 deletions amsn2/gui/front_ends/qt4/chatWindow.ui
Expand Up @@ -63,7 +63,7 @@
</widget>
</widget>
<widget class="QWidget" name="layoutWidget" >
<layout class="QVBoxLayout" name="verticalLayout_2" >
<layout class="QVBoxLayout" name="inputLayout" >
<item>
<widget class="QToolBar" name="toolBar" >
<property name="minimumSize" >
Expand Down Expand Up @@ -103,36 +103,6 @@
<addaction name="actionNudge" />
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout" >
<item>
<widget class="QTextEdit" name="inputWidget" >
<property name="enabled" >
<bool>true</bool>
</property>
<property name="minimumSize" >
<size>
<width>0</width>
<height>0</height>
</size>
</property>
<property name="baseSize" >
<size>
<width>0</width>
<height>40</height>
</size>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="sendButton" >
<property name="text" >
<string>Send Message</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
</widget>
Expand Down
19 changes: 18 additions & 1 deletion amsn2/gui/front_ends/qt4/chat_window.py
Expand Up @@ -22,8 +22,22 @@

from PyQt4.QtCore import *
from PyQt4.QtGui import *
from PyQt4 import *
from ui_chatWindow import Ui_ChatWindow
from amsn2.core.views import ContactView, StringView

class InputWidget(QTextEdit):
def __init__(self, Parent = None):
QTextEdit.__init__(self, Parent)
self.setTextInteractionFlags(Qt.TextEditorInteraction)

def keyPressEvent(self, event):
print "key pressed:" + str(event.key())
if event.key() == Qt.Key_Enter or event.key() == Qt.Key_Return:
print "handle!!"
self.emit(SIGNAL("enterKeyTriggered()"))
else:
QTextEdit.keyPressEvent(self, event)

class aMSNChatWindow(QTabWidget, base.aMSNChatWindow):
def __init__(self, amsn_core, Parent=None):
Expand All @@ -42,13 +56,15 @@ def __init__(self, amsn_conversation, Parent=None):
self._amsn_conversation = amsn_conversation
self.ui = Ui_ChatWindow()
self.ui.setupUi(self)
self.ui.inputWidget = InputWidget(self)
self.ui.inputLayout.addWidget(self.ui.inputWidget)
self._statusBar = QStatusBar(self)
self.layout().addWidget(self._statusBar)

self.loadEmoticonList()

QObject.connect(self.ui.inputWidget, SIGNAL("textChanged()"), self.processInput)
QObject.connect(self.ui.sendButton, SIGNAL("clicked()"), self.__sendMessage)
QObject.connect(self.ui.inputWidget, SIGNAL("enterKeyTriggered()"), self.__sendMessage)
QObject.connect(self.ui.actionInsert_Emoticon, SIGNAL("triggered()"), self.showEmoticonList)
self.enterShortcut = QShortcut(QKeySequence("Enter"), self.ui.inputWidget)
self.nudgeShortcut = QShortcut(QKeySequence("Ctrl+G"), self)
Expand Down Expand Up @@ -141,4 +157,5 @@ def onMessageReceived(self, sender, message):
def onNudgeReceived(self, sender):
self.ui.textEdit.append(unicode("<b>"+sender.name.toString()+" "+self.tr("sent you a nudge!")+("</b>")))
pass


21 changes: 4 additions & 17 deletions amsn2/gui/front_ends/qt4/ui_chatWindow.py
Expand Up @@ -2,7 +2,7 @@

# Form implementation generated from reading ui file 'chatWindow.ui'
#
# Created: Tue Oct 7 00:36:00 2008
# Created: Thu Oct 9 22:21:07 2008
# by: PyQt4 UI code generator 4.4.3
#
# WARNING! All changes made in this file will be lost!
Expand Down Expand Up @@ -39,8 +39,8 @@ def setupUi(self, ChatWindow):
self.verticalLayout.addWidget(self.label_2)
self.layoutWidget1 = QtGui.QWidget(self.splitter_2)
self.layoutWidget1.setObjectName("layoutWidget1")
self.verticalLayout_2 = QtGui.QVBoxLayout(self.layoutWidget1)
self.verticalLayout_2.setObjectName("verticalLayout_2")
self.inputLayout = QtGui.QVBoxLayout(self.layoutWidget1)
self.inputLayout.setObjectName("inputLayout")
self.toolBar = QtGui.QToolBar(self.layoutWidget1)
self.toolBar.setMinimumSize(QtCore.QSize(0, 32))
self.toolBar.setMaximumSize(QtCore.QSize(16777215, 32))
Expand All @@ -49,19 +49,7 @@ def setupUi(self, ChatWindow):
self.toolBar.setAcceptDrops(True)
self.toolBar.setMovable(False)
self.toolBar.setObjectName("toolBar")
self.verticalLayout_2.addWidget(self.toolBar)
self.horizontalLayout = QtGui.QHBoxLayout()
self.horizontalLayout.setObjectName("horizontalLayout")
self.inputWidget = QtGui.QTextEdit(self.layoutWidget1)
self.inputWidget.setEnabled(True)
self.inputWidget.setMinimumSize(QtCore.QSize(0, 0))
self.inputWidget.setBaseSize(QtCore.QSize(0, 40))
self.inputWidget.setObjectName("inputWidget")
self.horizontalLayout.addWidget(self.inputWidget)
self.sendButton = QtGui.QPushButton(self.layoutWidget1)
self.sendButton.setObjectName("sendButton")
self.horizontalLayout.addWidget(self.sendButton)
self.verticalLayout_2.addLayout(self.horizontalLayout)
self.inputLayout.addWidget(self.toolBar)
self.verticalLayout_3.addWidget(self.splitter_2)
self.actionInsert_Emoticon = QtGui.QAction(ChatWindow)
self.actionInsert_Emoticon.setObjectName("actionInsert_Emoticon")
Expand All @@ -78,7 +66,6 @@ def retranslateUi(self, ChatWindow):
self.label.setText(QtGui.QApplication.translate("ChatWindow", "Something here...", None, QtGui.QApplication.UnicodeUTF8))
self.label_2.setText(QtGui.QApplication.translate("ChatWindow", "Contact image", None, QtGui.QApplication.UnicodeUTF8))
self.toolBar.setWindowTitle(QtGui.QApplication.translate("ChatWindow", "Quick Actions", None, QtGui.QApplication.UnicodeUTF8))
self.sendButton.setText(QtGui.QApplication.translate("ChatWindow", "Send Message", None, QtGui.QApplication.UnicodeUTF8))
self.actionInsert_Emoticon.setText(QtGui.QApplication.translate("ChatWindow", "Insert Emoticon", None, QtGui.QApplication.UnicodeUTF8))
self.actionNudge.setText(QtGui.QApplication.translate("ChatWindow", "Nudge", None, QtGui.QApplication.UnicodeUTF8))

0 comments on commit d2648ed

Please sign in to comment.