1
0
mirror of https://github.com/qTox/qTox.git synced 2024-03-22 14:00:36 +08:00

tab completion for groupchats (fixes #486)

This commit is contained in:
dubslow 2014-10-20 05:01:22 -05:00
parent 6f316c549a
commit 5b85f79055
6 changed files with 23 additions and 8 deletions

View File

@ -138,7 +138,8 @@ HEADERS += src/widget/form/addfriendform.h \
src/widget/maskablepixmapwidget.h \
src/videosource.h \
src/cameraworker.h \
src/widget/videosurface.h
src/widget/videosurface.h \
src/widget/form/tabcompleter.h
SOURCES += \
src/widget/form/addfriendform.cpp \
@ -186,4 +187,5 @@ SOURCES += \
src/widget/maskablepixmapwidget.cpp \
src/cameraworker.cpp \
src/widget/videosurface.cpp \
src/netvideosource.cpp
src/netvideosource.cpp \
src/widget/form/tabcompleter.cpp

View File

@ -22,7 +22,7 @@
#include <QDateTime>
// Spacing in px inserted when the author of the last message changes
#define AUTHOR_CHANGE_SPACING 5
#define AUTHOR_CHANGE_SPACING 5 // why the hell is this a thing? surely the different font is enough?
class QLabel;
class QVBoxLayout;

View File

@ -15,6 +15,7 @@
*/
#include "groupchatform.h"
#include "tabcompleter.h"
#include "src/group.h"
#include "src/widget/groupwidget.h"
#include "src/widget/tool/chattextedit.h"
@ -33,6 +34,8 @@ GroupChatForm::GroupChatForm(Group* chatGroup)
namesList = new QLabel();
namesList->setObjectName("peersLabel");
tabber = new TabCompleter(msgEdit, group);
fileButton->setEnabled(false);
callButton->setVisible(false);
videoButton->setVisible(false);
@ -59,6 +62,8 @@ GroupChatForm::GroupChatForm(Group* chatGroup)
connect(sendButton, SIGNAL(clicked()), this, SLOT(onSendTriggered()));
connect(msgEdit, SIGNAL(enterPressed()), this, SLOT(onSendTriggered()));
connect(msgEdit, &ChatTextEdit::tabPressed, tabber, &TabCompleter::complete);
connect(msgEdit, &ChatTextEdit::keyPressed, tabber, &TabCompleter::reset);
setAcceptDrops(true);
}

View File

@ -21,6 +21,7 @@
namespace Ui {class MainWindow;}
class Group;
class TabCompleter;
class GroupChatForm : public GenericChatForm
{
@ -41,6 +42,7 @@ protected:
private:
Group* group;
QLabel *nusersLabel, *namesList;
TabCompleter* tabber;
};
#endif // GROUPCHATFORM_H

View File

@ -27,11 +27,15 @@ ChatTextEdit::ChatTextEdit(QWidget *parent) :
void ChatTextEdit::keyPressEvent(QKeyEvent * event)
{
int key = event->key();
if ((key == Qt::Key_Enter || key == Qt::Key_Return)
&& !(event->modifiers() && Qt::ShiftModifier))
{
if ((key == Qt::Key_Enter || key == Qt::Key_Return) && !(event->modifiers() && Qt::ShiftModifier))
emit enterPressed();
return;
else if (key == Qt::Key_Tab)
emit tabPressed();
else if (key == Qt::Key_Backspace) // because of the backspace() hack in tabber, we can't emit on these
QTextEdit::keyPressEvent(event);
else
{
emit keyPressed();
QTextEdit::keyPressEvent(event);
}
QTextEdit::keyPressEvent(event);
}

View File

@ -28,6 +28,8 @@ public:
signals:
void enterPressed();
void tabPressed();
void keyPressed();
public slots: