本文整理汇总了C++中QMenu::insertSeparator方法的典型用法代码示例。如果您正苦于以下问题:C++ QMenu::insertSeparator方法的具体用法?C++ QMenu::insertSeparator怎么用?C++ QMenu::insertSeparator使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QMenu
的用法示例。
在下文中一共展示了QMenu::insertSeparator方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: QMenuBar
QMenuBar*
ActionCollection::createMenuBar( QWidget *parent )
{
QMenuBar* menuBar = new QMenuBar( parent );
QMenu* controlsMenu = new QMenu( tr( "&Controls" ), menuBar );
controlsMenu->addAction( m_actionCollection[ "playPause" ] );
controlsMenu->addAction( m_actionCollection[ "previousTrack" ] );
controlsMenu->addAction( m_actionCollection[ "nextTrack" ] );
controlsMenu->addSeparator();
controlsMenu->addAction( m_actionCollection[ "togglePrivacy" ] );
controlsMenu->addAction( m_actionCollection[ "showOfflineSources" ] );
controlsMenu->addSeparator();
controlsMenu->addAction( m_actionCollection[ "loadXSPF" ] );
controlsMenu->addAction( m_actionCollection[ "updateCollection" ] );
controlsMenu->addAction( m_actionCollection[ "rescanCollection" ] );
controlsMenu->addSeparator();
controlsMenu->addAction( m_actionCollection[ "quit" ] );
QMenu* settingsMenu = new QMenu( tr( "&Settings" ), menuBar );
#ifndef Q_OS_MAC
settingsMenu->addAction( m_actionCollection[ "toggleMenuBar" ] );
#endif
settingsMenu->addAction( m_actionCollection[ "preferences" ] );
QMenu* helpMenu = new QMenu( tr( "&Help" ), menuBar );
helpMenu->addAction( m_actionCollection[ "diagnostics" ] );
helpMenu->addAction( m_actionCollection[ "openLogfile" ] );
helpMenu->addAction( m_actionCollection[ "legalInfo" ] );
helpMenu->addAction( m_actionCollection[ "aboutTomahawk" ] );
// Setup update check
#ifndef Q_OS_MAC
helpMenu->insertSeparator( m_actionCollection[ "legalInfo" ] );
#endif
#if defined( Q_OS_MAC ) && defined( HAVE_SPARKLE )
helpMenu->addAction( m_actionCollection[ "checkForUpdates" ] );
#elif defined( Q_WS_WIN )
helpMenu->addSeparator();
helpMenu->addAction( m_actionCollection[ "checkForUpdates" ] );
#endif
if ( qApp->arguments().contains( "--debug" ) )
{
helpMenu->addSeparator();
helpMenu->addAction( m_actionCollection[ "crashNow" ] );
}
menuBar->addMenu( controlsMenu );
menuBar->addMenu( settingsMenu );
#if defined( Q_OS_MAC )
QMenu* windowMenu = new QMenu( tr( "&Window" ), menuBar );
windowMenu->addAction( m_actionCollection[ "minimize" ] );
windowMenu->addAction( m_actionCollection[ "zoom" ] );
windowMenu->addAction( m_actionCollection[ "fullscreen" ] );
menuBar->addMenu( windowMenu );
#endif
menuBar->addMenu( helpMenu );
return menuBar;
}
示例2: xAxisClicked
/**
* When x-axis is clicked, the pixel coordinates are converted to graph coordinates, and displayed in a pop-up menu.
* @param &x :: A reference to a click on the x-axis.
*/
void LabelTool::xAxisClicked(const QwtPolygon &x)
{
populateMantidCurves();
// Obtains the x value of the pixel coordinate.
QPoint xx = x.point(0);
int xPosition = xx.x();
// Obtains the origins of the graph area and of the axis.
QPoint canvasOrigin = d_graph->plotWidget()->canvas()->pos();
int canvasOriginX = canvasOrigin.x();
QPoint xOrigin = d_graph->plotWidget()->axisWidget(QwtPlot::xBottom)->pos();
int xAxisOriginXValue = xOrigin.x();
/**
* The difference in the origins is calculated then taken into account when converting the pixel coordinates of the
* axis into graph coordinates.
*/
int deltaOrigins = canvasOriginX - xAxisOriginXValue;
int xPositionCorrected = xPosition - deltaOrigins;
double xPos = d_graph->plotWidget()->invTransform(QwtPlot::xBottom, xPositionCorrected);
if( xPos < 0)
{
return;
}
std::stringstream precisionValue;
precisionValue.precision(6);
precisionValue << xPos;
m_xPosSigFigs = precisionValue.str();
QMenu * clickMenu = new QMenu(d_graph);
QAction * addXAxisLabel = new QAction(tr(QString::fromStdString(m_xPosSigFigs.c_str())), this);
clickMenu->addAction(addXAxisLabel);
connect(addXAxisLabel,SIGNAL(triggered()), this, SLOT(insertXCoord()));
clickMenu->insertSeparator();
clickMenu->exec(QCursor::pos());
}
示例3: createActions
void ProjectManager::createActions()
{
newProjectAct = new QAction(tr("New Project"),this);
newProjectAct->setToolTip(tr("Create New Project"));
connect(newProjectAct,SIGNAL(triggered()),this,SLOT(newProject()));
openProjectAct = new QAction(tr("Open Project"),this);
openProjectAct->setToolTip(tr("Open Project"));
connect(openProjectAct,SIGNAL(triggered()),this,SLOT(openProject()));
closeProjectAct = new QAction(tr("Close Project"),this);
closeProjectAct->setToolTip(tr("Close Project"));
connect(closeProjectAct,SIGNAL(triggered()),this,SLOT(closeProject()));
QMenu *fileMenu = liteApp->mainWindow()->fileMenu();
QAction *seperator = fileMenu->insertSeparator(fileMenu->actions()[0]);
fileMenu->insertActions(seperator,QList<QAction*>() << newProjectAct
<< openProjectAct << closeProjectAct);
}
示例4: contextMenuEvent
void VMdEditor::contextMenuEvent(QContextMenuEvent *p_event)
{
QMenu *menu = createStandardContextMenu();
menu->setToolTipsVisible(true);
VEditTab *editTab = dynamic_cast<VEditTab *>(parent());
Q_ASSERT(editTab);
if (editTab->isEditMode()) {
const QList<QAction *> actions = menu->actions();
if (textCursor().hasSelection()) {
initCopyAsMenu(actions.isEmpty() ? NULL : actions.last(), menu);
} else {
QAction *saveExitAct = new QAction(VIconUtils::menuIcon(":/resources/icons/save_exit.svg"),
tr("&Save Changes And Read"),
menu);
saveExitAct->setToolTip(tr("Save changes and exit edit mode"));
connect(saveExitAct, &QAction::triggered,
this, [this]() {
emit m_object->saveAndRead();
});
QAction *discardExitAct = new QAction(VIconUtils::menuIcon(":/resources/icons/discard_exit.svg"),
tr("&Discard Changes And Read"),
menu);
discardExitAct->setToolTip(tr("Discard changes and exit edit mode"));
connect(discardExitAct, &QAction::triggered,
this, [this]() {
emit m_object->discardAndRead();
});
menu->insertAction(actions.isEmpty() ? NULL : actions[0], discardExitAct);
menu->insertAction(discardExitAct, saveExitAct);
}
if (!actions.isEmpty()) {
menu->insertSeparator(actions[0]);
}
}
menu->exec(p_event->globalPos());
delete menu;
}
示例5: slotCustomContextMenuRequested
void ColorView::slotCustomContextMenuRequested(const QPoint& p) {
QMenu* m = new QMenu(this);
QAction* reloadA = new QAction(tr("Reload"), this);
QAction* createA = new QAction(tr("Create..."), this);
QAction* editA = new QAction(tr("Edit..."), this);
QAction* deleteA = new QAction(tr("Delete"), this);
connect(reloadA, SIGNAL(activated()), this, SLOT(slotReload()));
connect(createA, SIGNAL(activated()), (ColorItemModel*) model(), SLOT(createNew()));
connect(editA, SIGNAL(activated()), this, SLOT(slotEdit()));
connect(deleteA, SIGNAL(activated()), this, SLOT(slotDelete()));
m->addAction(createA);
if (selectedIndexes().count() == 1) {
m->addAction(editA);
}
if (selectedIndexes().count() > 0) {
m->addAction(deleteA);
}
m->insertSeparator(reloadA);
m->addAction(reloadA);
m->exec(mapToGlobal(p));
}
示例6: onContextMenu
void DesignerEventHandler::onContextMenu(QContextMenuEvent * e)
{
QMenu * menu = new QMenu(parentWidget);
QAction * copy_action = menu->addAction(tr("Copy"), this, SLOT(onCopy()));
menu->addAction(tr("Paste"), this, SLOT(onPaste()));
QAction * delete_action = menu->addAction(tr("Delete"), this, SLOT(onDelete()));
QAction * delete_with_s_action = menu->addAction(tr("Delete with sourcers"), this, SLOT(onDeleteWithSourcers()));
QMenu* go = menu->addMenu(tr("Geometry operations"));
go->addAction(tr("Align left") , this, SLOT(onAlignLeft()));
go->addAction(tr("Align top") , this, SLOT(onAlignTop()));
go->addAction(tr("Align right"), this, SLOT(onAlignRight()));
go->addAction(tr("Align bottom"),this, SLOT(onAlignBottom()));
go->addAction(tr("Align vertical"),this, SLOT(onAlignVertical()));
go->addAction(tr("Align horisontal"), this, SLOT (onAlignHorizontal()) );
go->addAction(tr("Queue x"), this, SLOT (onQuequeX()) );
go->addAction(tr("Queue y"), this, SLOT (onQuequeY()) );
go->insertSeparator();
go->addAction(tr("Same width"), this, SLOT(onSameWidth()));
go->addAction(tr("Same height"), this, SLOT(onSameHeight()));
QMenu* popupWindows = menu->addMenu(tr("Popup windows"));
QMenu* leftButtonPW = popupWindows->addMenu(tr("Left button"));
QAction * left_pw_add_action = leftButtonPW->addAction( tr("Add"), this, SLOT(onLeftPwAdd()));
QAction * left_pw_copy_action = leftButtonPW->addAction( tr("Copy"), this, SLOT(onLeftPwCopy()));
leftButtonPW->addAction( tr("Paste"), this, SLOT(onLeftPwPaste()));
QAction * left_pw_delete_action = leftButtonPW->addAction( tr("Delete"), this, SLOT(onLeftDelete()));
QMenu* rightButtonPW = popupWindows->addMenu (tr ("Right button"));
QAction * right_pw_add_action = rightButtonPW->addAction( tr("Add"), this, SLOT(onRightPwAdd()));
QAction * right_pw_copy_action = rightButtonPW->addAction( tr("Copy"), this, SLOT(onRightPwCopy()));
rightButtonPW->addAction( tr("Paste"), this, SLOT(onRightPwPaste()));
QAction * right_pw_delete_action = rightButtonPW->addAction( tr("Delete"), this, SLOT(onRightDelete()));
QAction* show_properties_action = menu->addAction(tr("Properties"), this, SLOT(showProps()));
QFont f = show_properties_action->font();
f.setBold(true);
show_properties_action->setFont(f);
menu->addAction( tr("Export lists"), this, SLOT(onExportLists()) );
//menu->insertSeparator();
QMenu * predef = menu->addMenu ("Predef windows");
QStringList names = PredefPw::Factory::availableNames();
for (QStringList::iterator iter = names.begin(); iter != names.end(); ++iter ) {
QAction * a = predef->addAction (*iter);
//a->setMenu (predef);
a->setData (12345);
}
menu->addAction ( "Find sourcer", this, SLOT (onFindSourcerByWidget() ) );
if (selected_widgets.count( ) == 0 ){
copy_action->setEnabled(false);
delete_action->setEnabled(false);
delete_with_s_action->setEnabled(false);
go->setEnabled(false);
popupWindows->setEnabled(false);
}
else {
VtlWidget * w = (VtlWidget*)checkWidget(e->pos());
if (w) {
if (w->isLbPopupCreated()) {
left_pw_add_action->setEnabled(false);
}
else {
left_pw_copy_action->setEnabled(false);
left_pw_delete_action->setEnabled(false);
}
if (w->isRbPopupCreated()) {
right_pw_add_action->setEnabled(false);
}
else {
right_pw_copy_action->setEnabled(false);
right_pw_delete_action->setEnabled(false);
}
}
}
if ( context_widget )
context_widget->prepareContextMenu (menu);
if (e->state() & Qt::ControlModifier )
control_modifier = true;
QAction * a = menu->exec(e->globalPos());
control_modifier = false;
if ( a && a->data().toInt() == 12345 ) {
QMessageBox box ( vtl::app );
QAbstractButton * left_btn = box.addButton ("Left" , QMessageBox::ActionRole );
QAbstractButton * right_btn = box.addButton ("Right", QMessageBox::ActionRole );
box.setWindowTitle ("Mouse button?");
box.exec ();
if ( box.clickedButton() == left_btn ) {
for (SWPtrList::iterator iter = selected_widgets.begin(); iter != selected_widgets.end(); ++iter ) {
(*iter)->createLbPredefPw ( a->text() );
}
}
else if (box.clickedButton() == right_btn ) {
for (SWPtrList::iterator iter = selected_widgets.begin(); iter != selected_widgets.end(); ++iter ) {
//.........这里部分代码省略.........
示例7: QMenuBar
QMenuBar*
ActionCollection::createMenuBar( QWidget *parent )
{
QMenuBar* menuBar = new QMenuBar( parent );
menuBar->setFont( TomahawkUtils::systemFont() );
QMenu* controlsMenu = new QMenu( tr( "&Controls" ), menuBar );
controlsMenu->setFont( TomahawkUtils::systemFont() );
controlsMenu->addAction( m_actionCollection[ "playPause" ] );
controlsMenu->addAction( m_actionCollection[ "previousTrack" ] );
controlsMenu->addAction( m_actionCollection[ "nextTrack" ] );
controlsMenu->addSeparator();
controlsMenu->addAction( m_actionCollection[ "togglePrivacy" ] );
controlsMenu->addAction( m_actionCollection[ "showOfflineSources" ] );
controlsMenu->addSeparator();
controlsMenu->addAction( m_actionCollection[ "importPlaylist" ] );
controlsMenu->addAction( m_actionCollection[ "updateCollection" ] );
controlsMenu->addAction( m_actionCollection[ "rescanCollection" ] );
controlsMenu->addSeparator();
controlsMenu->addAction( m_actionCollection[ "quit" ] );
QMenu* settingsMenu = new QMenu( tr( "&Settings" ), menuBar );
settingsMenu->setFont( TomahawkUtils::systemFont() );
#ifndef Q_OS_MAC
settingsMenu->addAction( m_actionCollection[ "toggleMenuBar" ] );
#endif
settingsMenu->addAction( m_actionCollection[ "preferences" ] );
QMenu* helpMenu = new QMenu( tr( "&Help" ), menuBar );
helpMenu->setFont( TomahawkUtils::systemFont() );
helpMenu->addAction( m_actionCollection[ "diagnostics" ] );
helpMenu->addAction( m_actionCollection[ "openLogfile" ] );
helpMenu->addAction( m_actionCollection[ "legalInfo" ] );
helpMenu->addAction( m_actionCollection["getSupport"] );
helpMenu->addAction( m_actionCollection["reportBug"] );
helpMenu->addAction( m_actionCollection["helpTranslate"] );
helpMenu->addSeparator();
QMenu* whatsNew = helpMenu->addMenu( ImageRegistry::instance()->icon( RESPATH "images/whatsnew.svg" ), tr( "What's New in ..." ) );
whatsNew->setFont( TomahawkUtils::systemFont() );
whatsNew->addAction( m_actionCollection[ "whatsnew_0_8" ] );
helpMenu->addAction( m_actionCollection[ "aboutTomahawk" ] );
// Setup update check
#ifndef Q_OS_MAC
helpMenu->insertSeparator( m_actionCollection[ "legalInfo" ] );
#endif
#if defined( Q_OS_MAC ) && defined( HAVE_SPARKLE )
helpMenu->addAction( m_actionCollection[ "checkForUpdates" ] );
#elif defined( Q_OS_WIN )
helpMenu->addSeparator();
helpMenu->addAction( m_actionCollection[ "checkForUpdates" ] );
#endif
if ( qApp->arguments().contains( "--debug" ) )
{
helpMenu->addSeparator();
helpMenu->addAction( m_actionCollection[ "crashNow" ] );
}
menuBar->addMenu( controlsMenu );
menuBar->addMenu( settingsMenu );
#if defined( Q_OS_MAC )
QMenu* windowMenu = new QMenu( tr( "&Window" ), menuBar );
windowMenu->setFont( TomahawkUtils::systemFont() );
windowMenu->addAction( m_actionCollection[ "minimize" ] );
windowMenu->addAction( m_actionCollection[ "zoom" ] );
windowMenu->addAction( m_actionCollection[ "fullscreen" ] );
menuBar->addMenu( windowMenu );
#endif
menuBar->addMenu( helpMenu );
return menuBar;
}
示例8: showContextMenu
void Contact::showContextMenu(const QPoint& p)
{
bool online = account()->loggedIn();
bool self = u_.isSelf();
bool inList = u_.inList();
bool isPrivate = u_.isPrivate();
bool isAgent = u_.isTransport();
bool avail = u_.isAvailable();
QAction *status = NULL;
QAction *mood = NULL;
QAction *geo = NULL;
QAction *bookmarksManage = NULL;
QMap<QAction*,int> bookmarks;
QAction *addToContactList = NULL;
QAction *serviceDiscovery = NULL;
QAction *xmlConsole = NULL;
QAction *sendMessage = NULL;
QAction *startChat = NULL;
#ifdef WHITEBOARDING
QAction *openWhiteboard = NULL;
#endif
QAction *RC = NULL;
QAction *voiceCall = NULL;
QAction *upload = NULL;
#ifdef XEP-0136
QAction *archive = NULL;
#endif
QAction *history = NULL;
QAction *info = NULL;
QAction *rename = NULL;
QAction *authResend = NULL;
QAction *authRequest = NULL;
QAction *authRemove = NULL;
QAction *remove = NULL;
QAction *meta = NULL;
QAction *group = NULL;
QAction *avatAssign = NULL;
QAction *avatClear = NULL;
QAction *pgp = NULL;
QAction *block = NULL;
QAction *unblock = NULL;
QAction *copyJid = NULL;
QAction *copyStatusMsg = NULL;
QAction *goToUrl = NULL;
QAction *logon = NULL;
QMenu pm(0);
if(self) {
status = pm.addAction(List::tr("Set &Status"));
#ifdef USE_PEP
if(online && account()->serverInfoManager()->hasPEP()) {
QMenu *set = pm.addMenu(List::tr("PEP"));
mood = set->addAction(IconsetFactory::icon("psi/smile").icon(),List::tr("Set Mood"));
geo = set->addAction(List::tr("Geolocation"));
avatAssign = set->addAction(List::tr("Set Avatar"));
avatClear = set->addAction(List::tr("Unset Avatar"));
}
#endif
QMenu *bm = pm.addMenu(List::tr("Bookmarks"));
bookmarksManage = bm->addAction(List::tr("Manage..."));
if (account()->bookmarkManager()->isAvailable()) {
int idx = 0;
bm->insertSeparator();
foreach(ConferenceBookmark c, account()->bookmarkManager()->conferences()) {
bookmarks[bm->addAction(QString(List::tr("Join %1")).arg(c.name()))] = idx;
idx++;
}
}
示例9: setupActions
void QucsHelp::setupActions()
{
QToolBar *toolbar = new QToolBar(this,"main_toolbar");
this->addToolBar(toolbar);
QMenuBar *bar = menuBar();
const QKeySequence ks = QKeySequence();
QAction *quitAction = new QAction(QIcon((":/bitmaps/quit.png")),
tr("&Quit"), (const QKeySequence&)Qt::CTRL+Qt::Key_Q, this,"");
QAction *backAction = new QAction(QIcon((":/bitmaps/back.png")),
tr("&Back"), Qt::ALT+Qt::Key_Left, this,"");
QAction *forwardAction = new QAction(QIcon((":/bitmaps/forward.png")),
tr("&Forward"), Qt::ALT+Qt::Key_Right, this,"");
QAction *homeAction = new QAction(QIcon((":/bitmaps/home.png")),
tr("&Home"),Qt::CTRL+Qt::Key_H,this,"");
previousAction = new QAction(QIcon((":/bitmaps/previous.png")),tr("&Previous"),
ks, this,"");
nextAction = new QAction(QIcon((":/bitmaps/next.png")),
tr("&Next"), ks, this,"");
viewBrowseDock = new QAction(tr("&Table of Contents"), 0, this,"");
viewBrowseDock->setToggleAction(true);
viewBrowseDock->setOn(true);
viewBrowseDock->setStatusTip(tr("Enables/disables the table of contents"));
viewBrowseDock->setWhatsThis(tr("Table of Contents\n\nEnables/disables the table of contents"));
connect(quitAction,SIGNAL(activated()),qApp,SLOT(quit()));
connect(backAction,SIGNAL(activated()),textBrowser,SLOT(backward()));
connect(textBrowser,SIGNAL(backwardAvailable(bool)),backAction,SLOT(setEnabled(bool)));
connect(forwardAction,SIGNAL(activated()),textBrowser,SLOT(forward()));
connect(textBrowser,SIGNAL(forwardAvailable(bool)),forwardAction,SLOT(setEnabled(bool)));
connect(homeAction,SIGNAL(activated()),textBrowser,SLOT(home()));
connect(homeAction,SIGNAL(activated()),this,SLOT(gohome()));
connect(textBrowser,SIGNAL(sourceChanged(const QUrl &)),this,SLOT(slotSourceChanged(const QUrl &)));
connect(previousAction,SIGNAL(activated()),this,SLOT(previousLink()));
connect(nextAction,SIGNAL(activated()),this,SLOT(nextLink()));
connect(viewBrowseDock, SIGNAL(toggled(bool)), SLOT(slotToggleSidebar(bool)));
backAction->addTo(toolbar);
forwardAction->addTo(toolbar);
toolbar->addSeparator();
homeAction->addTo(toolbar);
previousAction->addTo(toolbar);
nextAction->addTo(toolbar);
toolbar->addSeparator();
quitAction->addTo(toolbar);
QMenu *fileMenu = new QMenu(this);
quitAction->addTo(fileMenu);
QMenu *viewMenu = new QMenu(this);
backAction->addTo(viewMenu);
forwardAction->addTo(viewMenu);
homeAction->addTo(viewMenu);
previousAction->addTo(viewMenu);
nextAction->addTo(viewMenu);
viewMenu->insertSeparator();
viewBrowseDock->addTo(viewMenu);
QMenu *helpMenu = new QMenu(this);
helpMenu->insertItem(tr("&About Qt"),qApp,SLOT(aboutQt()));
bar->insertItem(tr("&File"), fileMenu );
bar->insertItem(tr("&View"),viewMenu);
bar->insertSeparator();
bar->insertItem(tr("&Help"),helpMenu);
}
示例10: eventFilter
bool MarkdownEditor::eventFilter(QObject* watched, QEvent* event)
{
if (event->type() == QEvent::MouseButtonPress)
{
mouseButtonDown = true;
}
else if (event->type() == QEvent::MouseButtonRelease)
{
mouseButtonDown = false;
}
else if (event->type() == QEvent::MouseButtonDblClick)
{
mouseButtonDown = true;
}
if (event->type() != QEvent::ContextMenu || !spellCheckEnabled || this->isReadOnly())
{
return QPlainTextEdit::eventFilter(watched, event);
}
else
{
// Check spelling of text block under mouse
QContextMenuEvent* contextEvent = static_cast<QContextMenuEvent*>(event);
cursorForWord = cursorForPosition(contextEvent->pos());
QTextCharFormat::UnderlineStyle spellingErrorUnderlineStyle =
(QTextCharFormat::UnderlineStyle)
QApplication::style()->styleHint
(
QStyle::SH_SpellCheckUnderlineStyle
);
// Get the formatting for the cursor position under the mouse,
// and see if it has the spell check error underline style.
//
bool wordHasSpellingError = false;
int blockPosition = cursorForWord.positionInBlock();
QList<QTextLayout::FormatRange> formatList =
textCursor().block().layout()->additionalFormats();
int mispelledWordStartPos = 0;
int mispelledWordLength = 0;
for (int i = 0; i < formatList.length(); i++)
{
QTextLayout::FormatRange formatRange = formatList[i];
if
(
(blockPosition >= formatRange.start)
&& (blockPosition <= (formatRange.start + formatRange.length))
&& (formatRange.format.underlineStyle() == spellingErrorUnderlineStyle)
)
{
mispelledWordStartPos = formatRange.start;
mispelledWordLength = formatRange.length;
wordHasSpellingError = true;
break;
}
}
// The word under the mouse is spelled correctly, so use the default
// processing for the context menu and return.
//
if (!wordHasSpellingError)
{
return QPlainTextEdit::eventFilter(watched, event);
}
// Select the misspelled word.
cursorForWord.movePosition(QTextCursor::PreviousCharacter, QTextCursor::MoveAnchor, blockPosition - mispelledWordStartPos);
cursorForWord.movePosition(QTextCursor::NextCharacter, QTextCursor::KeepAnchor, mispelledWordLength);
wordUnderMouse = cursorForWord.selectedText();
QStringList suggestions = dictionary.suggestions(wordUnderMouse);
QMenu* popupMenu = createStandardContextMenu();
QAction* firstAction = popupMenu->actions().first();
spellingActions.clear();
if (!suggestions.empty())
{
for (int i = 0; i < suggestions.size(); i++)
{
QAction* suggestionAction = new QAction(suggestions[i], this);
spellingActions.append(suggestionAction);
popupMenu->insertAction(firstAction, suggestionAction);
}
}
else
{
QAction* noSuggestionsAction =
new QAction(tr("No spelling suggestions found"), this);
noSuggestionsAction->setEnabled(false);
spellingActions.append(noSuggestionsAction);
popupMenu->insertAction(firstAction, noSuggestionsAction);
}
popupMenu->insertSeparator(firstAction);
popupMenu->insertAction(firstAction, addWordToDictionaryAction);
popupMenu->insertSeparator(firstAction);
//.........这里部分代码省略.........
示例11: fillMenu
void PickboardConfig::fillMenu(QMenu& menu)
{
resetA = menu.addAction(tr("Reset"));
helpA = menu.addAction(tr("Help"));
menu.insertSeparator(helpA);
}
示例12: helpback
HelpWindow::HelpWindow( const QString& home_, const QString& _path,
QWidget* parent, const char *name) :
Q3MainWindow( parent, name, Qt::WDestructiveClose ),
pathCombo( 0 ), selectedURL()
{
DigitDebug::ctor(QString("helpwindow " + QString::number((ulong) this, 16)));
readHistory();
readBookmarks();
browser = new Q3TextBrowser( this );
CHECK_PTR_ENGAUGE(browser);
browser->mimeSourceFactory()->setFilePath( _path );
browser->setFrameStyle( Q3Frame::Panel | Q3Frame::Sunken );
connect( browser, SIGNAL( textChanged() ),
this, SLOT( textChanged() ) );
setCentralWidget( browser );
if ( !home_.isEmpty() )
browser->setSource( home_ );
connect( browser, SIGNAL( highlighted( const QString&) ),
statusBar(), SLOT( message( const QString&)) );
// display help window in previous position with same size
DefaultSettings& rSettings = DefaultSettings::instance();
move(rSettings.getWindowHelpPosition());
resize(rSettings.getWindowHelpSize());
QMenu* file = new QMenu( this );
CHECK_PTR_ENGAUGE(file);
file->insertItem( tr("&Open File"), this, SLOT( openFile() ), Qt::CTRL+Qt::Key_O );
file->insertItem( tr("&Print"), this, SLOT( print() ), Qt::CTRL+Qt::Key_P );
file->insertSeparator();
file->insertItem( tr("&Close"), this, SLOT( close() ), Qt::CTRL+Qt::Key_Q );
//file->insertItem( tr("E&xit"), qApp, SLOT( closeAllWindows() ), Qt::CTRL+Qt::Key_X );
// The same three icons are used twice each.
QPixmap helpback (helpback_xpm);
QPixmap helpforward (helpforward_xpm);
QPixmap helphome (helphome_xpm);
QIcon icon_back (helpback);
QIcon icon_forward (helpforward);
QIcon icon_home (helphome);
QMenu* go = new QMenu( this );
CHECK_PTR_ENGAUGE(go);
backwardId = go->insertItem( icon_back,
tr("&Backward"), browser, SLOT( backward() ),
Qt::CTRL+Qt::Key_Left );
forwardId = go->insertItem( icon_forward,
tr("&Forward"), browser, SLOT( forward() ),
Qt::CTRL+Qt::Key_Right );
go->insertItem( icon_home, tr("&Home"), browser, SLOT( home() ) );
hist = new QMenu( this );
CHECK_PTR_ENGAUGE(hist);
QStringList::Iterator it = history.begin();
for ( ; it != history.end(); ++it )
mHistory[ hist->insertItem( *it ) ] = *it;
connect( hist, SIGNAL( activated( int ) ),
this, SLOT( histChosen( int ) ) );
bookm = new QMenu( this );
CHECK_PTR_ENGAUGE(bookm);
bookm->insertItem( tr( "Add Bookmark" ), this, SLOT( addBookmark() ) );
bookm->insertSeparator();
QStringList::Iterator it2 = bookmarks.begin();
for ( ; it2 != bookmarks.end(); ++it2 )
mBookmarks[ bookm->insertItem( *it2 ) ] = *it2;
connect( bookm, SIGNAL( activated( int ) ),
this, SLOT( bookmChosen( int ) ) );
menuBar()->insertItem( tr("&File"), file );
menuBar()->insertItem( tr("&Go"), go );
menuBar()->insertItem( tr( "History" ), hist );
menuBar()->insertItem( tr( "Bookmarks" ), bookm );
menuBar()->setItemEnabled( forwardId, FALSE);
menuBar()->setItemEnabled( backwardId, FALSE);
connect( browser, SIGNAL( backwardAvailable( bool ) ),
this, SLOT( setBackwardAvailable( bool ) ) );
connect( browser, SIGNAL( forwardAvailable( bool ) ),
this, SLOT( setForwardAvailable( bool ) ) );
Q3ToolBar* toolbar = new Q3ToolBar( this );
CHECK_PTR_ENGAUGE(toolbar);
addToolBar( toolbar, "Toolbar");
QToolButton* button;
button = new QToolButton( icon_back, tr("Backward"), "", browser, SLOT(backward()), toolbar );
CHECK_PTR_ENGAUGE(button);
connect( browser, SIGNAL( backwardAvailable(bool) ), button, SLOT( setEnabled(bool) ) );
button->setEnabled( FALSE );
button = new QToolButton( icon_forward, tr("Forward"), "", browser, SLOT(forward()), toolbar );
CHECK_PTR_ENGAUGE(button);
//.........这里部分代码省略.........