mirror of
https://github.com/qTox/qTox.git
synced 2024-03-22 14:00:36 +08:00
Merge branch 'pr488'
This commit is contained in:
commit
b6d581a462
8
qtox.pro
8
qtox.pro
|
@ -135,10 +135,12 @@ HEADERS += src/widget/form/addfriendform.h \
|
|||
src/widget/tool/chatactions/filetransferaction.h \
|
||||
src/widget/tool/chatactions/systemmessageaction.h \
|
||||
src/widget/tool/chatactions/actionaction.h \
|
||||
src/widget/tool/chatactions/alertaction.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 \
|
||||
|
@ -183,7 +185,9 @@ SOURCES += \
|
|||
src/widget/tool/chatactions/filetransferaction.cpp \
|
||||
src/widget/tool/chatactions/systemmessageaction.cpp \
|
||||
src/widget/tool/chatactions/actionaction.cpp \
|
||||
src/widget/tool/chatactions/alertaction.cpp \
|
||||
src/widget/maskablepixmapwidget.cpp \
|
||||
src/cameraworker.cpp \
|
||||
src/widget/videosurface.cpp \
|
||||
src/netvideosource.cpp
|
||||
src/netvideosource.cpp \
|
||||
src/widget/form/tabcompleter.cpp
|
||||
|
|
|
@ -70,6 +70,7 @@ QColor Style::getColor(Style::ColorPalette entry)
|
|||
QColor("#414141").lighter(120),
|
||||
QColor("#d1d1d1"),
|
||||
QColor("#ffffff"),
|
||||
QColor("#ff7700"),
|
||||
};
|
||||
|
||||
return palette[entry];
|
||||
|
@ -108,6 +109,7 @@ QString Style::resolve(QString qss)
|
|||
{"@mediumGreyLight", getColor(MediumGreyLight).name()},
|
||||
{"@lightGrey", getColor(LightGrey).name()},
|
||||
{"@white", getColor(White).name()},
|
||||
{"@orange", getColor(Orange).name()},
|
||||
|
||||
// fonts
|
||||
{"@extraBig", qssifyFont(getFont(ExtraBig))},
|
||||
|
|
|
@ -37,6 +37,7 @@ public:
|
|||
MediumGreyLight,
|
||||
LightGrey,
|
||||
White,
|
||||
Orange,
|
||||
};
|
||||
|
||||
enum Font
|
||||
|
|
|
@ -87,7 +87,7 @@ void ChatForm::onSendTriggered()
|
|||
if (msg.isEmpty())
|
||||
return;
|
||||
QString name = Widget::getInstance()->getUsername();
|
||||
if (msg.startsWith("/me "))
|
||||
if (msg.startsWith("/me"))
|
||||
{
|
||||
msg = msg.right(msg.length() - 4);
|
||||
addMessage(name, msg, true);
|
||||
|
|
|
@ -25,6 +25,7 @@
|
|||
#include "src/widget/tool/chatactions/messageaction.h"
|
||||
#include "src/widget/tool/chatactions/systemmessageaction.h"
|
||||
#include "src/widget/tool/chatactions/actionaction.h"
|
||||
#include "src/widget/tool/chatactions/alertaction.h"
|
||||
#include "src/widget/chatareawidget.h"
|
||||
#include "src/widget/tool/chattextedit.h"
|
||||
#include "src/widget/maskablepixmapwidget.h"
|
||||
|
@ -173,7 +174,7 @@ void GenericChatForm::addMessage(QString author, QString message, bool isAction,
|
|||
QString date = datetime.toString(Settings::getInstance().getTimestampFormat());
|
||||
bool isMe = (author == Widget::getInstance()->getUsername());
|
||||
|
||||
if (!isAction && message.startsWith("/me "))
|
||||
if (!isAction && message.startsWith("/me"))
|
||||
{ // always render actions regardless of what core thinks
|
||||
isAction = true;
|
||||
message = message.right(message.length()-4);
|
||||
|
@ -193,6 +194,13 @@ void GenericChatForm::addMessage(QString author, QString message, bool isAction,
|
|||
previousName = author;
|
||||
}
|
||||
|
||||
void GenericChatForm::addAlertMessage(QString author, QString message, QDateTime datetime)
|
||||
{
|
||||
QString date = datetime.toString(Settings::getInstance().getTimestampFormat());
|
||||
chatWidget->insertMessage(new AlertAction(author, message, date));
|
||||
previousName = author;
|
||||
}
|
||||
|
||||
void GenericChatForm::onEmoteButtonClicked()
|
||||
{
|
||||
// don't show the smiley selection widget if there are no smileys available
|
||||
|
|
|
@ -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;
|
||||
|
@ -45,6 +45,7 @@ public:
|
|||
virtual void setName(const QString &newName);
|
||||
virtual void show(Ui::MainWindow &ui);
|
||||
void addMessage(QString author, QString message, bool isAction = false, QDateTime datetime=QDateTime::currentDateTime());
|
||||
void addAlertMessage(QString author, QString message, QDateTime datetime=QDateTime::currentDateTime());
|
||||
void addSystemInfoMessage(const QString &message, const QString &type, const QDateTime &datetime=QDateTime::currentDateTime());
|
||||
int getNumberOfMessages();
|
||||
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
|
122
src/widget/form/tabcompleter.cpp
Normal file
122
src/widget/form/tabcompleter.cpp
Normal file
|
@ -0,0 +1,122 @@
|
|||
/*
|
||||
Copyright (C) 2005-2014 by the Quassel Project and Project Tox
|
||||
devel@quassel-irc.org and https://tox.im
|
||||
|
||||
This file is part of qTox, a Qt-based graphical interface for Tox.
|
||||
|
||||
This program is libre software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
|
||||
See the COPYING file for more details.
|
||||
*/
|
||||
|
||||
/* This file was taken from the Quassel IRC client source (src/uisupport), and
|
||||
was greatly simplified for use in qTox. */
|
||||
|
||||
#include "tabcompleter.h"
|
||||
#include "src/core.h"
|
||||
#include "src/group.h"
|
||||
#include "src/widget/tool/chattextedit.h"
|
||||
#include <QRegExp>
|
||||
#include <QKeyEvent>
|
||||
|
||||
const QString TabCompleter::nickSuffix = QString(": ");
|
||||
|
||||
TabCompleter::TabCompleter(ChatTextEdit* msgEdit, Group* group)
|
||||
: QObject(msgEdit), msgEdit(msgEdit), group(group), enabled(false)
|
||||
{
|
||||
}
|
||||
|
||||
/* from quassel/src/uisupport/multilineedit.h
|
||||
// Compatibility methods with the rest of the classes which still expect this to be a QLineEdit
|
||||
inline QString text() const { return toPlainText(); }
|
||||
inline QString html() const { return toHtml(); }
|
||||
inline int cursorPosition() const { return textCursor().position(); }
|
||||
inline void insert(const QString &newText) { insertPlainText(newText); }
|
||||
inline void backspace() { keyPressEvent(new QKeyEvent(QEvent::KeyPress, Qt::Key_Backspace, Qt::NoModifier)); }
|
||||
*/
|
||||
|
||||
void TabCompleter::buildCompletionList()
|
||||
{
|
||||
// ensure a safe state in case we return early.
|
||||
completionMap.clear();
|
||||
nextCompletion = completionMap.begin();
|
||||
|
||||
// split the string on the given RE (not chars, nums or braces/brackets) and take the last section
|
||||
QString tabAbbrev = msgEdit->toPlainText().left(msgEdit->textCursor().position()).section(QRegExp("[^\\w\\d-_\\[\\]{}|`^.\\\\]"), -1, -1);
|
||||
// that section is then used as the completion regex
|
||||
QRegExp regex(QString("^[-_\\[\\]{}|`^.\\\\]*").append(QRegExp::escape(tabAbbrev)), Qt::CaseInsensitive);
|
||||
|
||||
for(auto name : group->peers.values())
|
||||
if (regex.indexIn(name) > -1)
|
||||
completionMap[name.toLower()] = name;
|
||||
|
||||
nextCompletion = completionMap.begin();
|
||||
lastCompletionLength = tabAbbrev.length();
|
||||
}
|
||||
|
||||
|
||||
void TabCompleter::complete()
|
||||
{
|
||||
if (!enabled) {
|
||||
buildCompletionList();
|
||||
enabled = true;
|
||||
}
|
||||
|
||||
if (nextCompletion != completionMap.end()) {
|
||||
// clear previous completion
|
||||
for (int i = 0; i < lastCompletionLength; i++) {
|
||||
msgEdit->keyPressEvent(new QKeyEvent(QEvent::KeyPress, Qt::Key_Backspace, Qt::NoModifier));
|
||||
}
|
||||
|
||||
// insert completion
|
||||
msgEdit->insertPlainText(*nextCompletion);
|
||||
|
||||
// remember charcount to delete next time and advance to next completion
|
||||
lastCompletionLength = nextCompletion->length();
|
||||
nextCompletion++;
|
||||
|
||||
// we're completing the first word of the line
|
||||
if (msgEdit->textCursor().position() == lastCompletionLength) {
|
||||
msgEdit->insertPlainText(nickSuffix);
|
||||
lastCompletionLength += nickSuffix.length();
|
||||
}
|
||||
}
|
||||
else { // we're at the end of the list -> start over again
|
||||
if (!completionMap.isEmpty()) {
|
||||
nextCompletion = completionMap.begin();
|
||||
complete();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void TabCompleter::reset()
|
||||
{
|
||||
enabled = false;
|
||||
}
|
||||
|
||||
// this determines the sort order
|
||||
bool TabCompleter::SortableString::operator<(const SortableString &other) const
|
||||
{
|
||||
QString name = Core::getInstance()->getUsername();
|
||||
if (this->contents == name)
|
||||
return false;
|
||||
else if (other.contents == name)
|
||||
return true;
|
||||
|
||||
/* QDateTime thisTime = thisUser->lastChannelActivity(_currentBufferId);
|
||||
QDateTime thatTime = thatUser->lastChannelActivity(_currentBufferId);
|
||||
|
||||
|
||||
if (thisTime.isValid() || thatTime.isValid())
|
||||
return thisTime > thatTime;
|
||||
*/ // this could be a useful feature at some point
|
||||
|
||||
return QString::localeAwareCompare(this->contents, other.contents) < 0;
|
||||
}
|
61
src/widget/form/tabcompleter.h
Normal file
61
src/widget/form/tabcompleter.h
Normal file
|
@ -0,0 +1,61 @@
|
|||
/*
|
||||
Copyright (C) 2005-2014 by the Quassel Project and Project Tox
|
||||
devel@quassel-irc.org and https://tox.im
|
||||
|
||||
This file is part of qTox, a Qt-based graphical interface for Tox.
|
||||
|
||||
This program is libre software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
|
||||
See the COPYING file for more details.
|
||||
*/
|
||||
|
||||
/* This file was taken from the Quassel IRC client source (src/uisupport), and
|
||||
was greatly simplified for use in qTox. */
|
||||
|
||||
#ifndef TABCOMPLETER_H
|
||||
#define TABCOMPLETER_H
|
||||
|
||||
#include <QString>
|
||||
#include <QMap>
|
||||
#include <QObject> // I'm really confused why I need this
|
||||
|
||||
class ChatTextEdit;
|
||||
class Group;
|
||||
|
||||
class TabCompleter : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit TabCompleter(ChatTextEdit* msgEdit, Group* group);
|
||||
|
||||
public slots:
|
||||
void complete();
|
||||
void reset();
|
||||
|
||||
private:
|
||||
struct SortableString {
|
||||
inline SortableString(const QString &n) { contents = n; }
|
||||
bool operator<(const SortableString &other) const;
|
||||
QString contents;
|
||||
};
|
||||
|
||||
ChatTextEdit* msgEdit;
|
||||
Group* group;
|
||||
bool enabled;
|
||||
const static QString nickSuffix;
|
||||
|
||||
QMap<SortableString, QString> completionMap;
|
||||
QMap<SortableString, QString>::Iterator nextCompletion;
|
||||
int lastCompletionLength;
|
||||
|
||||
void buildCompletionList();
|
||||
};
|
||||
|
||||
|
||||
#endif
|
|
@ -15,11 +15,10 @@
|
|||
*/
|
||||
|
||||
#include "actionaction.h"
|
||||
#include "src/misc/smileypack.h"
|
||||
#include <QDebug>
|
||||
|
||||
ActionAction::ActionAction(const QString &author, const QString &message, const QString &date, const bool& me) :
|
||||
ChatAction(me, author, date),
|
||||
message(message)
|
||||
ActionAction::ActionAction(const QString &author, QString message, const QString &date, const bool& me) :
|
||||
MessageAction(author, author+" "+message, date, me)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -45,24 +44,5 @@ QString ActionAction::getName()
|
|||
|
||||
QString ActionAction::getMessage()
|
||||
{
|
||||
QString message_ = SmileyPack::getInstance().smileyfied(toHtmlChars(message));
|
||||
|
||||
// detect urls
|
||||
QRegExp exp("(www\\.|http[s]?:\\/\\/|ftp:\\/\\/)\\S+");
|
||||
int offset = 0;
|
||||
while ((offset = exp.indexIn(message_, offset)) != -1)
|
||||
{
|
||||
QString url = exp.cap();
|
||||
|
||||
// add scheme if not specified
|
||||
if (exp.cap(1) == "www.")
|
||||
url.prepend("http://");
|
||||
|
||||
QString htmledUrl = QString("<a href=\"%1\">%1</a>").arg(url);
|
||||
message_.replace(offset, exp.cap().length(), htmledUrl);
|
||||
|
||||
offset += htmledUrl.length();
|
||||
}
|
||||
|
||||
return QString("<div class=action>%1 %2</div>").arg(name).arg(message_);
|
||||
return MessageAction::getMessage("action");
|
||||
}
|
||||
|
|
|
@ -17,12 +17,12 @@
|
|||
#ifndef ACTIONACTION_H
|
||||
#define ACTIONACTION_H
|
||||
|
||||
#include "chataction.h"
|
||||
#include "messageaction.h"
|
||||
|
||||
class ActionAction : public ChatAction
|
||||
class ActionAction : public MessageAction
|
||||
{
|
||||
public:
|
||||
ActionAction(const QString &author, const QString &message, const QString& date, const bool&);
|
||||
ActionAction(const QString &author, QString message, const QString& date, const bool&);
|
||||
virtual ~ActionAction(){;}
|
||||
virtual QString getMessage();
|
||||
virtual QString getName();
|
||||
|
|
47
src/widget/tool/chatactions/alertaction.cpp
Normal file
47
src/widget/tool/chatactions/alertaction.cpp
Normal file
|
@ -0,0 +1,47 @@
|
|||
/*
|
||||
Copyright (C) 2014 by Project Tox <https://tox.im>
|
||||
|
||||
This file is part of qTox, a Qt-based graphical interface for Tox.
|
||||
|
||||
This program is libre software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
|
||||
See the COPYING file for more details.
|
||||
*/
|
||||
|
||||
#include "alertaction.h"
|
||||
|
||||
AlertAction::AlertAction(const QString &author, const QString &message, const QString &date) :
|
||||
MessageAction(author, message, date, false)
|
||||
{
|
||||
}
|
||||
|
||||
void AlertAction::setup(QTextCursor cursor, QTextEdit *)
|
||||
{
|
||||
// When this function is called, we're supposed to only update ourselve when needed
|
||||
// Nobody should ask us to do anything with our content, we're on our own
|
||||
// Except we never udpate on our own, so we can safely free our resources
|
||||
|
||||
(void) cursor;
|
||||
message.clear();
|
||||
message.squeeze();
|
||||
name.clear();
|
||||
name.squeeze();
|
||||
date.clear();
|
||||
date.squeeze();
|
||||
}
|
||||
/*
|
||||
QString AlertAction::getName()
|
||||
{
|
||||
return QString("<div class=%1>%2</div>").arg("alert_name").arg(toHtmlChars(name));
|
||||
}
|
||||
*/
|
||||
QString AlertAction::getMessage()
|
||||
{
|
||||
return MessageAction::getMessage("alert");
|
||||
}
|
35
src/widget/tool/chatactions/alertaction.h
Normal file
35
src/widget/tool/chatactions/alertaction.h
Normal file
|
@ -0,0 +1,35 @@
|
|||
/*
|
||||
Copyright (C) 2014 by Project Tox <https://tox.im>
|
||||
|
||||
This file is part of qTox, a Qt-based graphical interface for Tox.
|
||||
|
||||
This program is libre software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
|
||||
See the COPYING file for more details.
|
||||
*/
|
||||
|
||||
#ifndef ALERTACTION_H
|
||||
#define ALERTACTION_H
|
||||
|
||||
#include "messageaction.h"
|
||||
|
||||
class AlertAction : public MessageAction
|
||||
{
|
||||
public:
|
||||
AlertAction(const QString &author, const QString &message, const QString& date);
|
||||
virtual ~AlertAction(){;}
|
||||
virtual QString getMessage();
|
||||
//virtual QString getName(); only do the message for now; preferably would do the whole row
|
||||
virtual void setup(QTextCursor cursor, QTextEdit*) override;
|
||||
|
||||
private:
|
||||
QString message;
|
||||
};
|
||||
|
||||
#endif // MESSAGEACTION_H
|
|
@ -38,7 +38,7 @@ void MessageAction::setup(QTextCursor cursor, QTextEdit *)
|
|||
date.squeeze();
|
||||
}
|
||||
|
||||
QString MessageAction::getMessage()
|
||||
QString MessageAction::getMessage(QString div)
|
||||
{
|
||||
QString message_ = SmileyPack::getInstance().smileyfied(toHtmlChars(message));
|
||||
|
||||
|
@ -65,14 +65,19 @@ QString MessageAction::getMessage()
|
|||
for (QString& s : messageLines)
|
||||
{
|
||||
if (QRegExp("^[ ]*>.*").exactMatch(s))
|
||||
message_ += "<span class=quote>>" + s.right(s.length()-4) + "</span><br/>";
|
||||
message_ += "<span class=quote>" + s.right(s.length()-4) + "</span><br/>";
|
||||
else
|
||||
message_ += s + "<br/>";
|
||||
}
|
||||
message_ = message_.left(message_.length()-4);
|
||||
|
||||
if (isMe)
|
||||
return QString("<div class=message_me>" + message_ + "</div>");
|
||||
else
|
||||
return QString("<div class=message>" + message_ + "</div>");
|
||||
return QString(QString("<div class=%1>").arg(div) + message_ + "</div>");
|
||||
}
|
||||
|
||||
QString MessageAction::getMessage()
|
||||
{
|
||||
if (isMe)
|
||||
return getMessage("message_me");
|
||||
else
|
||||
return getMessage("message");
|
||||
}
|
||||
|
|
|
@ -25,9 +25,10 @@ public:
|
|||
MessageAction(const QString &author, const QString &message, const QString &date, const bool &me);
|
||||
virtual ~MessageAction(){;}
|
||||
virtual QString getMessage();
|
||||
virtual QString getMessage(QString div);
|
||||
virtual void setup(QTextCursor cursor, QTextEdit*) override;
|
||||
|
||||
private:
|
||||
protected:
|
||||
QString message;
|
||||
};
|
||||
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -28,6 +28,8 @@ public:
|
|||
|
||||
signals:
|
||||
void enterPressed();
|
||||
void tabPressed();
|
||||
void keyPressed();
|
||||
|
||||
public slots:
|
||||
|
||||
|
|
|
@ -749,14 +749,19 @@ void Widget::onGroupMessageReceived(int groupnumber, const QString& message, con
|
|||
if (!g)
|
||||
return;
|
||||
|
||||
g->chatForm->addMessage(author, message);
|
||||
QString name = core->getUsername();
|
||||
bool targeted = (author != name) && message.contains(name, Qt::CaseInsensitive);
|
||||
if (targeted)
|
||||
g->chatForm->addAlertMessage(author, message);
|
||||
else
|
||||
g->chatForm->addMessage(author, message);
|
||||
|
||||
if ((static_cast<GenericChatroomWidget*>(g->widget) != activeChatroomWidget) || isMinimized() || !isActiveWindow())
|
||||
{
|
||||
g->hasNewMessages = 1;
|
||||
newMessageAlert(); // sound alert on any message, not just naming user
|
||||
if (message.contains(core->getUsername(), Qt::CaseInsensitive))
|
||||
if (targeted)
|
||||
{
|
||||
newMessageAlert();
|
||||
g->userWasMentioned = 1; // useful for highlighting line or desktop notifications
|
||||
}
|
||||
g->widget->updateStatusLight();
|
||||
|
@ -772,17 +777,23 @@ void Widget::onGroupNamelistChanged(int groupnumber, int peernumber, uint8_t Cha
|
|||
g = createGroup(groupnumber);
|
||||
}
|
||||
|
||||
QString name = core->getGroupPeerName(groupnumber, peernumber);
|
||||
TOX_CHAT_CHANGE change = static_cast<TOX_CHAT_CHANGE>(Change);
|
||||
if (change == TOX_CHAT_CHANGE_PEER_ADD)
|
||||
{
|
||||
QString name = core->getGroupPeerName(groupnumber, peernumber);
|
||||
if (name.isEmpty())
|
||||
name = tr("<Unknown>", "Placeholder when we don't know someone's name in a group chat");
|
||||
g->addPeer(peernumber,name);
|
||||
//g->chatForm->addSystemInfoMessage(tr("%1 has joined the chat").arg(name), "green");
|
||||
// we can't display these messages until irungentoo fixes peernumbers
|
||||
// https://github.com/irungentoo/toxcore/issues/1128
|
||||
}
|
||||
else if (change == TOX_CHAT_CHANGE_PEER_DEL)
|
||||
{
|
||||
g->removePeer(peernumber);
|
||||
else if (change == TOX_CHAT_CHANGE_PEER_NAME)
|
||||
//g->chatForm->addSystemInfoMessage(tr("%1 has left the chat").arg(name), "silver");
|
||||
}
|
||||
else if (change == TOX_CHAT_CHANGE_PEER_NAME) // core overwrites old name before telling us it changed...
|
||||
g->updatePeer(peernumber,core->getGroupPeerName(groupnumber, peernumber));
|
||||
}
|
||||
|
||||
|
|
|
@ -38,8 +38,8 @@ span.quote {
|
|||
}
|
||||
|
||||
div.green {
|
||||
margin-top: 12px;
|
||||
margin-bottom: 12px;
|
||||
margin-top: 6px;
|
||||
margin-bottom: 6px;
|
||||
margin-left: 0px;
|
||||
margin-right: 0px;
|
||||
color: @white;
|
||||
|
@ -48,8 +48,8 @@ div.green {
|
|||
}
|
||||
|
||||
div.silver {
|
||||
margin-top: 12px;
|
||||
margin-bottom: 12px;
|
||||
margin-top: 6px;
|
||||
margin-bottom: 6px;
|
||||
margin-left: 0px;
|
||||
margin-right: 0px;
|
||||
color: @black;
|
||||
|
@ -58,8 +58,8 @@ div.silver {
|
|||
}
|
||||
|
||||
div.red {
|
||||
margin-top: 12px;
|
||||
margin-bottom: 12px;
|
||||
margin-top: 6px;
|
||||
margin-bottom: 6px;
|
||||
margin-left: 0px;
|
||||
margin-right: 0px;
|
||||
color: @white;
|
||||
|
@ -67,6 +67,20 @@ div.red {
|
|||
font: @small;
|
||||
}
|
||||
|
||||
div.alert {
|
||||
margin-left: 0px;
|
||||
margin-right: 0px;
|
||||
color: @black;
|
||||
background-color: @orange;
|
||||
font: @big;
|
||||
}
|
||||
|
||||
div.alert_name {
|
||||
color: @black;
|
||||
background-color: @orange;
|
||||
font: @bigBold;
|
||||
}
|
||||
|
||||
div.button {
|
||||
margin-top: 0px;
|
||||
margin-bottom: 0px;
|
||||
|
|
Loading…
Reference in New Issue
Block a user