2014-06-25 04:11:11 +08:00
|
|
|
#ifndef WIDGET_H
|
|
|
|
#define WIDGET_H
|
|
|
|
|
|
|
|
#include <QThread>
|
|
|
|
#include <QWidget>
|
|
|
|
#include <QString>
|
2014-07-01 10:12:17 +08:00
|
|
|
#include <QHBoxLayout>
|
|
|
|
#include <QMenu>
|
2014-06-25 04:11:11 +08:00
|
|
|
#include "core.h"
|
2014-06-27 06:42:45 +08:00
|
|
|
#include "widget/form/addfriendform.h"
|
|
|
|
#include "widget/form/settingsform.h"
|
2014-06-30 05:38:48 +08:00
|
|
|
#include "camera.h"
|
2014-06-25 04:11:11 +08:00
|
|
|
|
2014-07-01 10:12:17 +08:00
|
|
|
#define PIXELS_TO_ACT 5
|
|
|
|
|
2014-06-25 04:11:11 +08:00
|
|
|
namespace Ui {
|
|
|
|
class Widget;
|
|
|
|
}
|
|
|
|
|
|
|
|
class GroupWidget;
|
|
|
|
class AddFriendForm;
|
|
|
|
class SettingsForm;
|
2014-07-01 04:52:03 +08:00
|
|
|
struct FriendWidget;
|
2014-06-25 04:11:11 +08:00
|
|
|
class Group;
|
2014-07-01 04:52:03 +08:00
|
|
|
struct Friend;
|
2014-06-25 04:11:11 +08:00
|
|
|
|
|
|
|
class Widget : public QWidget
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
public:
|
|
|
|
explicit Widget(QWidget *parent = 0);
|
2014-07-01 10:12:17 +08:00
|
|
|
enum TitleMode { CleanTitle = 0, OnlyCloseButton, MenuOff, MaxMinOff, FullScreenMode, MaximizeModeOff, MinimizeModeOff, FullTitle };
|
|
|
|
void setTitlebarMode(const TitleMode &flag);
|
|
|
|
void setTitlebarMenu(QMenu *menu, const QString &icon = "");
|
|
|
|
void setCentralWidget(QWidget *widget, const QString &widgetName);
|
2014-06-25 04:11:11 +08:00
|
|
|
QString getUsername();
|
2014-06-26 07:48:20 +08:00
|
|
|
Core* getCore();
|
2014-06-30 20:49:42 +08:00
|
|
|
Camera* getCamera();
|
2014-06-25 04:11:11 +08:00
|
|
|
static Widget* getInstance();
|
2014-06-30 05:38:48 +08:00
|
|
|
void showTestCamview();
|
2014-07-01 03:14:51 +08:00
|
|
|
void newMessageAlert();
|
|
|
|
bool isFriendWidgetCurActiveWidget(Friend* f);
|
|
|
|
void updateFriendStatusLights(int friendId);
|
2014-07-01 10:12:17 +08:00
|
|
|
int useNativeTheme;
|
2014-06-25 04:11:11 +08:00
|
|
|
~Widget();
|
|
|
|
|
|
|
|
signals:
|
|
|
|
void friendRequestAccepted(const QString& userId);
|
|
|
|
void friendRequested(const QString& friendAddress, const QString& message);
|
|
|
|
void statusSet(Status status);
|
|
|
|
void statusSelected(Status status);
|
|
|
|
void usernameChanged(const QString& username);
|
|
|
|
void statusMessageChanged(const QString& statusMessage);
|
|
|
|
|
|
|
|
private slots:
|
2014-07-01 10:12:17 +08:00
|
|
|
void maximizeBtnClicked();
|
|
|
|
void minimizeBtnClicked();
|
2014-06-25 04:11:11 +08:00
|
|
|
void onConnected();
|
|
|
|
void onDisconnected();
|
|
|
|
void onStatusSet(Status status);
|
|
|
|
void onAddClicked();
|
|
|
|
void onGroupClicked();
|
|
|
|
void onTransferClicked();
|
|
|
|
void onSettingsClicked();
|
|
|
|
void onFailedToStartCore();
|
|
|
|
void onUsernameChanged(const QString& newUsername, const QString& oldUsername);
|
|
|
|
void onStatusMessageChanged(const QString& newStatusMessage, const QString& oldStatusMessage);
|
|
|
|
void onUsernameChanged(const QString& newUsername);
|
|
|
|
void onStatusMessageChanged(const QString& newStatusMessage);
|
|
|
|
void setUsername(const QString& username);
|
|
|
|
void setStatusMessage(const QString &statusMessage);
|
|
|
|
void addFriend(int friendId, const QString& userId);
|
2014-06-27 01:45:47 +08:00
|
|
|
void addFriendFailed(const QString& userId);
|
2014-06-25 04:11:11 +08:00
|
|
|
void onFriendStatusChanged(int friendId, Status status);
|
|
|
|
void onFriendStatusMessageChanged(int friendId, const QString& message);
|
|
|
|
void onFriendUsernameChanged(int friendId, const QString& username);
|
|
|
|
void onFriendStatusMessageLoaded(int friendId, const QString& message);
|
|
|
|
void onFriendUsernameLoaded(int friendId, const QString& username);
|
|
|
|
void onFriendWidgetClicked(FriendWidget* widget);
|
|
|
|
void onFriendMessageReceived(int friendId, const QString& message);
|
|
|
|
void onFriendRequestReceived(const QString& userId, const QString& message);
|
2014-06-30 05:38:48 +08:00
|
|
|
void onEmptyGroupCreated(int groupId);
|
2014-07-03 15:22:12 +08:00
|
|
|
void onGroupInviteReceived(int32_t friendId, const uint8_t *publicKey);
|
2014-06-25 04:11:11 +08:00
|
|
|
void onGroupMessageReceived(int groupnumber, int friendgroupnumber, const QString& message);
|
|
|
|
void onGroupNamelistChanged(int groupnumber, int peernumber, uint8_t change);
|
|
|
|
void onGroupWidgetClicked(GroupWidget* widget);
|
|
|
|
void removeFriend(int friendId);
|
2014-07-02 05:50:07 +08:00
|
|
|
void copyFriendIdToClipboard(int friendId);
|
2014-06-25 04:11:11 +08:00
|
|
|
void removeGroup(int groupId);
|
|
|
|
|
2014-07-01 10:12:17 +08:00
|
|
|
protected slots:
|
|
|
|
void moveWindow(QMouseEvent *e);
|
|
|
|
|
2014-06-25 04:11:11 +08:00
|
|
|
private:
|
|
|
|
void hideMainForms();
|
|
|
|
Group* createGroup(int groupId);
|
|
|
|
|
|
|
|
private:
|
|
|
|
Ui::Widget *ui;
|
2014-07-01 10:12:17 +08:00
|
|
|
QHBoxLayout *centralLayout;
|
|
|
|
QPoint dragPosition;
|
|
|
|
TitleMode m_titleMode;
|
|
|
|
bool moveWidget;
|
|
|
|
bool inResizeZone;
|
|
|
|
bool allowToResize;
|
|
|
|
bool resizeVerSup;
|
|
|
|
bool resizeHorEsq;
|
|
|
|
bool resizeDiagSupEsq;
|
|
|
|
bool resizeDiagSupDer;
|
|
|
|
void mouseMoveEvent(QMouseEvent *e);
|
|
|
|
void mousePressEvent(QMouseEvent *e);
|
|
|
|
void mouseReleaseEvent(QMouseEvent *e);
|
|
|
|
void mouseDoubleClickEvent(QMouseEvent *e);
|
|
|
|
void paintEvent (QPaintEvent *);
|
|
|
|
void resizeWindow(QMouseEvent *e);
|
|
|
|
bool event(QEvent *event);
|
|
|
|
int isWindowMinimized;
|
2014-06-25 04:11:11 +08:00
|
|
|
Core* core;
|
|
|
|
QThread* coreThread;
|
|
|
|
AddFriendForm friendForm;
|
|
|
|
SettingsForm settingsForm;
|
|
|
|
static Widget* instance;
|
2014-06-27 07:35:30 +08:00
|
|
|
FriendWidget* activeFriendWidget;
|
2014-06-27 09:47:16 +08:00
|
|
|
GroupWidget* activeGroupWidget;
|
2014-06-28 00:32:40 +08:00
|
|
|
int isFriendWidgetActive, isGroupWidgetActive;
|
2014-06-30 05:38:48 +08:00
|
|
|
SelfCamView* camview;
|
|
|
|
Camera* camera;
|
2014-06-25 04:11:11 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif // WIDGET_H
|