Пример #1
0
CWinMain::CWinMain( QWidget* parent ) :
	QMainWindow( parent ),
	ui( new Ui::CWinMain )
{
	ui->setupUi( this );

	//Initialize vaiables
	bypassCloseEvent = false;
	interfaceLoaded = false;

	ui->actionAres->setChecked( quazaaSettings.Ares.Enable );
	ui->actionEDonkey->setChecked( quazaaSettings.EDonkey.Enable );
	ui->actionGnutella2->setChecked( quazaaSettings.Gnutella2.Enable );

	//Load And Set Up User Interface
	quazaaSettings.loadWindowSettings( this );
	restoreState( quazaaSettings.WinMain.MainToolbar );

	//Set up the status bar
	labelIPAddress = new QLabel( tr( "Current IP:" ) );
	ui->statusbar->addWidget( labelIPAddress );
	labelCurrentIPAddress = new QLabel( tr( "Unknown" ) );
	ui->statusbar->addWidget( labelCurrentIPAddress );
	toolButtonAddressToClipboard = new QToolButton( this );
	toolButtonAddressToClipboard->setText( tr( "Copy Address" ) );
	toolButtonAddressToClipboard->setAutoRaise( true );
	connect( toolButtonAddressToClipboard, SIGNAL( clicked() ), this, SLOT( onCopyIP() ) );
	ui->statusbar->addWidget( toolButtonAddressToClipboard );

	tcpFirewalled = ":/Resource/Network/ShieldRed.png";
	udpFirewalled = ":/Resource/Network/ShieldRed.png";
	labelFirewallStatus = new QLabel(
		tr( "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0//EN\" \"http://www.w3.org/TR/REC-html40/strict.dtd\"> <html><head><meta name=\"qrichtext\" content=\"1\" /><style type=\"text/css\">p, li { white-space: pre-wrap; }</style></head><body style=\" font-family:'Segoe UI'; font-size:10pt; font-weight:400; font-style:normal;\"><p style=\" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\">TCP: <img src=\":/Resource/Network/ShieldRed.png\" /> UDP: <img src=\":/Resource/Network/ShieldRed.png\" /></p></body></html>" ) );
	ui->statusbar->addPermanentWidget( labelFirewallStatus );
	labelBandwidthTotals = new QLabel();
	ui->statusbar->addPermanentWidget( labelBandwidthTotals );

	//Add the tabs
	pageHome = new CWidgetHome();
	ui->stackedWidgetMain->addWidget( pageHome );
	pageLibrary = new CWidgetLibrary();
	ui->stackedWidgetMain->addWidget( pageLibrary );
	pageMedia = new CWidgetMedia();
	ui->stackedWidgetMain->addWidget( pageMedia );
	pageSearch = new WidgetSearch();
	ui->stackedWidgetMain->addWidget( pageSearch );
	pageTransfers = new CWidgetTransfers();
	ui->stackedWidgetMain->addWidget( pageTransfers );
	pageSecurity = new CWidgetSecurity();
	ui->stackedWidgetMain->addWidget( pageSecurity );
	pageActivity = new WidgetActivity();
	ui->stackedWidgetMain->addWidget( pageActivity );
	pageIrcMain = new CWidgetIrcMain();
	ui->stackedWidgetMain->addWidget( pageIrcMain );
	pageHostCache = new WidgetHostCache;
	ui->stackedWidgetMain->addWidget( pageHostCache );
	pageDiscovery = new CWidgetDiscovery;
	ui->stackedWidgetMain->addWidget( pageDiscovery );
	pageScheduler = new CWidgetScheduler;
	ui->stackedWidgetMain->addWidget( pageScheduler );
	pageGraph = new CWidgetGraph;
	ui->stackedWidgetMain->addWidget( pageGraph );
	pagePacketDump = new CWidgetPacketDump;
	ui->stackedWidgetMain->addWidget( pagePacketDump );
	pageSearchMonitor = new CWidgetSearchMonitor;
	ui->stackedWidgetMain->addWidget( pageSearchMonitor );
	pageHitMonitor = new CWidgetHitMonitor;
	ui->stackedWidgetMain->addWidget( pageHitMonitor );

	dlgPrivateMessages = 0;

	// Set up the navigation toolbar
	actionGroupMainNavigation = new QActionGroup( this );
	actionGroupMainNavigation->addAction( ui->actionHome );
	actionGroupMainNavigation->addAction( ui->actionLibrary );
	actionGroupMainNavigation->addAction( ui->actionMedia );
	actionGroupMainNavigation->addAction( ui->actionSearch );
	actionGroupMainNavigation->addAction( ui->actionTransfers );
	actionGroupMainNavigation->addAction( ui->actionSecurity );
	actionGroupMainNavigation->addAction( ui->actionActivity );
	actionGroupMainNavigation->addAction( ui->actionChat );
	actionGroupMainNavigation->addAction( ui->actionHostCache );
	actionGroupMainNavigation->addAction( ui->actionDiscovery );
	actionGroupMainNavigation->addAction( ui->actionScheduler );
	actionGroupMainNavigation->addAction( ui->actionGraph );
	actionGroupMainNavigation->addAction( ui->actionPacketDump );
	actionGroupMainNavigation->addAction( ui->actionSearchMonitor );
	actionGroupMainNavigation->addAction( ui->actionHitMonitor );
	ui->stackedWidgetMain->setCurrentIndex( quazaaSettings.WinMain.ActiveTab );
	switch ( quazaaSettings.WinMain.ActiveTab )
	{
	case 0:
		ui->actionHome->setChecked( true );
		break;
	case 1:
		ui->actionLibrary->setChecked( true );
		break;
	case 2:
		ui->actionMedia->setChecked( true );
		break;
	case 3:
		ui->actionSearch->setChecked( true );
		pageSearch->focusSearchInput();
		break;
	case 4:
		ui->actionTransfers->setChecked( true );
		break;
	case 5:
		ui->actionSecurity->setChecked( true );
		break;
	case 6:
		ui->actionActivity->setChecked( true );
		break;
	case 7:
		ui->actionChat->setChecked( true );
		break;
	case 8:
		ui->actionHostCache->setChecked( true );
		break;
	case 9:
		ui->actionDiscovery->setChecked( true );
		break;
	case 10:
		ui->actionScheduler->setChecked( true );
		break;
	case 11:
		ui->actionGraph->setChecked( true );
		break;
	case 12:
		ui->actionPacketDump->setChecked( true );
		break;
	case 13:
		ui->actionSearchMonitor->setChecked( true );
		break;
	case 14:
		ui->actionHitMonitor->setChecked( true );
		break;
	default:
		ui->actionHome->setChecked( true );
		break;
	}

	connect( ui->actionNewSearch, SIGNAL( triggered() ), pageSearch, SLOT( on_toolButtonNewSearch_clicked() ) );
	connect( pageHome, SIGNAL( requestSearch( QString* ) ), this, SLOT( startNewSearch( QString* ) ) );
	connect( pageHome, SIGNAL( triggerLibrary() ), this, SLOT( on_actionLibrary_triggered() ) );
	connect( pageHome, SIGNAL( triggerSecurity() ), this, SLOT( on_actionSecurity_triggered() ) );
	connect( pageHome, SIGNAL( triggerTransfers() ), this, SLOT( on_actionTransfers_triggered() ) );

	neighboursRefresher = new QTimer( this );
	connect( neighboursRefresher, SIGNAL( timeout() ), this, SLOT( updateStatusBar() ) );
	connect( neighboursRefresher, SIGNAL( timeout() ), pageActivity->panelNeighbours, SLOT( onTimer() ) );

	update();
	qApp->processEvents();

	interfaceLoaded = true;

	connect( &chatCore, SIGNAL( openChatWindow( ChatSession* ) ), this, SLOT( OpenChat( ChatSession* ) ) );
	connect( &networkG2, SIGNAL( localAddressChanged() ), this, SLOT( localAddressChanged() ) );
	connect( &shareManager, SIGNAL( hasherStarted( int ) ), this, SLOT( onHasherStarted( int ) ) );
	setSkin();
}
Пример #2
0
WinMain::WinMain(QWidget* parent) :
	QMainWindow(parent),
	ui(new Ui::WinMain)
{
	ui->setupUi(this);

	//Initialize vaiables
	bypassCloseEvent = false;
	interfaceLoaded = false;

	ui->actionAres->setChecked(quazaaSettings.Ares.Enable);
	ui->actionEDonkey->setChecked(quazaaSettings.EDonkey.Enable);
	ui->actionGnutella2->setChecked(quazaaSettings.Gnutella2.Enable);

	//Load And Set Up User Interface
	quazaaSettings.loadWindowSettings(this);
	restoreState(quazaaSettings.WinMain.MainToolbar);

	//Set up the menu toolbar
	ui->toolBarMainMenu->addWidget(ui->menubarMain);

	//Set up the status bar
	tcpFirewalled = ":/Resource/Network/ShieldRed.png";
	udpFirewalled = ":/Resource/Network/ShieldRed.png";
	labelFirewallStatus = new QLabel(tr("<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0//EN\" \"http://www.w3.org/TR/REC-html40/strict.dtd\"> <html><head><meta name=\"qrichtext\" content=\"1\" /><style type=\"text/css\">p, li { white-space: pre-wrap; }</style></head><body style=\" font-family:'Segoe UI'; font-size:10pt; font-weight:400; font-style:normal;\"><p style=\" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\">TCP: <img src=\":/Resource/Network/ShieldRed.png\" /> UDP: <img src=\":/Resource/Network/ShieldRed.png\" /></p></body></html>"));
	ui->statusbar->addPermanentWidget(labelFirewallStatus);
	labelBandwidthTotals = new QLabel();
	ui->statusbar->addPermanentWidget(labelBandwidthTotals);

	//Add the tabs
	pageHome = new WidgetHome();
	ui->stackedWidgetMain->addWidget(pageHome);
	pageLibrary = new WidgetLibrary();
	ui->stackedWidgetMain->addWidget(pageLibrary);
	pageMedia = new WidgetMedia();
	ui->stackedWidgetMain->addWidget(pageMedia);
	pageSearch = new WidgetSearch();
	ui->stackedWidgetMain->addWidget(pageSearch);
	pageTransfers = new WidgetTransfers();
	ui->stackedWidgetMain->addWidget(pageTransfers);
	pageSecurity = new WidgetSecurity();
	ui->stackedWidgetMain->addWidget(pageSecurity);
	pageActivity = new WidgetActivity();
	ui->stackedWidgetMain->addWidget(pageActivity);
	pageChat = new WidgetChat();
	ui->stackedWidgetMain->addWidget(pageChat);
	pageHostCache = new WidgetHostCache;
	ui->stackedWidgetMain->addWidget(pageHostCache);
	pageDiscovery = new WidgetDiscovery;
	ui->stackedWidgetMain->addWidget(pageDiscovery);
	pageScheduler = new WidgetScheduler;
	ui->stackedWidgetMain->addWidget(pageScheduler);
	pageGraph = new WidgetGraph;
	ui->stackedWidgetMain->addWidget(pageGraph);
	pagePacketDump = new WidgetPacketDump;
	ui->stackedWidgetMain->addWidget(pagePacketDump);
	pageSearchMonitor = new WidgetSearchMonitor;
	ui->stackedWidgetMain->addWidget(pageSearchMonitor);
	pageHitMonitor = new WidgetHitMonitor;
	ui->stackedWidgetMain->addWidget(pageHitMonitor);

	dlgPrivateMessages = 0;

	// Set up the navigation toolbar
	actionGroupMainNavigation = new QActionGroup(this);
	actionGroupMainNavigation->addAction(ui->actionHome);
	actionGroupMainNavigation->addAction(ui->actionLibrary);
	actionGroupMainNavigation->addAction(ui->actionMedia);
	actionGroupMainNavigation->addAction(ui->actionSearch);
	actionGroupMainNavigation->addAction(ui->actionTransfers);
	actionGroupMainNavigation->addAction(ui->actionSecurity);
	actionGroupMainNavigation->addAction(ui->actionActivity);
	actionGroupMainNavigation->addAction(ui->actionChat);
	actionGroupMainNavigation->addAction(ui->actionHostCache);
	actionGroupMainNavigation->addAction(ui->actionDiscovery);
	actionGroupMainNavigation->addAction(ui->actionScheduler);
	actionGroupMainNavigation->addAction(ui->actionGraph);
	actionGroupMainNavigation->addAction(ui->actionPacketDump);
	actionGroupMainNavigation->addAction(ui->actionSearchMonitor);
	actionGroupMainNavigation->addAction(ui->actionHitMonitor);
	ui->stackedWidgetMain->setCurrentIndex(quazaaSettings.WinMain.ActiveTab);
	switch(quazaaSettings.WinMain.ActiveTab)
	{
		case 0:
			ui->labelMainHeaderLogo->setPixmap(QPixmap(":/Resource/Generic/Home.png"));
			ui->labelMainHeaderText->setText(tr("Quazaa Home"));
			ui->actionHome->setChecked(true);
			break;
		case 1:
			ui->labelMainHeaderLogo->setPixmap(QPixmap(":/Resource/Library/Library.png"));
			ui->labelMainHeaderText->setText(tr("Library"));
			ui->actionLibrary->setChecked(true);
			break;
		case 2:
			ui->labelMainHeaderLogo->setPixmap(QPixmap(":/Resource/Media/Media.png"));
			ui->labelMainHeaderText->setText(tr("Media"));
			ui->actionMedia->setChecked(true);
			break;
		case 3:
			ui->labelMainHeaderLogo->setPixmap(QPixmap(":/Resource/Generic/Search.png"));
			ui->labelMainHeaderText->setText(tr("Search"));
			ui->actionSearch->setChecked(true);
			break;
		case 4:
			ui->labelMainHeaderLogo->setPixmap(QPixmap(":/Resource/Generic/Transfers.png"));
			ui->labelMainHeaderText->setText(tr("Transfers"));
			ui->actionTransfers->setChecked(true);
			break;
		case 5:
			ui->labelMainHeaderLogo->setPixmap(QPixmap(":/Resource/Security/Security.png"));
			ui->labelMainHeaderText->setText(tr("Security"));
			ui->actionSecurity->setChecked(true);
			break;
		case 6:
			ui->labelMainHeaderLogo->setPixmap(QPixmap(":/Resource/Generic/Globe.png"));
			ui->labelMainHeaderText->setText(tr("Activity"));
			ui->actionActivity->setChecked(true);
			break;
		case 7:
			ui->labelMainHeaderLogo->setPixmap(QPixmap(":/Resource/Chat/Chat.png"));
			ui->labelMainHeaderText->setText(tr("Chat"));
			ui->actionChat->setChecked(true);
			break;
		case 8:
			ui->labelMainHeaderLogo->setPixmap(QPixmap(":/Resource/Network/HostCache.png"));
			ui->labelMainHeaderText->setText(tr("Host Cache"));
			ui->actionHostCache->setChecked(true);
			break;
		case 9:
			ui->labelMainHeaderLogo->setPixmap(QPixmap(":/Resource/Network/Discovery.png"));
			ui->labelMainHeaderText->setText(tr("Discovery"));
			ui->actionDiscovery->setChecked(true);
			break;
		case 10:
			ui->labelMainHeaderLogo->setPixmap(QPixmap(":/Resource/Generic/Scheduler.png"));
			ui->labelMainHeaderText->setText(tr("Scheduler"));
			ui->actionScheduler->setChecked(true);
			break;
		case 11:
			ui->labelMainHeaderLogo->setPixmap(QPixmap(":/Resource/Generic/Graph.png"));
			ui->labelMainHeaderText->setText(tr("Graph"));
			ui->actionGraph->setChecked(true);
			break;
		case 12:
			ui->labelMainHeaderLogo->setPixmap(QPixmap(":/Resource/Network/PacketDump.png"));
			ui->labelMainHeaderText->setText(tr("Packet Dump"));
			ui->actionPacketDump->setChecked(true);
			break;
		case 13:
			ui->labelMainHeaderLogo->setPixmap(QPixmap(":/Resource/Network/SearchMonitor.png"));
			ui->labelMainHeaderText->setText(tr("Search Monitor"));
			ui->actionSearchMonitor->setChecked(true);
			break;
		case 14:
			ui->labelMainHeaderLogo->setPixmap(QPixmap(":/Resource/Network/HitMonitor.png"));
			ui->labelMainHeaderText->setText(tr("Hit Monitor"));
			ui->actionHitMonitor->setChecked(true);
			break;
		default:
			ui->labelMainHeaderLogo->setPixmap(QPixmap(":/Resource/Generic/Home.png"));
			ui->labelMainHeaderText->setText(tr("Quazaa Home"));
			ui->actionHome->setChecked(true);
			break;
	}
        ui->menubarMain->setStyleSheet("QMenuBar::item:!selected,  QMenuBar::item:!pressed { color: " + qApp->palette().buttonText().color().name() + "; background: transparent; }");
	connect(ui->actionNewSearch, SIGNAL(triggered()), pageSearch, SLOT(on_toolButtonNewSearch_clicked()));
	connect(pageHome, SIGNAL(requestSearch(QString*)), this, SLOT(startNewSearch(QString*)));
	connect(pageHome, SIGNAL(triggerLibrary()), this, SLOT(on_actionLibrary_triggered()));
	connect(pageHome, SIGNAL(triggerSecurity()), this, SLOT(on_actionSecurity_triggered()));
	connect(pageHome, SIGNAL(triggerTransfers()), this, SLOT(on_actionTransfers_triggered()));

	neighboursRefresher = new QTimer(this);
	connect(neighboursRefresher, SIGNAL(timeout()), this, SLOT(updateStatusBar()));
	connect(neighboursRefresher, SIGNAL(timeout()), pageActivity->panelNeighbours, SLOT(onTimer()));

	update();
	qApp->processEvents();

	interfaceLoaded = true;

	connect(&ChatCore, SIGNAL(openChatWindow(CChatSession*)), this, SLOT(OpenChat(CChatSession*)));
}