commit e1bf0c68995ab39d9ea89c5dc6b8031409948388 Author: Tomas Touceda chiiph@gentoo.org Date: Tue May 24 14:44:23 2011 -0300
Add a menu to reattach tabs and fix a wrong disconnect
This menu should work in every platform, it's the basic idea implementation. From here, drag and drop for the each tab is a better idea from the usability point of view, but it needs to be done with testing in each platform. --- src/vidalia/MainWindow.cpp | 30 ++++++++++++++++++++++++++++++ src/vidalia/MainWindow.h | 3 +++ src/vidalia/VAttachButton.cpp | 2 +- 3 files changed, 34 insertions(+), 1 deletions(-)
diff --git a/src/vidalia/MainWindow.cpp b/src/vidalia/MainWindow.cpp index 6e16ee4..6ee1883 100644 --- a/src/vidalia/MainWindow.cpp +++ b/src/vidalia/MainWindow.cpp @@ -106,6 +106,8 @@ MainWindow::MainWindow()
_engine = new PluginEngine();
+ _dummy = new QAction(tr("No dettached tabs"), this); + createGUI(); createConnections();
@@ -164,6 +166,8 @@ MainWindow::createActions() void MainWindow::createMenuBar() { + _reattachMenu.setTitle(tr("Reattach tabs")); + QMenuBar *menu = menuBar(); menu->clear();
@@ -192,6 +196,11 @@ MainWindow::createMenuBar() pluginsMenu->addSeparator(); pluginsMenu->addAction(_actionDebugDialog);
+ menu->addMenu(&_reattachMenu); + _dummy->setText(tr("No detached tabs")); + _reattachMenu.addAction(_dummy); + _dummy->setEnabled(false); + QMenu *helpMenu = menu->addMenu(tr("Help")); helpMenu->addAction(_actionVidaliaHelp); helpMenu->addSeparator(); @@ -225,6 +234,8 @@ MainWindow::createTrayMenu() menu->addAction(_actionNewIdentity); menu->addSeparator(); menu->addAction(_actionShowControlPanel); + + menu->addMenu(&_reattachMenu);
#if !defined(Q_WS_MAC) /* These aren't added to the dock menu on Mac, since they are in the @@ -1503,6 +1514,17 @@ void MainWindow::attachTab() { qWarning() << "ATTACHHHHHHHHHH"; + QAction *act = qobject_cast<QAction *>(sender()); + VidaliaTab *tab = qobject_cast<VidaliaTab *>(act->parent()); + qWarning() << tab; + _detachedTabMap.removeAll(tab->getTitle()); + tab->setParent(ui.tabWidget); + addTab(tab); + _reattachMenu.removeAction(act); + if(_reattachMenu.actions().size() < 1) { + _reattachMenu.addAction(_dummy); + _dummy->setEnabled(false); + } }
void @@ -1519,6 +1541,11 @@ MainWindow::detachTab() QString key = _tabMap.at(index); _tabMap.removeAll(key); _detachedTabMap << key; + + QAction *act = new QAction(tab->getTitle(), tab); + connect(act, SIGNAL(triggered()), this, SLOT(attachTab())); + _reattachMenu.addAction(act); + _reattachMenu.removeAction(_dummy); }
void @@ -1530,6 +1557,9 @@ MainWindow::handleAttachedClose() if(index < 0) { qWarning() << "DETACHEEEEDDDDDDDDDDDDD"; tab->setParent(ui.tabWidget); + + _detachedTabMap.removeAll(tab->getTitle()); + addTab(tab); delTab(ui.tabWidget->currentIndex()); } else { diff --git a/src/vidalia/MainWindow.h b/src/vidalia/MainWindow.h index 722a217..b7874fd 100644 --- a/src/vidalia/MainWindow.h +++ b/src/vidalia/MainWindow.h @@ -284,6 +284,9 @@ private: QAction *_actionExit; QAction *_actionDebugDialog;
+ QMenu _reattachMenu; + QAction *_dummy; + Ui::MainWindow ui; /**< Qt Designer generated object. */
StatusTab _statusTab; /**< Status tab that displays the load progress and a short log */ diff --git a/src/vidalia/VAttachButton.cpp b/src/vidalia/VAttachButton.cpp index 42a4b3e..fa51b0d 100644 --- a/src/vidalia/VAttachButton.cpp +++ b/src/vidalia/VAttachButton.cpp @@ -10,7 +10,7 @@ VAttachButton::VAttachButton(QWidget *parent) :
VAttachButton::~VAttachButton() { - disconnect(0,0,0,0); + disconnect(this,0,0,0); }
void