1
0
mirror of https://github.com/qTox/qTox.git synced 2024-03-22 14:00:36 +08:00
qTox/widget/widget.h

150 lines
4.9 KiB
C
Raw Normal View History

2014-07-07 00:19:45 +08:00
/*
Copyright (C) 2014 by Project Tox <https://tox.im>
This file is part of qTox, a Qt-based graphical interface for Tox.
This program is libre software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
See the COPYING file for more details.
*/
2014-06-25 04:11:11 +08:00
#ifndef WIDGET_H
#define WIDGET_H
#include <QMainWindow>
#include "widget/form/addfriendform.h"
#include "widget/form/settingswidget.h"
#include "widget/form/filesform.h"
2014-09-11 21:44:34 +08:00
#include "corestructs.h"
2014-06-25 04:11:11 +08:00
#define PIXELS_TO_ACT 7
2014-06-25 04:11:11 +08:00
namespace Ui {
class MainWindow;
2014-06-25 04:11:11 +08:00
}
class GenericChatroomWidget;
2014-06-25 04:11:11 +08:00
class Group;
2014-07-01 04:52:03 +08:00
struct Friend;
2014-09-11 21:44:34 +08:00
class QSplitter;
class SelfCamView;
class QMenu;
class Core;
class Camera;
class FriendListWidget;
2014-06-25 04:11:11 +08:00
class Widget : public QMainWindow
2014-06-25 04:11:11 +08:00
{
Q_OBJECT
public:
explicit Widget(QWidget *parent = 0);
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();
QThread* getCoreThread();
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);
bool getIsWindowMinimized();
2014-06-25 04:11:11 +08:00
~Widget();
virtual void closeEvent(QCloseEvent *event);
2014-06-25 04:11:11 +08:00
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:
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 setUsername(const QString& username);
void setStatusMessage(const QString &statusMessage);
void addFriend(int friendId, const QString& userId);
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 onChatroomWidgetClicked(GenericChatroomWidget *);
2014-06-25 04:11:11 +08:00
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 removeFriend(int friendId);
void copyFriendIdToClipboard(int friendId);
2014-06-25 04:11:11 +08:00
void removeGroup(int groupId);
2014-07-06 04:54:27 +08:00
void setStatusOnline();
void setStatusAway();
void setStatusBusy();
2014-06-25 04:11:11 +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::MainWindow *ui;
QSplitter *centralLayout;
QPoint dragPosition;
TitleMode m_titleMode;
bool moveWidget;
bool inResizeZone;
bool allowToResize;
bool resizeVerSup;
bool resizeHorEsq;
bool resizeDiagSupEsq;
bool resizeDiagSupDer;
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;
SettingsWidget settingsWidget;
FilesForm filesForm;
2014-06-25 04:11:11 +08:00
static Widget* instance;
GenericChatroomWidget* activeChatroomWidget;
2014-08-22 23:19:16 +08:00
FriendListWidget* contactListWidget;
2014-06-30 05:38:48 +08:00
SelfCamView* camview;
Camera* camera;
bool notify(QObject *receiver, QEvent *event);
2014-07-21 02:17:06 +08:00
bool eventFilter(QObject *, QEvent *event);
2014-06-25 04:11:11 +08:00
};
#endif // WIDGET_H