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
|
|
|
|
|
2014-08-11 16:00:08 +08:00
|
|
|
#include <QMainWindow>
|
2014-10-21 02:03:44 +08:00
|
|
|
#include <QSystemTrayIcon>
|
2014-10-24 02:39:28 +08:00
|
|
|
#include <QMessageBox>
|
2014-10-08 12:26:25 +08:00
|
|
|
#include "form/addfriendform.h"
|
|
|
|
#include "form/settingswidget.h"
|
|
|
|
#include "form/settings/identityform.h"
|
|
|
|
#include "form/filesform.h"
|
|
|
|
#include "src/corestructs.h"
|
2014-06-25 04:11:11 +08:00
|
|
|
|
2014-07-05 14:50:18 +08:00
|
|
|
#define PIXELS_TO_ACT 7
|
2014-07-01 10:12:17 +08:00
|
|
|
|
2014-06-25 04:11:11 +08:00
|
|
|
namespace Ui {
|
2014-08-11 16:00:08 +08:00
|
|
|
class MainWindow;
|
2014-06-25 04:11:11 +08:00
|
|
|
}
|
|
|
|
|
2014-09-02 00:20:28 +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;
|
2014-10-08 22:42:09 +08:00
|
|
|
class VideoSurface;
|
2014-09-11 21:44:34 +08:00
|
|
|
class QMenu;
|
|
|
|
class Core;
|
|
|
|
class Camera;
|
|
|
|
class FriendListWidget;
|
2014-09-26 22:39:29 +08:00
|
|
|
class MaskablePixmapWidget;
|
2014-10-16 17:47:58 +08:00
|
|
|
class QTimer;
|
2014-10-18 07:06:30 +08:00
|
|
|
class QTranslator;
|
2014-06-25 04:11:11 +08:00
|
|
|
|
2014-08-11 16:00:08 +08:00
|
|
|
class Widget : public QMainWindow
|
2014-06-25 04:11:11 +08:00
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
public:
|
|
|
|
explicit Widget(QWidget *parent = 0);
|
2014-07-01 10:12:17 +08:00
|
|
|
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-07-07 06:03:37 +08:00
|
|
|
QThread* getCoreThread();
|
2014-06-30 20:49:42 +08:00
|
|
|
Camera* getCamera();
|
2014-06-25 04:11:11 +08:00
|
|
|
static Widget* getInstance();
|
2014-11-10 16:09:20 +08:00
|
|
|
void newMessageAlert(GenericChatroomWidget* chat);
|
2014-07-01 03:14:51 +08:00
|
|
|
bool isFriendWidgetCurActiveWidget(Friend* f);
|
2014-09-01 00:29:55 +08:00
|
|
|
bool getIsWindowMinimized();
|
2014-10-09 13:30:33 +08:00
|
|
|
static QList<QString> searchProfiles();
|
2014-10-09 16:07:26 +08:00
|
|
|
void clearContactsList();
|
2014-10-18 07:06:30 +08:00
|
|
|
void setIdleTimer(int minutes);
|
|
|
|
void setTranslation();
|
2014-10-24 02:39:28 +08:00
|
|
|
Q_INVOKABLE QMessageBox::StandardButton showWarningMsgBox(const QString& title, const QString& msg,
|
|
|
|
QMessageBox::StandardButtons buttonss = QMessageBox::Ok);
|
2014-11-02 19:24:14 +08:00
|
|
|
Q_INVOKABLE void setEnabledThreadsafe(bool enabled);
|
2014-11-10 07:31:29 +08:00
|
|
|
Q_INVOKABLE bool askMsgboxQuestion(const QString& title, const QString& msg);
|
2014-06-25 04:11:11 +08:00
|
|
|
~Widget();
|
2014-08-11 16:00:08 +08:00
|
|
|
|
|
|
|
virtual void closeEvent(QCloseEvent *event);
|
2014-10-20 19:50:12 +08:00
|
|
|
virtual void changeEvent(QEvent *event);
|
|
|
|
|
2014-11-10 21:06:35 +08:00
|
|
|
void clearAllReceipts();
|
2014-06-25 04:11:11 +08:00
|
|
|
|
2014-10-20 11:07:51 +08:00
|
|
|
public slots:
|
|
|
|
void onSettingsClicked();
|
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);
|
2014-10-15 10:06:44 +08:00
|
|
|
void changeProfile(const QString& profile);
|
2014-06-25 04:11:11 +08:00
|
|
|
|
|
|
|
private slots:
|
|
|
|
void onConnected();
|
|
|
|
void onDisconnected();
|
|
|
|
void onStatusSet(Status status);
|
|
|
|
void onAddClicked();
|
|
|
|
void onGroupClicked();
|
|
|
|
void onTransferClicked();
|
|
|
|
void onFailedToStartCore();
|
2014-10-06 04:49:44 +08:00
|
|
|
void onBadProxyCore();
|
2014-09-24 22:51:16 +08:00
|
|
|
void onAvatarClicked();
|
|
|
|
void onSelfAvatarLoaded(const QPixmap &pic);
|
2014-06-25 04:11:11 +08:00
|
|
|
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);
|
2014-11-10 03:23:43 +08:00
|
|
|
void addFriendFailed(const QString& userId, const QString& errorInfo = QString());
|
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);
|
2014-09-02 00:20:28 +08:00
|
|
|
void onChatroomWidgetClicked(GenericChatroomWidget *);
|
2014-10-02 14:01:23 +08:00
|
|
|
void onFriendMessageReceived(int friendId, const QString& message, bool isAction);
|
2014-06-25 04:11:11 +08:00
|
|
|
void onFriendRequestReceived(const QString& userId, const QString& message);
|
2014-11-01 22:19:11 +08:00
|
|
|
void onReceiptRecieved(int friendId, int receipt);
|
2014-06-30 05:38:48 +08:00
|
|
|
void onEmptyGroupCreated(int groupId);
|
2014-11-13 07:13:11 +08:00
|
|
|
void onGroupInviteReceived(int32_t friendId, uint8_t type, QByteArray invite);
|
2014-11-01 21:00:43 +08:00
|
|
|
void onGroupMessageReceived(int groupnumber, const QString& message, const QString& author, bool isAction);
|
2014-06-25 04:11:11 +08:00
|
|
|
void onGroupNamelistChanged(int groupnumber, int peernumber, uint8_t change);
|
|
|
|
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-06 04:54:27 +08:00
|
|
|
void setStatusOnline();
|
|
|
|
void setStatusAway();
|
|
|
|
void setStatusBusy();
|
2014-09-24 00:35:06 +08:00
|
|
|
void onMessageSendResult(int friendId, const QString& message, int messageId);
|
|
|
|
void onGroupSendResult(int groupId, const QString& message, int result);
|
2014-10-08 10:20:38 +08:00
|
|
|
void playRingtone();
|
2014-10-21 02:03:44 +08:00
|
|
|
void onIconClick(QSystemTrayIcon::ActivationReason);
|
2014-10-16 17:47:58 +08:00
|
|
|
void onUserAway();
|
2014-10-24 19:25:40 +08:00
|
|
|
void getPassword(QString info, int passtype, uint8_t* salt);
|
2014-11-14 04:33:11 +08:00
|
|
|
void onSetShowSystemTray(bool newValue);
|
2014-07-01 10:12:17 +08:00
|
|
|
|
2014-06-25 04:11:11 +08:00
|
|
|
private:
|
2014-10-15 23:45:41 +08:00
|
|
|
void init();
|
2014-06-25 04:11:11 +08:00
|
|
|
void hideMainForms();
|
2014-10-04 16:54:50 +08:00
|
|
|
virtual bool event(QEvent * e);
|
2014-06-25 04:11:11 +08:00
|
|
|
Group* createGroup(int groupId);
|
2014-11-12 07:00:24 +08:00
|
|
|
void removeFriend(Friend* f, bool fake = false);
|
|
|
|
void removeGroup(Group* g, bool fake = false);
|
2014-10-09 13:30:33 +08:00
|
|
|
QString askProfiles();
|
|
|
|
QString detectProfile();
|
2014-10-21 02:03:44 +08:00
|
|
|
QSystemTrayIcon *icon;
|
|
|
|
QMenu *trayMenu;
|
|
|
|
QAction *statusOnline,
|
|
|
|
*statusAway,
|
|
|
|
*statusBusy,
|
|
|
|
*actionQuit;
|
2014-06-25 04:11:11 +08:00
|
|
|
|
2014-08-11 16:00:08 +08:00
|
|
|
Ui::MainWindow *ui;
|
2014-07-03 14:43:23 +08:00
|
|
|
QSplitter *centralLayout;
|
2014-07-01 10:12:17 +08:00
|
|
|
QPoint dragPosition;
|
2014-06-25 04:11:11 +08:00
|
|
|
Core* core;
|
|
|
|
QThread* coreThread;
|
2014-10-18 22:54:52 +08:00
|
|
|
AddFriendForm* addFriendForm;
|
2014-09-30 17:44:27 +08:00
|
|
|
SettingsWidget* settingsWidget;
|
2014-10-18 22:54:52 +08:00
|
|
|
FilesForm* filesForm;
|
2014-06-25 04:11:11 +08:00
|
|
|
static Widget* instance;
|
2014-09-02 00:20:28 +08:00
|
|
|
GenericChatroomWidget* activeChatroomWidget;
|
2014-08-22 23:19:16 +08:00
|
|
|
FriendListWidget* contactListWidget;
|
2014-09-26 22:39:29 +08:00
|
|
|
MaskablePixmapWidget* profilePicture;
|
2014-07-03 14:43:23 +08:00
|
|
|
bool notify(QObject *receiver, QEvent *event);
|
2014-10-16 17:47:58 +08:00
|
|
|
bool autoAwayActive = false;
|
|
|
|
QTimer* idleTimer;
|
2014-10-18 07:06:30 +08:00
|
|
|
QTranslator* translator;
|
2014-06-25 04:11:11 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif // WIDGET_H
|