1 /***************************************************************************
2 *                                                                         *
3 *   This program is free software; you can redistribute it and/or modify  *
4 *   it under the terms of the GNU General Public License as published by  *
5 *   the Free Software Foundation; either version 3 of the License, or     *
6 *   (at your option) any later version.                                   *
7 *                                                                         *
8 ***************************************************************************/
9 
10 #pragma once
11 
12 #include "ui_PrivateMessage.h"
13 #include "ArenaWidget.h"
14 #include "HubFrame.h"
15 
16 class QKeyEvent;
17 class QEvent;
18 class QObject;
19 class QCloseEvent;
20 class QMenu;
21 class QShowEvent;
22 
23 class PMWindow: public  QWidget,
24                 private Ui::UIPrivateMessage,
25                 public  ArenaWidget
26 {
27     Q_OBJECT
28     Q_INTERFACES(ArenaWidget)
29 
30 public:
31     friend class HubFrame;
32 
33     PMWindow(QString cid, QString hubUrl);
34     virtual ~PMWindow();
35 
36     QString  getArenaTitle();
37     QString  getArenaShortTitle();
38     QWidget *getWidget();
39     QMenu   *getMenu();
40     const QPixmap &getPixmap();
role()41     ArenaWidget::Role role() const { return ArenaWidget::PrivateMessage; }
requestFilter()42     void requestFilter() { slotHideFindFrame(); }
requestFocus()43     void requestFocus() { plainTextEdit_INPUT->setFocus(); }
44     void setCompleter(QCompleter *, UserListModel *);
45 
46     void addStatus(QString);
47     void sendMessage(QString,bool = false, bool = false);
inputWidget()48     QWidget *inputWidget() const { return plainTextEdit_INPUT; }
49 
setHasHighlightMessages(bool h)50     void setHasHighlightMessages(bool h) { hasHighlightMessages = (h && !isVisible()); }
51 
hasNewMessages()52     bool hasNewMessages() { return (hasMessages || hasHighlightMessages); }
53 
54 public Q_SLOTS:
55     void slotActivate();
56     void clearChat();
57     void nextMsg();
58     void prevMsg();
59 
60 private Q_SLOTS:
61     void slotHub();
62     void slotShare();
63     void slotSmile();
64     void slotSettingChanged(const QString&, const QString&);
65     void slotSmileContextMenu();
66     void slotSmileClicked();
67     void slotHideFindFrame();
68     void slotFindTextEdited(const QString &);
69     void slotFindAll();
slotFindForward()70     void slotFindForward() { findText(0); }
slotFindBackward()71     void slotFindBackward(){ findText(QTextDocument::FindBackward); }
72     void slotClose();
73 
74 Q_SIGNALS:
75     void privateMessageClosed(QString);
76     void inputTextChanged();
77     void inputTextMenu();
78 
79 protected:
80     virtual bool eventFilter(QObject*, QEvent*);
81     virtual void closeEvent(QCloseEvent *);
82     virtual void showEvent(QShowEvent *);
83 
84 private:
85     void addStatusMessage(QString);
86     void addOutput(QString);
87 
88     void updateStyles();
89 
90     void findText(QTextDocument::FindFlags);
91 
92     bool hasMessages;
93     bool hasHighlightMessages;
94 
95     QString cid;
96     QString hubUrl;
97     QString nick_;
98     QMenu *arena_menu;
99 
100     QStringList out_messages;
101     int out_messages_index;
102     bool out_messages_unsent;
103 };
104