void DockableTabWidget::showPopupMenu( const QPoint& pos ) { uint tabsCount = count(); if ( tabsCount < 2 ) { // there's no point in splitting the window if it's just got one tab in it return; } QPoint globalClickPos = mapToGlobal( pos ); // show the pop-up only if you click a tab, and not the window contents { QWidget* w = widget(0); QPoint posInTab = w->mapFromGlobal( globalClickPos ); if ( posInTab.y() >= 0 ) { // it's already in the tab contents area - don't show the menu return; } } // create the menu QMenu* popupMenu = new QMenu( this ); { QAction* undockAction = new QAction( "Undock", this ); connect( undockAction, SIGNAL( triggered() ), this, SLOT( undockTab() ) ); popupMenu->addAction( undockAction ); } // display the menu popupMenu->popup( globalClickPos ); }
/** Default constructor */ PopupChatWindow::PopupChatWindow(bool tabbed, QWidget *parent, Qt::WFlags flags) : QMainWindow(parent, flags) { /* Invoke Qt Designer generated QObject setup routine */ ui.setupUi(this); tabbedWindow = tabbed; firstShow = true; chatDialog = NULL; ui.tabWidget->setVisible(tabbedWindow); if (Settings->getChatFlags() & RS_CHAT_TABBED_WINDOW) { ui.actionDockTab->setVisible(tabbedWindow == false); ui.actionUndockTab->setVisible(tabbedWindow); } else { ui.actionDockTab->setVisible(false); ui.actionUndockTab->setVisible(false); } setAttribute(Qt::WA_DeleteOnClose, true); connect(ui.actionAvatar, SIGNAL(triggered()),this, SLOT(getAvatar())); connect(ui.actionDockTab, SIGNAL(triggered()), this, SLOT(dockTab())); connect(ui.actionUndockTab, SIGNAL(triggered()), this, SLOT(undockTab())); connect(ui.tabWidget, SIGNAL(tabCloseRequested(int)), this, SLOT(tabCloseRequested(int))); connect(ui.tabWidget, SIGNAL(currentChanged(int)), this, SLOT(tabCurrentChanged(int))); setWindowIcon(QIcon(IMAGE_WINDOW)); }
/** Default constructor */ PopupChatWindow::PopupChatWindow(bool tabbed, QWidget *parent, Qt::WFlags flags) : QMainWindow(parent, flags) { /* Invoke Qt Designer generated QObject setup routine */ ui.setupUi(this); tabbedWindow = tabbed; firstShow = true; chatDialog = NULL; mEmptyIcon = NULL; ui.tabWidget->setVisible(tabbedWindow); if (Settings->getChatFlags() & RS_CHAT_TABBED_WINDOW) { ui.actionDockTab->setVisible(tabbedWindow == false); ui.actionUndockTab->setVisible(tabbedWindow); } else { ui.actionDockTab->setVisible(false); ui.actionUndockTab->setVisible(false); } setAttribute(Qt::WA_DeleteOnClose, true); connect(ui.actionAvatar, SIGNAL(triggered()),this, SLOT(getAvatar())); connect(ui.actionColor, SIGNAL(triggered()), this, SLOT(setStyle())); connect(ui.actionDockTab, SIGNAL(triggered()), this, SLOT(dockTab())); connect(ui.actionUndockTab, SIGNAL(triggered()), this, SLOT(undockTab())); connect(ui.actionSetOnTop, SIGNAL(toggled(bool)), this, SLOT(setOnTop())); connect(ui.tabWidget, SIGNAL(tabChanged(ChatDialog*)), this, SLOT(tabChanged(ChatDialog*))); connect(ui.tabWidget, SIGNAL(tabClosed(ChatDialog*)), this, SLOT(tabClosed(ChatDialog*))); connect(rApp, SIGNAL(blink(bool)), this, SLOT(blink(bool))); if (tabbedWindow) { /* signal toggled is called */ ui.actionSetOnTop->setChecked(Settings->valueFromGroup("ChatWindow", "OnTop", false).toBool()); } setWindowIcon(QIcon(IMAGE_WINDOW)); }