mirror of
https://github.com/RetroShare/RetroShare.git
synced 2024-10-01 02:35:48 -04:00
Source code maintenance
Memory leaks: - PeersDialog::insertPeers -> takeTopLevelItem, takeChild - activate correct page on creating a new forum or channel from PeersDialog (problems with RS_RELEASE_VERSION) new static method to activate a page MainWindow::activatePage git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@2842 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
parent
ed566d85b9
commit
fb58beef4f
@ -1289,6 +1289,8 @@ void ForumsDialog::replytomessage()
|
||||
nMsgDialog->addRecipient( msgInfo.srcId ) ;
|
||||
nMsgDialog->show();
|
||||
nMsgDialog->activateWindow();
|
||||
|
||||
/* window will destroy itself! */
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -27,7 +27,6 @@
|
||||
#include <QIcon>
|
||||
#include <QPixmap>
|
||||
|
||||
#include "ChannelFeed.h"
|
||||
#include "ShareManager.h"
|
||||
#include "NetworkView.h"
|
||||
#include "LinksDialog.h"
|
||||
@ -103,6 +102,17 @@
|
||||
#define IMAGE_TWOONLINE ":/images/rstray2.png"
|
||||
#define IMAGE_BLOGS ":/images/kblogger.png"
|
||||
|
||||
/*static*/ MainWindow *MainWindow::_instance = NULL;
|
||||
|
||||
/** create main window */
|
||||
/*static*/ MainWindow *MainWindow::Create ()
|
||||
{
|
||||
if (_instance == NULL) {
|
||||
_instance = new MainWindow ();
|
||||
}
|
||||
|
||||
return _instance;
|
||||
}
|
||||
|
||||
/** Constructor */
|
||||
MainWindow::MainWindow(QWidget* parent, Qt::WFlags flags)
|
||||
@ -184,29 +194,24 @@ MainWindow::MainWindow(QWidget* parent, Qt::WFlags flags)
|
||||
messageAction = createPageAction(QIcon(IMAGE_MESSAGES), tr("Messages"), grp));
|
||||
|
||||
#ifndef RS_RELEASE_VERSION
|
||||
ChannelFeed *channelFeed = NULL;
|
||||
ui.stackPages->add(channelFeed = new ChannelFeed(ui.stackPages),
|
||||
createPageAction(QIcon(IMAGE_CHANNELS), tr("Channels"), grp));
|
||||
#endif
|
||||
|
||||
#ifdef BLOGS
|
||||
BlogsDialog *blogsFeed = NULL;
|
||||
ui.stackPages->add(blogsFeed = new BlogsDialog(ui.stackPages),
|
||||
createPageAction(QIcon(IMAGE_BLOGS), tr("Blogs"), grp));
|
||||
#endif
|
||||
|
||||
ForumsDialog *forumsDialog = NULL;
|
||||
ui.stackPages->add(forumsDialog = new ForumsDialog(ui.stackPages),
|
||||
createPageAction(QIcon(IMAGE_FORUMS), tr("Forums"), grp));
|
||||
|
||||
#ifndef RS_RELEASE_VERSION
|
||||
LinksDialog *linksDialog = NULL;
|
||||
ui.stackPages->add(linksDialog = new LinksDialog(ui.stackPages),
|
||||
createPageAction(QIcon(IMAGE_LINKS), tr("Links Cloud"), grp));
|
||||
#endif
|
||||
|
||||
#ifndef RS_RELEASE_VERSION
|
||||
NewsFeed *newsFeed = NULL;
|
||||
ui.stackPages->add(newsFeed = new NewsFeed(ui.stackPages),
|
||||
createPageAction(QIcon(IMAGE_NEWSFEED), tr("News Feed"), grp));
|
||||
#endif
|
||||
@ -440,9 +445,60 @@ void MainWindow::showWindow(Page page)
|
||||
/* Show the dialog. */
|
||||
RWindow::showWindow();
|
||||
/* Set the focus to the specified page. */
|
||||
ui.stackPages->setCurrentIndex((int)page);
|
||||
activatePage (page);
|
||||
}
|
||||
|
||||
/** Set focus to the given page. */
|
||||
/*static*/ void MainWindow::activatePage(Page page)
|
||||
{
|
||||
if (_instance == NULL) {
|
||||
return;
|
||||
}
|
||||
|
||||
MainPage *Page = NULL;
|
||||
|
||||
switch (page) {
|
||||
case Network:
|
||||
Page = _instance->networkDialog;
|
||||
break;
|
||||
case Friends:
|
||||
Page = _instance->peersDialog;
|
||||
break;
|
||||
case Search:
|
||||
Page = _instance->searchDialog;
|
||||
break;
|
||||
case Transfers:
|
||||
Page = _instance->transfersDialog;
|
||||
break;
|
||||
case SharedDirectories:
|
||||
Page = _instance->sharedfilesDialog;
|
||||
break;
|
||||
case Messages:
|
||||
Page = _instance->messagesDialog;
|
||||
break;
|
||||
#ifndef RS_RELEASE_VERSION
|
||||
case Links:
|
||||
Page = _instance->linksDialog;
|
||||
break;
|
||||
case Channels:
|
||||
Page = _instance->channelFeed;
|
||||
break;
|
||||
#endif
|
||||
case Forums:
|
||||
Page = _instance->forumsDialog;
|
||||
break;
|
||||
#ifdef BLOGS
|
||||
case Blogs:
|
||||
Page = _instance->blogsFeed;
|
||||
break;
|
||||
#endif
|
||||
}
|
||||
|
||||
if (Page) {
|
||||
/* Set the focus to the specified page. */
|
||||
_instance->ui.stackPages->setCurrentPage(Page);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/***** TOOL BAR FUNCTIONS *****/
|
||||
@ -450,13 +506,9 @@ void MainWindow::showWindow(Page page)
|
||||
/** Add a Friend ShortCut */
|
||||
void MainWindow::addFriend()
|
||||
{
|
||||
ConnectFriendWizard* connwiz = new ConnectFriendWizard(this);
|
||||
ConnectFriendWizard connwiz (this);
|
||||
|
||||
// set widget to be deleted after close
|
||||
connwiz->setAttribute( Qt::WA_DeleteOnClose, true);
|
||||
|
||||
|
||||
connwiz->show();
|
||||
connwiz.exec ();
|
||||
}
|
||||
|
||||
/** Shows Share Manager */
|
||||
@ -468,9 +520,9 @@ void MainWindow::openShareManager()
|
||||
|
||||
/** Shows Messages Dialog */
|
||||
void
|
||||
MainWindow::showMess(MainWindow::Page page)
|
||||
MainWindow::showMess()
|
||||
{
|
||||
showWindow(page);
|
||||
showWindow(MainWindow::Messages);
|
||||
}
|
||||
|
||||
|
||||
|
@ -39,6 +39,11 @@
|
||||
#include "SharedFilesDialog.h"
|
||||
#include "MessengerWindow.h"
|
||||
#include "PluginsPage.h"
|
||||
#include "ForumsDialog.h"
|
||||
|
||||
#ifndef RS_RELEASE_VERSION
|
||||
#include "ChannelFeed.h"
|
||||
#endif
|
||||
|
||||
#include "bwgraph/bwgraph.h"
|
||||
#include "help/browser/helpbrowser.h"
|
||||
@ -50,6 +55,16 @@
|
||||
class PeerStatus;
|
||||
class NATStatus;
|
||||
class RatesStatus;
|
||||
class ForumsDialog;
|
||||
|
||||
#ifndef RS_RELEASE_VERSION
|
||||
class LinksDialog;
|
||||
class NewsFeed;
|
||||
#endif
|
||||
|
||||
#ifdef BLOGS
|
||||
class BlogsDialog;
|
||||
#endif
|
||||
|
||||
class MainWindow : public RWindow
|
||||
{
|
||||
@ -72,8 +87,8 @@ public:
|
||||
|
||||
};
|
||||
|
||||
/** Default Constructor */
|
||||
MainWindow(QWidget *parent = 0, Qt::WFlags flags = 0);
|
||||
/** Create main window */
|
||||
static MainWindow *Create ();
|
||||
|
||||
/** Destructor. */
|
||||
~MainWindow();
|
||||
@ -91,7 +106,18 @@ public:
|
||||
MessagesDialog *messagesDialog;
|
||||
SharedFilesDialog *sharedfilesDialog;
|
||||
MessengerWindow *messengerWindow;
|
||||
Idle *idle;
|
||||
ForumsDialog *forumsDialog;
|
||||
Idle *idle;
|
||||
|
||||
#ifndef RS_RELEASE_VERSION
|
||||
ChannelFeed *channelFeed;
|
||||
LinksDialog *linksDialog;
|
||||
NewsFeed *newsFeed;
|
||||
#endif
|
||||
|
||||
#ifdef BLOGS
|
||||
BlogsDialog *blogsFeed;
|
||||
#endif
|
||||
|
||||
#ifdef UNFINISHED
|
||||
ApplicationWindow *applicationWindow;
|
||||
@ -104,12 +130,17 @@ public slots:
|
||||
//void show();
|
||||
/** Shows the config dialog with focus set to the given page. */
|
||||
void showWindow(Page page);
|
||||
/** Set focus to the given page. */
|
||||
static void activatePage (Page page);
|
||||
|
||||
void updateHashingInfo(const QString&) ;
|
||||
void displayErrorMessage(int,int,const QString&) ;
|
||||
void postModDirectories(bool update_local);
|
||||
|
||||
protected:
|
||||
/** Default Constructor */
|
||||
MainWindow(QWidget *parent = 0, Qt::WFlags flags = 0);
|
||||
|
||||
void closeEvent(QCloseEvent *);
|
||||
|
||||
/** Called when the user changes the UI translation. */
|
||||
@ -141,7 +172,7 @@ private slots:
|
||||
/** Called when a child window requests the given help <b>topic</b>. */
|
||||
void showHelpDialog(const QString &topic);
|
||||
|
||||
void showMess(MainWindow::Page page = MainWindow::Messages);
|
||||
void showMess();
|
||||
void showSettings();
|
||||
void setStyle();
|
||||
|
||||
@ -158,6 +189,8 @@ private:
|
||||
|
||||
void createTrayIcon();
|
||||
|
||||
static MainWindow *_instance;
|
||||
|
||||
/** Defines the actions for the tray menu */
|
||||
QAction* _settingsAct;
|
||||
QAction* _bandwidthAct;
|
||||
|
@ -346,6 +346,8 @@ void MessagesDialog::replytomessage()
|
||||
nMsgDialog->addRecipient( msgInfo.srcId ) ;
|
||||
nMsgDialog->show();
|
||||
nMsgDialog->activateWindow();
|
||||
|
||||
/* window will destroy itself! */
|
||||
}
|
||||
|
||||
void MessagesDialog::replyallmessage()
|
||||
@ -401,6 +403,8 @@ void MessagesDialog::replyallmessage()
|
||||
|
||||
nMsgDialog->show();
|
||||
nMsgDialog->activateWindow();
|
||||
|
||||
/* window will destroy itself! */
|
||||
}
|
||||
|
||||
void MessagesDialog::forwardmessage()
|
||||
@ -458,6 +462,8 @@ void MessagesDialog::forwardmessage()
|
||||
//nMsgDialog->addRecipient( msgInfo.srcId ) ;
|
||||
nMsgDialog->show();
|
||||
nMsgDialog->activateWindow();
|
||||
|
||||
/* window will destroy itself! */
|
||||
}
|
||||
|
||||
void MessagesDialog::togglefileview()
|
||||
|
@ -23,7 +23,6 @@
|
||||
#include "MessagesPopupDialog.h"
|
||||
#include "MessagesDialog.h"
|
||||
|
||||
#include "msgs/ChanMsgDialog.h"
|
||||
#include "util/printpreview.h"
|
||||
|
||||
#include "rsiface/rsiface.h"
|
||||
|
@ -97,7 +97,7 @@ void MessengerWindow::releaseInstance()
|
||||
|
||||
/** Constructor */
|
||||
MessengerWindow::MessengerWindow(QWidget* parent, Qt::WFlags flags)
|
||||
: maxTimeBeforeIdle(30), RWindow("MessengerWindow", parent, flags)
|
||||
: RWindow("MessengerWindow", parent, flags), maxTimeBeforeIdle(30)
|
||||
{
|
||||
/* Invoke the Qt Designer generated object setup routine */
|
||||
ui.setupUi(this);
|
||||
@ -572,12 +572,9 @@ std::string getPeersRsCertId(QTreeWidgetItem *i)
|
||||
/** Add a Friend ShortCut */
|
||||
void MessengerWindow::addFriend()
|
||||
{
|
||||
ConnectFriendWizard* connwiz = new ConnectFriendWizard(this);
|
||||
// set widget to be deleted after close
|
||||
connwiz->setAttribute( Qt::WA_DeleteOnClose, true);
|
||||
|
||||
connwiz->show();
|
||||
ConnectFriendWizard connwiz (this);
|
||||
|
||||
connwiz.exec ();
|
||||
}
|
||||
|
||||
/** Open a QFileDialog to browse for export a file. */
|
||||
@ -808,7 +805,7 @@ void MessengerWindow::show()
|
||||
QWidget::show();
|
||||
} else {
|
||||
QWidget::activateWindow();
|
||||
setWindowState(windowState() & ~Qt::WindowMinimized | Qt::WindowActive);
|
||||
setWindowState((windowState() & ~Qt::WindowMinimized) | Qt::WindowActive);
|
||||
QWidget::raise();
|
||||
}
|
||||
}
|
||||
@ -858,6 +855,8 @@ void MessengerWindow::sendMessage()
|
||||
|
||||
nMsgDialog->newMsg();
|
||||
nMsgDialog->show();
|
||||
|
||||
/* window will destroy itself! */
|
||||
}
|
||||
|
||||
LogoBar & MessengerWindow::getLogoBar() const {
|
||||
@ -1058,10 +1057,10 @@ void MessengerWindow::savestatus()
|
||||
|
||||
void MessengerWindow::checkAndSetIdle(int idleTime){
|
||||
|
||||
if((idleTime >= maxTimeBeforeIdle) && !isIdle){
|
||||
if((idleTime >= (int) maxTimeBeforeIdle) && !isIdle){
|
||||
setIdle(true);
|
||||
}else
|
||||
if((idleTime < maxTimeBeforeIdle) && isIdle){
|
||||
if((idleTime < (int) maxTimeBeforeIdle) && isIdle){
|
||||
setIdle(false);
|
||||
}
|
||||
|
||||
|
@ -44,6 +44,8 @@
|
||||
#include "gui/forums/CreateForum.h"
|
||||
#include "gui/channels/CreateChannel.h"
|
||||
|
||||
#include "MainWindow.h"
|
||||
|
||||
#include <sstream>
|
||||
#include <time.h>
|
||||
#include <sys/stat.h>
|
||||
@ -391,7 +393,7 @@ void PeersDialog::insertPeers()
|
||||
}
|
||||
}
|
||||
if (!found) {
|
||||
peertreeWidget->takeTopLevelItem(index);
|
||||
delete (peertreeWidget->takeTopLevelItem(index));
|
||||
} else {
|
||||
index++;
|
||||
}
|
||||
@ -418,7 +420,7 @@ void PeersDialog::insertPeers()
|
||||
if ((!rsPeers->getPeerDetails(*it, detail) || !detail.accept_connection)
|
||||
&& detail.gpg_id != rsPeers->getGPGOwnId()) {
|
||||
//don't accept anymore connection, remove from the view
|
||||
peertreeWidget->takeTopLevelItem(peertreeWidget->indexOfTopLevelItem(gpg_item));
|
||||
delete (peertreeWidget->takeTopLevelItem(peertreeWidget->indexOfTopLevelItem(gpg_item)));
|
||||
continue;
|
||||
}
|
||||
|
||||
@ -438,7 +440,7 @@ void PeersDialog::insertPeers()
|
||||
while (childIndex < gpg_item->childCount()) {
|
||||
std::string ssl_id = (gpg_item->child(childIndex))->text(3).toStdString();
|
||||
if (!rsPeers->isFriend(ssl_id)) {
|
||||
gpg_item->takeChild(childIndex);
|
||||
delete (gpg_item->takeChild(childIndex));
|
||||
} else {
|
||||
childIndex++;
|
||||
}
|
||||
@ -706,6 +708,8 @@ void PeersDialog::msgfriend()
|
||||
|
||||
nMsgDialog->newMsg();
|
||||
nMsgDialog->show();
|
||||
|
||||
/* window will destroy itself! */
|
||||
}
|
||||
|
||||
|
||||
@ -1531,38 +1535,36 @@ void PeersDialog::changeAvatarClicked()
|
||||
|
||||
void PeersDialog::on_actionAdd_Friend_activated()
|
||||
{
|
||||
ConnectFriendWizard* connectwiz = new ConnectFriendWizard(this);
|
||||
ConnectFriendWizard connectwiz (this);
|
||||
|
||||
// set widget to be deleted after close
|
||||
connectwiz->setAttribute( Qt::WA_DeleteOnClose, true);
|
||||
|
||||
|
||||
connectwiz->show();
|
||||
connectwiz.exec ();
|
||||
}
|
||||
|
||||
void PeersDialog::on_actionCreate_New_Forum_activated()
|
||||
{
|
||||
((MainPageStack*)this->parent())->setCurrentIndex(8); // swtich to forum view
|
||||
static CreateForum *cf = new CreateForum(this);
|
||||
cf->show();
|
||||
MainWindow::activatePage (MainWindow::Forums);
|
||||
|
||||
CreateForum cf (this);
|
||||
cf.exec();
|
||||
|
||||
}
|
||||
|
||||
void PeersDialog::on_actionCreate_New_Channel_activated()
|
||||
{
|
||||
#ifndef RS_RELEASE_VERSION
|
||||
MainWindow::activatePage (MainWindow::Channels);
|
||||
|
||||
CreateChannel *cf = new CreateChannel(NULL);
|
||||
((MainPageStack*)this->parent())->setCurrentIndex(6); // swtich to forum view
|
||||
|
||||
cf->setWindowTitle(tr("Create a new Channel"));
|
||||
cf->ui.labelicon->setPixmap(QPixmap(":/images/add_channel64.png"));
|
||||
CreateChannel cf (this);
|
||||
cf.setWindowTitle(tr("Create a new Channel"));
|
||||
cf.ui.labelicon->setPixmap(QPixmap(":/images/add_channel64.png"));
|
||||
QString titleStr("<span style=\"font-size:24pt; font-weight:500;"
|
||||
"color:#32CD32;\">%1</span>");
|
||||
cf->ui.textlabelcreatforums->setText( titleStr.arg( tr("New Channel") ) ) ;
|
||||
cf->show();
|
||||
|
||||
cf.ui.textlabelcreatforums->setText( titleStr.arg( tr("New Channel") ) ) ;
|
||||
cf.exec();
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
/** Loads own personal status */
|
||||
void PeersDialog::loadmypersonalstatus()
|
||||
{
|
||||
@ -1572,8 +1574,8 @@ void PeersDialog::loadmypersonalstatus()
|
||||
|
||||
void PeersDialog::statusmessage()
|
||||
{
|
||||
static StatusMessage *statusmsgdialog = new StatusMessage();
|
||||
statusmsgdialog->show();
|
||||
StatusMessage statusmsgdialog (this);
|
||||
statusmsgdialog.exec();
|
||||
}
|
||||
|
||||
void PeersDialog::addExtraFile()
|
||||
|
@ -1218,6 +1218,8 @@ void SearchDialog::sendLinkTo( )
|
||||
|
||||
nMsgDialog->insertMsgText(RSLinkClipboard::toHtml().toStdString()) ;
|
||||
nMsgDialog->show();
|
||||
|
||||
/* window will destroy itself! */
|
||||
}
|
||||
|
||||
void SearchDialog::togglereset()
|
||||
|
@ -349,6 +349,8 @@ void SharedFilesDialog::sendremoteLinkTo()
|
||||
nMsgDialog->insertMsgText(RSLinkClipboard::toHtml().toStdString());
|
||||
|
||||
nMsgDialog->show();
|
||||
|
||||
/* window will destroy itself! */
|
||||
}
|
||||
|
||||
void SharedFilesDialog::sendLinkTo()
|
||||
@ -370,6 +372,8 @@ void SharedFilesDialog::sendLinkTo()
|
||||
nMsgDialog->insertMsgText(RSLinkClipboard::toHtml().toStdString());
|
||||
|
||||
nMsgDialog->show();
|
||||
|
||||
/* window will destroy itself! */
|
||||
}
|
||||
|
||||
void SharedFilesDialog::sendHtmlLinkTo( )
|
||||
@ -390,6 +394,8 @@ void SharedFilesDialog::sendHtmlLinkTo( )
|
||||
nMsgDialog->insertMsgText(RSLinkClipboard::toHtml().toStdString());
|
||||
|
||||
nMsgDialog->show();
|
||||
|
||||
/* window will destroy itself! */
|
||||
}
|
||||
|
||||
//void SharedFilesDialog::sendLinktoChat()
|
||||
@ -525,6 +531,8 @@ void SharedFilesDialog::recommendFilesTo( std::string rsid )
|
||||
|
||||
nMsgDialog->sendMessage();
|
||||
nMsgDialog->close();
|
||||
|
||||
/* window will destroy itself! */
|
||||
}
|
||||
|
||||
void SharedFilesDialog::recommendFilesToMsg( std::string rsid )
|
||||
@ -548,6 +556,8 @@ void SharedFilesDialog::recommendFilesToMsg( std::string rsid )
|
||||
|
||||
std::cout << "recommending to " << rsid << std::endl ;
|
||||
nMsgDialog->addRecipient(rsid) ;
|
||||
|
||||
/* window will destroy itself! */
|
||||
}
|
||||
|
||||
//#endif
|
||||
|
@ -7,12 +7,7 @@
|
||||
#include <rsiface/rsturtle.h>
|
||||
#endif
|
||||
|
||||
#include "gui/NetworkDialog.h"
|
||||
#include "gui/PeersDialog.h"
|
||||
#include "gui/SharedFilesDialog.h"
|
||||
#include "gui/TransfersDialog.h"
|
||||
#include "gui/MessagesDialog.h"
|
||||
#include "gui/MessengerWindow.h"
|
||||
#include "gui/RsAutoUpdatePage.h"
|
||||
|
||||
#include "gui/toaster/OnlineToaster.h"
|
||||
#include "gui/toaster/MessageToaster.h"
|
||||
|
@ -122,7 +122,7 @@ int main(int argc, char *argv[])
|
||||
|
||||
rsicontrol->StartupRetroShare();
|
||||
|
||||
MainWindow *w = new MainWindow;
|
||||
MainWindow *w = MainWindow::Create ();
|
||||
|
||||
// I'm using a signal to transfer the hashing info to the mainwindow, because Qt schedules signals properly to
|
||||
// avoid clashes between infos from threads.
|
||||
|
Loading…
Reference in New Issue
Block a user