medViewContainer::medViewContainer(medViewContainerSplitter *parent): QFrame(parent), d(new medViewContainerPrivate) { d->parent = parent; d->uuid = QUuid::createUuid(); medViewContainerManager::instance()->registerNewContainer(this); d->view = NULL; d->viewToolbar = NULL; d->defaultWidget = new QWidget; d->defaultWidget->setObjectName("defaultWidget"); QLabel *defaultLabel = new QLabel(tr("Drag'n drop series here from the left panel or")); QPushButton *openButton= new QPushButton(tr("open a file from your system")); QVBoxLayout *defaultLayout = new QVBoxLayout(d->defaultWidget); defaultLayout->addWidget(defaultLabel); defaultLayout->addWidget(openButton); connect(openButton, SIGNAL(clicked()), this, SLOT(openFromSystem())); d->menuButton = new QPushButton(this); d->menuButton->setIcon(QIcon(":/pixmaps/tools.png")); d->menuButton->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Fixed); d->menuButton->setToolTip(tr("Tools")); d->toolBarMenu = new QMenu(this); connect(d->menuButton, SIGNAL(clicked()), this, SLOT(popupMenu())); d->openAction = new QAction(tr("Open"), d->toolBarMenu); d->openAction->setIcon(QIcon(":/pixmaps/open.png")); d->openAction->setToolTip(tr("Open a file from your system")); d->openAction->setIconVisibleInMenu(true); connect(d->openAction, SIGNAL(triggered()), this, SLOT(openFromSystem())); d->closeContainerButton = new QPushButton(this); d->closeContainerButton->setIcon(QIcon(":/pixmaps/closebutton.png")); d->closeContainerButton->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Fixed); d->closeContainerButton->setToolTip(tr("Close")); d->closeContainerButton->setFocusPolicy(Qt::NoFocus); d->vSplitAction = new QAction(tr("V split"), d->toolBarMenu); d->vSplitAction->setIcon(QIcon(":/pixmaps/splitbutton_vertical.png")); d->vSplitAction->setToolTip(tr("Split vertically")); d->vSplitAction->setIconVisibleInMenu(true); connect(d->vSplitAction, SIGNAL(triggered()), this, SIGNAL(vSplitRequest())); d->hSplitAction = new QAction(tr("H split"), d->toolBarMenu); d->hSplitAction->setIcon(QIcon(":/pixmaps/splitbutton_horizontal.png")); d->hSplitAction->setToolTip(tr("Split horizontally")); d->hSplitAction->setIconVisibleInMenu(true); connect(d->hSplitAction, SIGNAL(triggered()), this, SIGNAL(hSplitRequest())); // make it a parameter to get synch between state of the container and the maximized button. d->maximizedAction = new QAction(tr("Maximized"), d->toolBarMenu); d->maximizedAction->setToolTip("Toggle maximized / unmaximized"); d->maximizedAction->setCheckable(true); QIcon maximizedIcon(":/icons/maximize.svg"); maximizedIcon.addFile(":/icons/un_maximize.svg", QSize(16,16), QIcon::Normal, QIcon::On); d->maximizedAction->setIcon(maximizedIcon); d->maximizedAction->setIconVisibleInMenu(true); d->maximized = false; connect(d->maximizedAction, SIGNAL(triggered()), this, SLOT(toggleMaximized())); d->maximizedAction->setEnabled(false); d->toolBarMenu = new QMenu(this); d->toolBarMenu->addActions(QList<QAction*>() << d->openAction); d->toolBarMenu->addSeparator(); d->toolBarMenu->addActions(QList<QAction*>() << d->vSplitAction << d->hSplitAction); d->toolBarMenu->addSeparator(); d->toolBarMenu->addActions(QList<QAction*>() << d->maximizedAction); d->poolIndicator = new medPoolIndicator; QWidget* toolBar = new QWidget(this); toolBar->setObjectName("containerToolBar"); toolBar->setSizePolicy(QSizePolicy::Ignored, QSizePolicy::Fixed); d->toolBarLayout = new QHBoxLayout(toolBar); d->toolBarLayout->setContentsMargins(0, 0, 0, 0); d->toolBarLayout->setSpacing(2); QWidget *viewToolbarContainer = new QWidget(this); viewToolbarContainer->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Fixed); d->viewToolbarContainerLayout = new QHBoxLayout(viewToolbarContainer); d->viewToolbarContainerLayout->setContentsMargins(2, 0, 2, 0); d->viewToolbarContainerLayout->setSpacing(2); QWidget *containerToolbar = new QWidget(this); containerToolbar->setSizePolicy(QSizePolicy::Maximum, QSizePolicy::Fixed); QHBoxLayout *containerToolbarLayout = new QHBoxLayout(containerToolbar); containerToolbarLayout->setContentsMargins(2, 0, 2, 0); containerToolbarLayout->setSpacing(2); containerToolbarLayout->addWidget(d->poolIndicator); containerToolbarLayout->addWidget(d->menuButton); containerToolbarLayout->addWidget(d->closeContainerButton); d->toolBarLayout->addWidget(viewToolbarContainer); d->toolBarLayout->addWidget(containerToolbar,0,Qt::AlignRight); d->mainLayout = new QGridLayout(this); d->mainLayout->setContentsMargins(0, 0, 0, 0); d->mainLayout->setSpacing(0); d->mainLayout->addWidget(toolBar, 0, 0, Qt::AlignTop); d->mainLayout->addWidget(d->defaultWidget, 0, 0, 0, 0, Qt::AlignCenter); this->setAcceptDrops(true); this->setUserSplittable(true); this->setClosingMode(medViewContainer::CLOSE_CONTAINER); this->setMultiLayered(true); this->setFocusPolicy(Qt::ClickFocus); this->setMouseTracking(true); this->setUserOpenable(true); d->selected = false; this->setSelected(false); d->defaultStyleSheet = this->styleSheet(); }
void CMapWidget::showContextMenu(Q3PopupMenu *menu) { CMapView *view = mapManager->getActiveView(); CMapElement *el = view->getSelectedElement(); popupMenu(el, menu, selectedPos); }
void GameWidget::onMouseLongPress(QPoint point, QSize size) { emit popupMenu(); }
void OutputPaneManager::init() { ActionContainer *mwindow = ActionManager::actionContainer(Constants::M_WINDOW); const Context globalContext(Constants::C_GLOBAL); // Window->Output Panes ActionContainer *mpanes = ActionManager::createMenu(Constants::M_WINDOW_PANES); mwindow->addMenu(mpanes, Constants::G_WINDOW_PANES); mpanes->menu()->setTitle(tr("Output &Panes")); mpanes->appendGroup("Coreplugin.OutputPane.ActionsGroup"); mpanes->appendGroup("Coreplugin.OutputPane.PanesGroup"); Command *cmd; cmd = ActionManager::registerAction(m_clearAction, "Coreplugin.OutputPane.clear", globalContext); m_clearButton->setDefaultAction(cmd->action()); mpanes->addAction(cmd, "Coreplugin.OutputPane.ActionsGroup"); cmd = ActionManager::registerAction(m_prevAction, "Coreplugin.OutputPane.previtem", globalContext); cmd->setDefaultKeySequence(QKeySequence(tr("Shift+F6"))); m_prevToolButton->setDefaultAction(cmd->action()); mpanes->addAction(cmd, "Coreplugin.OutputPane.ActionsGroup"); cmd = ActionManager::registerAction(m_nextAction, "Coreplugin.OutputPane.nextitem", globalContext); m_nextToolButton->setDefaultAction(cmd->action()); cmd->setDefaultKeySequence(QKeySequence(tr("F6"))); mpanes->addAction(cmd, "Coreplugin.OutputPane.ActionsGroup"); cmd = ActionManager::registerAction(m_minMaxAction, "Coreplugin.OutputPane.minmax", globalContext); cmd->setDefaultKeySequence(QKeySequence(UseMacShortcuts ? tr("Ctrl+9") : tr("Alt+9"))); cmd->setAttribute(Command::CA_UpdateText); cmd->setAttribute(Command::CA_UpdateIcon); mpanes->addAction(cmd, "Coreplugin.OutputPane.ActionsGroup"); connect(m_minMaxAction, SIGNAL(triggered()), this, SLOT(slotMinMax())); m_minMaxButton->setDefaultAction(cmd->action()); mpanes->addSeparator(globalContext, "Coreplugin.OutputPane.ActionsGroup"); QFontMetrics titleFm = m_titleLabel->fontMetrics(); int minTitleWidth = 0; m_panes = ExtensionSystem::PluginManager::getObjects<IOutputPane>(); qSort(m_panes.begin(), m_panes.end(), &comparePanes); const int n = m_panes.size(); int shortcutNumber = 1; const Id baseId = "QtCreator.Pane."; for (int i = 0; i != n; ++i) { IOutputPane *outPane = m_panes.at(i); const int idx = m_outputWidgetPane->addWidget(outPane->outputWidget(this)); QTC_CHECK(idx == i); connect(outPane, SIGNAL(showPage(int)), this, SLOT(showPage(int))); connect(outPane, SIGNAL(hidePage()), this, SLOT(slotHide())); connect(outPane, SIGNAL(togglePage(int)), this, SLOT(togglePage(int))); connect(outPane, SIGNAL(navigateStateUpdate()), this, SLOT(updateNavigateState())); connect(outPane, SIGNAL(flashButton()), this, SLOT(flashButton())); connect(outPane, SIGNAL(setBadgeNumber(int)), this, SLOT(setBadgeNumber(int))); QWidget *toolButtonsContainer = new QWidget(m_opToolBarWidgets); QHBoxLayout *toolButtonsLayout = new QHBoxLayout; toolButtonsLayout->setMargin(0); toolButtonsLayout->setSpacing(0); foreach (QWidget *toolButton, outPane->toolBarWidgets()) toolButtonsLayout->addWidget(toolButton); toolButtonsLayout->addStretch(5); toolButtonsContainer->setLayout(toolButtonsLayout); m_opToolBarWidgets->addWidget(toolButtonsContainer); minTitleWidth = qMax(minTitleWidth, titleFm.width(outPane->displayName())); QString suffix = outPane->displayName().simplified(); suffix.remove(QLatin1Char(' ')); const Id id = baseId.withSuffix(suffix); QAction *action = new QAction(outPane->displayName(), this); Command *cmd = ActionManager::registerAction(action, id, globalContext); mpanes->addAction(cmd, "Coreplugin.OutputPane.PanesGroup"); m_actions.append(action); m_ids.append(id); cmd->setDefaultKeySequence(QKeySequence(paneShortCut(shortcutNumber))); OutputPaneToggleButton *button = new OutputPaneToggleButton(shortcutNumber, outPane->displayName(), cmd->action()); ++shortcutNumber; m_buttonsWidget->layout()->addWidget(button); m_buttons.append(button); connect(button, SIGNAL(clicked()), this, SLOT(buttonTriggered())); bool visible = outPane->priorityInStatusBar() != -1; button->setVisible(visible); connect(action, SIGNAL(triggered()), this, SLOT(shortcutTriggered())); } m_titleLabel->setMinimumWidth(minTitleWidth + m_titleLabel->contentsMargins().left() + m_titleLabel->contentsMargins().right()); m_buttonsWidget->layout()->addWidget(m_manageButton); connect(m_manageButton, SIGNAL(clicked()), this, SLOT(popupMenu())); readSettings(); }
SelectFrameAction::SelectFrameAction(const QString &text, QToolBar *parent) : KToolBarPopupAction(KIcon(), text, parent), m_Parent(parent), m_CurrentBorder(TabularCell::None) { setIcon(generateIcon()); QWidget *page = new QWidget(parent); QVBoxLayout *layout = new QVBoxLayout(); layout->setMargin(0); layout->setSpacing(0); page->setLayout(layout); QWidget *buttonBox = new QWidget(page); QHBoxLayout *buttonBoxLayout = new QHBoxLayout(); buttonBoxLayout->setMargin(0); buttonBoxLayout->setSpacing(KDialog::spacingHint()); buttonBox->setLayout(buttonBoxLayout); m_pbNone = new QToolButton(buttonBox); m_pbLeftRight = new QToolButton(buttonBox); m_pbTopBottom = new QToolButton(buttonBox); m_pbAll = new QToolButton(buttonBox); m_pbNone->setIcon(QIcon(QPixmap(const_cast<const char**>(no_border_xpm)))); m_pbLeftRight->setIcon(QIcon(QPixmap(const_cast<const char**>(lr_border_xpm)))); m_pbTopBottom->setIcon(QIcon(QPixmap(const_cast<const char**>(tb_border_xpm)))); m_pbAll->setIcon(QIcon(QPixmap(const_cast<const char**>(all_border_xpm)))); buttonBoxLayout->addStretch(); buttonBoxLayout->addWidget(m_pbNone); buttonBoxLayout->addWidget(m_pbLeftRight); buttonBoxLayout->addWidget(m_pbTopBottom); buttonBoxLayout->addWidget(m_pbAll); buttonBoxLayout->addStretch(); QWidget *frameWidget = new QWidget(page); QHBoxLayout *frameWidgetLayout = new QHBoxLayout(); frameWidgetLayout->setMargin(0); frameWidgetLayout->setSpacing(KDialog::spacingHint()); frameWidget->setLayout(frameWidgetLayout); m_FrameWidget = new TabularFrameWidget(frameWidget); frameWidgetLayout->addStretch(); frameWidgetLayout->addWidget(m_FrameWidget); frameWidgetLayout->addStretch(); m_pbDone = new KPushButton(KIcon("dialog-ok-apply"), i18n("Apply"), page); layout->addWidget(buttonBox); layout->addWidget(frameWidget); layout->addWidget(m_pbDone); QWidgetAction *widgetAction = new QWidgetAction(this); widgetAction->setDefaultWidget(page); popupMenu()->addAction(widgetAction); connect(this, SIGNAL(triggered(bool)), this, SLOT(slotTriggered())); connect(m_pbNone, SIGNAL(clicked()), this, SLOT(slotNoneClicked())); connect(m_pbLeftRight, SIGNAL(clicked()), this, SLOT(slotLeftRightClicked())); connect(m_pbTopBottom, SIGNAL(clicked()), this, SLOT(slotTopBottomClicked())); connect(m_pbAll, SIGNAL(clicked()), this, SLOT(slotAllClicked())); connect(m_pbDone, SIGNAL(clicked()), this, SLOT(slotDoneClicked())); }
void KTagComboBox::mousePressEvent( QMouseEvent * ) { popupMenu(); }
Korn::Korn(QWidget *parent, KornSettings *settings, WFlags f) : QFrame(parent, "korn", f) { int count=0; KornButton *button; QBoxLayout::Direction dir= QBoxLayout::TopToBottom; _optionsDialog = 0; _noConfig = false; // popup menu menu = new QPopupMenu(); menu->insertItem(i18n("&Setup"), this, SLOT( optionDlg() )); menu->insertSeparator(); menu->insertItem(i18n("&Help"), this, SLOT( help() )); menu->insertItem(i18n("&About"), this, SLOT( about() )); menu->insertSeparator(); menu->insertItem(i18n("E&xit"), qApp, SLOT( quit() )); // widget decorations if(settings->layout() == KornSettings::horizontal ) dir = QBoxLayout::LeftToRight; QBoxLayout *layout = new QBoxLayout(this, dir, 2); setFrameStyle(Panel | Raised); setLineWidth(1); // read settings and create boxes options = new QList<KornBox>; options->setAutoDelete( true ); while( !settings->done() ) { // create a new button with these settings button = new KornButton(this, settings); button->resize(20,20); layout->addWidget(button); connect( button, SIGNAL( rightClick() ), this, SLOT( popupMenu() )); button->show(); /// keep track of settings locally KornBox *thisBox = new KornBox; thisBox->name = settings->name().data(); thisBox->caption = settings->caption().data(); thisBox->path = settings->file().data(); thisBox->poll = settings->pollTime(); thisBox->notify = settings->audioCmd().data(); thisBox->click = settings->clickCmd().data(); options->append( thisBox ); count++; settings->nextBox(); } // dont layout or resize if no buttons were created // This should be changed, perhaps to a default single button if( !settings->valid() || count == 0 ) { // no valid config _noConfig = true; int result = KMsgBox::yesNo(0, i18n("korn: configure now?"), i18n("you have not yet configured korn.\n" "would you like to do this now?"), KMsgBox::QUESTION, i18n("Yes"), i18n("No - Quit")); if( result == 1 ) { // create a list with the default mailbox in it. KornBox *box = new KornBox; box->name = i18n("personal"); box->caption = i18n("Inbox"); box->path = (const char *)getenv("MAIL"); box->poll = 240; options->append( box ); optionDlg(); } else { qApp->quit(); } return; } if( dir == QBoxLayout::LeftToRight ) resize(count*(2+20)+2,4+20); else resize(4+20, count*(2+20)+2); // move to the saved position if a position was saved if( settings->geomSet() ) { setGeometry( settings->geom().x(), settings->geom().y(), width(), height() ); } else { // save position KConfig *config = KApplication::getKApplication()->getConfig(); config->setGroup("Korn"); config->writeEntry("PosX", frameGeometry().x(), true); config->writeEntry("PosY", frameGeometry().y(), true); config->writeEntry("winHeight", frameGeometry().height(), true); } if( settings->noMouse() ) { XSelectInput( x11Display(), handle(), ExposureMask | StructureNotifyMask ); } }
KMenu* Contact::popupMenu( ChatSession * ) { return popupMenu(); }
MyVis::~MyVis() { disconnect(fsAct, SIGNAL(triggered()), this, SLOT(fKey())); delete fsAct; disconnect(this, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(popupMenu())); }