From 3baae3a6024313c2721fa456c842a8a82c2042e0 Mon Sep 17 00:00:00 2001 From: thunder2 Date: Sun, 18 Jul 2010 21:28:56 +0000 Subject: [PATCH] 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 --- retroshare-gui/src/gui/MainWindow.cpp | 30 +++++++++++++++++++++++++-- retroshare-gui/src/gui/MainWindow.h | 2 ++ 2 files changed, 30 insertions(+), 2 deletions(-) diff --git a/retroshare-gui/src/gui/MainWindow.cpp b/retroshare-gui/src/gui/MainWindow.cpp index 3f2d40599..3a9c573a6 100644 --- a/retroshare-gui/src/gui/MainWindow.cpp +++ b/retroshare-gui/src/gui/MainWindow.cpp @@ -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()); +} diff --git a/retroshare-gui/src/gui/MainWindow.h b/retroshare-gui/src/gui/MainWindow.h index a1ef95b02..1fe082815 100644 --- a/retroshare-gui/src/gui/MainWindow.h +++ b/retroshare-gui/src/gui/MainWindow.h @@ -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 ;