mirror of
https://github.com/qTox/qTox.git
synced 2024-03-22 14:00:36 +08:00
Merge branch 'pr1454'
This commit is contained in:
commit
821b01a90b
|
@ -169,24 +169,12 @@ GenericChatForm::GenericChatForm(QWidget *parent)
|
|||
connect(emoteButton, &QPushButton::clicked, this, &GenericChatForm::onEmoteButtonClicked);
|
||||
connect(chatWidget, &ChatLog::customContextMenuRequested, this, &GenericChatForm::onChatContextMenuRequested);
|
||||
|
||||
new QShortcut(Qt::CTRL + Qt::Key_PageUp, this, SLOT(previousContact()));
|
||||
new QShortcut(Qt::CTRL + Qt::Key_PageDown, this, SLOT(nextContact()));
|
||||
new QShortcut(Qt::CTRL + Qt::SHIFT + Qt::Key_L, this, SLOT(clearChatArea()));
|
||||
|
||||
chatWidget->setStyleSheet(Style::getStylesheet(":/ui/chatArea/chatArea.css"));
|
||||
headWidget->setStyleSheet(Style::getStylesheet(":/ui/chatArea/chatHead.css"));
|
||||
}
|
||||
|
||||
void GenericChatForm::previousContact()
|
||||
{
|
||||
parent->previousContact();
|
||||
}
|
||||
|
||||
void GenericChatForm::nextContact()
|
||||
{
|
||||
parent->nextContact();
|
||||
}
|
||||
|
||||
bool GenericChatForm::isEmpty()
|
||||
{
|
||||
return chatWidget->isEmpty();
|
||||
|
|
|
@ -76,8 +76,6 @@ protected slots:
|
|||
void clearChatArea(bool);
|
||||
void clearChatArea();
|
||||
void onSelectAllClicked();
|
||||
void previousContact();
|
||||
void nextContact();
|
||||
|
||||
protected:
|
||||
QString resolveToxID(const ToxID &id);
|
||||
|
|
|
@ -87,6 +87,32 @@ void FriendListWidget::onGroupchatPositionChanged(bool top)
|
|||
}
|
||||
}
|
||||
|
||||
QList<GenericChatroomWidget*> FriendListWidget::getAllFriends()
|
||||
{
|
||||
QList<GenericChatroomWidget*> friends;
|
||||
|
||||
for (int i = 0; i < mainLayout->count(); ++i)
|
||||
{
|
||||
QLayout* subLayout = mainLayout->itemAt(i)->layout();
|
||||
|
||||
if(!subLayout)
|
||||
continue;
|
||||
|
||||
for (int j = 0; j < subLayout->count(); ++j)
|
||||
{
|
||||
GenericChatroomWidget* widget =
|
||||
reinterpret_cast<GenericChatroomWidget*>(subLayout->itemAt(j)->widget());
|
||||
|
||||
if(!widget)
|
||||
continue;
|
||||
|
||||
friends.append(widget);
|
||||
}
|
||||
}
|
||||
|
||||
return friends;
|
||||
}
|
||||
|
||||
void FriendListWidget::moveWidget(QWidget *w, Status s)
|
||||
{
|
||||
QVBoxLayout* l = getFriendLayout(s);
|
||||
|
|
|
@ -19,7 +19,9 @@
|
|||
|
||||
#include <QWidget>
|
||||
#include <QHash>
|
||||
#include <QList>
|
||||
#include "src/core/corestructs.h"
|
||||
#include "src/widget/genericchatroomwidget.h"
|
||||
|
||||
class QVBoxLayout;
|
||||
class QGridLayout;
|
||||
|
@ -33,6 +35,8 @@ public:
|
|||
QVBoxLayout* getGroupLayout();
|
||||
QVBoxLayout* getFriendLayout(Status s);
|
||||
|
||||
QList<GenericChatroomWidget*> getAllFriends();
|
||||
|
||||
signals:
|
||||
|
||||
public slots:
|
||||
|
|
|
@ -30,7 +30,12 @@ void ChatTextEdit::keyPressEvent(QKeyEvent * event)
|
|||
if ((key == Qt::Key_Enter || key == Qt::Key_Return) && !(event->modifiers() & Qt::ShiftModifier))
|
||||
emit enterPressed();
|
||||
else if (key == Qt::Key_Tab)
|
||||
{
|
||||
if (event->modifiers())
|
||||
event->ignore();
|
||||
else
|
||||
emit tabPressed();
|
||||
}
|
||||
else if (key == Qt::Key_Up && this->toPlainText().isEmpty())
|
||||
{
|
||||
this->setText(lastMessage);
|
||||
|
|
|
@ -200,6 +200,10 @@ void Widget::init()
|
|||
|
||||
// keyboard shortcuts
|
||||
new QShortcut(Qt::CTRL + Qt::Key_Q, this, SLOT(close()));
|
||||
new QShortcut(Qt::CTRL + Qt::SHIFT + Qt::Key_Tab, this, SLOT(previousContact()));
|
||||
new QShortcut(Qt::CTRL + Qt::Key_Tab, this, SLOT(nextContact()));
|
||||
new QShortcut(Qt::CTRL + Qt::Key_PageUp, this, SLOT(previousContact()));
|
||||
new QShortcut(Qt::CTRL + Qt::Key_PageDown, this, SLOT(nextContact()));
|
||||
|
||||
addFriendForm->show(*ui);
|
||||
setWindowTitle(tr("Add friend"));
|
||||
|
@ -1235,6 +1239,23 @@ void Widget::onSplitterMoved(int pos, int index)
|
|||
saveSplitterGeometry();
|
||||
}
|
||||
|
||||
void Widget::cycleContacts(int offset)
|
||||
{
|
||||
if (!activeChatroomWidget)
|
||||
return;
|
||||
|
||||
FriendListWidget* friendList = static_cast<FriendListWidget*>(ui->friendList->widget());
|
||||
QList<GenericChatroomWidget*> friends = friendList->getAllFriends();
|
||||
|
||||
int activeIndex = friends.indexOf(activeChatroomWidget);
|
||||
int bounded = (activeIndex + offset) % friends.length();
|
||||
|
||||
if(bounded < 0)
|
||||
bounded += friends.length();
|
||||
|
||||
emit friends[bounded]->chatroomWidgetClicked(friends[bounded]);
|
||||
}
|
||||
|
||||
void Widget::processOfflineMsgs()
|
||||
{
|
||||
if (OfflineMsgEngine::globalMutex.tryLock())
|
||||
|
@ -1271,13 +1292,12 @@ void Widget::reloadTheme()
|
|||
|
||||
void Widget::nextContact()
|
||||
{
|
||||
// dont know how to get current/previous/next contact from friendlistwidget
|
||||
qDebug() << "next contact";
|
||||
cycleContacts(1);
|
||||
}
|
||||
|
||||
void Widget::previousContact()
|
||||
{
|
||||
qDebug() << "previous contact";
|
||||
cycleContacts(-1);
|
||||
}
|
||||
|
||||
QString Widget::getStatusIconPath(Status status)
|
||||
|
|
|
@ -158,6 +158,7 @@ private:
|
|||
void removeGroup(Group* g, bool fake = false);
|
||||
void saveWindowGeometry();
|
||||
void saveSplitterGeometry();
|
||||
void cycleContacts(int offset);
|
||||
SystemTrayIcon *icon;
|
||||
QMenu *trayMenu;
|
||||
QAction *statusOnline,
|
||||
|
|
Loading…
Reference in New Issue
Block a user