diff --git a/src/widget/form/genericchatform.cpp b/src/widget/form/genericchatform.cpp index 9704680f1..df0808af1 100644 --- a/src/widget/form/genericchatform.cpp +++ b/src/widget/form/genericchatform.cpp @@ -20,6 +20,7 @@ #include #include #include +#include #include "src/misc/smileypack.h" #include "src/widget/emoticonswidget.h" @@ -42,7 +43,6 @@ GenericChatForm::GenericChatForm(QWidget *parent) , audioOutputFlag(false) { curRow = 0; - headWidget = new QWidget(); nameLabel = new CroppingLabel(); @@ -169,10 +169,23 @@ GenericChatForm::GenericChatForm(QWidget *parent) connect(emoteButton, &QPushButton::clicked, this, &GenericChatForm::onEmoteButtonClicked); connect(chatWidget, &ChatLog::customContextMenuRequested, this, &GenericChatForm::onChatContextMenuRequested); + new QShortcut(QKeySequence(Qt::Key_PageUp), this, SLOT(previousContact())); + new QShortcut(QKeySequence(Qt::Key_PageDown), this, SLOT(nextContact())); + 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(); diff --git a/src/widget/form/genericchatform.h b/src/widget/form/genericchatform.h index e32a34cd3..3f859bf8c 100644 --- a/src/widget/form/genericchatform.h +++ b/src/widget/form/genericchatform.h @@ -34,6 +34,7 @@ class CroppingLabel; class ChatTextEdit; class ChatLog; class MaskablePixmapWidget; +class Widget; struct ToxID; namespace Ui { @@ -74,12 +75,15 @@ protected slots: void onCopyLogClicked(); void clearChatArea(bool); void onSelectAllClicked(); + void previousContact(); + void nextContact(); protected: QString resolveToxID(const ToxID &id); void insertChatMessage(ChatMessage::Ptr msg); ToxID previousId; + Widget *parent; QMenu menu; int curRow; CroppingLabel *nameLabel; diff --git a/src/widget/widget.cpp b/src/widget/widget.cpp index e7aadbeb2..13ef49335 100644 --- a/src/widget/widget.cpp +++ b/src/widget/widget.cpp @@ -746,6 +746,7 @@ void Widget::onFriendUsernameChanged(int friendId, const QString& username) void Widget::onChatroomWidgetClicked(GenericChatroomWidget *widget) { + qDebug() << "active chat"; hideMainForms(); widget->setChatForm(*ui); if (activeChatroomWidget != nullptr) @@ -1197,3 +1198,14 @@ void Widget::reloadTheme() for (Group* g : GroupList::getAllGroups()) g->getGroupWidget()->reloadTheme(); } + +void Widget::nextContact() +{ + // dont know how to get current/previous/next contact from friendlistwidget + qDebug() << "next contact"; +} + +void Widget::previousContact() +{ + qDebug() << "previous contact"; +} diff --git a/src/widget/widget.h b/src/widget/widget.h index 30310cc13..9bb3ef529 100644 --- a/src/widget/widget.h +++ b/src/widget/widget.h @@ -104,6 +104,8 @@ public slots: void onGroupTitleChanged(int groupnumber, const QString& author, const QString& title); void playRingtone(); void onFriendTypingChanged(int friendId, bool isTyping); + void nextContact(); + void previousContact(); signals: void friendRequestAccepted(const QString& userId); @@ -141,7 +143,7 @@ private slots: private: void hideMainForms(); virtual bool event(QEvent * e); - Group* createGroup(int groupId); + Group *createGroup(int groupId); void removeFriend(Friend* f, bool fake = false); void removeGroup(Group* g, bool fake = false); void saveWindowGeometry(); @@ -156,17 +158,17 @@ private: Ui::MainWindow *ui; QSplitter *centralLayout; QPoint dragPosition; - AddFriendForm* addFriendForm; - SettingsWidget* settingsWidget; - FilesForm* filesForm; - static Widget* instance; - GenericChatroomWidget* activeChatroomWidget; - FriendListWidget* contactListWidget; - MaskablePixmapWidget* profilePicture; + AddFriendForm *addFriendForm; + SettingsWidget *settingsWidget; + FilesForm *filesForm; + static Widget *instance; + GenericChatroomWidget *activeChatroomWidget; + FriendListWidget *contactListWidget; + MaskablePixmapWidget *profilePicture; bool notify(QObject *receiver, QEvent *event); bool autoAwayActive = false; Status beforeDisconnect = Status::Offline; - QTimer* timer, *offlineMsgTimer; + QTimer *timer, *offlineMsgTimer; QTranslator* translator; QRegExp nameMention, sanitizedNameMention; bool eventFlag;