本文整理汇总了C++中QAction::setIconText方法的典型用法代码示例。如果您正苦于以下问题:C++ QAction::setIconText方法的具体用法?C++ QAction::setIconText怎么用?C++ QAction::setIconText使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QAction
的用法示例。
在下文中一共展示了QAction::setIconText方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: saveActions
QStringList TToolbarEditor::saveActions() {
logger()->debug("saveActions");
QStringList list;
for (int row = 0; row < active_actions_table->rowCount(); row++) {
QTableWidgetItem* item = active_actions_table->item(row, COL_NAME);
if (item) {
QString action_name = item->text();
if (action_name.startsWith("separator")) {
action_name = "separator";
}
QString s = action_name;
bool ns = getVis(row, COL_NS);
bool fs = getVis(row, COL_FS);
if (ns) {
if (!fs) {
s += "|1|0";
}
} else if (fs) {
s += "|0|1";
} else {
s += "|0|0";
}
list << s;
if (action_name != "separator") {
// Update icon text
QAction* action = findAction(action_name, *all_actions);
if (action) {
item = active_actions_table->item(row, COL_DESC);
if (item) {
QString action_icon_text = TActionsEditor::actionTextToDescription(
item->text(), action_name).trimmed();
if (!action_icon_text.isEmpty()) {
QString action_text = TActionsEditor::actionTextToDescription(action->text(), action_name);
if (action_text != action_icon_text) {
action->setIconText(action_icon_text);
action->setProperty("modified", true);
logger()->debug("saveActions: updated icon text '"
+ action_name + "' to '" + action_icon_text
+ "'");
} else {
action_icon_text = TActionsEditor::actionTextToDescription(action->iconText(), action_name);
if (action_icon_text != action_text) {
action->setIconText(action_text);
logger()->debug("saveActions: cleared icon text "
+ action_name);
}
}
}
}
}
}
}
}
return list;
}
示例2: if
void
Viewer::treeContextMenu(const QPoint& pos)
{
QPoint globalPos = this->ui.repoView->viewport()->mapToGlobal(pos);
QAction* selectedItem = treeMenu.exec(globalPos);
if (selectedItem) {
if (selectedItem->iconText() == EXPAND_ACTION)
{
expand(true);
selectedItem->setText(COLLAPSE_ACTION);
selectedItem->setIconText(COLLAPSE_ACTION);
}
else if (selectedItem->iconText() == COLLAPSE_ACTION)
{
expand(false);
selectedItem->setText(EXPAND_ACTION);
selectedItem->setIconText(EXPAND_ACTION);
}
else if (selectedItem->iconText() == SELECTION_TO_NODE_VIEW ||
selectedItem->iconText() == SELECTION_TO_GRAPH_VIEW)
{
// reset all the display flags
this->dataSource_->modelRoot()->resetDisplays();
QModelIndexList q = this->ui.repoView->selectionModel()->selectedRows();
for (int c = 0; c < q.size(); ++c) {
// get the node and set the display flag
TreeNode *t = model_->getNode(q[c]);
t->setDisplay(true);
}
if (selectedItem->iconText() == SELECTION_TO_NODE_VIEW)
{
updateNodeView(true);
}
else {
updateGraphView(true);
}
}
else if (selectedItem->iconText() == NODE_VIEW_OPTIONS_ACTION)
{
showNodeOptions();
}
else if (selectedItem->iconText() == GRAPH_OPTIONS_ACTION)
{
showGraphOptions();
}
}
}
示例3: accel
void tst_QToolBar::accel()
{
#ifdef Q_WS_MAC
extern void qt_set_sequence_auto_mnemonic(bool b);
qt_set_sequence_auto_mnemonic(true);
#endif
QMainWindow mw;
QToolBar *toolBar = mw.addToolBar("test");
QAction *action = toolBar->addAction("&test");
action->setIconText(action->text()); // we really want that mnemonic in the button!
QSignalSpy spy(action, SIGNAL(triggered(bool)));
mw.show();
QApplication::setActiveWindow(&mw);
QTest::qWait(100);
QTRY_COMPARE(QApplication::activeWindow(), static_cast<QWidget *>(&mw));
QTest::keyClick(&mw, Qt::Key_T, Qt::AltModifier);
QTest::qWait(300);
QTRY_COMPARE(spy.count(), 1);
#ifdef Q_WS_MAC
qt_set_sequence_auto_mnemonic(false);
#endif
}
示例4: QWidget
NoteDialog::NoteDialog(Note *note) : QWidget()
{
setWindowTitle(note == 0 ? "Nouvelle note" : note->title());
// Récupération des options
m_settings = new QSettings("yellownote.ini", QSettings::IniFormat);
// Création des champs title et content
m_noteEdit = new NoteEdit(m_settings, this);
m_note = note;
// Assignation du dialog à la note
attachToNote();
// Si on est en modification, on remplit les champs
if (note != 0)
{
m_noteEdit->update(note->title(), note->content());
}
QAction *actionInfos = new QAction("&Infos", this);
actionInfos->setIcon(QIcon(":/note/infos"));
actionInfos->setIconText("Infos");
connect(actionInfos, SIGNAL(triggered()), this, SLOT(infos()));
m_actionDelete = new QAction("&Supprimer", this);
m_actionDelete->setIcon(QIcon(":/note/delete"));
m_actionDelete->setIconText("Supprimer");
connect(m_actionDelete, SIGNAL(triggered()), this, SLOT(deleteMe()));
QWidget *spacerWidget = new QWidget(this);
spacerWidget->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred);
spacerWidget->setVisible(true);
QToolBar *toolBar = new QToolBar;
toolBar->setToolButtonStyle(Qt::ToolButtonTextBesideIcon);
toolBar->addWidget(spacerWidget);
toolBar->addAction(actionInfos);
toolBar->addAction(m_actionDelete);
QVBoxLayout *mainLayout = new QVBoxLayout;
mainLayout->setMargin(0);
mainLayout->setSpacing(0);
mainLayout->addWidget(toolBar);
mainLayout->addWidget(m_noteEdit);
setLayout(mainLayout);
// Réassignation de la taille de la fenêtre
if (m_settings->contains("note/size"))
{
resize(m_settings->value("note/size").toSize());
}
// Donne le focus à la fenêtre (quand elle est créée
// depuis un raccouri clavier global)
setFocus();
}
示例5: CellToolBase
TableTool::TableTool(KoCanvasBase* canvas)
: CellToolBase(canvas)
, d(new Private)
{
setObjectName(QLatin1String("TableTool"));
d->selection = new Selection(canvas);
d->tableShape = 0;
QAction* importAction = new QAction(koIcon("document-import"), i18n("Import OpenDocument Spreadsheet File"), this);
importAction->setIconText(i18n("Import"));
addAction("import", importAction);
connect(importAction, SIGNAL(triggered()), this, SLOT(importDocument()));
QAction* exportAction = new QAction(koIcon("document-export"), i18n("Export OpenDocument Spreadsheet File"), this);
exportAction->setIconText(i18n("Export"));
addAction("export", exportAction);
connect(exportAction, SIGNAL(triggered()), this, SLOT(exportDocument()));
}
示例6: buildToolBar
void MainWindow::buildToolBar()
{
m_fileToolBar = addToolBar("File Tool Bar");
m_fileToolBar->setMovable(true);
QAction * newSystemAction = new QAction(QIcon("Icons/New.png"), "New", this);
connect(newSystemAction, SIGNAL(triggered()), m_system, SLOT(newSystem()));
QAction * openSystemAction = new QAction(QIcon("Icons/Open.png"), "Open", this);
connect(openSystemAction, SIGNAL(triggered()), m_system, SLOT(openSystem()));
QAction * saveSystemAction = new QAction(QIcon("Icons/Save.png"), "Save", this);
connect(saveSystemAction, SIGNAL(triggered()), m_system, SLOT(saveSystem()));
QAction * saveSystemAsAction = new QAction(QIcon("Icons/SaveAs.png"), QString::fromUtf8("Save As\u2026"), this);
saveSystemAsAction->setIconText("AA");
connect(saveSystemAsAction, SIGNAL(triggered()), m_system, SLOT(saveSystemAs()));
m_fileToolBar->addAction(newSystemAction);
m_fileToolBar->addAction(openSystemAction);
m_fileToolBar->addAction(saveSystemAction);
m_fileToolBar->addAction(saveSystemAsAction);
m_deviceToolBar = addToolBar("Device Tool Bar");
m_deviceToolBar->setMovable(true);
QAction * addPlaneMirrorAction = new QAction(QIcon("Icons/PlaneMirror.png"), "Add Plane Mirror", this);
connect(addPlaneMirrorAction, SIGNAL(triggered()), m_system, SLOT(addPlaneMirror()));
QAction * addConcaveMirrorAction = new QAction(QIcon("Icons/ConcaveMirror.png"), "Add Concave Mirror", this);
connect(addConcaveMirrorAction, SIGNAL(triggered()), m_system, SLOT(addConcaveMirror()));
QAction * addDiffractionGratingAction = new QAction(QIcon("Icons/DiffractionGrating.png"), "Add Diffraction Grating", this);
connect(addDiffractionGratingAction, SIGNAL(triggered()), m_system, SLOT(addDiffractionGrating()));
QAction * addSlitAction = new QAction(QIcon("Icons/Slit.png"), "Add Slit", this);
connect(addSlitAction, SIGNAL(triggered()), m_system, SLOT(addSlit()));
QAction * addPointSourceAction = new QAction(QIcon("Icons/PointSource.png"), "Add Point Source", this);
connect(addPointSourceAction, SIGNAL(triggered()), m_system, SLOT(addPointSource()));
QAction * removeReflectorAction = new QAction(QIcon("Icons/RemoveReflector.png"), "Remove Reflector", this);
connect(removeReflectorAction, SIGNAL(triggered()), m_system, SLOT(removeReflector()));
QAction * removeLightSourceAction = new QAction(QIcon("Icons/RemoveLightSource.png"), "Remove Light Source", this);
connect(removeLightSourceAction, SIGNAL(triggered()), m_system, SLOT(removeLightSource()));
m_deviceToolBar->addAction(addPlaneMirrorAction);
m_deviceToolBar->addAction(addConcaveMirrorAction);
m_deviceToolBar->addAction(addDiffractionGratingAction);
m_deviceToolBar->addAction(addSlitAction);
m_deviceToolBar->addSeparator();
m_deviceToolBar->addAction(addPointSourceAction);
m_deviceToolBar->addSeparator();
m_deviceToolBar->addAction(removeReflectorAction);
m_deviceToolBar->addAction(removeLightSourceAction);
m_zoomToolBar = addToolBar("Zoom Tool Bar");
m_zoomToolBar->setMovable(true);
ZoomWidget * zoomWidget = new ZoomWidget(this);
connect(zoomWidget, SIGNAL(valueChanged(int)), m_system, SLOT(zoom(int)));
m_zoomToolBar->addAction(QIcon("Icons/ZoomIn.png"), "Zoom In", zoomWidget, SLOT(stepUp()));
m_zoomToolBar->addWidget(zoomWidget);
m_zoomToolBar->addAction(QIcon("Icons/ZoomOut.png"), "Zoom Out", zoomWidget, SLOT(stepDown()));
}
示例7: BaseClass
ExplorerServerTreeItem::ExplorerServerTreeItem(QTreeWidget *view,MongoServer *const server) : BaseClass(view),
_server(server),
_bus(AppRegistry::instance().bus())
{
QAction *openShellAction = new QAction("Open Shell", this);
openShellAction->setIcon(GuiRegistry::instance().mongodbIcon());
VERIFY(connect(openShellAction, SIGNAL(triggered()), SLOT(ui_openShell())));
QAction *refreshServer = new QAction("Refresh", this);
VERIFY(connect(refreshServer, SIGNAL(triggered()), SLOT(ui_refreshServer())));
QAction *createDatabase = new QAction("Create Database", this);
VERIFY(connect(createDatabase, SIGNAL(triggered()), SLOT(ui_createDatabase())));
QAction *serverStatus = new QAction("Server Status", this);
VERIFY(connect(serverStatus, SIGNAL(triggered()), SLOT(ui_serverStatus())));
QAction *serverVersion = new QAction("MongoDB Version", this);
VERIFY(connect(serverVersion, SIGNAL(triggered()), SLOT(ui_serverVersion())));
QAction *serverHostInfo = new QAction("Host Info", this);
VERIFY(connect(serverHostInfo, SIGNAL(triggered()), SLOT(ui_serverHostInfo())));
QAction *showLog = new QAction("Show Log", this);
VERIFY(connect(showLog, SIGNAL(triggered()), SLOT(ui_showLog())));
QAction *disconnectAction = new QAction("Disconnect", this);
disconnectAction->setIconText("Disconnect");
VERIFY(connect(disconnectAction, SIGNAL(triggered()), SLOT(ui_disconnectServer())));
BaseClass::_contextMenu->addAction(openShellAction);
BaseClass::_contextMenu->addAction(refreshServer);
BaseClass::_contextMenu->addSeparator();
BaseClass::_contextMenu->addAction(createDatabase);
BaseClass::_contextMenu->addAction(serverStatus);
BaseClass::_contextMenu->addAction(serverHostInfo);
BaseClass::_contextMenu->addAction(serverVersion);
BaseClass::_contextMenu->addSeparator();
BaseClass::_contextMenu->addAction(showLog);
BaseClass::_contextMenu->addAction(disconnectAction);
_bus->subscribe(this, DatabaseListLoadedEvent::Type, _server);
_bus->subscribe(this, MongoServerLoadingDatabasesEvent::Type, _server);
setText(0, buildServerName());
setIcon(0, GuiRegistry::instance().serverIcon());
setExpanded(false);
setChildIndicatorPolicy(QTreeWidgetItem::ShowIndicator);
}
示例8: add
void TasksViewer::add(const QString &iconName, QString text, QToolBar *toolBar,
const char *slot, QString iconText) {
#if QT_VERSION >= 0x050500
QAction *action = new QAction(
createQIconOnOffPNG(iconName.toLatin1().constData(), false), text, this);
#else
QAction *action = new QAction(
createQIconOnOffPNG(iconName.toAscii().constData(), false), text, this);
#endif
action->setIconText(iconText);
bool ret = connect(action, SIGNAL(triggered(bool)),
(TaskTreeModel *)m_treeView->model(), slot);
assert(ret);
toolBar->addAction(action);
m_actions.push_back(action);
}
示例9:
QAction *KUndoActions::createUndoAction(QUndoStack *undoStack, KActionCollection *actionCollection, const QString &actionName)
{
QAction *action = undoStack->createUndoAction(actionCollection);
if (actionName.isEmpty()) {
action->setObjectName(QLatin1String(KStandardAction::name(KStandardAction::Undo)));
} else {
action->setObjectName(actionName);
}
action->setIcon(KisIconUtils::loadIcon(QStringLiteral("edit-undo")));
action->setIconText(i18n("Undo"));
action->setShortcuts(KStandardShortcut::undo());
actionCollection->addAction(action->objectName(), action);
return action;
}
示例10:
QAction* KUndo2Stack::createUndoAction(KActionCollection* actionCollection, const QString& actionName)
{
QAction* action = KUndo2QStack::createUndoAction(actionCollection);
if (actionName.isEmpty()) {
action->setObjectName(KStandardAction::name(KStandardAction::Undo));
} else {
action->setObjectName(actionName);
}
action->setIcon(koIcon("edit-undo"));
action->setIconText(i18n("Undo"));
action->setShortcuts(KStandardShortcut::undo());
actionCollection->addAction(action->objectName(), action);
return action;
}
示例11: qWarning
Command *ActionManagerPrivate::registerOverridableAction(QAction *action, const QString &id, bool checkUnique)
{
OverrideableAction *a = 0;
const int uid = UniqueIDManager::instance()->uniqueIdentifier(id);
if (CommandPrivate * c = m_idCmdMap.value(uid, 0)) {
a = qobject_cast<OverrideableAction *>(c);
if (!a) {
qWarning() << "registerAction: id" << id << "is registered with a different command type.";
return c;
}
} else {
a = new OverrideableAction(uid);
m_idCmdMap.insert(uid, a);
}
if (!a->action()) {
QAction *baseAction = new QAction(m_mainWnd);
baseAction->setObjectName(id);
baseAction->setCheckable(action->isCheckable());
baseAction->setIcon(action->icon());
baseAction->setIconText(action->iconText());
baseAction->setText(action->text());
baseAction->setToolTip(action->toolTip());
baseAction->setStatusTip(action->statusTip());
baseAction->setWhatsThis(action->whatsThis());
baseAction->setChecked(action->isChecked());
baseAction->setSeparator(action->isSeparator());
baseAction->setShortcutContext(Qt::ApplicationShortcut);
baseAction->setEnabled(false);
baseAction->setParent(m_mainWnd);
#ifdef Q_WS_MAC
baseAction->setIconVisibleInMenu(false);
#endif
a->setAction(baseAction);
m_mainWnd->addAction(baseAction);
a->setKeySequence(a->keySequence());
a->setDefaultKeySequence(QKeySequence());
} else if (checkUnique) {
qWarning() << "registerOverridableAction: id" << id << "is already registered.";
}
return a;
}
示例12: Home
void pdp::MainWindow::setupUi() {
// Add back button
QPushButton* back = new QPushButton(QIcon(":/common/res/common/back.png"), QApplication::translate("MainWindow", "Zur\303\274ck", 0, QApplication::UnicodeUTF8));
ui_main.tabWidget->setCornerWidget(back, Qt::TopRightCorner);
QObject::connect(back, SIGNAL(clicked()), this, SLOT(onBack()));
// Add the "start" tab.
new pdp::Home(this->ui_main.tabWidget, this);
// Creates progressDialog
m_progressDialog = new QProgressDialog("", QString(), 0, 100, this);
m_progressDialog->setMinimumDuration(0);
//m_progressDialog->setWindowModality(Qt::WindowModal);
// Correction of automatic segmentation via 3d interactive segmentation
m_NumberOfInstancesOfThreeDEditing = 0;
QMenu *menuWerkzeug;
menuWerkzeug = new QMenu(ui_main.menubar);
menuWerkzeug->setObjectName(QString::fromUtf8("menuWerkzeug"));
menuWerkzeug->setTitle(QApplication::translate("MainWindow", "Werkzeug", 0, QApplication::UnicodeUTF8));
ui_main.menubar->addMenu(menuWerkzeug);
QAction *actionThreeDEditing = new QAction(this);
actionThreeDEditing->setObjectName(QString::fromUtf8("actionThreeDEditing"));
actionThreeDEditing->setIconText("3DEditing");
QIcon icn_menu;
icn_menu.addFile(":/threeDEditing/res/threeDEditing/Rubber-32.png");
actionThreeDEditing->setIcon(icn_menu);
menuWerkzeug->addAction(actionThreeDEditing);
QObject::connect(actionThreeDEditing, SIGNAL(triggered()), this, SLOT(CreateThreeDEditing()));
// AutoRun
if(AUTO_IMPORT == 1)
CreateThreeDEditing();
}
示例13: helper
ListView::ListView( QObject* parent, QWidget* parentWidget ) : View( parent ),
m_model( NULL ),
m_selectedIssueId( 0 ),
m_isRead( false ),
m_isSubscribed( false ),
m_isAdmin( false ),
m_hasIssues( false ),
m_currentViewId( 0 ),
m_searchColumn( Column_Name )
{
QAction* action;
action = new QAction( IconLoader::icon( "file-reload" ), tr( "&Update Folder" ), this );
action->setShortcut( QKeySequence::Refresh );
connect( action, SIGNAL( triggered() ), this, SLOT( updateFolder() ), Qt::QueuedConnection );
setAction( "updateFolder", action );
action = new QAction( IconLoader::icon( "issue-open" ), tr( "&Open Issue" ), this );
action->setShortcut( QKeySequence::Open );
connect( action, SIGNAL( triggered() ), this, SLOT( openIssue() ), Qt::QueuedConnection );
setAction( "openIssue", action );
action = new QAction( IconLoader::icon( "issue-new" ), tr( "&Add Issue..." ), this );
action->setShortcut( QKeySequence::New );
connect( action, SIGNAL( triggered() ), this, SLOT( addIssue() ), Qt::QueuedConnection );
setAction( "addIssue", action );
action = new QAction( IconLoader::icon( "edit-modify" ), tr( "&Edit Attributes..." ), this );
action->setShortcut( tr( "F2" ) );
connect( action, SIGNAL( triggered() ), this, SLOT( editIssue() ), Qt::QueuedConnection );
setAction( "editIssue", action );
action = new QAction( IconLoader::icon( "issue-clone" ), tr( "Clone Issue..." ), this );
connect( action, SIGNAL( triggered() ), this, SLOT( cloneIssue() ), Qt::QueuedConnection );
setAction( "cloneIssue", action );
action = new QAction( IconLoader::icon( "issue-move" ), tr( "&Move Issue..." ), this );
action->setIconText( tr( "Move" ) );
connect( action, SIGNAL( triggered() ), this, SLOT( moveIssue() ), Qt::QueuedConnection );
setAction( "moveIssue", action );
action = new QAction( IconLoader::icon( "edit-delete" ), tr( "&Delete Issue" ), this );
action->setIconText( tr( "Delete" ) );
action->setShortcut( QKeySequence::Delete );
connect( action, SIGNAL( triggered() ), this, SLOT( deleteIssue() ), Qt::QueuedConnection );
setAction( "deleteIssue", action );
action = new QAction( IconLoader::icon( "issue" ), tr( "Mark As Read" ), this );
connect( action, SIGNAL( triggered() ), this, SLOT( markAsRead() ), Qt::QueuedConnection );
setAction( "markAsRead", action );
action = new QAction( IconLoader::icon( "folder-read" ), tr( "Mark All As Read" ), this );
action->setIconText( tr( "Mark All As Read", "icon text" ) );
setAction( "popupMarkAll", action );
action = new QAction( IconLoader::icon( "folder-read" ), tr( "Mark All As Read" ), this );
connect( action, SIGNAL( triggered() ), this, SLOT( markAllAsRead() ), Qt::QueuedConnection );
setAction( "markAllAsRead", action );
action = new QAction( IconLoader::icon( "folder-unread" ), tr( "Mark All As Unread" ), this );
connect( action, SIGNAL( triggered() ), this, SLOT( markAllAsUnread() ), Qt::QueuedConnection );
setAction( "markAllAsUnread", action );
action = new QAction( IconLoader::icon( "issue-subscribe" ), tr( "Subscribe" ), this );
connect( action, SIGNAL( triggered() ), this, SLOT( subscribe() ), Qt::QueuedConnection );
setAction( "subscribe", action );
action = new QAction( IconLoader::icon( "file-print" ), tr( "Print List" ), this );
action->setIconText( tr( "Print" ) );
action->setShortcut( QKeySequence::Print );
connect( action, SIGNAL( triggered() ), this, SLOT( printReport() ), Qt::QueuedConnection );
setAction( "printReport", action );
action = new QAction( IconLoader::icon( "export-pdf" ), tr( "Export List" ), this );
action->setIconText( tr( "Export" ) );
setAction( "popupExport", action );
action = new QAction( IconLoader::icon( "export-csv" ), tr( "Export To CSV" ), this );
connect( action, SIGNAL( triggered() ), this, SLOT( exportCsv() ), Qt::QueuedConnection );
setAction( "exportCsv", action );
action = new QAction( IconLoader::icon( "export-html" ), tr( "Export To HTML" ), this );
connect( action, SIGNAL( triggered() ), this, SLOT( exportHtml() ), Qt::QueuedConnection );
setAction( "exportHtml", action );
action = new QAction( IconLoader::icon( "export-pdf" ), tr( "Export To PDF" ), this );
connect( action, SIGNAL( triggered() ), this, SLOT( exportPdf() ), Qt::QueuedConnection );
setAction( "exportPdf", action );
action = new QAction( IconLoader::icon( "configure-views" ), tr( "&Manage Views..." ), this );
connect( action, SIGNAL( triggered() ), this, SLOT( manageViews() ), Qt::QueuedConnection );
setAction( "manageViews", action );
action = new QAction( IconLoader::icon( "view-new" ), tr( "Add View" ), this );
setAction( "popupAddView", action );
action = new QAction( IconLoader::icon( "view-new" ), tr( "&Add View" ), this );
connect( action, SIGNAL( triggered() ), this, SLOT( addView() ), Qt::QueuedConnection );
setAction( "addView", action );
//.........这里部分代码省略.........
示例14: initKAction
void KJumpingCube::initKAction() {
QAction * action;
QSignalMapper * gameMapper = new QSignalMapper (this);
connect (gameMapper, SIGNAL (mapped(int)), m_game, SLOT (gameActions(int)));
action = KStandardGameAction::gameNew (gameMapper, SLOT (map()), this);
actionCollection()->addAction (action->objectName(), action);
gameMapper->setMapping (action, NEW);
action = KStandardGameAction::load (gameMapper, SLOT (map()), this);
actionCollection()->addAction (action->objectName(), action);
gameMapper->setMapping (action, LOAD);
action = KStandardGameAction::save (gameMapper, SLOT (map()), this);
actionCollection()->addAction (action->objectName(), action);
gameMapper->setMapping (action, SAVE);
action = KStandardGameAction::saveAs (gameMapper, SLOT (map()), this);
actionCollection()->addAction (action->objectName(), action);
gameMapper->setMapping (action, SAVE_AS);
action = KStandardGameAction::hint (gameMapper, SLOT(map()), this);
actionCollection()->addAction (action->objectName(), action);
gameMapper->setMapping (action, HINT);
action = KStandardGameAction::undo (gameMapper, SLOT (map()), this);
actionCollection()->addAction (action->objectName(), action);
gameMapper->setMapping (action, UNDO);
action->setEnabled (false);
action = KStandardGameAction::redo (gameMapper, SLOT (map()), this);
actionCollection()->addAction (action->objectName(), action);
gameMapper->setMapping (action, REDO);
action->setEnabled (false);
actionButton = new QPushButton (this);
actionButton->setObjectName ("ActionButton");
// Action button's style sheet: parameters for red, green and clicked colors.
buttonLook =
"QPushButton#ActionButton { color: white; background-color: %1; "
"border-style: outset; border-width: 2px; border-radius: 10px; "
"border-color: beige; font: bold 14px; min-width: 10em; "
"padding: 6px; margin: 5px; margin-left: 10px; } "
"QPushButton#ActionButton:pressed { background-color: %2; "
"border-style: inset; } "
"QPushButton#ActionButton:disabled { color: white;"
"border-color: beige; background-color: steelblue; }";
gameMapper->setMapping (actionButton, BUTTON);
connect (actionButton, SIGNAL(clicked()), gameMapper, SLOT(map()));
QWidgetAction *widgetAction = new QWidgetAction(this);
widgetAction->setDefaultWidget(actionButton);
actionCollection()->addAction (QLatin1String ("action_button"), widgetAction);
changeButton (true, true); // Load the button's style sheet.
changeButton (false); // Set the button to be inactive.
action = KStandardAction::preferences (m_game, SLOT(showSettingsDialog()),
actionCollection());
qDebug() << "PREFERENCES ACTION is" << action->objectName();
action->setIconText (i18n("Settings"));
action = KStandardGameAction::quit (this, SLOT (close()), this);
actionCollection()->addAction (action->objectName(), action);
setupGUI();
}
示例15: QPlainTextEdit
PostWindow::PostWindow(QWidget* parent):
QPlainTextEdit(parent)
{
setReadOnly(true);
setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOn);
QRect availableScreenRect = qApp->desktop()->availableGeometry(this);
mSizeHint = QSize( availableScreenRect.width() / 2.7, 300 );
QAction * action;
QAction *copyAction = new QAction(tr("Copy"), this);
connect(copyAction, SIGNAL(triggered()), this, SLOT(copy()));
copyAction->setShortcut( Main::settings()->shortcut("IDE/shortcuts/copy") );
copyAction->setShortcutContext( Qt::WidgetShortcut );
addAction(copyAction);
mClearAction = new QAction(tr("Clear"), this);
connect(mClearAction, SIGNAL(triggered()), this, SLOT(clear()));
addAction(mClearAction);
action = new QAction(this);
action->setSeparator(true);
addAction(action);
action = new QAction(tr("Enlarge Post Font"), this);
action->setIconText("+");
action->setShortcut(tr("Ctrl++", "Enlarge Font"));
action->setShortcutContext( Qt::WidgetShortcut );
action->setToolTip(tr("Enlarge font"));
connect(action, SIGNAL(triggered()), this, SLOT(zoomIn()));
addAction(action);
action = new QAction(tr("Shrink Post Font"), this);
action->setIconText("-");
action->setShortcut(tr("Ctrl+-", "Shrink Font"));
action->setShortcutContext( Qt::WidgetShortcut );
action->setToolTip(tr("Shrink font"));
connect(action, SIGNAL(triggered()), this, SLOT(zoomOut()));
addAction(action);
action = new QAction(this);
action->setSeparator(true);
addAction(action);
mLineWrapAction = action = new QAction(tr("Wrap Text"), this);
action->setCheckable(true);
addAction(action);
connect( action, SIGNAL(triggered(bool)), this, SLOT(setLineWrap(bool)) );
mAutoScrollAction = new QAction(tr("Auto Scroll"), this);
mAutoScrollAction->setToolTip(tr("Scroll to bottom on new posts"));
mAutoScrollAction->setCheckable(true);
mAutoScrollAction->setChecked(true);
addAction(mAutoScrollAction);
setContextMenuPolicy(Qt::ActionsContextMenu);
connect(this, SIGNAL(scrollToBottomRequest()),
this, SLOT(scrollToBottom()), Qt::QueuedConnection);
connect(mAutoScrollAction, SIGNAL(triggered(bool)),
this, SLOT(onAutoScrollTriggered(bool)));
applySettings( Main::settings() );
}