2007-11-14 22:18:48 -05:00
|
|
|
/****************************************************************
|
|
|
|
* RetroShare is distributed under the following license:
|
|
|
|
*
|
|
|
|
* Copyright (C) 2006,2007 The RetroShare Team
|
|
|
|
*
|
|
|
|
* This program is free 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 2
|
|
|
|
* 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 General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
2009-08-19 18:19:35 -04:00
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
2007-11-14 22:18:48 -05:00
|
|
|
* Boston, MA 02110-1301, USA.
|
|
|
|
****************************************************************/
|
|
|
|
|
|
|
|
#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
|
|
|
|
|
|
|
#include "ui_MainWindow.h"
|
2009-12-31 08:36:39 -05:00
|
|
|
#include "gui/common/rwindow.h"
|
2007-11-14 22:18:48 -05:00
|
|
|
|
2010-07-23 14:52:58 -04:00
|
|
|
class QComboBox;
|
|
|
|
class QLabel;
|
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;
|
2009-05-02 18:14:20 -04:00
|
|
|
class RatesStatus;
|
2011-01-07 11:56:57 -05:00
|
|
|
class DiscStatus;
|
2010-10-27 08:49:46 -04:00
|
|
|
class DHTStatus;
|
2010-10-09 14:35:34 -04:00
|
|
|
class HashingStatus;
|
2010-05-02 20:09:55 -04:00
|
|
|
class ForumsDialog;
|
2011-05-17 13:27:47 -04:00
|
|
|
class FriendsDialog;
|
2010-06-08 17:38:36 -04:00
|
|
|
class ChatDialog;
|
|
|
|
class NetworkDialog;
|
|
|
|
class SearchDialog;
|
|
|
|
class TransfersDialog;
|
|
|
|
class MessagesDialog;
|
|
|
|
class SharedFilesDialog;
|
|
|
|
class MessengerWindow;
|
|
|
|
class PluginsPage;
|
2010-07-23 14:52:58 -04:00
|
|
|
class ChannelFeed;
|
|
|
|
class BandwidthGraph;
|
2010-05-02 20:09:55 -04:00
|
|
|
|
2010-11-20 15:58:35 -05:00
|
|
|
#ifdef RS_USE_LINKS
|
2010-05-02 20:09:55 -04:00
|
|
|
class LinksDialog;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef BLOGS
|
|
|
|
class BlogsDialog;
|
|
|
|
#endif
|
2008-06-16 16:28:16 -04:00
|
|
|
|
2010-07-23 14:52:58 -04:00
|
|
|
#ifdef UNFINISHED
|
|
|
|
class ApplicationWindow;
|
|
|
|
#endif
|
|
|
|
|
2008-08-15 16:07:54 -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. */
|
2010-11-04 07:14:47 -04:00
|
|
|
Search = 2, /** Search page. */
|
|
|
|
Transfers = 3, /** Transfers page. */
|
|
|
|
SharedDirectories = 4, /** Shared Directories page. */
|
|
|
|
Messages = 5, /** Messages page. */
|
|
|
|
Channels = 6, /** Channels page. */
|
|
|
|
Forums = 7, /** Forums page. */
|
2010-05-13 15:20:40 -04:00
|
|
|
#ifdef BLOGS
|
2010-11-04 07:14:47 -04:00
|
|
|
Blogs = 8, /** Blogs page. */
|
2010-05-13 15:20:40 -04:00
|
|
|
#endif
|
2010-11-20 15:58:35 -05:00
|
|
|
#ifdef RS_USE_LINKS
|
2010-11-04 07:14:47 -04:00
|
|
|
Links = 9, /** Links page. */
|
2010-07-17 17:17:14 -04:00
|
|
|
#endif
|
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();
|
|
|
|
|
2010-05-23 17:32:58 -04:00
|
|
|
/** Shows the MainWindow dialog with focus set to the given page. */
|
|
|
|
static void showWindow(Page page);
|
|
|
|
/** 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);
|
|
|
|
|
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
|
|
|
|
2009-02-02 07:07:07 -05:00
|
|
|
NetworkDialog *networkDialog;
|
2011-05-17 13:27:47 -04:00
|
|
|
FriendsDialog *friendsDialog;
|
2007-11-14 22:18:48 -05:00
|
|
|
SearchDialog *searchDialog;
|
|
|
|
TransfersDialog *transfersDialog;
|
|
|
|
ChatDialog *chatDialog;
|
|
|
|
MessagesDialog *messagesDialog;
|
|
|
|
SharedFilesDialog *sharedfilesDialog;
|
2010-05-02 20:09:55 -04:00
|
|
|
ForumsDialog *forumsDialog;
|
2010-07-17 17:17:14 -04:00
|
|
|
ChannelFeed *channelFeed;
|
2010-05-02 20:09:55 -04:00
|
|
|
Idle *idle;
|
2010-04-27 08:18:44 -04:00
|
|
|
|
2010-11-20 15:58:35 -05:00
|
|
|
#ifdef RS_USE_LINKS
|
2010-05-02 20:09:55 -04:00
|
|
|
LinksDialog *linksDialog;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef BLOGS
|
|
|
|
BlogsDialog *blogsFeed;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#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();
|
2007-11-14 22:18:48 -05:00
|
|
|
|
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);
|
|
|
|
|
2007-11-14 22:18:48 -05:00
|
|
|
public slots:
|
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-08-09 08:16:21 -04:00
|
|
|
void updateMessages();
|
2010-08-09 17:20:34 -04:00
|
|
|
void updateForums();
|
2010-10-06 20:17:42 -04:00
|
|
|
void updateChannels(int type);
|
2010-11-24 19:20:25 -05:00
|
|
|
void updateTransfers(int count);
|
2010-09-20 20:08:06 -04:00
|
|
|
void privateChatChanged(int list, int type);
|
2010-04-24 18:09:47 -04:00
|
|
|
|
2011-04-14 19:58:30 -04:00
|
|
|
void linkActivated(const QUrl &url);
|
|
|
|
|
2009-12-30 21:23:02 -05:00
|
|
|
protected:
|
2010-05-02 20:09:55 -04:00
|
|
|
/** Default Constructor */
|
|
|
|
MainWindow(QWidget *parent = 0, Qt::WFlags flags = 0);
|
|
|
|
|
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();
|
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
|
|
|
|
|
|
|
/* default parameter for connect with the actions of the combined systray icon */
|
|
|
|
void trayIconMessagesClicked(QSystemTrayIcon::ActivationReason e = QSystemTrayIcon::Trigger);
|
|
|
|
void trayIconForumsClicked(QSystemTrayIcon::ActivationReason e = QSystemTrayIcon::Trigger);
|
|
|
|
void trayIconChannelsClicked(QSystemTrayIcon::ActivationReason e = QSystemTrayIcon::Trigger);
|
|
|
|
void trayIconChatClicked(QSystemTrayIcon::ActivationReason e = QSystemTrayIcon::Trigger);
|
|
|
|
void trayIconTransfersClicked(QSystemTrayIcon::ActivationReason e = QSystemTrayIcon::Trigger);
|
2007-11-14 22:18:48 -05:00
|
|
|
|
|
|
|
/** Toolbar fns. */
|
|
|
|
void addFriend();
|
|
|
|
void showMessengerWindow();
|
2011-07-06 09:08:27 -04:00
|
|
|
void showDhtWindow();
|
|
|
|
|
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();
|
2008-03-27 19:40:37 -04:00
|
|
|
void setStyle();
|
2010-07-20 15:45:07 -04:00
|
|
|
void statusChangedMenu(QAction *pAction);
|
2010-07-18 17:28:56 -04:00
|
|
|
void statusChangedComboBox(int index);
|
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
|
|
|
|
|
|
|
void on_actionQuick_Start_Wizard_activated();
|
|
|
|
|
2007-11-14 22:18:48 -05:00
|
|
|
private:
|
2009-11-24 15:17:13 -05:00
|
|
|
void createTrayIcon();
|
2010-11-25 19:54:18 -05:00
|
|
|
void createNotifyIcons();
|
|
|
|
void updateTrayCombine();
|
2009-08-19 18:19:35 -04:00
|
|
|
|
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
|
|
|
|
2008-03-30 19:28:57 -04:00
|
|
|
/** Creates a new action for a Main page. */
|
2007-11-14 22:18:48 -05:00
|
|
|
QAction* createPageAction(QIcon img, QString text, QActionGroup *group);
|
|
|
|
/** Adds a new action to the toolbar. */
|
|
|
|
void addAction(QAction *action, const char *slot = 0);
|
2009-08-19 18:19:35 -04:00
|
|
|
|
2007-11-14 22:18:48 -05:00
|
|
|
void loadStyleSheet(const QString &sheetName);
|
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;
|
2010-08-09 08:16:21 -04:00
|
|
|
QSystemTrayIcon *trayIconMessages;
|
2010-08-09 17:20:34 -04:00
|
|
|
QSystemTrayIcon *trayIconForums;
|
2010-10-06 20:17:42 -04:00
|
|
|
QSystemTrayIcon *trayIconChannels;
|
2010-09-01 13:56:15 -04:00
|
|
|
QSystemTrayIcon *trayIconChat;
|
2010-11-24 19:20:25 -05:00
|
|
|
QSystemTrayIcon *trayIconTransfers;
|
2011-07-13 15:24:33 -04:00
|
|
|
QMenu *notifyMenu;
|
|
|
|
QString notifyToolTip;
|
2010-11-25 19:54:18 -05:00
|
|
|
QAction *trayActionMessages;
|
|
|
|
QAction *trayActionForums;
|
|
|
|
QAction *trayActionChannels;
|
|
|
|
QAction *trayActionChat;
|
|
|
|
QAction *trayActionTransfers;
|
2008-03-31 08:06:56 -04:00
|
|
|
QAction *toggleVisibilityAction, *toolAct;
|
2008-06-09 20:48:18 -04:00
|
|
|
|
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;
|
2009-05-02 18:14:20 -04:00
|
|
|
RatesStatus *ratesstatus;
|
2011-01-07 11:56:57 -05:00
|
|
|
DiscStatus *discstatus;
|
2010-10-09 14:35:34 -04:00
|
|
|
HashingStatus *hashingstatus;
|
2010-07-18 17:28:56 -04:00
|
|
|
QComboBox *statusComboBox;
|
2009-02-02 07:07:07 -05:00
|
|
|
|
2010-08-09 17:20:34 -04:00
|
|
|
QAction *messageAction;
|
|
|
|
QAction *forumAction;
|
2010-10-06 20:17:42 -04:00
|
|
|
QAction *channelAction;
|
2010-11-24 19:20:25 -05:00
|
|
|
QAction *transferAction;
|
2010-07-17 19:19:43 -04:00
|
|
|
|
|
|
|
/* Status */
|
|
|
|
std::set <QObject*> m_apStatusObjects; // added objects for status
|
|
|
|
bool m_bStatusLoadDone;
|
|
|
|
|
|
|
|
void loadOwnStatus();
|
|
|
|
|
|
|
|
// idle function
|
|
|
|
void setIdle(bool Idle);
|
|
|
|
bool isIdle;
|
2009-08-19 18:19:35 -04:00
|
|
|
|
2007-11-14 22:18:48 -05:00
|
|
|
/** Qt Designer generated object */
|
|
|
|
Ui::MainWindow ui;
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|