diff --git a/src/widget/form/genericchatform.cpp b/src/widget/form/genericchatform.cpp index 5674b515b..387335693 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,24 @@ 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(); @@ -322,6 +336,11 @@ void GenericChatForm::addSystemInfoMessage(const QString &message, ChatMessage:: insertChatMessage(ChatMessage::createChatInfoMessage(message, type, datetime)); } +void GenericChatForm::clearChatArea() +{ + clearChatArea(true); +} + void GenericChatForm::clearChatArea(bool notinform) { chatWidget->clear(); diff --git a/src/widget/form/genericchatform.h b/src/widget/form/genericchatform.h index e32a34cd3..499daee3b 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 { @@ -73,13 +74,17 @@ protected slots: void onSaveLogClicked(); void onCopyLogClicked(); void clearChatArea(bool); + void clearChatArea(); 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 6079433d5..23d55de3b 100644 --- a/src/widget/widget.cpp +++ b/src/widget/widget.cpp @@ -710,6 +710,7 @@ void Widget::onFriendUsernameChanged(int friendId, const QString& username) void Widget::onChatroomWidgetClicked(GenericChatroomWidget *widget) { + qDebug() << "active chat"; hideMainForms(); widget->setChatForm(*ui); if (activeChatroomWidget != nullptr) @@ -1209,3 +1210,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 6b72500aa..a36283667 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); @@ -142,7 +144,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(); @@ -157,17 +159,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;