本文整理汇总了C++中QAction::setPriority方法的典型用法代码示例。如果您正苦于以下问题:C++ QAction::setPriority方法的具体用法?C++ QAction::setPriority怎么用?C++ QAction::setPriority使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QAction
的用法示例。
在下文中一共展示了QAction::setPriority方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: setupEditActions
void BrailleMusicEditor::setupEditActions() {
auto tb = new QToolBar(this);
tb->setWindowTitle(tr("Edit Actions"));
addToolBar(tb);
auto menu = new QMenu(tr("&Edit"), this);
menuBar()->addMenu(menu);
QAction *a;
a = actionUndo =
new QAction(QIcon::fromTheme("edit-undo"), tr("&Undo"), this);
a->setShortcut(QKeySequence::Undo);
tb->addAction(a);
menu->addAction(a);
a = actionRedo =
new QAction(QIcon::fromTheme("edit-redo"), tr("&Redo"), this);
a->setPriority(QAction::LowPriority);
a->setShortcut(QKeySequence::Redo);
tb->addAction(a);
menu->addAction(a);
menu->addSeparator();
a = actionCut = new QAction(QIcon::fromTheme("edit-cut"), tr("Cu&t"), this);
a->setPriority(QAction::LowPriority);
a->setShortcut(QKeySequence::Cut);
tb->addAction(a);
menu->addAction(a);
a = actionCopy =
new QAction(QIcon::fromTheme("edit-copy"), tr("&Copy"), this);
a->setPriority(QAction::LowPriority);
a->setShortcut(QKeySequence::Copy);
tb->addAction(a);
menu->addAction(a);
a = actionPaste =
new QAction(QIcon::fromTheme("edit-paste"), tr("&Paste"), this);
a->setPriority(QAction::LowPriority);
a->setShortcut(QKeySequence::Paste);
tb->addAction(a);
menu->addAction(a);
#ifndef QT_NO_CLIPBOARD
if (const QMimeData *md = QApplication::clipboard()->mimeData())
actionPaste->setEnabled(md->hasText());
#endif
menu->addSeparator();
a = new QAction(tr("&Reformat"), this);
a->setPriority(QAction::LowPriority);
a->setShortcut(Qt::Key_F9);
a->setEnabled(false);
connect(this, &BrailleMusicEditor::scoreAvailable, a, &QAction::setEnabled);
connect(a, &QAction::triggered, this, &BrailleMusicEditor::editReformat);
tb->addAction(a);
menu->addAction(a);
}
示例2: setupEditActions
void TextEdit::setupEditActions()
{
QToolBar *tb = new QToolBar(this);
tb->setWindowTitle(tr("Edit Actions"));
addToolBar(tb);
QMenu *menu = new QMenu(tr("&Edit"), this);
menuBar()->addMenu(menu);
QAction *a;
a = actionUndo = new QAction(QIcon::fromTheme("edit-undo", QIcon(rsrcPath + "/editundo.png")),
tr("&Undo"), this);
a->setShortcut(QKeySequence::Undo);
tb->addAction(a);
menu->addAction(a);
a = actionRedo = new QAction(QIcon::fromTheme("edit-redo", QIcon(rsrcPath + "/editredo.png")),
tr("&Redo"), this);
a->setPriority(QAction::LowPriority);
a->setShortcut(QKeySequence::Redo);
tb->addAction(a);
menu->addAction(a);
menu->addSeparator();
a = actionCut = new QAction(QIcon::fromTheme("edit-cut", QIcon(rsrcPath + "/editcut.png")),
tr("Cu&t"), this);
a->setPriority(QAction::LowPriority);
a->setShortcut(QKeySequence::Cut);
tb->addAction(a);
menu->addAction(a);
a = actionCopy = new QAction(QIcon::fromTheme("edit-copy", QIcon(rsrcPath + "/editcopy.png")),
tr("&Copy"), this);
a->setPriority(QAction::LowPriority);
a->setShortcut(QKeySequence::Copy);
tb->addAction(a);
menu->addAction(a);
a = actionPaste = new QAction(QIcon::fromTheme("edit-paste", QIcon(rsrcPath + "/editpaste.png")),
tr("&Paste"), this);
a->setPriority(QAction::LowPriority);
a->setShortcut(QKeySequence::Paste);
tb->addAction(a);
menu->addAction(a);
#ifndef QT_NO_CLIPBOARD
if (const QMimeData *md = QApplication::clipboard()->mimeData())
actionPaste->setEnabled(md->hasText());
#endif
}
示例3: createWidget
void Dialog::createWidget() {
createdWidgetx = true;
dgReadByUser = false;
int w = smiles->size().width() / W_CNT;
int h = smiles->size().height() / H_CNT;
lwHistory = new QListWidget();
teMessage = new TextEditMessage();
//teHistory->setReadOnly(true);
addWidget(lwHistory);
setStretchFactor(0, 2);
panel = new QToolBar();
QIcon newIcon = QPixmap::fromImage(smiles->copy(w, 0, w, h));
QAction *a = new QAction(newIcon, QString("&Smiles"), 0);
a->setPriority(QAction::LowPriority);
a->setShortcut(Qt::CTRL + Qt::Key_S);
connect(a, SIGNAL(triggered()), this, SLOT(slotClickedSmileMenu()));
panel->addAction(a);
panel->setFixedHeight(30);
//panel->pos()
/*QMenuBar *panel = new QMenuBar(this);
panel->setFixedHeight(30);
panel->setAutoFillBackground(true);
panel->setStyleSheet("QMenuBar { background-color: #f3f2f1; } QMenuBar::item { background-color: #f3f2f1; }");
//panel->setStyleSheet("QMenuBar::item { icon-size: 32px; } ");
//panel->setStyleSheet("QMenuBar::button { background-color: #ffffff; }");*/
addWidget(panel);
addWidget(teMessage);
smileMenu = new QMenu("Smiles");
smileMenu->setIcon(QPixmap::fromImage(smiles->copy(w, 0, w, h)));
smileMenu->setStyleSheet("QMenu { background-color: #ffffff;}");
QGridLayout *lytSmiles = new QGridLayout(smileMenu);
QPalette palw;
palw.setBrush(smileMenu->backgroundRole(), Qt::white);
smileMenu->setAutoFillBackground(true);
smileMenu->setPalette(palw);
for (int i = 0; i < W_CNT; ++i)
for (int j = 0; j < H_CNT; ++j) {
QImage icon = smiles->copy(j * w, i * h, w, h);
SmileButton *but = new SmileButton(icon, W_CNT * i + j);
connect(but, SIGNAL(clicked()), this, SLOT(slotSmilesClicked()));
lytSmiles->addWidget(but, i, j);
//teMessage->document()->addResource(QTextDocument::ImageResource, QUrl(but->name()), smiles->copy(j * w, i * h, w, h));
//teHistory->document()->addResource(QTextDocument::ImageResource, QUrl(but->name()), smiles->copy(j * w, i * h, w, h));
}
reloadResource(message());
smileMenu->setFixedSize(lytSmiles->sizeHint());
lwHistory->scrollToBottom();
connect(&tmrNotActive, SIGNAL(timeout()), this, SLOT(slotNotActiveBehav()));
connect(teMessage, SIGNAL(gotFocus()), this, SLOT(slotFinishReadMessage()));
connect(teMessage, SIGNAL(lostFocus()), this, SLOT(slotNotActiveBehav()));
}
示例4: setupEditActions
void TextEdit::setupEditActions()
{
QToolBar *tb = new QToolBar(this);
tb->setWindowTitle(tr("Edit Actions"));
addToolBar(tb);
QMenu *menu = new QMenu(tr("&Edit"), this);
menuBar()->addMenu(menu);
QAction *a;
a = actionUndo = new QAction(QIcon(":/res/smallUndo.png"),tr("&Undo"), this);
a->setShortcut(QKeySequence::Undo);
tb->addAction(a);
menu->addAction(a);
a = actionRedo = new QAction(QIcon(":/res/smallRedo.png"), tr("&Redo"), this);
a->setPriority(QAction::LowPriority);
a->setShortcut(QKeySequence::Redo);
tb->addAction(a);
menu->addAction(a);
menu->addSeparator();
a = actionCut = new QAction(QIcon(":/res/smallcut.png"),tr("Cu&t"), this);
a->setPriority(QAction::LowPriority);
a->setShortcut(QKeySequence::Cut);
tb->addAction(a);
menu->addAction(a);
a = actionCopy = new QAction(QIcon(":/res/smallcopy.png"), tr("&Copy"), this);
a->setPriority(QAction::LowPriority);
a->setShortcut(QKeySequence::Copy);
tb->addAction(a);
menu->addAction(a);
a = actionPaste = new QAction(QIcon(":/res/smallpaste.png"), tr("&Paste"), this);
a->setPriority(QAction::LowPriority);
a->setShortcut(QKeySequence::Paste);
tb->addAction(a);
menu->addAction(a);
#ifndef QT_NO_CLIPBOARD
actionPaste->setEnabled(!QApplication::clipboard()->text().isEmpty());
#endif
}
示例5: setupFileActions
void TextEdit::setupFileActions()
{
QToolBar *tb = new QToolBar(this);
tb->setWindowTitle(tr("File Actions"));
addToolBar(tb);
QMenu *menu = new QMenu(tr("&File"), this);
menuBar()->addMenu(menu);
QAction *a;
QIcon newIcon = QIcon::fromTheme("document-new", QIcon(rsrcPath + "/filenew.png"));
a = new QAction( newIcon, tr("&New"), this);
a->setPriority(QAction::LowPriority);
a->setShortcut(QKeySequence::New);
connect(a, SIGNAL(triggered()), this, SLOT(fileNew()));
tb->addAction(a);
menu->addAction(a);
a = new QAction(QIcon::fromTheme("document-open", QIcon(rsrcPath + "/fileopen.png")),
tr("&Open..."), this);
a->setShortcut(QKeySequence::Open);
connect(a, SIGNAL(triggered()), this, SLOT(fileOpen()));
tb->addAction(a);
menu->addAction(a);
menu->addSeparator();
actionSave = a = new QAction(QIcon::fromTheme("document-save", QIcon(rsrcPath + "/filesave.png")),
tr("&Save"), this);
a->setShortcut(QKeySequence::Save);
connect(a, SIGNAL(triggered()), this, SLOT(fileSave()));
a->setEnabled(false);
tb->addAction(a);
menu->addAction(a);
menu->addSeparator();
a = new QAction(tr("Save &As ODT..."), this);
a->setPriority(QAction::LowPriority);
connect(a, SIGNAL(triggered()), this, SLOT(fileSaveAsOdt()));
menu->addAction(a);
a = new QAction(tr("Save &As HTML..."), this);
a->setPriority(QAction::LowPriority);
connect(a, SIGNAL(triggered()), this, SLOT(fileSaveAsHtml()));
menu->addAction(a);
menu->addSeparator();
#ifndef QT_NO_PRINTER
//a = new QAction(QIcon::fromTheme("document-print", QIcon(rsrcPath + "/fileprint.png")),
// tr("&Print..."), this);
//a->setPriority(QAction::LowPriority);
//a->setShortcut(QKeySequence::Print);
//connect(a, SIGNAL(triggered()), this, SLOT(filePrint()));
//tb->addAction(a);
//menu->addAction(a);
//a = new QAction(QIcon::fromTheme("fileprint", QIcon(rsrcPath + "/fileprint.png")),
// tr("Print Preview..."), this);
//connect(a, SIGNAL(triggered()), this, SLOT(filePrintPreview()));
//menu->addAction(a);
a = new QAction(QIcon::fromTheme("exportpdf", QIcon(rsrcPath + "/exportpdf.png")),
tr("&Export PDF..."), this);
a->setPriority(QAction::LowPriority);
a->setShortcut(Qt::CTRL + Qt::Key_D);
connect(a, SIGNAL(triggered()), this, SLOT(filePrintPdf()));
tb->addAction(a);
menu->addAction(a);
menu->addSeparator();
#endif
a = new QAction(tr("&Quit"), this);
a->setShortcut(Qt::CTRL + Qt::Key_Q);
connect(a, SIGNAL(triggered()), this, SLOT(close()));
menu->addAction(a);
}
示例6: PlaylistBrowserCategory
PodcastCategory::PodcastCategory( QWidget *parent )
: PlaylistBrowserCategory( Playlists::PodcastChannelPlaylist,
"podcasts",
s_configGroup,
The::podcastModel(),
parent )
{
setPrettyName( i18n( "Podcasts" ) );
setShortDescription( i18n( "List of podcast subscriptions and episodes" ) );
setIcon( KIcon( "podcast-amarok" ) );
setLongDescription( i18n( "Manage your podcast subscriptions and browse individual episodes. "
"Downloading episodes to the disk is also done here, or you can tell "
"Amarok to do this automatically." ) );
setImagePath( KStandardDirs::locate( "data", "amarok/images/hover_info_podcasts.png" ) );
// set background
if( AmarokConfig::showBrowserBackgroundImage() )
setBackgroundImage( imagePath() );
QAction *addPodcastAction = new QAction( KIcon( "list-add-amarok" ), i18n("&Add Podcast"),
m_toolBar );
addPodcastAction->setPriority( QAction::NormalPriority );
m_toolBar->insertAction( m_separator, addPodcastAction );
connect( addPodcastAction, SIGNAL(triggered( bool )), The::podcastModel(), SLOT(addPodcast()) );
QAction *updateAllAction = new QAction( KIcon("view-refresh-amarok"), QString(), m_toolBar );
updateAllAction->setToolTip( i18n("&Update All") );
updateAllAction->setPriority( QAction::LowPriority );
m_toolBar->insertAction( m_separator, updateAllAction );
connect( updateAllAction, SIGNAL(triggered( bool )),
The::podcastModel(), SLOT(refreshPodcasts()) );
QAction *importOpmlAction = new QAction( KIcon("document-import")
, i18n( "Import OPML File" )
, m_toolBar
);
importOpmlAction->setToolTip( i18n( "Import OPML File" ) );
importOpmlAction->setPriority( QAction::LowPriority );
m_toolBar->addAction( importOpmlAction );
connect( importOpmlAction, SIGNAL( triggered() ), SLOT( slotImportOpml() ) );
PlaylistBrowserView *view = static_cast<PlaylistBrowserView*>( playlistView() );
connect( view, SIGNAL(currentItemChanged(QModelIndex)), SLOT(showInfo(QModelIndex)) );
//transparency
// QPalette p = m_podcastTreeView->palette();
// QColor c = p.color( QPalette::Base );
// c.setAlpha( 0 );
// p.setColor( QPalette::Base, c );
//
// c = p.color( QPalette::AlternateBase );
// c.setAlpha( 77 );
// p.setColor( QPalette::AlternateBase, c );
//
// m_podcastTreeView->setPalette( p );
//
// QSizePolicy sizePolicy1(QSizePolicy::MinimumExpanding, QSizePolicy::Expanding);
// sizePolicy1.setHorizontalStretch(0);
// sizePolicy1.setVerticalStretch(0);
// sizePolicy1.setHeightForWidth(m_podcastTreeView->sizePolicy().hasHeightForWidth());
// m_podcastTreeView->setSizePolicy(sizePolicy1);
}
示例7: redoIcon
MainWindow::MainWindow(QWidget *parent, Qt::WFlags flags)
: QMainWindow(parent, flags)
, mUi(new Ui::MainWindow)
, mMapDocument(0)
, mActionHandler(new MapDocumentActionHandler(this))
, mLayerDock(new LayerDock(this))
, mTilesetDock(new TilesetDock(this))
, mZoomLabel(new QLabel)
, mStatusInfoLabel(new QLabel)
, mClipboardManager(new ClipboardManager(this))
, mDocumentManager(DocumentManager::instance())
{
mUi->setupUi(this);
setCentralWidget(mDocumentManager->widget());
PluginManager::instance()->loadPlugins();
#ifdef Q_WS_MAC
MacSupport::addFullscreen(this);
#endif
Preferences *preferences = Preferences::instance();
QIcon redoIcon(QLatin1String(":images/16x16/edit-redo.png"));
QIcon undoIcon(QLatin1String(":images/16x16/edit-undo.png"));
QIcon tiledIcon(QLatin1String(":images/tiled-icon-16.png"));
tiledIcon.addFile(QLatin1String(":images/tiled-icon-32.png"));
setWindowIcon(tiledIcon);
// Add larger icon versions for actions used in the tool bar
QIcon newIcon = mUi->actionNew->icon();
QIcon openIcon = mUi->actionOpen->icon();
QIcon saveIcon = mUi->actionSave->icon();
newIcon.addFile(QLatin1String(":images/24x24/document-new.png"));
openIcon.addFile(QLatin1String(":images/24x24/document-open.png"));
saveIcon.addFile(QLatin1String(":images/24x24/document-save.png"));
redoIcon.addFile(QLatin1String(":images/24x24/edit-redo.png"));
undoIcon.addFile(QLatin1String(":images/24x24/edit-undo.png"));
mUi->actionNew->setIcon(newIcon);
mUi->actionOpen->setIcon(openIcon);
mUi->actionSave->setIcon(saveIcon);
QUndoGroup *undoGroup = mDocumentManager->undoGroup();
QAction *undoAction = undoGroup->createUndoAction(this, tr("Undo"));
QAction *redoAction = undoGroup->createRedoAction(this, tr("Redo"));
mUi->mainToolBar->setToolButtonStyle(Qt::ToolButtonFollowStyle);
mUi->actionNew->setPriority(QAction::LowPriority);
redoAction->setPriority(QAction::LowPriority);
redoAction->setIcon(redoIcon);
undoAction->setIcon(undoIcon);
redoAction->setIconText(tr("Redo"));
undoAction->setIconText(tr("Undo"));
connect(undoGroup, SIGNAL(cleanChanged(bool)), SLOT(updateWindowTitle()));
UndoDock *undoDock = new UndoDock(undoGroup, this);
addDockWidget(Qt::RightDockWidgetArea, mLayerDock);
addDockWidget(Qt::RightDockWidgetArea, undoDock);
tabifyDockWidget(undoDock, mLayerDock);
addDockWidget(Qt::RightDockWidgetArea, mTilesetDock);
statusBar()->addPermanentWidget(mZoomLabel);
mUi->actionNew->setShortcuts(QKeySequence::New);
mUi->actionOpen->setShortcuts(QKeySequence::Open);
mUi->actionSave->setShortcuts(QKeySequence::Save);
mUi->actionSaveAs->setShortcuts(QKeySequence::SaveAs);
mUi->actionClose->setShortcuts(QKeySequence::Close);
mUi->actionQuit->setShortcuts(QKeySequence::Quit);
mUi->actionCut->setShortcuts(QKeySequence::Cut);
mUi->actionCopy->setShortcuts(QKeySequence::Copy);
mUi->actionPaste->setShortcuts(QKeySequence::Paste);
mUi->actionDelete->setShortcuts(QKeySequence::Delete);
undoAction->setShortcuts(QKeySequence::Undo);
redoAction->setShortcuts(QKeySequence::Redo);
mUi->actionShowGrid->setChecked(preferences->showGrid());
mUi->actionSnapToGrid->setChecked(preferences->snapToGrid());
mUi->actionHighlightCurrentLayer->setChecked(preferences->highlightCurrentLayer());
// Make sure Ctrl+= also works for zooming in
QList<QKeySequence> keys = QKeySequence::keyBindings(QKeySequence::ZoomIn);
keys += QKeySequence(tr("Ctrl+="));
keys += QKeySequence(tr("+"));
mUi->actionZoomIn->setShortcuts(keys);
keys = QKeySequence::keyBindings(QKeySequence::ZoomOut);
keys += QKeySequence(tr("-"));
mUi->actionZoomOut->setShortcuts(keys);
mUi->menuEdit->insertAction(mUi->actionCut, undoAction);
mUi->menuEdit->insertAction(mUi->actionCut, redoAction);
mUi->menuEdit->insertSeparator(mUi->actionCut);
mUi->menuEdit->insertAction(mUi->actionPreferences,
mActionHandler->actionSelectAll());
mUi->menuEdit->insertAction(mUi->actionPreferences,
mActionHandler->actionSelectNone());
mUi->menuEdit->insertSeparator(mUi->actionPreferences);
mUi->mainToolBar->addAction(undoAction);
mUi->mainToolBar->addAction(redoAction);
//.........这里部分代码省略.........
示例8: redoIcon
MainWindow::MainWindow(QWidget *parent, Qt::WindowFlags flags)
: QMainWindow(parent, flags)
, mUi(new Ui::MainWindow)
, mMapDocument(0)
, mActionHandler(new MapDocumentActionHandler(this))
, mMapsDock(new MapsDock(this))
, mTilesetDock(new TilesetDock(this))
, mMiniMapDock(new MiniMapDock(this))
, mZoomable(0)
, mZoomComboBox(new QComboBox)
, mStatusInfoLabel(new QLabel)
, mValidationErrorWidget(new QWidget)
, mValidationErrorLabel(new QLabel)
, mDocumentManager(DocumentManager::instance())
, mQuickStampManager(new QuickStampManager(this))
, mToolManager(new ToolManager(this))
, mKodableMapValidator(new KodableMapValidator(this))
{
mUi->setupUi(this);
setCentralWidget(mDocumentManager->widget());
#ifdef Q_OS_MAC
MacSupport::addFullscreen(this);
#endif
Preferences *preferences = Preferences::instance();
QIcon redoIcon(QLatin1String(":images/16x16/edit-redo.png"));
QIcon undoIcon(QLatin1String(":images/16x16/edit-undo.png"));
QIcon windowIcon(QLatin1String(":images/kodable-editor-icon.png"));
setWindowIcon(windowIcon);
// Add larger icon versions for actions used in the tool bar
QIcon newIcon = mUi->actionNew->icon();
QIcon openIcon = mUi->actionOpen->icon();
QIcon saveIcon = mUi->actionSave->icon();
newIcon.addFile(QLatin1String(":images/24x24/document-new.png"));
openIcon.addFile(QLatin1String(":images/24x24/document-open.png"));
saveIcon.addFile(QLatin1String(":images/24x24/document-save.png"));
redoIcon.addFile(QLatin1String(":images/24x24/edit-redo.png"));
undoIcon.addFile(QLatin1String(":images/24x24/edit-undo.png"));
mUi->actionNew->setIcon(newIcon);
mUi->actionOpen->setIcon(openIcon);
mUi->actionSave->setIcon(saveIcon);
QUndoGroup *undoGroup = mDocumentManager->undoGroup();
QAction *undoAction = undoGroup->createUndoAction(this, tr("Undo"));
QAction *redoAction = undoGroup->createRedoAction(this, tr("Redo"));
mUi->mainToolBar->setToolButtonStyle(Qt::ToolButtonFollowStyle);
mUi->actionNew->setPriority(QAction::LowPriority);
redoAction->setPriority(QAction::LowPriority);
redoAction->setIcon(redoIcon);
undoAction->setIcon(undoIcon);
redoAction->setIconText(tr("Redo"));
undoAction->setIconText(tr("Undo"));
connect(undoGroup, SIGNAL(cleanChanged(bool)), SLOT(updateWindowTitle()));
UndoDock *undoDock = new UndoDock(undoGroup, this);
PropertiesDock *propertiesDock = new PropertiesDock(this);
addDockWidget(Qt::LeftDockWidgetArea, undoDock);
addDockWidget(Qt::LeftDockWidgetArea, mMapsDock);
addDockWidget(Qt::RightDockWidgetArea, mMiniMapDock);
addDockWidget(Qt::RightDockWidgetArea, mTilesetDock);
addDockWidget(Qt::RightDockWidgetArea, propertiesDock);
tabifyDockWidget(undoDock, mMapsDock);
// These dock widgets may not be immediately useful to many people, so
// they are hidden by default.
undoDock->setVisible(false);
mMapsDock->setVisible(false);
mMiniMapDock->setVisible(false);
QHBoxLayout *errorBoxLayout = new QHBoxLayout;
QLabel *iconLabel = new QLabel;
iconLabel->setPixmap(QPixmap(QLatin1String(":images/16x16/dialog-warning.png")));
errorBoxLayout->addWidget(iconLabel);
errorBoxLayout->addWidget(mValidationErrorLabel);
mValidationErrorWidget->setLayout(errorBoxLayout);
mValidationErrorWidget->setVisible(false);
statusBar()->addPermanentWidget(mValidationErrorWidget);
statusBar()->addPermanentWidget(mZoomComboBox);
mUi->actionNew->setShortcuts(QKeySequence::New);
mUi->actionOpen->setShortcuts(QKeySequence::Open);
mUi->actionSave->setShortcuts(QKeySequence::Save);
mUi->actionSaveAs->setShortcuts(QKeySequence::SaveAs);
mUi->actionClose->setShortcuts(QKeySequence::Close);
mUi->actionQuit->setShortcuts(QKeySequence::Quit);
mUi->actionCut->setShortcuts(QKeySequence::Cut);
mUi->actionCopy->setShortcuts(QKeySequence::Copy);
mUi->actionPaste->setShortcuts(QKeySequence::Paste);
mUi->actionDelete->setShortcuts(QKeySequence::Delete);
undoAction->setShortcuts(QKeySequence::Undo);
redoAction->setShortcuts(QKeySequence::Redo);
mUi->actionShowGrid->setChecked(preferences->showGrid());
//.........这里部分代码省略.........
示例9: setupFileActions
void TextEdit::setupFileActions()
{
standardToolBar = new QToolBar(this);
standardToolBar->setWindowTitle(tr("File Actions"));
addToolBar(standardToolBar);
QMenu *menu = new QMenu(tr("&File"), this);
menuBar()->addMenu(menu);
QAction *a;
a = new QAction( QIcon(":/res/smallNew.png"), tr("&New"), this);
a->setPriority(QAction::LowPriority);
a->setShortcut(QKeySequence::New);
connect(a, SIGNAL(triggered()), this, SLOT(fileNew()));
standardToolBar->addAction(a);
menu->addAction(a);
a = new QAction(QIcon(":/res/smallOpen.png"), tr("&Open..."), this);
a->setShortcut(QKeySequence::Open);
connect(a, SIGNAL(triggered()), this, SLOT(fileOpen()));
standardToolBar->addAction(a);
menu->addAction(a);
menu->addSeparator();
actionSave = a = new QAction(QIcon(":/res/smallSave.png"),tr("&Save"), this);
a->setShortcut(QKeySequence::Save);
connect(a, SIGNAL(triggered()), this, SLOT(fileSave()));
a->setEnabled(false);
standardToolBar->addAction(a);
menu->addAction(a);
a = new QAction(tr("Save &As..."), this);
a->setPriority(QAction::LowPriority);
connect(a, SIGNAL(triggered()), this, SLOT(fileSaveAs()));
menu->addAction(a);
menu->addSeparator();
#ifndef QT_NO_PRINTER
a = new QAction(QIcon(":/res/smallPrint.png"),tr("&Print..."), this);
a->setPriority(QAction::LowPriority);
a->setShortcut(QKeySequence::Print);
connect(a, SIGNAL(triggered()), this, SLOT(filePrint()));
standardToolBar->addAction(a);
menu->addAction(a);
a = new QAction(QIcon(":/res/smallPrintPreview.png"),tr("Print Preview..."), this);
connect(a, SIGNAL(triggered()), this, SLOT(filePrintPreview()));
menu->addAction(a);
a = new QAction(QIcon(":/res/smallSavePDF.png"),tr("&Export PDF..."), this);
a->setPriority(QAction::LowPriority);
a->setShortcut(Qt::CTRL + Qt::Key_D);
connect(a, SIGNAL(triggered()), this, SLOT(filePrintPdf()));
standardToolBar->addAction(a);
menu->addAction(a);
menu->addSeparator();
#endif
a = new QAction(tr("&Quit"), this);
a->setShortcut(Qt::CTRL + Qt::Key_Q);
connect(a, SIGNAL(triggered()), this, SLOT(close()));
menu->addAction(a);
}
示例10: setupFileActions
void BrailleMusicEditor::setupFileActions() {
auto tb = new QToolBar(this);
tb->setWindowTitle(tr("File Actions"));
addToolBar(tb);
auto menu = new QMenu(tr("&File"), this);
menuBar()->addMenu(menu);
QAction *a;
auto newIcon = QIcon::fromTheme("document-new");
a = new QAction(newIcon, tr("&New"), this);
a->setPriority(QAction::LowPriority);
a->setShortcut(QKeySequence::New);
connect(a, &QAction::triggered, this, &BrailleMusicEditor::fileNew);
tb->addAction(a);
menu->addAction(a);
a = new QAction(QIcon::fromTheme("document-open"), tr("&Open..."), this);
a->setShortcut(QKeySequence::Open);
connect(a, &QAction::triggered, this, &BrailleMusicEditor::fileOpen);
tb->addAction(a);
menu->addAction(a);
menu->addSeparator();
actionSave = a =
new QAction(QIcon::fromTheme("document-save"), tr("&Save"), this);
a->setShortcut(QKeySequence::Save);
connect(a, &QAction::triggered, this, &BrailleMusicEditor::fileSave);
a->setEnabled(false);
tb->addAction(a);
menu->addAction(a);
a = new QAction(tr("Save &As..."), this);
a->setPriority(QAction::LowPriority);
connect(a, &QAction::triggered, this, &BrailleMusicEditor::fileSaveAs);
menu->addAction(a);
menu->addSeparator();
a = new QAction(tr("&Compile"), this);
a->setPriority(QAction::LowPriority);
a->setShortcut(Qt::Key_F8);
connect(a, &QAction::triggered, this, &BrailleMusicEditor::fileCompile);
menu->addAction(a);
a = new QAction(tr("Export &MusicXML"), this);
a->setPriority(QAction::LowPriority);
connect(a, &QAction::triggered, this,
&BrailleMusicEditor::fileExportMusicXML);
a->setEnabled(false);
connect(this, &BrailleMusicEditor::scoreAvailable, a, &QAction::setEnabled);
menu->addAction(a);
a = new QAction(tr("Export &LilyPond"), this);
a->setPriority(QAction::LowPriority);
connect(a, &QAction::triggered, this,
&BrailleMusicEditor::fileExportLilyPond);
a->setEnabled(false);
connect(this, &BrailleMusicEditor::scoreAvailable, a, &QAction::setEnabled);
menu->addAction(a);
menu->addSeparator();
a = new QAction(tr("&Quit"), this);
a->setShortcut(Qt::CTRL + Qt::Key_Q);
connect(a, &QAction::triggered, this, &BrailleMusicEditor::close);
menu->addAction(a);
connect(this, &BrailleMusicEditor::scoreAvailable,
this, &BrailleMusicEditor::runLilyPond);
}