void ItemEditorWidget::initMenuItems() { Q_ASSERT(m_editor); foreach (QAction *action, m_toolBar->actions()) delete action; QAction *act; act = new QAction( iconSave(), tr("Save"), m_editor ); m_toolBar->addAction(act); act->setToolTip( tr("Save Item (<strong>F2</strong>)") ); act->setShortcut( QKeySequence(tr("F2", "Shortcut to save item editor changes")) ); connect( act, SIGNAL(triggered()), this, SLOT(saveAndExit()) ); act = new QAction( iconCancel(), tr("Cancel"), m_editor ); m_toolBar->addAction(act); act->setToolTip( tr("Cancel Editing and Revert Changes") ); act->setShortcut( QKeySequence(tr("Escape", "Shortcut to revert item editor changes")) ); connect( act, SIGNAL(triggered()), this, SIGNAL(cancel()) ); QPlainTextEdit *plainTextEdit = qobject_cast<QPlainTextEdit*>(m_editor); if (plainTextEdit != NULL) { plainTextEdit->setFrameShape(QFrame::NoFrame); act = new QAction( iconUndo(), tr("Undo"), m_editor ); m_toolBar->addAction(act); act->setShortcut(QKeySequence::Undo); act->setEnabled(false); connect( act, SIGNAL(triggered()), plainTextEdit, SLOT(undo()) ); connect( plainTextEdit, SIGNAL(undoAvailable(bool)), act, SLOT(setEnabled(bool)) ); act = new QAction( iconRedo(), tr("Redo"), m_editor ); m_toolBar->addAction(act); act->setShortcut(QKeySequence::Redo); act->setEnabled(false); connect( act, SIGNAL(triggered()), plainTextEdit, SLOT(redo()) ); connect( plainTextEdit, SIGNAL(redoAvailable(bool)), act, SLOT(setEnabled(bool)) ); } }
void ItemEditorWidget::initMenuItems() { Q_ASSERT(m_editor); auto frame = qobject_cast<QFrame*>(m_editor); if (frame) frame->setFrameShape(QFrame::NoFrame); for (auto action : m_toolBar->actions()) delete action; QAction *act; act = new QAction( iconSave(), tr("Save"), m_editor ); m_toolBar->addAction(act); act->setToolTip( tr("Save Item (<strong>F2</strong>)") ); act->setShortcut( QKeySequence(tr("F2", "Shortcut to save item editor changes")) ); connect( act, &QAction::triggered, this, &ItemEditorWidget::saveAndExit ); act = new QAction( iconCancel(), tr("Cancel"), m_editor ); m_toolBar->addAction(act); act->setToolTip( tr("Cancel Editing and Revert Changes") ); act->setShortcut( QKeySequence(tr("Escape", "Shortcut to revert item editor changes")) ); connect( act, &QAction::triggered, this, &ItemEditorWidget::cancel ); auto doc = document(); if (document()) { m_toolBar->addSeparator(); act = new QAction( iconUndo(), tr("Undo"), m_editor ); m_toolBar->addAction(act); act->setShortcut(QKeySequence::Undo); act->setEnabled(false); connect( act, &QAction::triggered, doc, static_cast<void (QTextDocument::*)()>(&QTextDocument::undo) ); connect( doc, &QTextDocument::undoAvailable, act, &QAction::setEnabled ); act = new QAction( iconRedo(), tr("Redo"), m_editor ); m_toolBar->addAction(act); act->setShortcut(QKeySequence::Redo); act->setEnabled(false); connect( act, &QAction::triggered, doc, static_cast<void (QTextDocument::*)()>(&QTextDocument::redo) ); connect( doc, &QTextDocument::redoAvailable, act, &QAction::setEnabled ); m_toolBar->addSeparator(); act = new QAction( iconFont(), tr("Font"), m_editor ); m_toolBar->addAction(act); connect( act, &QAction::triggered, this, &ItemEditorWidget::setFont ); act = new QAction( iconBold(), tr("Bold"), m_editor ); m_toolBar->addAction(act); act->setShortcut( QKeySequence::Bold ); connect( act, &QAction::triggered, this, &ItemEditorWidget::toggleBoldText ); act = new QAction( iconItalic(), tr("Italic"), m_editor ); m_toolBar->addAction(act); act->setShortcut( QKeySequence::Italic ); connect( act, &QAction::triggered, this, &ItemEditorWidget::toggleItalicText ); act = new QAction( iconUnderline(), tr("Underline"), m_editor ); m_toolBar->addAction(act); act->setShortcut( QKeySequence::Underline ); connect( act, &QAction::triggered, this, &ItemEditorWidget::toggleUnderlineText ); act = new QAction( iconStrikethrough(), tr("Strikethrough"), m_editor ); m_toolBar->addAction(act); connect( act, &QAction::triggered, this, &ItemEditorWidget::toggleStrikethroughText ); m_toolBar->addSeparator(); act = new QAction( iconForeground(), tr("Foreground"), m_editor ); m_toolBar->addAction(act); connect( act, &QAction::triggered, this, &ItemEditorWidget::setForeground ); act = new QAction( iconBackground(), tr("Background"), m_editor ); m_toolBar->addAction(act); connect( act, &QAction::triggered, this, &ItemEditorWidget::setBackground ); m_toolBar->addSeparator(); act = new QAction( iconEraseStyle(), tr("Erase Style"), m_editor ); m_toolBar->addAction(act); connect( act, &QAction::triggered, this, &ItemEditorWidget::eraseStyle ); m_toolBar->addSeparator(); act = new QAction( iconSearch(), tr("Search"), m_editor ); act->setShortcuts(QKeySequence::Find); m_toolBar->addAction(act); connect( act, &QAction::triggered, this, &ItemEditorWidget::searchRequest ); } }
void QmitkPointListWidget::SetupUi() { //Setup the buttons m_ToggleAddPoint = new QPushButton(); m_ToggleAddPoint->setMaximumSize(25,25); m_ToggleAddPoint->setCheckable(true); m_ToggleAddPoint->setToolTip("Toggle point editing (use SHIFT + Left Mouse Button to add Points)"); QIcon iconAdd(":/QtWidgetsExt/btnSetPoints.xpm"); m_ToggleAddPoint->setIcon(iconAdd); m_AddPoint = new QPushButton(); m_AddPoint->setMaximumSize(25,25); m_AddPoint->setToolTip("Manually add point"); QIcon iconAddManually(":/QtWidgetsExt/btnSetPointsManually.xpm"); m_AddPoint->setIcon(iconAddManually); m_RemovePointBtn = new QPushButton(); m_RemovePointBtn->setMaximumSize(25, 25); const QIcon iconDel(":/QtWidgetsExt/btnClear.xpm"); m_RemovePointBtn->setIcon(iconDel); m_RemovePointBtn->setToolTip("Erase one point from list (Hotkey: DEL)"); m_MovePointUpBtn = new QPushButton(); m_MovePointUpBtn->setMaximumSize(25, 25); const QIcon iconUp(":/QtWidgetsExt/btnUp.xpm"); m_MovePointUpBtn->setIcon(iconUp); m_MovePointUpBtn->setToolTip("Swap selected point upwards (Hotkey: F2)"); m_MovePointDownBtn = new QPushButton(); m_MovePointDownBtn->setMaximumSize(25, 25); const QIcon iconDown(":/QtWidgetsExt/btnDown.xpm"); m_MovePointDownBtn->setIcon(iconDown); m_MovePointDownBtn->setToolTip("Swap selected point downwards (Hotkey: F3)"); m_SavePointsBtn = new QPushButton(); m_SavePointsBtn->setMaximumSize(25, 25); QIcon iconSave(":/QtWidgetsExt/btnSave.xpm"); m_SavePointsBtn->setIcon(iconSave); m_SavePointsBtn->setToolTip("Save points to file"); m_LoadPointsBtn = new QPushButton(); m_LoadPointsBtn->setMaximumSize(25, 25); QIcon iconLoad(":/QtWidgetsExt/btnLoad.xpm"); m_LoadPointsBtn->setIcon(iconLoad); m_LoadPointsBtn->setToolTip("Load list of points from file (REPLACES current content)"); int i; QBoxLayout* lay1; QBoxLayout* lay2; switch (m_Orientation) { case 0: lay1 = new QVBoxLayout(this); lay2 = new QHBoxLayout(); i = 0; break; case 1: lay1 = new QHBoxLayout(this); lay2 = new QVBoxLayout(); i=-1; break; case 2: lay1 = new QHBoxLayout(this); lay2 = new QVBoxLayout(); i=0; break; default: lay1 = new QVBoxLayout(this); lay2 = new QHBoxLayout(); i=-1; break; } //setup Layouts this->setLayout(lay1); lay1->addLayout(lay2); lay2->stretch(true); lay2->addWidget(m_ToggleAddPoint); lay2->addWidget(m_AddPoint); lay2->addWidget(m_RemovePointBtn); lay2->addWidget(m_MovePointUpBtn); lay2->addWidget(m_MovePointDownBtn); lay2->addWidget(m_SavePointsBtn); lay2->addWidget(m_LoadPointsBtn); lay1->insertWidget(i,m_PointListView); this->setLayout(lay1); }