1
0
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:
tux3 2015-05-07 19:02:57 +02:00
commit 821b01a90b
No known key found for this signature in database
GPG Key ID: 7E086DD661263264
7 changed files with 61 additions and 19 deletions

View File

@ -169,24 +169,12 @@ GenericChatForm::GenericChatForm(QWidget *parent)
connect(emoteButton, &QPushButton::clicked, this, &GenericChatForm::onEmoteButtonClicked); connect(emoteButton, &QPushButton::clicked, this, &GenericChatForm::onEmoteButtonClicked);
connect(chatWidget, &ChatLog::customContextMenuRequested, this, &GenericChatForm::onChatContextMenuRequested); 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())); new QShortcut(Qt::CTRL + Qt::SHIFT + Qt::Key_L, this, SLOT(clearChatArea()));
chatWidget->setStyleSheet(Style::getStylesheet(":/ui/chatArea/chatArea.css")); chatWidget->setStyleSheet(Style::getStylesheet(":/ui/chatArea/chatArea.css"));
headWidget->setStyleSheet(Style::getStylesheet(":/ui/chatArea/chatHead.css")); headWidget->setStyleSheet(Style::getStylesheet(":/ui/chatArea/chatHead.css"));
} }
void GenericChatForm::previousContact()
{
parent->previousContact();
}
void GenericChatForm::nextContact()
{
parent->nextContact();
}
bool GenericChatForm::isEmpty() bool GenericChatForm::isEmpty()
{ {
return chatWidget->isEmpty(); return chatWidget->isEmpty();

View File

@ -76,8 +76,6 @@ protected slots:
void clearChatArea(bool); void clearChatArea(bool);
void clearChatArea(); void clearChatArea();
void onSelectAllClicked(); void onSelectAllClicked();
void previousContact();
void nextContact();
protected: protected:
QString resolveToxID(const ToxID &id); QString resolveToxID(const ToxID &id);

View File

@ -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) void FriendListWidget::moveWidget(QWidget *w, Status s)
{ {
QVBoxLayout* l = getFriendLayout(s); QVBoxLayout* l = getFriendLayout(s);

View File

@ -19,7 +19,9 @@
#include <QWidget> #include <QWidget>
#include <QHash> #include <QHash>
#include <QList>
#include "src/core/corestructs.h" #include "src/core/corestructs.h"
#include "src/widget/genericchatroomwidget.h"
class QVBoxLayout; class QVBoxLayout;
class QGridLayout; class QGridLayout;
@ -33,6 +35,8 @@ public:
QVBoxLayout* getGroupLayout(); QVBoxLayout* getGroupLayout();
QVBoxLayout* getFriendLayout(Status s); QVBoxLayout* getFriendLayout(Status s);
QList<GenericChatroomWidget*> getAllFriends();
signals: signals:
public slots: public slots:

View File

@ -25,12 +25,17 @@ ChatTextEdit::ChatTextEdit(QWidget *parent) :
} }
void ChatTextEdit::keyPressEvent(QKeyEvent * event) void ChatTextEdit::keyPressEvent(QKeyEvent * event)
{ {
int key = event->key(); 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(); emit enterPressed();
else if (key == Qt::Key_Tab) else if (key == Qt::Key_Tab)
emit tabPressed(); {
if (event->modifiers())
event->ignore();
else
emit tabPressed();
}
else if (key == Qt::Key_Up && this->toPlainText().isEmpty()) else if (key == Qt::Key_Up && this->toPlainText().isEmpty())
{ {
this->setText(lastMessage); this->setText(lastMessage);

View File

@ -200,6 +200,10 @@ void Widget::init()
// keyboard shortcuts // keyboard shortcuts
new QShortcut(Qt::CTRL + Qt::Key_Q, this, SLOT(close())); 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); addFriendForm->show(*ui);
setWindowTitle(tr("Add friend")); setWindowTitle(tr("Add friend"));
@ -1235,6 +1239,23 @@ void Widget::onSplitterMoved(int pos, int index)
saveSplitterGeometry(); 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() void Widget::processOfflineMsgs()
{ {
if (OfflineMsgEngine::globalMutex.tryLock()) if (OfflineMsgEngine::globalMutex.tryLock())
@ -1271,13 +1292,12 @@ void Widget::reloadTheme()
void Widget::nextContact() void Widget::nextContact()
{ {
// dont know how to get current/previous/next contact from friendlistwidget cycleContacts(1);
qDebug() << "next contact";
} }
void Widget::previousContact() void Widget::previousContact()
{ {
qDebug() << "previous contact"; cycleContacts(-1);
} }
QString Widget::getStatusIconPath(Status status) QString Widget::getStatusIconPath(Status status)

View File

@ -158,6 +158,7 @@ private:
void removeGroup(Group* g, bool fake = false); void removeGroup(Group* g, bool fake = false);
void saveWindowGeometry(); void saveWindowGeometry();
void saveSplitterGeometry(); void saveSplitterGeometry();
void cycleContacts(int offset);
SystemTrayIcon *icon; SystemTrayIcon *icon;
QMenu *trayMenu; QMenu *trayMenu;
QAction *statusOnline, QAction *statusOnline,