2018-12-25 15:34:59 -05:00
|
|
|
/*******************************************************************************
|
|
|
|
* gui/MainWindow.h *
|
|
|
|
* *
|
|
|
|
* Copyright (c) 2006 Retroshare Team <retroshare.project@gmail.com> *
|
|
|
|
* *
|
|
|
|
* This program is free software: you can redistribute it and/or modify *
|
|
|
|
* it under the terms of the GNU Affero 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 *
|
|
|
|
* GNU Affero General Public License for more details. *
|
|
|
|
* *
|
|
|
|
* You should have received a copy of the GNU Affero General Public License *
|
|
|
|
* along with this program. If not, see <https://www.gnu.org/licenses/>. *
|
|
|
|
* *
|
|
|
|
*******************************************************************************/
|
2007-11-14 22:18:48 -05:00
|
|
|
|
|
|
|
#ifndef _MainWindow_H
|
|
|
|
#define _MainWindow_H
|
|
|
|
|
|
|
|
#include <QSystemTrayIcon>
|
2010-07-17 19:19:43 -04:00
|
|
|
#include <set>
|
2007-11-14 22:18:48 -05:00
|
|
|
|
2009-12-31 08:36:39 -05:00
|
|
|
#include "gui/common/rwindow.h"
|
2007-11-14 22:18:48 -05:00
|
|
|
|
2012-12-20 08:30:16 -05:00
|
|
|
namespace Ui {
|
|
|
|
class MainWindow;
|
|
|
|
}
|
|
|
|
|
2010-07-23 14:52:58 -04:00
|
|
|
class QComboBox;
|
|
|
|
class QLabel;
|
2012-12-20 08:30:16 -05:00
|
|
|
class QActionGroup;
|
2014-05-09 22:38:47 -04:00
|
|
|
class QListWidgetItem;
|
2010-07-17 19:19:43 -04:00
|
|
|
class Idle;
|
2008-06-16 16:28:16 -04:00
|
|
|
class PeerStatus;
|
2009-05-01 08:45:27 -04:00
|
|
|
class NATStatus;
|
2010-10-27 08:49:46 -04:00
|
|
|
class DHTStatus;
|
2010-10-09 14:35:34 -04:00
|
|
|
class HashingStatus;
|
2014-05-29 12:15:26 -04:00
|
|
|
class DiscStatus;
|
|
|
|
class RatesStatus;
|
|
|
|
class OpModeStatus;
|
|
|
|
class SoundStatus;
|
|
|
|
class ToasterDisable;
|
2014-11-02 15:29:06 -05:00
|
|
|
class SysTrayStatus;
|
2018-01-19 07:42:16 -05:00
|
|
|
class TorStatus ;
|
2013-09-07 00:21:48 -04:00
|
|
|
//class ForumsDialog;
|
2014-05-29 12:15:26 -04:00
|
|
|
class GxsChannelDialog ;
|
|
|
|
class GxsForumsDialog ;
|
2014-07-22 11:04:36 -04:00
|
|
|
class PostedDialog;
|
2011-05-17 13:27:47 -04:00
|
|
|
class FriendsDialog;
|
2016-12-27 14:42:47 -05:00
|
|
|
class IdDialog;
|
2013-02-22 16:42:27 -05:00
|
|
|
class ChatLobbyWidget;
|
2017-01-26 16:35:33 -05:00
|
|
|
class SettingsPage ;
|
2010-06-08 17:38:36 -04:00
|
|
|
class ChatDialog;
|
|
|
|
class NetworkDialog;
|
|
|
|
class SearchDialog;
|
|
|
|
class TransfersDialog;
|
|
|
|
class MessagesDialog;
|
|
|
|
class PluginsPage;
|
2016-12-12 15:16:56 -05:00
|
|
|
class HomePage;
|
2020-02-22 13:01:09 -05:00
|
|
|
//class ChannelFeed;
|
2010-07-23 14:52:58 -04:00
|
|
|
class BandwidthGraph;
|
2012-12-20 08:30:16 -05:00
|
|
|
class MainPage;
|
2013-02-22 16:42:27 -05:00
|
|
|
class NewsFeed;
|
2012-12-20 08:30:16 -05:00
|
|
|
class UserNotify;
|
2010-05-02 20:09:55 -04:00
|
|
|
|
2019-08-21 09:23:25 -04:00
|
|
|
#ifdef MESSENGER_WINDOW
|
|
|
|
class MessengerWindow;
|
|
|
|
#endif
|
2010-07-23 14:52:58 -04:00
|
|
|
#ifdef UNFINISHED
|
|
|
|
class ApplicationWindow;
|
|
|
|
#endif
|
|
|
|
|
2014-05-01 07:46:25 -04:00
|
|
|
class MainWindow : public RWindow
|
2007-11-14 22:18:48 -05:00
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
public:
|
|
|
|
/** Main dialog pages. */
|
|
|
|
enum Page {
|
2010-11-04 07:14:47 -04:00
|
|
|
/* Fixed numbers for load and save the last page */
|
|
|
|
Network = 0, /** Network page. */
|
2011-05-17 13:27:47 -04:00
|
|
|
Friends = 1, /** Friends page. */
|
2013-02-22 16:42:27 -05:00
|
|
|
ChatLobby = 2, /** Chat Lobby page. */
|
2010-11-04 07:14:47 -04:00
|
|
|
Transfers = 3, /** Transfers page. */
|
|
|
|
SharedDirectories = 4, /** Shared Directories page. */
|
|
|
|
Messages = 5, /** Messages page. */
|
2014-05-27 17:14:05 -04:00
|
|
|
Channels = 6, /** Channels page. */
|
|
|
|
Forums = 7, /** Forums page. */
|
2013-02-22 16:42:27 -05:00
|
|
|
Search = 8, /** Search page. */
|
2014-07-22 11:04:36 -04:00
|
|
|
Posted = 11, /** Posted links */
|
2020-02-22 13:01:09 -05:00
|
|
|
People = 12, /** People page. */
|
|
|
|
Options = 13 /** People page. */
|
2017-01-26 16:35:33 -05:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
enum StatusElement {
|
2017-03-03 14:35:18 -05:00
|
|
|
StatusGrpStatus = 0x01,
|
|
|
|
StatusCompactMode = 0x02,
|
|
|
|
StatusShowToolTip = 0x03,
|
|
|
|
StatusShowStatus = 0x04,
|
|
|
|
StatusShowPeer = 0x05,
|
|
|
|
StatusShowNAT = 0x06,
|
|
|
|
StatusShowDHT = 0x07,
|
|
|
|
StatusShowHashing = 0x08,
|
|
|
|
StatusShowDisc = 0x09,
|
|
|
|
StatusShowRate = 0x0a,
|
|
|
|
StatusShowOpMode = 0x0b,
|
|
|
|
StatusShowSound = 0x0c,
|
|
|
|
StatusShowToaster = 0x0d,
|
|
|
|
StatusShowSystray = 0x0e,
|
2007-11-14 22:18:48 -05:00
|
|
|
};
|
|
|
|
|
2010-05-02 20:09:55 -04:00
|
|
|
/** Create main window */
|
|
|
|
static MainWindow *Create ();
|
2010-07-17 19:19:43 -04:00
|
|
|
static MainWindow *getInstance();
|
2009-08-19 18:19:35 -04:00
|
|
|
|
2007-11-14 22:18:48 -05:00
|
|
|
/** Destructor. */
|
|
|
|
~MainWindow();
|
|
|
|
|
2012-03-30 19:02:52 -04:00
|
|
|
static void raiseWindow();
|
2010-05-23 17:32:58 -04:00
|
|
|
/** Shows the MainWindow dialog with focus set to the given page. */
|
|
|
|
static void showWindow(Page page);
|
2012-12-20 08:30:16 -05:00
|
|
|
static void showWindow(MainPage *page);
|
2010-05-23 17:32:58 -04:00
|
|
|
/** Set focus to the given page. */
|
2010-11-04 07:14:47 -04:00
|
|
|
static bool activatePage (Page page);
|
|
|
|
static Page getActivatePage ();
|
2010-05-23 17:32:58 -04:00
|
|
|
|
2010-05-27 15:48:52 -04:00
|
|
|
/** get page */
|
|
|
|
static MainPage *getPage (Page page);
|
|
|
|
|
2012-08-05 16:12:55 -04:00
|
|
|
const QList<UserNotify*> &getUserNotifyList();
|
|
|
|
|
2009-08-19 18:19:35 -04:00
|
|
|
/* A Bit of a Hack... but public variables for
|
|
|
|
* the dialogs, so we can add them to the
|
2007-11-14 22:18:48 -05:00
|
|
|
* Notify Class...
|
|
|
|
*/
|
2009-08-19 18:19:35 -04:00
|
|
|
|
2013-02-22 16:42:27 -05:00
|
|
|
// NetworkDialog *networkDialog;
|
|
|
|
// SearchDialog *searchDialog;
|
|
|
|
|
2016-12-12 15:16:56 -05:00
|
|
|
HomePage *homePage;
|
2014-04-26 12:32:33 -04:00
|
|
|
NewsFeed *newsFeed;
|
|
|
|
FriendsDialog *friendsDialog;
|
|
|
|
TransfersDialog *transfersDialog;
|
2017-03-03 14:35:18 -05:00
|
|
|
IdDialog *idDialog;
|
2014-04-26 12:32:33 -04:00
|
|
|
ChatLobbyWidget *chatLobbyDialog;
|
|
|
|
MessagesDialog *messagesDialog;
|
2017-01-26 16:35:33 -05:00
|
|
|
SettingsPage *settingsDialog;
|
2014-05-07 20:00:21 -04:00
|
|
|
GxsChannelDialog *gxschannelDialog ;
|
2014-04-26 12:32:33 -04:00
|
|
|
GxsForumsDialog *gxsforumDialog ;
|
2014-07-22 11:04:36 -04:00
|
|
|
PostedDialog *postedDialog;
|
2014-04-26 12:32:33 -04:00
|
|
|
|
2013-09-07 00:21:48 -04:00
|
|
|
// ForumsDialog *forumsDialog;
|
|
|
|
// ChannelFeed *channelFeed;
|
2010-05-02 20:09:55 -04:00
|
|
|
Idle *idle;
|
2010-04-27 08:18:44 -04:00
|
|
|
|
2010-05-02 20:09:55 -04:00
|
|
|
#ifdef UNFINISHED
|
2007-11-14 22:18:48 -05:00
|
|
|
ApplicationWindow *applicationWindow;
|
2009-12-05 08:42:24 -05:00
|
|
|
#endif
|
2009-02-11 17:50:12 -05:00
|
|
|
PluginsPage* pluginsPage ;
|
2007-11-14 22:18:48 -05:00
|
|
|
|
2010-06-15 12:51:48 -04:00
|
|
|
static void installGroupChatNotifier();
|
2010-11-25 19:54:18 -05:00
|
|
|
static void installNotifyIcons();
|
2012-07-30 09:27:40 -04:00
|
|
|
static void displayLobbySystrayMsg(const QString&,const QString&);
|
2007-11-14 22:18:48 -05:00
|
|
|
|
2017-01-26 16:35:33 -05:00
|
|
|
static void switchVisibilityStatus(MainWindow::StatusElement e,bool b);
|
|
|
|
|
2010-07-17 19:19:43 -04:00
|
|
|
/* initialize widget with status informations, status constant stored in data or in Qt::UserRole */
|
2010-07-20 15:45:07 -04:00
|
|
|
void initializeStatusObject(QObject *pObject, bool bConnect);
|
2010-07-17 19:19:43 -04:00
|
|
|
void removeStatusObject(QObject *pObject);
|
|
|
|
void setStatus(QObject *pObject, int nStatus);
|
|
|
|
|
2017-01-18 14:18:12 -05:00
|
|
|
QComboBox *statusComboBoxInstance();
|
|
|
|
PeerStatus *peerstatusInstance();
|
|
|
|
NATStatus *natstatusInstance();
|
|
|
|
DHTStatus *dhtstatusInstance();
|
|
|
|
HashingStatus *hashingstatusInstance();
|
|
|
|
DiscStatus *discstatusInstance();
|
|
|
|
RatesStatus *ratesstatusInstance();
|
|
|
|
OpModeStatus *opModeStatusInstance();
|
2014-05-29 12:15:26 -04:00
|
|
|
SoundStatus *soundStatusInstance();
|
|
|
|
ToasterDisable *toasterDisableInstance();
|
2014-11-02 15:29:06 -05:00
|
|
|
SysTrayStatus *sysTrayStatusInstance();
|
2014-05-29 12:15:26 -04:00
|
|
|
|
2017-10-23 04:42:03 -04:00
|
|
|
static bool hiddenmode;
|
|
|
|
|
2007-11-14 22:18:48 -05:00
|
|
|
public slots:
|
2016-03-01 07:08:33 -05:00
|
|
|
void receiveNewArgs(QStringList args);
|
2010-02-25 08:12:18 -05:00
|
|
|
void displayErrorMessage(int,int,const QString&) ;
|
2010-04-24 18:09:47 -04:00
|
|
|
void postModDirectories(bool update_local);
|
2010-08-09 08:16:21 -04:00
|
|
|
void displayDiskSpaceWarning(int loc,int size_limit_mb) ;
|
2010-07-17 19:19:43 -04:00
|
|
|
void checkAndSetIdle(int idleTime);
|
2010-04-24 18:09:47 -04:00
|
|
|
|
2013-03-15 19:08:54 -04:00
|
|
|
void externalLinkActivated(const QUrl &url);
|
2016-03-01 07:08:33 -05:00
|
|
|
void retroshareLinkActivated(const QUrl &url);
|
|
|
|
void openRsCollection(const QString &filename);
|
|
|
|
void processLastArgs();
|
2014-05-09 22:38:47 -04:00
|
|
|
//! Go to a specific part of the control panel.
|
|
|
|
void setNewPage(int page);
|
2014-05-29 12:15:26 -04:00
|
|
|
void setCompactStatusMode(bool compact);
|
2017-09-27 16:26:14 -04:00
|
|
|
void showBandwidthGraph();
|
2011-04-14 19:58:30 -04:00
|
|
|
|
2015-09-01 08:43:29 -04:00
|
|
|
void toggleStatusToolTip(bool toggle);
|
2009-12-30 21:23:02 -05:00
|
|
|
protected:
|
2010-05-02 20:09:55 -04:00
|
|
|
/** Default Constructor */
|
2013-10-18 17:10:33 -04:00
|
|
|
MainWindow(QWidget *parent = 0, Qt::WindowFlags flags = 0);
|
2010-05-02 20:09:55 -04:00
|
|
|
|
2009-12-30 21:23:02 -05:00
|
|
|
void closeEvent(QCloseEvent *);
|
|
|
|
|
|
|
|
/** Called when the user changes the UI translation. */
|
|
|
|
virtual void retranslateUi();
|
2007-11-14 22:18:48 -05:00
|
|
|
|
|
|
|
private slots:
|
|
|
|
|
|
|
|
void updateMenu();
|
2008-06-09 20:48:18 -04:00
|
|
|
void updateStatus();
|
2012-02-24 20:48:56 -05:00
|
|
|
void updateFriends();
|
2009-08-19 18:19:35 -04:00
|
|
|
|
2007-11-14 22:18:48 -05:00
|
|
|
void toggleVisibility(QSystemTrayIcon::ActivationReason e);
|
|
|
|
void toggleVisibilitycontextmenu();
|
2010-11-25 19:54:18 -05:00
|
|
|
|
2007-11-14 22:18:48 -05:00
|
|
|
/** Toolbar fns. */
|
|
|
|
void addFriend();
|
2017-11-12 16:46:29 -05:00
|
|
|
//void newRsCollection();
|
2019-08-21 09:23:25 -04:00
|
|
|
#ifdef MESSENGER_WINDOW
|
2007-11-14 22:18:48 -05:00
|
|
|
void showMessengerWindow();
|
2019-08-21 09:23:25 -04:00
|
|
|
#endif
|
2014-09-04 13:01:28 -04:00
|
|
|
void showStatisticsWindow();
|
2019-11-27 15:14:20 -05:00
|
|
|
#ifdef RS_JSONAPI
|
2019-11-10 11:38:16 -05:00
|
|
|
#ifdef RS_WEBUI
|
2015-04-28 10:55:13 -04:00
|
|
|
void showWebinterface();
|
2019-11-27 15:14:20 -05:00
|
|
|
#endif
|
2016-07-28 08:08:49 -04:00
|
|
|
#endif
|
2015-02-03 16:28:32 -05:00
|
|
|
//void servicePermission();
|
2011-07-06 09:08:27 -04:00
|
|
|
|
2009-12-05 08:42:24 -05:00
|
|
|
#ifdef UNFINISHED
|
2007-11-14 22:18:48 -05:00
|
|
|
void showApplWindow();
|
2009-12-05 08:42:24 -05:00
|
|
|
#endif
|
|
|
|
|
2009-05-01 12:17:24 -04:00
|
|
|
void showabout();
|
|
|
|
void openShareManager();
|
2009-12-30 21:23:02 -05:00
|
|
|
void displaySystrayMsg(const QString&,const QString&) ;
|
2009-08-19 18:19:35 -04:00
|
|
|
|
2009-05-01 12:17:24 -04:00
|
|
|
/** Displays the help browser and displays the most recently viewed help
|
2008-08-05 14:36:07 -04:00
|
|
|
* topic. */
|
|
|
|
void showHelpDialog();
|
|
|
|
/** Called when a child window requests the given help <b>topic</b>. */
|
|
|
|
void showHelpDialog(const QString &topic);
|
2008-03-31 09:00:00 -04:00
|
|
|
|
2010-05-02 20:09:55 -04:00
|
|
|
void showMess();
|
2009-07-23 13:11:51 -04:00
|
|
|
void showSettings();
|
2010-07-20 15:45:07 -04:00
|
|
|
void statusChangedMenu(QAction *pAction);
|
2010-07-18 17:28:56 -04:00
|
|
|
void statusChangedComboBox(int index);
|
2014-05-09 22:38:47 -04:00
|
|
|
void settingsChanged();
|
2009-08-19 18:19:35 -04:00
|
|
|
|
2007-11-14 22:18:48 -05:00
|
|
|
/** Called when user attempts to quit via quit button*/
|
|
|
|
void doQuit();
|
2010-01-08 08:00:00 -05:00
|
|
|
|
2012-08-05 16:12:55 -04:00
|
|
|
void updateTrayCombine();
|
2010-01-08 08:00:00 -05:00
|
|
|
|
2007-11-14 22:18:48 -05:00
|
|
|
private:
|
2014-05-09 22:38:47 -04:00
|
|
|
void initStackedPage();
|
|
|
|
void addPage(MainPage *page, QActionGroup *grp, QList<QPair<MainPage *, QPair<QAction *, QListWidgetItem *> > > *notify);
|
2009-11-24 15:17:13 -05:00
|
|
|
void createTrayIcon();
|
2010-11-25 19:54:18 -05:00
|
|
|
void createNotifyIcons();
|
2010-05-02 20:09:55 -04:00
|
|
|
static MainWindow *_instance;
|
|
|
|
|
2007-11-14 22:18:48 -05:00
|
|
|
/** A BandwidthGraph object which handles monitoring RetroShare bandwidth usage */
|
|
|
|
BandwidthGraph* _bandwidthGraph;
|
2009-08-19 18:19:35 -04:00
|
|
|
|
2014-05-10 14:05:18 -04:00
|
|
|
typedef void (MainWindow::*FunctionType)();
|
|
|
|
|
2008-03-30 19:28:57 -04:00
|
|
|
/** Creates a new action for a Main page. */
|
2012-08-08 06:48:29 -04:00
|
|
|
QAction* createPageAction(const QIcon &icon, const QString &text, QActionGroup *group);
|
2007-11-14 22:18:48 -05:00
|
|
|
/** Adds a new action to the toolbar. */
|
2014-05-10 14:05:18 -04:00
|
|
|
void addAction(QAction *action, FunctionType actionFunction, const char *slot = 0);
|
|
|
|
QMap<QString, FunctionType> _functionList;
|
2009-08-19 18:19:35 -04:00
|
|
|
|
2011-05-01 19:30:45 -04:00
|
|
|
QString nameAndLocation;
|
|
|
|
|
2007-11-14 22:18:48 -05:00
|
|
|
QSystemTrayIcon *trayIcon;
|
2011-07-13 15:24:33 -04:00
|
|
|
QMenu *notifyMenu;
|
|
|
|
QString notifyToolTip;
|
2008-03-31 08:06:56 -04:00
|
|
|
QAction *toggleVisibilityAction, *toolAct;
|
2012-08-05 16:12:55 -04:00
|
|
|
QList<UserNotify*> userNotifyList;
|
2008-06-09 20:48:18 -04:00
|
|
|
|
2014-05-29 12:15:26 -04:00
|
|
|
QComboBox *statusComboBox;
|
2008-06-16 16:28:16 -04:00
|
|
|
PeerStatus *peerstatus;
|
2009-05-01 08:45:27 -04:00
|
|
|
NATStatus *natstatus;
|
2010-10-27 08:49:46 -04:00
|
|
|
DHTStatus *dhtstatus;
|
2010-10-09 14:35:34 -04:00
|
|
|
HashingStatus *hashingstatus;
|
2014-05-29 12:15:26 -04:00
|
|
|
DiscStatus *discstatus;
|
|
|
|
RatesStatus *ratesstatus;
|
|
|
|
OpModeStatus *opModeStatus;
|
|
|
|
SoundStatus *soundStatus;
|
|
|
|
ToasterDisable *toasterDisable;
|
2014-11-02 15:29:06 -05:00
|
|
|
SysTrayStatus *sysTrayStatus;
|
2018-01-19 07:42:16 -05:00
|
|
|
TorStatus *torstatus;
|
2009-02-02 07:07:07 -05:00
|
|
|
|
2010-07-17 19:19:43 -04:00
|
|
|
/* Status */
|
|
|
|
std::set <QObject*> m_apStatusObjects; // added objects for status
|
|
|
|
bool m_bStatusLoadDone;
|
2012-02-24 20:48:56 -05:00
|
|
|
unsigned int onlineCount;
|
2010-07-17 19:19:43 -04:00
|
|
|
|
|
|
|
void loadOwnStatus();
|
|
|
|
|
|
|
|
// idle function
|
|
|
|
void setIdle(bool Idle);
|
|
|
|
bool isIdle;
|
2014-05-01 07:46:25 -04:00
|
|
|
|
|
|
|
Ui::MainWindow *ui ;
|
2007-11-14 22:18:48 -05:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|