2007-11-14 22:18:48 -05:00
|
|
|
/****************************************************************
|
|
|
|
* RetroShare is distributed under the following license:
|
|
|
|
*
|
|
|
|
* Copyright (C) 2006, 2007 crypton
|
|
|
|
*
|
|
|
|
* 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
|
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
|
|
|
* Boston, MA 02110-1301, USA.
|
|
|
|
****************************************************************/
|
|
|
|
|
|
|
|
#include <QtGui>
|
|
|
|
#include <QMessageBox>
|
|
|
|
#include <QSystemTrayIcon>
|
|
|
|
#include <QString>
|
|
|
|
#include <QtDebug>
|
|
|
|
#include <QIcon>
|
|
|
|
#include <QPixmap>
|
|
|
|
|
2008-11-29 15:17:58 -05:00
|
|
|
|
|
|
|
#include "NetworkView.h"
|
2008-03-30 17:05:14 -04:00
|
|
|
#include "LinksDialog.h"
|
|
|
|
#include "PhotoDialog.h"
|
2008-11-29 15:17:58 -05:00
|
|
|
#include "ForumsDialog.h"
|
|
|
|
#include "NewsFeed.h"
|
|
|
|
#include "PeersFeed.h"
|
|
|
|
#include "TransferFeed.h"
|
|
|
|
#include "MsgFeed.h"
|
|
|
|
#include "ChannelFeed.h"
|
2008-12-10 20:19:34 -05:00
|
|
|
#include "ShareManager.h"
|
2008-11-29 15:17:58 -05:00
|
|
|
|
2008-03-30 17:05:14 -04:00
|
|
|
|
2007-11-14 22:18:48 -05:00
|
|
|
#include <rshare.h>
|
|
|
|
#include "MainWindow.h"
|
|
|
|
#include "MessengerWindow.h"
|
|
|
|
#include "HelpDialog.h"
|
|
|
|
|
|
|
|
#include "games/qbackgammon/bgwindow.h"
|
2009-02-02 07:41:20 -05:00
|
|
|
//#include "smplayer.h"
|
2007-11-14 22:18:48 -05:00
|
|
|
|
2009-03-15 18:45:40 -04:00
|
|
|
#ifdef TURTLE_HOPPING
|
|
|
|
#include "gui/TurtleSearchDialog.h"
|
|
|
|
#endif
|
|
|
|
|
2008-06-15 11:34:56 -04:00
|
|
|
#include "statusbar/peerstatus.h"
|
2007-11-14 22:18:48 -05:00
|
|
|
#include "Preferences/PreferencesWindow.h"
|
|
|
|
#include "Settings/gsettingswin.h"
|
|
|
|
#include "util/rsversion.h"
|
|
|
|
|
|
|
|
#include "rsiface/rsiface.h"
|
2008-01-25 03:49:40 -05:00
|
|
|
#include "rsiface/rspeers.h"
|
2008-07-02 12:59:56 -04:00
|
|
|
#include "rsiface/rsfiles.h"
|
2007-11-14 22:18:48 -05:00
|
|
|
|
2009-03-28 06:41:49 -04:00
|
|
|
//#include "gui/connect/InviteDialog.h"
|
|
|
|
//#include "gui/connect/AddFriendDialog.h"
|
2009-03-26 12:58:06 -04:00
|
|
|
#include "gui/connect/ConnectFriendWizard.h"
|
2007-11-14 22:18:48 -05:00
|
|
|
|
2008-06-09 20:48:18 -04:00
|
|
|
#include <sstream>
|
|
|
|
#include <iomanip>
|
2008-12-07 13:34:54 -05:00
|
|
|
#include <unistd.h>
|
2007-11-14 22:18:48 -05:00
|
|
|
|
2009-01-27 20:24:41 -05:00
|
|
|
#define FONT QFont(tr("Arial"), 9)
|
2007-11-14 22:18:48 -05:00
|
|
|
|
|
|
|
/* Images for toolbar icons */
|
2008-11-27 20:14:58 -05:00
|
|
|
#define IMAGE_NETWORK ":/images/retrosharelogo1.png"
|
2008-07-10 06:34:49 -04:00
|
|
|
#define IMAGE_PEERS ":/images/groupchat.png"
|
2008-11-27 20:14:58 -05:00
|
|
|
#define IMAGE_SEARCH ":/images/filefind.png"
|
2008-03-30 19:28:57 -04:00
|
|
|
#define IMAGE_TRANSFERS ":/images/ktorrent32.png"
|
2008-07-30 12:24:07 -04:00
|
|
|
#define IMAGE_LINKS ":/images/knewsticker24.png"
|
2008-08-03 17:26:25 -04:00
|
|
|
#define IMAGE_FILES ":/images/fileshare24.png"
|
2007-12-13 11:02:33 -05:00
|
|
|
#define IMAGE_CHANNELS ":/images/channels.png"
|
2008-11-15 18:47:17 -05:00
|
|
|
#define IMAGE_FORUMS ":/images/konversation.png"
|
2009-03-15 18:45:40 -04:00
|
|
|
#define IMAGE_TURTLE ":/images/turtle.png"
|
2008-08-14 20:23:27 -04:00
|
|
|
#define IMAGE_PREFERENCES ":/images/kcmsystem24.png"
|
2008-03-31 09:57:16 -04:00
|
|
|
#define IMAGE_CHAT ":/images/groupchat.png"
|
2007-11-14 22:18:48 -05:00
|
|
|
#define IMAGE_RETROSHARE ":/images/rstray3.png"
|
|
|
|
#define IMAGE_ABOUT ":/images/informations_24x24.png"
|
|
|
|
#define IMAGE_STATISTIC ":/images/utilities-system-monitor.png"
|
|
|
|
#define IMAGE_MESSAGES ":/images/evolution.png"
|
|
|
|
#define IMAGE_BWGRAPH ":/images/ksysguard.png"
|
2008-03-31 08:06:56 -04:00
|
|
|
#define IMAGE_RSM32 ":/images/kdmconfig.png"
|
2007-11-14 22:18:48 -05:00
|
|
|
#define IMAGE_RSM16 ":/images/rsmessenger16.png"
|
|
|
|
#define IMAGE_CLOSE ":/images/close_normal.png"
|
2008-11-27 20:14:58 -05:00
|
|
|
#define IMAGE_SMPLAYER ":/images/smplayer_icon32.png"
|
2008-03-20 08:23:55 -04:00
|
|
|
#define IMAGE_BLOCK ":/images/blockdevice.png"
|
2008-03-27 19:40:37 -04:00
|
|
|
#define IMAGE_COLOR ":/images/highlight.png"
|
2008-03-30 17:05:14 -04:00
|
|
|
#define IMAGE_GAMES ":/images/kgames.png"
|
|
|
|
#define IMAGE_PHOTO ":/images/lphoto.png"
|
|
|
|
#define IMAGE_SMPLAYER ":/images/smplayer_icon32.png"
|
2008-03-30 19:28:57 -04:00
|
|
|
#define IMAGE_ADDFRIEND ":/images/add-friend24.png"
|
2009-03-28 06:41:49 -04:00
|
|
|
//#define IMAGE_INVITEFRIEND ":/images/invite-friend24.png"
|
2008-03-30 19:28:57 -04:00
|
|
|
#define IMAGE_ADDSHARE ":/images/directoryadd_24x24_shadow.png"
|
|
|
|
#define IMAGE_OPTIONS ":/images/settings.png"
|
|
|
|
#define IMAGE_QUIT ":/images/exit_24x24.png"
|
2008-07-31 11:29:14 -04:00
|
|
|
#define IMAGE_UNFINISHED ":/images/underconstruction.png"
|
2008-08-02 16:26:29 -04:00
|
|
|
#define IMAGE_MINIMIZE ":/images/window_nofullscreen.png"
|
|
|
|
#define IMAGE_MAXIMIZE ":/images/window_fullscreen.png"
|
2008-08-05 14:36:07 -04:00
|
|
|
#define IMG_HELP ":/images/help.png"
|
2008-11-29 15:17:58 -05:00
|
|
|
#define IMAGE_NEWSFEED ":/images/konqsidebar_news24.png"
|
2009-02-01 20:30:15 -05:00
|
|
|
#define IMAGE_PLUGINS ":/images/extension_32.png"
|
|
|
|
|
2007-11-14 22:18:48 -05:00
|
|
|
|
|
|
|
/* Keys for UI Preferences */
|
|
|
|
#define UI_PREF_PROMPT_ON_QUIT "UIOptions/ConfirmOnQuit"
|
|
|
|
/* uncomment this for release version */
|
|
|
|
|
2008-01-21 04:26:12 -05:00
|
|
|
/*****
|
|
|
|
* #define RS_RELEASE_VERSION 1
|
|
|
|
****/
|
2007-11-14 22:18:48 -05:00
|
|
|
|
2009-02-02 07:07:07 -05:00
|
|
|
//#define RS_RELEASE_VERSION 1
|
2008-11-13 18:06:32 -05:00
|
|
|
|
2007-11-14 22:18:48 -05:00
|
|
|
/** Constructor */
|
|
|
|
MainWindow::MainWindow(QWidget* parent, Qt::WFlags flags)
|
2008-08-15 16:07:54 -04:00
|
|
|
: RWindow("MainWindow", parent, flags)
|
2007-11-14 22:18:48 -05:00
|
|
|
{
|
|
|
|
/* Invoke the Qt Designer generated QObject setup routine */
|
|
|
|
ui.setupUi(this);
|
|
|
|
|
2008-08-15 13:49:57 -04:00
|
|
|
/* Create RshareSettings object */
|
|
|
|
_settings = new RshareSettings();
|
|
|
|
|
2009-01-11 06:56:43 -05:00
|
|
|
setWindowTitle(tr("RetroShare %1 RetroShare a private and secure decentralised commmunication platform").arg(retroshareVersion()));
|
2008-03-31 14:37:50 -04:00
|
|
|
|
|
|
|
mSMPlayer = NULL;
|
2007-11-14 22:18:48 -05:00
|
|
|
|
2009-02-02 07:07:07 -05:00
|
|
|
ui.toolBarservice->hide();
|
2007-11-14 22:18:48 -05:00
|
|
|
|
|
|
|
// Setting icons
|
|
|
|
this->setWindowIcon(QIcon(QString::fromUtf8(":/images/rstray3.png")));
|
2008-08-15 13:49:57 -04:00
|
|
|
|
2007-11-14 22:18:48 -05:00
|
|
|
/* Create all the dialogs of which we only want one instance */
|
|
|
|
_bandwidthGraph = new BandwidthGraph();
|
|
|
|
messengerWindow = new MessengerWindow();
|
2008-08-14 20:23:27 -04:00
|
|
|
_preferencesWindow = new PreferencesWindow();
|
2007-11-14 22:18:48 -05:00
|
|
|
messengerWindow->hide();
|
2008-04-24 08:58:27 -04:00
|
|
|
//messengerWindow->show();
|
2007-11-14 22:18:48 -05:00
|
|
|
applicationWindow = new ApplicationWindow();
|
|
|
|
applicationWindow->hide();
|
|
|
|
|
2008-03-31 09:00:00 -04:00
|
|
|
/** Left Side ToolBar**/
|
2008-03-31 02:31:57 -04:00
|
|
|
connect(ui.actionAdd_Friend, SIGNAL(triggered() ), this , SLOT( addFriend() ) );
|
2009-03-28 06:41:49 -04:00
|
|
|
// connect(ui.actionInvite_Friend, SIGNAL(triggered() ), this , SLOT( inviteFriend() ) );
|
2008-12-10 20:19:34 -05:00
|
|
|
connect(ui.actionAdd_Share, SIGNAL(triggered() ), this , SLOT( openShareManager() ) );
|
2008-03-31 02:31:57 -04:00
|
|
|
connect(ui.actionOptions, SIGNAL(triggered()), this, SLOT( showPreferencesWindow()) );
|
2008-03-31 09:00:00 -04:00
|
|
|
connect(ui.actionMessenger, SIGNAL(triggered()), this, SLOT( showMessengerWindow()) );
|
|
|
|
connect(ui.actionSMPlayer, SIGNAL(triggered()), this, SLOT( showsmplayer()) );
|
|
|
|
connect(ui.actionAbout, SIGNAL(triggered()), this, SLOT( showabout()) );
|
2008-03-31 08:17:15 -04:00
|
|
|
connect(ui.actionColor, SIGNAL(triggered()), this, SLOT( setStyle()) );
|
2009-02-02 07:07:07 -05:00
|
|
|
//connect(ui.actionSettings, SIGNAL(triggered()), this, SLOT( showSettings()) );
|
2009-01-07 16:12:31 -05:00
|
|
|
|
2008-08-14 20:23:27 -04:00
|
|
|
|
|
|
|
|
2007-11-14 22:18:48 -05:00
|
|
|
/** adjusted quit behaviour: trigger a warning that can be switched off in the saved
|
|
|
|
config file RetroShare.conf */
|
2008-03-31 02:31:57 -04:00
|
|
|
connect(ui.actionQuit, SIGNAL(triggered()), this, SLOT(doQuit()));
|
|
|
|
|
2008-01-18 18:18:21 -05:00
|
|
|
/* load the StyleSheet*/
|
|
|
|
loadStyleSheet(Rshare::stylesheet());
|
2007-11-14 22:18:48 -05:00
|
|
|
|
|
|
|
|
|
|
|
|
2008-03-30 17:05:14 -04:00
|
|
|
/* Create the Main pages and actions */
|
2007-11-14 22:18:48 -05:00
|
|
|
QActionGroup *grp = new QActionGroup(this);
|
2008-03-30 19:28:57 -04:00
|
|
|
|
2007-11-14 22:18:48 -05:00
|
|
|
|
2008-11-29 15:17:58 -05:00
|
|
|
NewsFeed *newsFeed = NULL;
|
|
|
|
ui.stackPages->add(newsFeed = new NewsFeed(ui.stackPages),
|
|
|
|
createPageAction(QIcon(IMAGE_NEWSFEED), tr("News Feed"), grp));
|
|
|
|
|
2007-11-14 22:18:48 -05:00
|
|
|
|
|
|
|
ui.stackPages->add(peersDialog = new PeersDialog(ui.stackPages),
|
|
|
|
createPageAction(QIcon(IMAGE_PEERS), tr("Friends"), grp));
|
2008-11-29 15:17:58 -05:00
|
|
|
|
|
|
|
//PeersFeed *peersFeed = NULL;
|
|
|
|
//ui.stackPages->add(peersFeed = new PeersFeed(ui.stackPages),
|
|
|
|
// createPageAction(QIcon(IMAGE_PEERS), tr("Peers"), grp));
|
2009-03-15 18:45:40 -04:00
|
|
|
#ifdef TURTLE_HOPPING
|
|
|
|
ui.stackPages->add(turtleDialog = new TurtleSearchDialog(ui.stackPages),
|
|
|
|
createPageAction(QIcon(IMAGE_TURTLE), tr("Turtle"), grp));
|
|
|
|
#endif
|
2007-11-14 22:18:48 -05:00
|
|
|
ui.stackPages->add(searchDialog = new SearchDialog(ui.stackPages),
|
|
|
|
createPageAction(QIcon(IMAGE_SEARCH), tr("Search"), grp));
|
|
|
|
|
|
|
|
ui.stackPages->add(transfersDialog = new TransfersDialog(ui.stackPages),
|
2008-11-29 15:17:58 -05:00
|
|
|
createPageAction(QIcon(IMAGE_TRANSFERS), tr("Transfers"), grp));
|
2007-11-14 22:18:48 -05:00
|
|
|
|
2008-11-29 15:17:58 -05:00
|
|
|
//TransferFeed *transferFeed = NULL;
|
|
|
|
//ui.stackPages->add(transferFeed = new TransferFeed(ui.stackPages),
|
|
|
|
// createPageAction(QIcon(IMAGE_LINKS), tr("Transfers"), grp));
|
|
|
|
|
2007-11-14 22:18:48 -05:00
|
|
|
ui.stackPages->add(sharedfilesDialog = new SharedFilesDialog(ui.stackPages),
|
|
|
|
createPageAction(QIcon(IMAGE_FILES), tr("Files"), grp));
|
|
|
|
|
|
|
|
|
2008-11-29 15:17:58 -05:00
|
|
|
//MsgFeed *msgFeed = NULL;
|
|
|
|
//ui.stackPages->add(msgFeed = new MsgFeed(ui.stackPages),
|
|
|
|
// createPageAction(QIcon(IMAGE_MESSAGES), tr("Messages"), grp));
|
|
|
|
|
2007-11-14 22:18:48 -05:00
|
|
|
ui.stackPages->add(messagesDialog = new MessagesDialog(ui.stackPages),
|
2008-11-29 15:17:58 -05:00
|
|
|
createPageAction(QIcon(IMAGE_MESSAGES), tr("Messages"), grp));
|
2008-03-30 17:05:14 -04:00
|
|
|
|
2008-05-24 16:23:15 -04:00
|
|
|
LinksDialog *linksDialog = NULL;
|
2008-03-30 17:05:14 -04:00
|
|
|
|
2007-11-14 22:18:48 -05:00
|
|
|
|
2008-03-03 09:12:39 -05:00
|
|
|
#ifdef RS_RELEASE_VERSION
|
|
|
|
channelsDialog = NULL;
|
2008-11-15 18:47:17 -05:00
|
|
|
ui.stackPages->add(linksDialog = new LinksDialog(ui.stackPages),
|
|
|
|
createPageAction(QIcon(IMAGE_LINKS), tr("Links Cloud"), grp));
|
2008-11-13 18:06:32 -05:00
|
|
|
|
|
|
|
ChannelFeed *channelFeed = NULL;
|
|
|
|
ui.stackPages->add(channelFeed = new ChannelFeed(ui.stackPages),
|
|
|
|
createPageAction(QIcon(IMAGE_CHANNELS), tr("Channel Feed"), grp));
|
|
|
|
|
2008-11-15 18:47:17 -05:00
|
|
|
ForumsDialog *forumsDialog = NULL;
|
|
|
|
ui.stackPages->add(forumsDialog = new ForumsDialog(ui.stackPages),
|
|
|
|
createPageAction(QIcon(IMAGE_FORUMS), tr("Forums"), grp));
|
|
|
|
|
2008-11-29 15:17:58 -05:00
|
|
|
|
2008-03-03 09:12:39 -05:00
|
|
|
#else
|
|
|
|
channelsDialog = NULL;
|
2008-11-13 18:06:32 -05:00
|
|
|
ui.stackPages->add(linksDialog = new LinksDialog(ui.stackPages),
|
|
|
|
createPageAction(QIcon(IMAGE_LINKS), tr("Links Cloud"), grp));
|
|
|
|
|
2009-02-02 08:01:53 -05:00
|
|
|
ChannelFeed *channelFeed = NULL;
|
|
|
|
ui.stackPages->add(channelFeed = new ChannelFeed(ui.stackPages),
|
|
|
|
createPageAction(QIcon(IMAGE_CHANNELS), tr("Channels"), grp));
|
2008-11-13 18:06:32 -05:00
|
|
|
|
2008-11-15 18:47:17 -05:00
|
|
|
ForumsDialog *forumsDialog = NULL;
|
|
|
|
ui.stackPages->add(forumsDialog = new ForumsDialog(ui.stackPages),
|
|
|
|
createPageAction(QIcon(IMAGE_FORUMS), tr("Forums"), grp));
|
|
|
|
|
2008-03-03 09:12:39 -05:00
|
|
|
#endif
|
2007-11-14 22:18:48 -05:00
|
|
|
|
2008-11-29 15:17:58 -05:00
|
|
|
ui.stackPages->add(networkDialog = new NetworkDialog(ui.stackPages),
|
|
|
|
createPageAction(QIcon(IMAGE_NETWORK), tr("Network"), grp));
|
|
|
|
|
2009-02-11 17:50:12 -05:00
|
|
|
ui.stackPages->add(pluginsPage = new PluginsPage(ui.stackPages),
|
|
|
|
createPageAction(QIcon(IMAGE_PLUGINS), tr("Plugins"), grp));
|
|
|
|
|
2007-11-14 22:18:48 -05:00
|
|
|
|
|
|
|
//ui.stackPages->add(groupsDialog = new GroupsDialog(ui.stackPages),
|
|
|
|
// createPageAction(QIcon(), tr("Groups"), grp));
|
|
|
|
|
|
|
|
//ui.stackPages->add(new StatisticDialog(ui.stackPages),
|
|
|
|
// createPageAction(QIcon(IMAGE_STATISTIC), tr("Statistics"), grp));
|
|
|
|
|
|
|
|
/* also an empty list of chat windows */
|
2008-07-10 14:52:56 -04:00
|
|
|
messengerWindow->setChatDialog(peersDialog);
|
2007-11-14 22:18:48 -05:00
|
|
|
|
|
|
|
/* Create the toolbar */
|
|
|
|
ui.toolBar->addActions(grp->actions());
|
|
|
|
ui.toolBar->addSeparator();
|
|
|
|
connect(grp, SIGNAL(triggered(QAction *)), ui.stackPages, SLOT(showPage(QAction *)));
|
2008-03-31 09:00:00 -04:00
|
|
|
|
2008-04-24 08:58:27 -04:00
|
|
|
/* Select the first action */
|
|
|
|
grp->actions()[0]->setChecked(true);
|
2007-11-14 22:18:48 -05:00
|
|
|
|
2008-03-31 14:37:50 -04:00
|
|
|
// Allow to play files from SharedFilesDialog.
|
|
|
|
connect(sharedfilesDialog, SIGNAL(playFiles( QStringList )), this, SLOT(playFiles( QStringList )));
|
|
|
|
connect(transfersDialog, SIGNAL(playFiles( QStringList )), this, SLOT(playFiles( QStringList )));
|
2007-11-14 22:18:48 -05:00
|
|
|
|
|
|
|
#ifdef RS_RELEASE_VERSION
|
2008-07-31 11:29:14 -04:00
|
|
|
//addAction(new QAction(QIcon(IMAGE_UNFINISHED), tr("Unfinished"), ui.toolBar), SLOT(showApplWindow()));
|
2008-04-03 10:36:29 -04:00
|
|
|
|
2008-06-09 20:48:18 -04:00
|
|
|
|
2007-11-14 22:18:48 -05:00
|
|
|
#else
|
2008-07-31 11:29:14 -04:00
|
|
|
addAction(new QAction(QIcon(IMAGE_UNFINISHED), tr("Unfinished"), ui.toolBar), SLOT(showApplWindow()));
|
2008-03-27 19:40:37 -04:00
|
|
|
|
2008-11-27 18:59:08 -05:00
|
|
|
toolAct = ui.toolBarservice->toggleViewAction();
|
|
|
|
toolAct->setText("Service");
|
2008-03-31 08:06:56 -04:00
|
|
|
toolAct->setShortcut(tr("Ctrl+T"));
|
|
|
|
toolAct->setIcon(QIcon(":/images/blockdevice2.png"));
|
2008-04-24 08:58:27 -04:00
|
|
|
//ui.toolBar->addAction(toolAct);
|
2007-11-14 22:18:48 -05:00
|
|
|
|
2008-03-30 19:28:57 -04:00
|
|
|
/* Create the Service pages and actions */
|
|
|
|
QActionGroup *servicegrp = new QActionGroup(this);
|
2008-03-31 08:06:56 -04:00
|
|
|
|
2008-03-30 19:28:57 -04:00
|
|
|
|
2008-04-24 08:58:27 -04:00
|
|
|
#if 0
|
2008-03-30 19:28:57 -04:00
|
|
|
LinksDialog *linksDialog = NULL;
|
|
|
|
ui.stackPages->add(linksDialog = new LinksDialog(ui.stackPages),
|
|
|
|
createPageAction(QIcon(IMAGE_LINKS), tr("Links Cloud"), servicegrp));
|
|
|
|
|
2008-03-31 02:31:57 -04:00
|
|
|
ChannelsDialog *channelsDialog = NULL;
|
|
|
|
ui.stackPages->add(channelsDialog = new ChannelsDialog(ui.stackPages),
|
|
|
|
createPageAction(QIcon(IMAGE_CHANNELS), tr("Channels"), servicegrp));
|
2008-03-30 19:28:57 -04:00
|
|
|
|
2008-03-31 02:31:57 -04:00
|
|
|
GamesDialog *gamesDialog = NULL;
|
|
|
|
ui.stackPages->add(gamesDialog = new GamesDialog(ui.stackPages),
|
|
|
|
createPageAction(QIcon(IMAGE_GAMES), tr("Games"), servicegrp));
|
2008-03-30 19:28:57 -04:00
|
|
|
|
2008-03-31 02:31:57 -04:00
|
|
|
PhotoDialog *photoDialog = NULL;
|
|
|
|
ui.stackPages->add(photoDialog = new PhotoDialog(ui.stackPages),
|
|
|
|
createPageAction(QIcon(IMAGE_PHOTO), tr("Photo View"), servicegrp));
|
2008-03-30 19:28:57 -04:00
|
|
|
|
2008-04-24 08:58:27 -04:00
|
|
|
#endif
|
2008-03-30 19:28:57 -04:00
|
|
|
|
|
|
|
|
|
|
|
/* Create the toolbarservice */
|
|
|
|
ui.toolBarservice->addActions(servicegrp->actions());
|
|
|
|
ui.toolBarservice->addSeparator();
|
|
|
|
connect(servicegrp, SIGNAL(triggered(QAction *)), ui.stackPages, SLOT(showPage(QAction *)));
|
2008-03-31 02:31:57 -04:00
|
|
|
|
2008-03-30 19:28:57 -04:00
|
|
|
ui.toolBarservice->addSeparator();
|
|
|
|
|
2008-04-03 10:36:29 -04:00
|
|
|
#endif
|
2008-06-16 16:28:16 -04:00
|
|
|
peerstatus = new PeerStatus();
|
|
|
|
statusBar()->addWidget(peerstatus);
|
2008-06-09 20:48:18 -04:00
|
|
|
|
2009-01-25 07:18:16 -05:00
|
|
|
QWidget *widget = new QWidget();
|
|
|
|
QSizePolicy sizePolicy(QSizePolicy::Maximum, QSizePolicy::Preferred);
|
|
|
|
sizePolicy.setHorizontalStretch(0);
|
|
|
|
sizePolicy.setVerticalStretch(0);
|
|
|
|
sizePolicy.setHeightForWidth(widget->sizePolicy().hasHeightForWidth());
|
|
|
|
widget->setSizePolicy(sizePolicy);
|
|
|
|
QHBoxLayout *horizontalLayout = new QHBoxLayout(widget);
|
|
|
|
horizontalLayout->setContentsMargins(0, 0, 0, 0);
|
|
|
|
horizontalLayout->setObjectName(QString::fromUtf8("horizontalLayout"));
|
|
|
|
_hashing_info_label = new QLabel(widget) ;
|
|
|
|
_hashing_info_label->setObjectName(QString::fromUtf8("label"));
|
|
|
|
|
|
|
|
horizontalLayout->addWidget(_hashing_info_label);
|
|
|
|
QSpacerItem *horizontalSpacer = new QSpacerItem(1000, 0, QSizePolicy::Expanding, QSizePolicy::Minimum);
|
|
|
|
horizontalLayout->addItem(horizontalSpacer);
|
|
|
|
|
|
|
|
statusBar()->addPermanentWidget(widget);
|
2009-01-22 16:06:54 -05:00
|
|
|
_hashing_info_label->hide() ;
|
2009-01-04 15:29:55 -05:00
|
|
|
|
|
|
|
statusBar()->addPermanentWidget(statusRates = new QLabel(tr("<strong>Down:</strong> 0.00 (kB/s) | <strong>Up:</strong> 0.00 (kB/s) ")));
|
2008-06-09 20:48:18 -04:00
|
|
|
|
2008-03-30 19:28:57 -04:00
|
|
|
//servicegrp->actions()[0]->setChecked(true);
|
2007-11-14 22:18:48 -05:00
|
|
|
|
|
|
|
/* Create the actions that will go in the tray menu */
|
|
|
|
createActions();
|
2008-03-30 17:05:14 -04:00
|
|
|
|
2007-11-14 22:18:48 -05:00
|
|
|
/******
|
|
|
|
* This is an annoying warning I get all the time...
|
|
|
|
* (no help!)
|
|
|
|
*
|
|
|
|
*
|
|
|
|
if (!QSystemTrayIcon::isSystemTrayAvailable())
|
|
|
|
QMessageBox::warning(0, tr("System tray is unavailable"),
|
|
|
|
tr("System tray unavailable"));
|
|
|
|
******/
|
|
|
|
|
|
|
|
// Tray icon Menu
|
|
|
|
menu = new QMenu(this);
|
|
|
|
QObject::connect(menu, SIGNAL(aboutToShow()), this, SLOT(updateMenu()));
|
|
|
|
toggleVisibilityAction =
|
|
|
|
menu->addAction(QIcon(IMAGE_RETROSHARE), tr("Show/Hide"), this, SLOT(toggleVisibilitycontextmenu()));
|
|
|
|
menu->addSeparator();
|
|
|
|
menu->addAction(_messengerwindowAct);
|
2009-01-07 16:12:31 -05:00
|
|
|
menu->addAction(_messagesAct);
|
2009-02-11 18:28:10 -05:00
|
|
|
menu->addAction(_bandwidthAct);
|
2007-11-18 18:35:53 -05:00
|
|
|
|
2007-11-14 22:18:48 -05:00
|
|
|
/* bandwidth only in development version */
|
|
|
|
#ifdef RS_RELEASE_VERSION
|
|
|
|
#else
|
2008-08-16 18:24:53 -04:00
|
|
|
menu->addAction(_appAct);
|
2007-11-14 22:18:48 -05:00
|
|
|
#endif
|
|
|
|
menu->addAction(_prefsAct);
|
2008-11-30 12:15:23 -05:00
|
|
|
//menu->addAction(_smplayerAct);
|
2008-08-05 14:36:07 -04:00
|
|
|
menu->addAction(_helpAct);
|
2007-11-14 22:18:48 -05:00
|
|
|
menu->addSeparator();
|
2008-08-02 16:26:29 -04:00
|
|
|
menu->addAction(QIcon(IMAGE_MINIMIZE), tr("Minimize"), this, SLOT(showMinimized()));
|
|
|
|
menu->addAction(QIcon(IMAGE_MAXIMIZE), tr("Maximize"), this, SLOT(showMaximized()));
|
2007-11-14 22:18:48 -05:00
|
|
|
menu->addSeparator();
|
|
|
|
menu->addAction(QIcon(IMAGE_CLOSE), tr("&Quit"), this, SLOT(doQuit()));
|
|
|
|
// End of Icon Menu
|
|
|
|
|
|
|
|
// Create the tray icon
|
|
|
|
trayIcon = new QSystemTrayIcon(this);
|
|
|
|
trayIcon->setToolTip(tr("RetroShare"));
|
|
|
|
trayIcon->setContextMenu(menu);
|
|
|
|
trayIcon->setIcon(QIcon(IMAGE_RETROSHARE));
|
|
|
|
|
|
|
|
connect(trayIcon, SIGNAL(activated(QSystemTrayIcon::ActivationReason)), this,
|
|
|
|
SLOT(toggleVisibility(QSystemTrayIcon::ActivationReason)));
|
|
|
|
trayIcon->show();
|
|
|
|
|
2008-06-09 20:48:18 -04:00
|
|
|
QTimer *timer = new QTimer(this);
|
|
|
|
timer->connect(timer, SIGNAL(timeout()), this, SLOT(updateStatus()));
|
2009-02-13 07:15:42 -05:00
|
|
|
timer->start(1000);
|
2007-11-14 22:18:48 -05:00
|
|
|
}
|
|
|
|
|
2008-06-09 20:48:18 -04:00
|
|
|
void MainWindow::updateStatus()
|
|
|
|
{
|
|
|
|
/* set users/friends/network */
|
|
|
|
float downKb = 0;
|
|
|
|
float upKb = 0;
|
|
|
|
rsicontrol -> ConfigGetDataRates(downKb, upKb);
|
|
|
|
|
|
|
|
std::ostringstream out;
|
2008-10-12 09:33:38 -04:00
|
|
|
out << "<strong>Down:</strong> " << std::setprecision(2) << std::fixed << downKb << " (kB/s) | <strong>Up:</strong> " << std::setprecision(2) << std::fixed << upKb << " (kB/s) ";
|
2008-06-09 20:48:18 -04:00
|
|
|
|
|
|
|
/* set uploads/download rates */
|
|
|
|
if (statusRates)
|
|
|
|
statusRates -> setText(QString::fromStdString(out.str()));
|
|
|
|
|
2008-06-16 16:28:16 -04:00
|
|
|
if (peerstatus)
|
|
|
|
peerstatus->setPeerStatus();
|
2008-06-09 20:48:18 -04:00
|
|
|
|
2008-06-15 11:34:56 -04:00
|
|
|
}
|
|
|
|
|
2009-01-22 16:06:54 -05:00
|
|
|
void MainWindow::updateHashingInfo(const QString& s)
|
|
|
|
{
|
|
|
|
if(s == "")
|
|
|
|
_hashing_info_label->hide() ;
|
|
|
|
else
|
|
|
|
{
|
|
|
|
_hashing_info_label->setText("Hashing file " + s) ;
|
|
|
|
_hashing_info_label->show() ;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-11-14 22:18:48 -05:00
|
|
|
/** Creates a new action associated with a config page. */
|
|
|
|
QAction* MainWindow::createPageAction(QIcon img, QString text, QActionGroup *group)
|
|
|
|
{
|
|
|
|
QAction *action = new QAction(img, text, group);
|
|
|
|
action->setCheckable(true);
|
|
|
|
action->setFont(FONT);
|
|
|
|
return action;
|
|
|
|
}
|
|
|
|
|
2008-03-30 19:28:57 -04:00
|
|
|
/** Creates a new action associated with a config page. */
|
|
|
|
QAction* MainWindow::createPageActionservice(QIcon img, QString text, QActionGroup *groupservice)
|
|
|
|
{
|
|
|
|
QAction *actionservice = new QAction(img, text, groupservice);
|
|
|
|
actionservice->setCheckable(true);
|
|
|
|
actionservice->setFont(FONT);
|
|
|
|
return actionservice;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-11-14 22:18:48 -05:00
|
|
|
/** Adds the given action to the toolbar and hooks its triggered() signal to
|
|
|
|
* the specified slot (if given). */
|
|
|
|
void MainWindow::addAction(QAction *action, const char *slot)
|
|
|
|
{
|
|
|
|
action->setFont(FONT);
|
|
|
|
ui.toolBar->addAction(action);
|
|
|
|
connect(action, SIGNAL(triggered()), this, slot);
|
|
|
|
}
|
|
|
|
|
2008-03-30 19:28:57 -04:00
|
|
|
/** Adds the given action to the toolbar and hooks its triggered() signal to
|
|
|
|
* the specified slot (if given). */
|
|
|
|
void MainWindow::addActionservice(QAction *actionservice, const char *slot)
|
|
|
|
{
|
|
|
|
actionservice->setFont(FONT);
|
|
|
|
ui.toolBarservice->addAction(actionservice);
|
|
|
|
connect(actionservice, SIGNAL(triggered()), this, slot);
|
|
|
|
}
|
|
|
|
|
2007-11-14 22:18:48 -05:00
|
|
|
/** Overloads the default show so we can load settings */
|
2009-01-07 16:12:31 -05:00
|
|
|
/*void MainWindow::show()
|
2007-11-14 22:18:48 -05:00
|
|
|
{
|
|
|
|
|
|
|
|
if (!this->isVisible()) {
|
|
|
|
QMainWindow::show();
|
|
|
|
} else {
|
|
|
|
QMainWindow::activateWindow();
|
|
|
|
setWindowState(windowState() & ~Qt::WindowMinimized | Qt::WindowActive);
|
|
|
|
QMainWindow::raise();
|
|
|
|
}
|
2009-01-07 16:12:31 -05:00
|
|
|
}*/
|
2007-11-14 22:18:48 -05:00
|
|
|
|
|
|
|
|
2009-01-07 16:12:31 -05:00
|
|
|
/** Shows the MainWindow with focus set to the given page. */
|
|
|
|
void MainWindow::showWindow(Page page)
|
2007-11-14 22:18:48 -05:00
|
|
|
{
|
|
|
|
/* Show the dialog. */
|
2009-01-07 16:12:31 -05:00
|
|
|
//show();
|
2007-11-14 22:18:48 -05:00
|
|
|
|
2009-01-07 16:12:31 -05:00
|
|
|
/* Show the dialog. */
|
|
|
|
RWindow::showWindow();
|
2007-11-14 22:18:48 -05:00
|
|
|
/* Set the focus to the specified page. */
|
|
|
|
ui.stackPages->setCurrentIndex((int)page);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/***** TOOL BAR FUNCTIONS *****/
|
|
|
|
|
|
|
|
/** Add a Friend ShortCut */
|
|
|
|
void MainWindow::addFriend()
|
|
|
|
{
|
2009-03-28 06:41:49 -04:00
|
|
|
ConnectFriendWizard* connwiz = new ConnectFriendWizard(this);
|
2007-11-14 22:18:48 -05:00
|
|
|
|
2009-03-28 06:41:49 -04:00
|
|
|
// set widget to be deleted after close
|
|
|
|
connwiz->setAttribute( Qt::WA_DeleteOnClose, true);
|
2007-11-14 22:18:48 -05:00
|
|
|
|
2009-03-28 06:41:49 -04:00
|
|
|
|
2009-03-26 12:58:06 -04:00
|
|
|
connwiz->show();
|
2007-11-14 22:18:48 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/** Add a Friend ShortCut */
|
2009-03-28 06:41:49 -04:00
|
|
|
/*void MainWindow::inviteFriend()
|
2007-11-14 22:18:48 -05:00
|
|
|
{
|
|
|
|
static InviteDialog *inviteDialog = new InviteDialog(this);
|
|
|
|
|
2008-01-25 03:49:40 -05:00
|
|
|
std::string invite = rsPeers->GetRetroshareInvite();
|
2007-11-14 22:18:48 -05:00
|
|
|
inviteDialog->setInfo(invite);
|
|
|
|
inviteDialog->show();
|
|
|
|
|
|
|
|
|
|
|
|
}
|
2009-03-28 06:41:49 -04:00
|
|
|
*/
|
2009-01-07 16:12:31 -05:00
|
|
|
/** Add a Share */
|
2007-11-14 22:18:48 -05:00
|
|
|
void MainWindow::addSharedDirectory()
|
|
|
|
{
|
|
|
|
/* Same Code as in Preferences Window (add Share) */
|
|
|
|
|
|
|
|
QString qdir = QFileDialog::getExistingDirectory(this, tr("Add Shared Directory"), "",
|
|
|
|
QFileDialog::ShowDirsOnly | QFileDialog::DontResolveSymlinks);
|
|
|
|
|
|
|
|
/* add it to the server */
|
|
|
|
std::string dir = qdir.toStdString();
|
|
|
|
if (dir != "")
|
|
|
|
{
|
2008-07-02 12:59:56 -04:00
|
|
|
rsFiles -> addSharedDirectory(dir);
|
2007-11-14 22:18:48 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2009-01-07 16:12:31 -05:00
|
|
|
/** Shows Share Manager */
|
2008-12-10 20:19:34 -05:00
|
|
|
void MainWindow::openShareManager()
|
|
|
|
{
|
|
|
|
static ShareManager* sharemanager = new ShareManager(this);
|
|
|
|
sharemanager->show();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2009-01-07 16:12:31 -05:00
|
|
|
/** Creates and displays the Configuration dialog with the current page set to
|
|
|
|
* <b>page</b>. */
|
|
|
|
void
|
|
|
|
MainWindow::showPreferencesWindow(PreferencesWindow::Page page)
|
2007-11-14 22:18:48 -05:00
|
|
|
{
|
2009-01-07 16:12:31 -05:00
|
|
|
_preferencesWindow->showWindow(page);
|
|
|
|
}
|
|
|
|
|
|
|
|
/** Shows Messages Dialog */
|
|
|
|
void
|
|
|
|
MainWindow::showMess(MainWindow::Page page)
|
|
|
|
{
|
|
|
|
showWindow(page);
|
|
|
|
}
|
|
|
|
|
2007-11-14 22:18:48 -05:00
|
|
|
|
|
|
|
/** Shows Options */
|
|
|
|
void MainWindow::showSettings()
|
|
|
|
{
|
|
|
|
static GSettingsWin *win = new GSettingsWin(this);
|
|
|
|
if (win->isHidden())
|
|
|
|
win->setNewPage(0);
|
|
|
|
win->show();
|
|
|
|
win->activateWindow();
|
|
|
|
}
|
|
|
|
|
|
|
|
/** Shows Messenger window */
|
|
|
|
void MainWindow::showMessengerWindow()
|
|
|
|
{
|
|
|
|
messengerWindow->show();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/** Shows Application window */
|
|
|
|
void MainWindow::showApplWindow()
|
|
|
|
{
|
|
|
|
applicationWindow->show();
|
|
|
|
}
|
|
|
|
|
|
|
|
/** Destructor. */
|
|
|
|
MainWindow::~MainWindow()
|
|
|
|
{
|
|
|
|
delete _bandwidthGraph;
|
|
|
|
delete _messengerwindowAct;
|
2008-11-30 12:15:23 -05:00
|
|
|
//delete _smplayerAct;
|
2008-08-14 20:23:27 -04:00
|
|
|
delete _preferencesWindow;
|
2007-11-14 22:18:48 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
/** Create and bind actions to events. Setup for initial
|
|
|
|
* tray menu configuration. */
|
|
|
|
void MainWindow::createActions()
|
|
|
|
{
|
|
|
|
|
|
|
|
_prefsAct = new QAction(QIcon(IMAGE_PREFERENCES), tr("Options"), this);
|
|
|
|
connect(_prefsAct, SIGNAL(triggered()), this, SLOT(showPreferencesWindow()));
|
|
|
|
|
|
|
|
_bandwidthAct = new QAction(QIcon(IMAGE_BWGRAPH), tr("Bandwidth Graph"), this);
|
|
|
|
connect(_bandwidthAct, SIGNAL(triggered()),
|
|
|
|
_bandwidthGraph, SLOT(showWindow()));
|
|
|
|
|
|
|
|
_messengerwindowAct = new QAction(QIcon(IMAGE_RSM16), tr("Open Messenger"), this);
|
|
|
|
connect(_messengerwindowAct, SIGNAL(triggered()),this, SLOT(showMessengerWindow()));
|
2009-01-07 16:12:31 -05:00
|
|
|
|
|
|
|
_messagesAct = new QAction(QIcon(IMAGE_MESSAGES), tr("Open Messages"), this);
|
|
|
|
connect(_messagesAct, SIGNAL(triggered()),this, SLOT(showMess()));
|
2007-11-18 18:35:53 -05:00
|
|
|
|
2008-08-16 18:24:53 -04:00
|
|
|
_appAct = new QAction(QIcon(IMAGE_UNFINISHED), tr("Applications"), this);
|
|
|
|
connect(_appAct, SIGNAL(triggered()),this, SLOT(showApplWindow()));
|
|
|
|
|
2008-11-29 15:17:58 -05:00
|
|
|
//_smplayerAct = new QAction(QIcon(IMAGE_SMPLAYER), tr("SMPlayer"), this);
|
|
|
|
//connect(_smplayerAct, SIGNAL(triggered()),this, SLOT(showsmplayer()));
|
2008-08-05 14:36:07 -04:00
|
|
|
|
|
|
|
_helpAct = new QAction(QIcon(IMG_HELP), tr("Help"), this);
|
|
|
|
connect(_helpAct, SIGNAL(triggered()), this, SLOT(showHelpDialog()));
|
2007-11-14 22:18:48 -05:00
|
|
|
|
2008-08-15 13:49:57 -04:00
|
|
|
|
2007-11-14 22:18:48 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
/** If the user attempts to quit the app, a check-warning is issued. This warning can be
|
|
|
|
turned off for future quit events.
|
|
|
|
*/
|
|
|
|
void MainWindow::doQuit()
|
|
|
|
{
|
|
|
|
RshareSettings rsharesettings;
|
|
|
|
QString key (UI_PREF_PROMPT_ON_QUIT);
|
|
|
|
bool doConfirm = rsharesettings.value(key, QVariant(true)).toBool();
|
|
|
|
if (doConfirm)
|
|
|
|
{
|
|
|
|
ConfirmQuitDialog * confirm = new ConfirmQuitDialog;
|
|
|
|
confirm->exec();
|
|
|
|
// save configuration setting
|
|
|
|
if (confirm->reminderCheckBox->checkState() == Qt::Checked)
|
|
|
|
{
|
|
|
|
rsharesettings.setValue(key, QVariant(false));
|
|
|
|
}
|
|
|
|
|
|
|
|
if (confirm->result() == QDialog::Accepted)
|
|
|
|
{
|
2008-04-09 08:57:26 -04:00
|
|
|
rsicontrol->rsGlobalShutDown();
|
2007-11-14 22:18:48 -05:00
|
|
|
qApp->quit();
|
|
|
|
} else {
|
|
|
|
delete confirm;
|
|
|
|
}
|
|
|
|
|
|
|
|
} else {
|
2008-04-09 08:57:26 -04:00
|
|
|
rsicontrol->rsGlobalShutDown();
|
2007-11-14 22:18:48 -05:00
|
|
|
qApp->quit();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void MainWindow::closeEvent(QCloseEvent *e)
|
|
|
|
{
|
|
|
|
static bool firstTime = true;
|
|
|
|
|
|
|
|
if (trayIcon->isVisible()) {
|
|
|
|
if (firstTime)
|
|
|
|
{
|
|
|
|
/*****
|
|
|
|
QMessageBox::information(this, tr("RetroShare System tray"),
|
|
|
|
tr("Application will continue running. Quit using context menu in the system tray"));
|
|
|
|
*****/
|
|
|
|
firstTime = false;
|
|
|
|
}
|
|
|
|
hide();
|
|
|
|
e->ignore();
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void MainWindow::updateMenu()
|
|
|
|
{
|
|
|
|
toggleVisibilityAction->setText(isVisible() ? tr("Hide") : tr("Show"));
|
|
|
|
}
|
|
|
|
|
|
|
|
void MainWindow::toggleVisibility(QSystemTrayIcon::ActivationReason e)
|
|
|
|
{
|
|
|
|
if(e == QSystemTrayIcon::Trigger || e == QSystemTrayIcon::DoubleClick){
|
|
|
|
if(isHidden()){
|
|
|
|
show();
|
|
|
|
if(isMinimized()){
|
|
|
|
if(isMaximized()){
|
|
|
|
showMaximized();
|
|
|
|
}else{
|
|
|
|
showNormal();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
raise();
|
|
|
|
activateWindow();
|
|
|
|
}else{
|
|
|
|
hide();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void MainWindow::toggleVisibilitycontextmenu()
|
|
|
|
{
|
|
|
|
if (isVisible())
|
|
|
|
hide();
|
|
|
|
else
|
|
|
|
show();
|
|
|
|
}
|
|
|
|
|
|
|
|
void MainWindow::loadStyleSheet(const QString &sheetName)
|
|
|
|
{
|
2008-01-19 12:13:50 -05:00
|
|
|
/** internal Stylesheets **/
|
|
|
|
//QFile file(":/qss/" + sheetName.toLower() + ".qss");
|
|
|
|
|
|
|
|
/** extern Stylesheets **/
|
|
|
|
QFile file(QApplication::applicationDirPath() + "/qss/" + sheetName.toLower() + ".qss");
|
|
|
|
|
2007-11-14 22:18:48 -05:00
|
|
|
file.open(QFile::ReadOnly);
|
|
|
|
QString styleSheet = QLatin1String(file.readAll());
|
|
|
|
|
|
|
|
qApp->setStyleSheet(styleSheet);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2007-12-13 11:02:33 -05:00
|
|
|
void MainWindow::startgammon()
|
|
|
|
{
|
2007-11-14 22:18:48 -05:00
|
|
|
BgWindow *bgWindow = new BgWindow(this);
|
|
|
|
bgWindow->show();
|
2007-12-13 11:02:33 -05:00
|
|
|
|
|
|
|
|
2007-11-14 22:18:48 -05:00
|
|
|
}
|
|
|
|
|
2007-12-13 11:02:33 -05:00
|
|
|
void MainWindow::startqcheckers()
|
2007-11-14 22:18:48 -05:00
|
|
|
{
|
2009-02-02 07:41:20 -05:00
|
|
|
#if 0
|
2007-12-13 11:02:33 -05:00
|
|
|
myTopLevel* top = new myTopLevel();
|
2007-11-14 22:18:48 -05:00
|
|
|
top->show();
|
2009-02-02 07:41:20 -05:00
|
|
|
#endif
|
2007-11-14 22:18:48 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-03-31 14:37:50 -04:00
|
|
|
/** Shows smplayer */
|
|
|
|
void MainWindow::showsmplayer()
|
2008-03-18 19:16:11 -04:00
|
|
|
{
|
2008-11-29 15:17:58 -05:00
|
|
|
return;
|
|
|
|
|
2008-11-30 12:15:23 -05:00
|
|
|
#if 0
|
2008-03-31 14:37:50 -04:00
|
|
|
if (mSMPlayer == 0)
|
|
|
|
{
|
|
|
|
mSMPlayer = new SMPlayer(QString::null, this);
|
2008-11-29 15:17:58 -05:00
|
|
|
mSMPlayer->gui()->hide();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
mSMPlayer->gui()->show();
|
2008-03-31 14:37:50 -04:00
|
|
|
}
|
2008-11-30 12:15:23 -05:00
|
|
|
#endif
|
2007-11-14 22:18:48 -05:00
|
|
|
}
|
2008-03-27 19:40:37 -04:00
|
|
|
|
2008-03-31 14:37:50 -04:00
|
|
|
void MainWindow::playFiles(QStringList files)
|
|
|
|
{
|
2008-11-30 12:15:23 -05:00
|
|
|
std::cerr << "MainWindow::playFiles() Can only play first currently" << std::endl;
|
|
|
|
QStringList::iterator it;
|
|
|
|
it = files.begin();
|
|
|
|
if (it == files.end())
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
std::string path = (*it).toStdString();
|
|
|
|
std::cerr << "MainWindow::playFiles() opening: " << path << std::endl;
|
|
|
|
|
|
|
|
openFile(path);
|
|
|
|
return;
|
2008-07-10 14:52:56 -04:00
|
|
|
|
2008-11-30 12:15:23 -05:00
|
|
|
#if 0
|
2008-03-31 14:37:50 -04:00
|
|
|
showsmplayer();
|
2008-07-10 14:52:56 -04:00
|
|
|
|
|
|
|
std::cerr << "MainWindow::playFiles() showsmplayer() done" << std::endl;
|
|
|
|
|
2008-11-29 15:17:58 -05:00
|
|
|
if (mSMPlayer)
|
|
|
|
mSMPlayer->gui()->openFiles(files);
|
2008-07-10 14:52:56 -04:00
|
|
|
|
|
|
|
std::cerr << "MainWindow::playFiles() done" << std::endl;
|
2008-11-30 12:15:23 -05:00
|
|
|
#endif
|
2008-03-31 14:37:50 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-03-31 09:00:00 -04:00
|
|
|
void MainWindow::showabout()
|
|
|
|
{
|
|
|
|
static HelpDialog *helpdlg = new HelpDialog(this);
|
|
|
|
helpdlg->show();
|
|
|
|
}
|
|
|
|
|
2008-08-05 14:36:07 -04:00
|
|
|
/** Displays the help browser and displays the most recently viewed help
|
|
|
|
* topic. */
|
|
|
|
void MainWindow::showHelpDialog()
|
|
|
|
{
|
|
|
|
showHelpDialog(QString());
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**< Shows the help browser and displays the given help <b>topic</b>. */
|
|
|
|
void MainWindow::showHelpDialog(const QString &topic)
|
|
|
|
{
|
|
|
|
static HelpBrowser *helpBrowser = 0;
|
|
|
|
if (!helpBrowser)
|
|
|
|
helpBrowser = new HelpBrowser(this);
|
|
|
|
helpBrowser->showWindow(topic);
|
|
|
|
}
|
|
|
|
|
2008-11-27 18:59:08 -05:00
|
|
|
void MainWindow::setStyle()
|
|
|
|
{
|
|
|
|
QString standardSheet = "{background-color: qlineargradient(x1:0, y1:0, x2:0, y2:1,stop:0 <color1>, stop:1 <color2>);}";
|
|
|
|
QColor stop1 = QColorDialog::getColor(Qt::white);
|
|
|
|
QColor stop2 = QColorDialog::getColor(Qt::black);
|
|
|
|
//QString widgetSheet = ".QWidget" + standardSheet.replace("<color1>", stop1.name()).replace("<color2>", stop2.name());
|
|
|
|
QString toolSheet = "QToolBar" + standardSheet.replace("<color1>", stop1.name()).replace("<color2>", stop2.name());
|
|
|
|
QString menuSheet = "QMenuBar" + standardSheet.replace("<color1>", stop1.name()).replace("<color2>", stop2.name());
|
|
|
|
qApp->setStyleSheet(/*widgetSheet + */toolSheet + menuSheet);
|
|
|
|
|
2008-03-27 19:40:37 -04:00
|
|
|
}
|
|
|
|
|
2008-11-30 12:15:23 -05:00
|
|
|
|
|
|
|
void openFile(std::string path)
|
|
|
|
{
|
|
|
|
bool isAbs = true;
|
|
|
|
QString surl("file://");
|
|
|
|
|
|
|
|
#if defined(Q_OS_WIN)
|
|
|
|
/* check that it is an absolute path */
|
|
|
|
if (path.size() < 4)
|
|
|
|
{
|
|
|
|
std::cerr << "[WIN] openPath() Very Small path ignoring: " << path;
|
|
|
|
std::cerr << std::endl;
|
2008-12-07 13:34:54 -05:00
|
|
|
return;
|
2008-11-30 12:15:23 -05:00
|
|
|
}
|
|
|
|
|
2008-12-07 13:34:54 -05:00
|
|
|
if ((path[1] == ':') && ((path[2] == '\\') || (path[2] == '/')))
|
2008-11-30 12:15:23 -05:00
|
|
|
{
|
|
|
|
isAbs = true;
|
|
|
|
}
|
|
|
|
#else
|
|
|
|
|
|
|
|
/* check that it is an absolute path */
|
|
|
|
if (path.size() < 1)
|
|
|
|
{
|
|
|
|
std::cerr << "[UNIX] openPath() Very Small path ignoring: " << path;
|
|
|
|
std::cerr << std::endl;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (path[0] == '/')
|
|
|
|
{
|
|
|
|
isAbs = true;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
if (!isAbs)
|
|
|
|
{
|
|
|
|
|
|
|
|
#define ROOT_PATH_SIZE 1024
|
|
|
|
|
|
|
|
char rootdir[ROOT_PATH_SIZE];
|
|
|
|
if (NULL == getcwd(rootdir, ROOT_PATH_SIZE))
|
|
|
|
{
|
|
|
|
std::cerr << "openPath() get Abs Failed: " << path;
|
|
|
|
std::cerr << std::endl;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
std::string rdir(rootdir);
|
|
|
|
surl += QString::fromStdString(rdir);
|
|
|
|
surl += '/';
|
|
|
|
}
|
|
|
|
|
|
|
|
surl += QString::fromStdString(path);
|
|
|
|
std::cerr << "openPath() opening AbsPath Url: " << surl.toStdString();
|
|
|
|
std::cerr << std::endl;
|
|
|
|
|
|
|
|
QUrl url(surl);
|
|
|
|
QDesktopServices::openUrl(url);
|
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
|