added status combobox to statusbar in MainWindow (initial code from defnax)

git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@3305 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
thunder2 2010-07-18 21:28:56 +00:00
parent 0049549eb7
commit 3baae3a602
2 changed files with 30 additions and 2 deletions

View File

@ -239,7 +239,7 @@ MainWindow::MainWindow(QWidget* parent, Qt::WFlags flags)
connect(grp, SIGNAL(triggered(QAction *)), ui.stackPages, SLOT(showPage(QAction *)));
#ifdef UNFINISHED
#ifdef UNFINISHED
ui.toolBar->addSeparator();
addAction(new QAction(QIcon(IMAGE_UNFINISHED), tr("Unfinished"), ui.toolBar), SLOT(showApplWindow()));
#endif
@ -248,13 +248,26 @@ MainWindow::MainWindow(QWidget* parent, Qt::WFlags flags)
grp->actions()[0]->setChecked(true);
/** StatusBar section ********/
/* initialize combobox in status bar */
statusComboBox = new QComboBox(statusBar());
initializeStatusObject(statusComboBox);
connect(statusComboBox, SIGNAL(activated(int)), this, SLOT(statusChangedComboBox(int)));
QWidget *widget = new QWidget();
QHBoxLayout *hbox = new QHBoxLayout();
hbox->setMargin(0);
hbox->setSpacing(6);
hbox->addWidget(statusComboBox);
widget->setLayout(hbox);
statusBar()->addWidget(widget);
peerstatus = new PeerStatus();
statusBar()->addWidget(peerstatus);
natstatus = new NATStatus();
statusBar()->addWidget(natstatus);
QWidget *widget = new QWidget();
widget = new QWidget();
QSizePolicy sizePolicy(QSizePolicy::Maximum, QSizePolicy::Preferred);
sizePolicy.setHorizontalStretch(0);
sizePolicy.setVerticalStretch(0);
@ -284,6 +297,9 @@ MainWindow::MainWindow(QWidget* parent, Qt::WFlags flags)
loadOwnStatus(); // hack; placed in constructor to preempt sendstatus, so status loaded from file
/* Set focus to the current page */
ui.stackPages->currentWidget()->setFocus();
idle = new Idle();
idle->start();
connect(idle, SIGNAL(secondsIdle(int)), this, SLOT(checkAndSetIdle(int)));
@ -993,3 +1009,13 @@ void MainWindow::statusChanged(QAction *pAction)
setStatus(pAction->parent(), pAction->data().toInt());
}
/* new status from combobox in statusbar */
void MainWindow::statusChangedComboBox(int index)
{
if (index < 0) {
return;
}
setStatus(statusComboBox, statusComboBox->itemData(index, Qt::UserRole).toInt());
}

View File

@ -182,6 +182,7 @@ private slots:
void showSettings();
void setStyle();
void statusChanged(QAction *pAction);
void statusChangedComboBox(int index);
/** Called when user attempts to quit via quit button*/
void doQuit();
@ -226,6 +227,7 @@ private:
PeerStatus *peerstatus;
NATStatus *natstatus;
RatesStatus *ratesstatus;
QComboBox *statusComboBox;
QLabel *_hashing_info_label ;