mirror of
https://github.com/RetroShare/RetroShare.git
synced 2024-10-01 02:35:48 -04:00
Merge pull request #1293 from chelovechishko/chalod
several fixes to chat gui
This commit is contained in:
commit
93aa5442a5
@ -128,11 +128,15 @@ ChatLobbyDialog::ChatLobbyDialog(const ChatLobbyId& lid, QWidget *parent, Qt::Wi
|
|||||||
QString headerText = headerItem->text(COLUMN_NAME );
|
QString headerText = headerItem->text(COLUMN_NAME );
|
||||||
ui.filterLineEdit->addFilter(QIcon(), headerText, COLUMN_NAME , QString("%1 %2").arg(tr("Search"), headerText));
|
ui.filterLineEdit->addFilter(QIcon(), headerText, COLUMN_NAME , QString("%1 %2").arg(tr("Search"), headerText));
|
||||||
|
|
||||||
|
// just empiric values
|
||||||
|
double scaler_factor = S > 25 ? 2.4 : 1.8;
|
||||||
|
QSize icon_size(scaler_factor * S, scaler_factor * S);
|
||||||
|
|
||||||
// Add a button to invite friends.
|
// Add a button to invite friends.
|
||||||
//
|
//
|
||||||
inviteFriendsButton = new QToolButton ;
|
inviteFriendsButton = new QToolButton ;
|
||||||
inviteFriendsButton->setMinimumSize(QSize(2.4*S,2.4*S)) ;
|
inviteFriendsButton->setMinimumSize(icon_size);
|
||||||
inviteFriendsButton->setMaximumSize(QSize(2.4*S,2.4*S)) ;
|
inviteFriendsButton->setMaximumSize(icon_size);
|
||||||
inviteFriendsButton->setText(QString()) ;
|
inviteFriendsButton->setText(QString()) ;
|
||||||
inviteFriendsButton->setAutoRaise(true) ;
|
inviteFriendsButton->setAutoRaise(true) ;
|
||||||
inviteFriendsButton->setToolTip(tr("Invite friends to this lobby"));
|
inviteFriendsButton->setToolTip(tr("Invite friends to this lobby"));
|
||||||
@ -144,7 +148,7 @@ ChatLobbyDialog::ChatLobbyDialog(const ChatLobbyId& lid, QWidget *parent, Qt::Wi
|
|||||||
QIcon icon ;
|
QIcon icon ;
|
||||||
icon.addPixmap(QPixmap(":/icons/png/invite.png")) ;
|
icon.addPixmap(QPixmap(":/icons/png/invite.png")) ;
|
||||||
inviteFriendsButton->setIcon(icon) ;
|
inviteFriendsButton->setIcon(icon) ;
|
||||||
inviteFriendsButton->setIconSize(QSize(2.4*S,2.4*S)) ;
|
inviteFriendsButton->setIconSize(icon_size);
|
||||||
}
|
}
|
||||||
|
|
||||||
connect(inviteFriendsButton, SIGNAL(clicked()), this , SLOT(inviteFriends()));
|
connect(inviteFriendsButton, SIGNAL(clicked()), this , SLOT(inviteFriends()));
|
||||||
@ -175,9 +179,9 @@ ChatLobbyDialog::ChatLobbyDialog(const ChatLobbyId& lid, QWidget *parent, Qt::Wi
|
|||||||
|
|
||||||
connect(ownIdChooser,SIGNAL(currentIndexChanged(int)),this,SLOT(changeNickname())) ;
|
connect(ownIdChooser,SIGNAL(currentIndexChanged(int)),this,SLOT(changeNickname())) ;
|
||||||
|
|
||||||
unsubscribeButton = new QToolButton ;
|
unsubscribeButton = new QToolButton;
|
||||||
unsubscribeButton->setMinimumSize(QSize(2.4*S,2.4*S)) ;
|
unsubscribeButton->setMinimumSize(icon_size);
|
||||||
unsubscribeButton->setMaximumSize(QSize(2.4*S,2.4*S)) ;
|
unsubscribeButton->setMaximumSize(icon_size);
|
||||||
unsubscribeButton->setText(QString()) ;
|
unsubscribeButton->setText(QString()) ;
|
||||||
unsubscribeButton->setAutoRaise(true) ;
|
unsubscribeButton->setAutoRaise(true) ;
|
||||||
unsubscribeButton->setToolTip(tr("Leave this chat room (Unsubscribe)"));
|
unsubscribeButton->setToolTip(tr("Leave this chat room (Unsubscribe)"));
|
||||||
@ -186,7 +190,7 @@ ChatLobbyDialog::ChatLobbyDialog(const ChatLobbyId& lid, QWidget *parent, Qt::Wi
|
|||||||
QIcon icon ;
|
QIcon icon ;
|
||||||
icon.addPixmap(QPixmap(":/icons/png/leave.png")) ;
|
icon.addPixmap(QPixmap(":/icons/png/leave.png")) ;
|
||||||
unsubscribeButton->setIcon(icon) ;
|
unsubscribeButton->setIcon(icon) ;
|
||||||
unsubscribeButton->setIconSize(QSize(2.4*S,2.4*S)) ;
|
unsubscribeButton->setIconSize(icon_size);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Initialize splitter */
|
/* Initialize splitter */
|
||||||
@ -246,8 +250,8 @@ void ChatLobbyDialog::participantsTreeWidgetCustomPopupMenu(QPoint)
|
|||||||
|
|
||||||
void ChatLobbyDialog::textBrowserAskContextMenu(QMenu* contextMnu, QString anchorForPosition, const QPoint /*point*/)
|
void ChatLobbyDialog::textBrowserAskContextMenu(QMenu* contextMnu, QString anchorForPosition, const QPoint /*point*/)
|
||||||
{
|
{
|
||||||
if (anchorForPosition.startsWith(PERSONID)){
|
if (anchorForPosition.startsWith(PERSONID)) {
|
||||||
QString strId = anchorForPosition.replace(PERSONID,"");
|
QString strId = anchorForPosition.replace(PERSONID, "");
|
||||||
if (strId.contains(" "))
|
if (strId.contains(" "))
|
||||||
strId.truncate(strId.indexOf(" "));
|
strId.truncate(strId.indexOf(" "));
|
||||||
|
|
||||||
@ -263,6 +267,8 @@ void ChatLobbyDialog::initParticipantsContextMenu(QMenu *contextMnu, QList<RsGxs
|
|||||||
{
|
{
|
||||||
if (!contextMnu)
|
if (!contextMnu)
|
||||||
return;
|
return;
|
||||||
|
if (idList.isEmpty())
|
||||||
|
return;
|
||||||
|
|
||||||
contextMnu->addAction(distantChatAct);
|
contextMnu->addAction(distantChatAct);
|
||||||
contextMnu->addAction(sendMessageAct);
|
contextMnu->addAction(sendMessageAct);
|
||||||
@ -281,7 +287,7 @@ void ChatLobbyDialog::initParticipantsContextMenu(QMenu *contextMnu, QList<RsGxs
|
|||||||
votePositiveAct->setEnabled(false);
|
votePositiveAct->setEnabled(false);
|
||||||
voteNeutralAct->setEnabled(false);
|
voteNeutralAct->setEnabled(false);
|
||||||
voteNegativeAct->setEnabled(false);
|
voteNegativeAct->setEnabled(false);
|
||||||
showInPeopleAct->setEnabled(idList.count()==1);
|
showInPeopleAct->setEnabled(idList.count() == 1);
|
||||||
|
|
||||||
distantChatAct->setData(QVariant::fromValue(idList));
|
distantChatAct->setData(QVariant::fromValue(idList));
|
||||||
sendMessageAct->setData(QVariant::fromValue(idList));
|
sendMessageAct->setData(QVariant::fromValue(idList));
|
||||||
@ -291,8 +297,6 @@ void ChatLobbyDialog::initParticipantsContextMenu(QMenu *contextMnu, QList<RsGxs
|
|||||||
voteNegativeAct->setData(QVariant::fromValue(idList));
|
voteNegativeAct->setData(QVariant::fromValue(idList));
|
||||||
showInPeopleAct->setData(QVariant::fromValue(idList));
|
showInPeopleAct->setData(QVariant::fromValue(idList));
|
||||||
|
|
||||||
if(idList.count()==1)
|
|
||||||
{
|
|
||||||
RsGxsId gxsid = idList.at(0);
|
RsGxsId gxsid = idList.at(0);
|
||||||
|
|
||||||
if(!gxsid.isNull() && !rsIdentity->isOwnId(gxsid))
|
if(!gxsid.isNull() && !rsIdentity->isOwnId(gxsid))
|
||||||
@ -304,7 +308,6 @@ void ChatLobbyDialog::initParticipantsContextMenu(QMenu *contextMnu, QList<RsGxs
|
|||||||
muteAct->setEnabled(true);
|
muteAct->setEnabled(true);
|
||||||
muteAct->setChecked(isParticipantMuted(gxsid));
|
muteAct->setChecked(isParticipantMuted(gxsid));
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ChatLobbyDialog::voteParticipant()
|
void ChatLobbyDialog::voteParticipant()
|
||||||
|
@ -65,6 +65,8 @@
|
|||||||
#include <time.h>
|
#include <time.h>
|
||||||
|
|
||||||
#define FMM 2.5//fontMetricsMultiplicator
|
#define FMM 2.5//fontMetricsMultiplicator
|
||||||
|
#define FMM_SMALLER 1.8
|
||||||
|
#define FMM_THRESHOLD 25
|
||||||
|
|
||||||
/*****
|
/*****
|
||||||
* #define CHAT_DEBUG 1
|
* #define CHAT_DEBUG 1
|
||||||
@ -75,9 +77,12 @@ ChatWidget::ChatWidget(QWidget *parent) :
|
|||||||
{
|
{
|
||||||
ui->setupUi(this);
|
ui->setupUi(this);
|
||||||
|
|
||||||
int iconHeight = FMM*QFontMetricsF(font()).height() ;
|
int iconHeight = QFontMetricsF(font()).height();
|
||||||
QSize iconSize = QSize(iconHeight,iconHeight);
|
double fmm = iconHeight > FMM_THRESHOLD ? FMM : FMM_SMALLER;
|
||||||
QSize buttonSize = QSize(iconSize + QSize((int)FMM,(int)FMM));
|
iconHeight *= fmm;
|
||||||
|
QSize iconSize = QSize(iconHeight, iconHeight);
|
||||||
|
int butt_size(iconSize.height() + fmm);
|
||||||
|
QSize buttonSize = QSize(butt_size, butt_size);
|
||||||
|
|
||||||
newMessages = false;
|
newMessages = false;
|
||||||
typing = false;
|
typing = false;
|
||||||
@ -259,9 +264,12 @@ void ChatWidget::addChatHorizontalWidget(QWidget *w)
|
|||||||
|
|
||||||
void ChatWidget::addChatBarWidget(QWidget *w)
|
void ChatWidget::addChatBarWidget(QWidget *w)
|
||||||
{
|
{
|
||||||
int iconHeight = FMM*QFontMetricsF(font()).height() ;
|
int iconHeight = QFontMetricsF(font()).height();
|
||||||
QSize iconSize = QSize(iconHeight,iconHeight);
|
double fmm = iconHeight > FMM_THRESHOLD ? FMM : FMM_SMALLER;
|
||||||
QSize buttonSize = QSize(iconSize + QSize((int)FMM,(int)FMM));
|
iconHeight *= fmm;
|
||||||
|
QSize iconSize = QSize(iconHeight, iconHeight);
|
||||||
|
int butt_size(iconSize.height() + fmm);
|
||||||
|
QSize buttonSize = QSize(butt_size, butt_size);
|
||||||
w->setFixedSize(buttonSize);
|
w->setFixedSize(buttonSize);
|
||||||
ui->pluginButtonFrame->layout()->addWidget(w) ;
|
ui->pluginButtonFrame->layout()->addWidget(w) ;
|
||||||
}
|
}
|
||||||
@ -1095,6 +1103,7 @@ void ChatWidget::contextMenuTextBrowser(QPoint point)
|
|||||||
|
|
||||||
contextMnu->addSeparator();
|
contextMnu->addSeparator();
|
||||||
contextMnu->addAction(ui->actionClearChatHistory);
|
contextMnu->addAction(ui->actionClearChatHistory);
|
||||||
|
if (ui->textBrowser->textCursor().selection().toPlainText().length())
|
||||||
contextMnu->addAction(ui->actionQuote);
|
contextMnu->addAction(ui->actionQuote);
|
||||||
contextMnu->addAction(ui->actionDropPlacemark);
|
contextMnu->addAction(ui->actionDropPlacemark);
|
||||||
|
|
||||||
@ -1161,12 +1170,13 @@ void ChatWidget::resetStatusBar()
|
|||||||
|
|
||||||
void ChatWidget::updateStatusTyping()
|
void ChatWidget::updateStatusTyping()
|
||||||
{
|
{
|
||||||
|
if(Settings->getChatDoNotSendIsTyping())
|
||||||
|
return;
|
||||||
if (time(NULL) - lastStatusSendTime > 5) // limit 'peer is typing' packets to at most every 10 sec
|
if (time(NULL) - lastStatusSendTime > 5) // limit 'peer is typing' packets to at most every 10 sec
|
||||||
{
|
{
|
||||||
#ifdef ONLY_FOR_LINGUIST
|
#ifdef ONLY_FOR_LINGUIST
|
||||||
tr("is typing...");
|
tr("is typing...");
|
||||||
#endif
|
#endif
|
||||||
if(!Settings->getChatDoNotSendIsTyping())
|
|
||||||
rsMsgs->sendStatusString(chatId, "is typing...");
|
rsMsgs->sendStatusString(chatId, "is typing...");
|
||||||
lastStatusSendTime = time(NULL) ;
|
lastStatusSendTime = time(NULL) ;
|
||||||
}
|
}
|
||||||
@ -1816,13 +1826,10 @@ bool ChatWidget::setStyle()
|
|||||||
void ChatWidget::quote()
|
void ChatWidget::quote()
|
||||||
{
|
{
|
||||||
QString text = ui->textBrowser->textCursor().selection().toPlainText();
|
QString text = ui->textBrowser->textCursor().selection().toPlainText();
|
||||||
if(text.length() > 0)
|
QStringList sl = text.split(QRegExp("[\r\n]"), QString::SkipEmptyParts);
|
||||||
{
|
|
||||||
QStringList sl = text.split(QRegExp("[\r\n]"),QString::SkipEmptyParts);
|
|
||||||
text = sl.join("\n> ");
|
text = sl.join("\n> ");
|
||||||
text.replace(QChar(-4)," ");//Char used when image on text.
|
text.replace(QChar(-4), " "); // Char used when image on text.
|
||||||
emit ui->chatTextEdit->append(QString("> ") + text);
|
emit ui->chatTextEdit->append(QString("> ") + text);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ChatWidget::dropPlacemark()
|
void ChatWidget::dropPlacemark()
|
||||||
|
@ -251,22 +251,53 @@ bool RSTextBrowser::checkImage(QPoint pos, QString &imageStr)
|
|||||||
*/
|
*/
|
||||||
QString RSTextBrowser::anchorForPosition(const QPoint &pos) const
|
QString RSTextBrowser::anchorForPosition(const QPoint &pos) const
|
||||||
{
|
{
|
||||||
|
// Many calls when time label shows up
|
||||||
QTextCursor cursor = cursorForPosition(pos);
|
QTextCursor cursor = cursorForPosition(pos);
|
||||||
cursor.select(QTextCursor::WordUnderCursor);
|
cursor.select(QTextCursor::WordUnderCursor);
|
||||||
|
QString word = cursor.selectedText();
|
||||||
QString anchor = "";
|
QString anchor = "";
|
||||||
if (!cursor.selectedText().isEmpty()){
|
if (word.isEmpty())
|
||||||
|
return anchor;
|
||||||
|
|
||||||
|
// For finding positions
|
||||||
|
QTextCursor cursor_line = cursorForPosition(pos);
|
||||||
|
cursor_line.select(QTextCursor::LineUnderCursor);
|
||||||
|
QString line = cursor_line.selectedText();
|
||||||
|
// End of nickname (more or less, of course, because some can has colon in
|
||||||
|
// name)
|
||||||
|
int end_of_name = line.indexOf(": ") + 1;
|
||||||
|
// Start of nickname (after time)
|
||||||
|
int space_index = line.indexOf(' ') + 1;
|
||||||
|
int word_index = line.indexOf(word) + 1;
|
||||||
|
int once = 1;
|
||||||
|
cursor_line.movePosition(QTextCursor::StartOfLine, QTextCursor::MoveAnchor, once);
|
||||||
|
bool after_name = cursor_line.position() + end_of_name < cursor.position();
|
||||||
|
bool cursor_after_time = space_index < word_index;
|
||||||
|
bool cursor_within_name = word_index <= end_of_name;
|
||||||
|
if (!after_name && cursor_after_time && cursor_within_name) {
|
||||||
|
cursor.movePosition(QTextCursor::StartOfLine, QTextCursor::MoveAnchor, once);
|
||||||
|
cursor.movePosition(QTextCursor::NextCharacter, QTextCursor::MoveAnchor,
|
||||||
|
space_index);
|
||||||
|
cursor.movePosition(QTextCursor::NextCharacter, QTextCursor::KeepAnchor,
|
||||||
|
end_of_name - space_index);
|
||||||
|
if (cursor.selectedText().isEmpty()) {
|
||||||
|
return anchor;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
return anchor;
|
||||||
|
}
|
||||||
|
|
||||||
QRegExp rx("<a name=\"(.*)\"",Qt::CaseSensitive, QRegExp::RegExp2);
|
QRegExp rx("<a name=\"(.*)\"",Qt::CaseSensitive, QRegExp::RegExp2);
|
||||||
rx.setMinimal(true);
|
rx.setMinimal(true);
|
||||||
QString sel = cursor.selection().toHtml();
|
QString sel = cursor.selection().toHtml();
|
||||||
QStringList anchors;
|
QStringList anchors;
|
||||||
int pos=0;
|
int position = 0;
|
||||||
while ((pos = rx.indexIn(sel,pos)) != -1) {
|
while ((position = rx.indexIn(sel, position)) != -1) {
|
||||||
anchors << rx.cap(1);
|
anchors << rx.cap(1);
|
||||||
pos += rx.matchedLength();
|
position += rx.matchedLength();
|
||||||
}
|
}
|
||||||
if (!anchors.isEmpty()){
|
if (!anchors.isEmpty()) {
|
||||||
anchor = anchors.at(0);
|
anchor = anchors.at(0);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
return anchor;
|
return anchor;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user