本文整理汇总了C++中QAction::font方法的典型用法代码示例。如果您正苦于以下问题:C++ QAction::font方法的具体用法?C++ QAction::font怎么用?C++ QAction::font使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QAction
的用法示例。
在下文中一共展示了QAction::font方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: on_list_customContextMenuRequested
void Pane::on_list_customContextMenuRequested(const QPoint &pos) {
File_info file = file_list_model.get_file_info(ui->list->indexAt(pos));
App_info_list apps = main_window->get_apps(file.mime_type);
QMenu* menu = new QMenu(this);
if (file.is_folder()) {
menu->addAction(tr("Browse"))->setEnabled(false);
}
if (file.is_file) {
menu->addAction(main_window->get_ui()->action_view);
menu->addAction(main_window->get_ui()->action_edit);
}
if (file.is_executable) {
menu->addAction(main_window->get_ui()->action_execute);
}
if (menu->actions().count() > 0) menu->addSeparator();
foreach(App_info app, apps) {
QAction* a = menu->addAction(tr("Open with %1 (%2)").arg(app.name()).arg(app.command()), this, SLOT(action_launch_triggered()));
QVariantList data;
data << QVariant::fromValue(app) << QVariant::fromValue(file);
a->setData(data);
if (app == apps.default_app) {
QFont f = a->font();
f.setBold(true);
a->setFont(f);
}
}
示例2: font
QFont QActionProto::font() const
{
QAction *item = qscriptvalue_cast<QAction*>(thisObject());
if (item)
return item->font();
return QFont();
}
示例3: createContextMenu
void SGSelectionTool::createContextMenu(const QList<QSGItem *> &items, QPoint pos)
{
QMenu contextMenu;
connect(&contextMenu, SIGNAL(hovered(QAction*)),
this, SLOT(contextMenuElementHovered(QAction*)));
const QList<QSGItem*> selectedItems = inspector()->selectedItems();
int shortcutKey = Qt::Key_1;
foreach (QSGItem *item, items) {
const QString title = inspector()->titleForItem(item);
QAction *elementAction = contextMenu.addAction(title);
elementAction->setData(QVariant::fromValue(item));
connect(elementAction, SIGNAL(triggered()), this, SLOT(contextMenuElementSelected()));
if (selectedItems.contains(item)) {
QFont font = elementAction->font();
font.setBold(true);
elementAction->setFont(font);
}
if (shortcutKey <= Qt::Key_9) {
elementAction->setShortcut(QKeySequence(shortcutKey));
shortcutKey++;
}
}
contextMenu.exec(pos);
}
示例4: contextMenuEvent
void SessionListWidget::contextMenuEvent(QContextMenuEvent *event)
{
QModelIndex index = indexAt(event->pos());
if (index.isValid()) {
JobDefinition &job = sessions[index.row()];
qDebug() << job;
QMenu *menu = new QMenu(this);
QAction *action;
switch(job.status) {
case JobDefinition::QUEUED: {
action = new QAction("Delete session", this);
action->setData(qVariantFromValue(&job));
connect(action, SIGNAL(triggered()), this, SLOT(removeSessionSlot()));
menu->addAction(action);
break;
}
case JobDefinition::HELD: {
action = new QAction("Resume session", this);
action->setData(qVariantFromValue(&job));
connect(action, SIGNAL(triggered()), this, SLOT(releaseSessionSlot()));
menu->addAction(action);
action = new QAction("Delete session", this);
action->setData(qVariantFromValue(&job));
connect(action, SIGNAL(triggered()), this, SLOT(removeSessionSlot()));
menu->addAction(action);
break;
}
case JobDefinition::RUNNING: {
action = new QAction("View session", this);
QFont f = action->font();
f.setBold(true);
action->setFont(f);
action->setData(qVariantFromValue(&job));
connect(action, SIGNAL(triggered()), this, SLOT(viewSessionSlot()));
menu->addAction(action);
action = new QAction("Delete session", this);
action->setData(qVariantFromValue(&job));
connect(action, SIGNAL(triggered()), this, SLOT(removeSessionSlot()));
menu->addAction(action);
break;
}
case JobDefinition::FINISHED: {
menu->addAction("Resume session [TODO]");
break;
}
}
menu->exec(QCursor::pos());
}
}
示例5: italicTextItem
static QAction* italicTextItem(const QString& s)
{
QAction* act = new QAction(s, NULL);
QFont italicFont = act->font();
italicFont.setItalic(true);
act->setFont(italicFont);
return act;
}
示例6: boldTextItem
static QAction* boldTextItem(const QString& s)
{
QAction* act = new QAction(s, NULL);
QFont boldFont = act->font();
boldFont.setBold(true);
act->setFont(boldFont);
return act;
}
示例7: QWidget
/** Constructor */
FeedReaderFeedItem::FeedReaderFeedItem(RsFeedReader *feedReader, FeedReaderNotify *notify, FeedHolder *parent, const FeedInfo &feedInfo, const FeedMsgInfo &msgInfo)
: QWidget(NULL), mFeedReader(feedReader), mNotify(notify), mParent(parent), ui(new Ui::FeedReaderFeedItem)
{
/* Invoke the Qt Designer generated object setup routine */
ui->setupUi(this);
setAttribute(Qt::WA_DeleteOnClose, true);
connect(ui->expandButton, SIGNAL(clicked(void)), this, SLOT(toggle(void)));
connect(ui->clearButton, SIGNAL(clicked(void)), this, SLOT(removeItem(void)));
connect(ui->readAndClearButton, SIGNAL(clicked()), this, SLOT(readAndClearItem()));
connect(ui->linkButton, SIGNAL(clicked()), this, SLOT(openLink()));
connect(mNotify, SIGNAL(msgChanged(QString,QString,int)), this, SLOT(msgChanged(QString,QString,int)), Qt::QueuedConnection);
ui->expandFrame->hide();
mFeedId = feedInfo.feedId;
mMsgId = msgInfo.msgId;
if (feedInfo.icon.empty()) {
ui->feedIconLabel->hide();
} else {
/* use icon from feed */
QPixmap pixmap;
if (pixmap.loadFromData(QByteArray::fromBase64(feedInfo.icon.c_str()))) {
ui->feedIconLabel->setPixmap(pixmap.scaled(16, 16, Qt::IgnoreAspectRatio, Qt::SmoothTransformation));
} else {
ui->feedIconLabel->hide();
}
}
ui->titleLabel->setText(QString::fromUtf8(feedInfo.name.c_str()));
ui->msgTitleLabel->setText(QString::fromUtf8(msgInfo.title.c_str()));
ui->descriptionLabel->setText(QString::fromUtf8((msgInfo.descriptionTransformed.empty() ? msgInfo.description : msgInfo.descriptionTransformed).c_str()));
ui->dateTimeLabel->setText(DateTime::formatLongDateTime(msgInfo.pubDate));
/* build menu for link button */
mLink = QString::fromUtf8(msgInfo.link.c_str());
if (mLink.isEmpty()) {
ui->linkButton->setEnabled(false);
} else {
QMenu *menu = new QMenu(this);
QAction *action = menu->addAction(tr("Open link in browser"), this, SLOT(openLink()));
menu->addAction(tr("Copy link to clipboard"), this, SLOT(copyLink()));
QFont font = action->font();
font.setBold(true);
action->setFont(font);
ui->linkButton->setMenu(menu);
}
}
示例8: data
QVariant pActionsModel::data( const QModelIndex& index, int role ) const
{
QAction* action = this->action( index );
if ( !action ) {
return QVariant();
}
switch ( role ) {
case Qt::DecorationRole:
switch ( index.column() ) {
case 0:
return action->icon();
default:
break;
}
break;
case Qt::DisplayRole:
case Qt::ToolTipRole:
switch ( index.column() ) {
case pActionsModel::Action:
return cleanText( action->text() );
case pActionsModel::Shortcut:
return action->shortcut().toString( QKeySequence::NativeText );
case pActionsModel::DefaultShortcut:
return defaultShortcut( action ).toString( QKeySequence::NativeText );
}
break;
case Qt::FontRole: {
QFont font = action->font();
if ( action->menu() ) {
font.setBold( true );
}
return font;
}
/*case Qt::BackgroundRole:
return action->menu() ? QBrush( QColor( 0, 0, 255, 20 ) ) : QVariant();*/
case pActionsModel::MenuRole:
return QVariant::fromValue( action->menu() );
case pActionsModel::ActionRole:
return QVariant::fromValue( action );
}
return QVariant();
}
示例9: tryInsertItem
void PopupProxy::tryInsertItem( HistoryItem const * const item,
int& remainingHeight,
const int index )
{
QAction *action = new QAction(m_proxy_for_menu);
QPixmap image( item->image() );
if ( image.isNull() ) {
// Squeeze text strings so that do not take up the entire screen (or more)
QString text = m_proxy_for_menu->fontMetrics().elidedText( item->text().simplified(), Qt::ElideMiddle, m_menu_width );
text.replace( '&', "&&" );
action->setText(text);
} else {
#if 0 // not used because QAction#setIcon does not respect this size; it does scale anyway. TODO: find a way to set a bigger image
const QSize max_size( m_menu_width,m_menu_height/4 );
if ( image.height() > max_size.height() || image.width() > max_size.width() ) {
image = image.scaled( max_size, Qt::KeepAspectRatio, Qt::SmoothTransformation );
}
#endif
action->setIcon(QIcon(image));
}
action->setData(item->uuid());
// if the m_proxy_for_menu is a submenu (aka a "More" menu) then it may the case, that there is no other action in that menu yet.
QAction *before = index < m_proxy_for_menu->actions().count() ? m_proxy_for_menu->actions().at(index) : 0;
// insert the new action to the m_proxy_for_menu
m_proxy_for_menu->insertAction(before, action);
// Determine height of a menu item.
QStyleOptionMenuItem style_options;
// It would be much easier to use QMenu::initStyleOptions. But that is protected, so until we have a better
// excuse to subclass that, I'd rather implement this manually.
// Note 2 properties, tabwidth and maxIconWidth, are not available from the public interface, so those are left out (probably not
// important for height. Also, Exlsive checkType is disregarded as I don't think we will ever use it)
style_options.initFrom(m_proxy_for_menu);
style_options.checkType = action->isCheckable() ? QStyleOptionMenuItem::NonExclusive : QStyleOptionMenuItem::NotCheckable;
style_options.checked = action->isChecked();
style_options.font = action->font();
style_options.icon = action->icon();
style_options.menuHasCheckableItems = true;
style_options.menuRect = m_proxy_for_menu->rect();
style_options.text = action->text();
int font_height = QFontMetrics(m_proxy_for_menu->fontMetrics()).height();
int itemheight = m_proxy_for_menu->style()->sizeFromContents(QStyle::CT_MenuItem,
&style_options,
QSize( 0, font_height ),
m_proxy_for_menu).height();
// Subtract the used height
remainingHeight -= itemheight;
}
示例10: markCurrent
void Favorites::markCurrent()
{
for (int n = FIRST_MENU_ENTRY; n < _menu->actions().count(); n++)
{
QAction * a = _menu->actions()[n];
QString file = a->data().toString();
QFont f = a->font();
if (file == current_file)
{
f.setBold(true);
a->setFont( f );
}
else
{
f.setBold(false);
a->setFont( f );
}
}
}
示例11: addTitle
QAction* KMenu::addTitle(const QIcon &icon, const QString &text, QAction* before)
{
QAction *buttonAction = new QAction(this);
QFont font = buttonAction->font();
font.setBold(true);
buttonAction->setFont(font);
buttonAction->setText(text);
buttonAction->setIcon(icon);
QWidgetAction *action = new QWidgetAction(this);
action->setObjectName(KMENU_TITLE);
QToolButton *titleButton = new QToolButton(this);
titleButton->installEventFilter(d); // prevent clicks on the title of the menu
titleButton->setDefaultAction(buttonAction);
titleButton->setDown(true); // prevent hover style changes in some styles
titleButton->setToolButtonStyle(Qt::ToolButtonTextBesideIcon);
action->setDefaultWidget(titleButton);
insertAction(before, action);
return action;
}
示例12: showProfileMenu
void MainStatusBar::showProfileMenu(const QPoint &global_pos, Qt::MouseButton button)
{
const gchar *profile_name = get_profile_name();
bool separator_added = false;
GList *fl_entry;
profile_def *profile;
QAction *pa;
init_profile_list();
fl_entry = current_profile_list();
profile_menu_.clear();
while (fl_entry && fl_entry->data) {
profile = (profile_def *) fl_entry->data;
if (!profile->is_global || !profile_exists(profile->name, false)) {
if (profile->is_global && !separator_added) {
profile_menu_.addSeparator();
separator_added = true;
}
pa = profile_menu_.addAction(profile->name);
if (strcmp(profile->name, profile_name) == 0) {
/* Bold current profile */
QFont pa_font = pa->font();
pa_font.setBold(true);
pa->setFont(pa_font);
pa->setCheckable(true);
pa->setChecked(true);
}
connect(pa, SIGNAL(triggered()), this, SLOT(switchToProfile()));
}
fl_entry = g_list_next(fl_entry);
}
if (button == Qt::LeftButton) {
profile_menu_.exec(global_pos);
} else {
ctx_menu_.exec(global_pos);
}
}
示例13: createContextMenu
void LiveSelectionTool::createContextMenu(QList<QGraphicsItem*> itemList, QPoint globalPos)
{
if (!QDeclarativeViewObserverPrivate::get(observer())->mouseInsideContextItem())
return;
QMenu contextMenu;
connect(&contextMenu, SIGNAL(hovered(QAction*)),
this, SLOT(contextMenuElementHovered(QAction*)));
m_contextMenuItemList = itemList;
contextMenu.addAction("Items");
contextMenu.addSeparator();
int shortcutKey = Qt::Key_1;
bool addKeySequence = true;
int i = 0;
foreach (QGraphicsItem * const item, itemList) {
QString itemTitle = titleForItem(item);
QAction *elementAction = contextMenu.addAction(itemTitle, this,
SLOT(contextMenuElementSelected()));
if (observer()->selectedItems().contains(item)) {
QFont boldFont = elementAction->font();
boldFont.setBold(true);
elementAction->setFont(boldFont);
}
elementAction->setData(i);
if (addKeySequence)
elementAction->setShortcut(QKeySequence(shortcutKey));
shortcutKey++;
if (shortcutKey > Qt::Key_9)
addKeySequence = false;
++i;
}
示例14: showNewsMenu
void NewsButton::showNewsMenu()
{
auto newsFeedMenu = new QMenu;
auto &feed = NewsFeed::instance();
for (const NewsItem &newsItem : feed.newsItems()) {
QAction *action = newsFeedMenu->addAction(newsItem.title);
if (feed.isUnread(newsItem)) {
QFont f = action->font();
f.setBold(true);
action->setFont(f);
action->setIcon(mUnreadIcon);
} else {
action->setIcon(mReadIcon);
}
connect(action, &QAction::triggered, [=] {
QDesktopServices::openUrl(newsItem.link);
NewsFeed::instance().markRead(newsItem);
});
}
newsFeedMenu->addSeparator();
QAction *action = newsFeedMenu->addAction(tr("News Archive"));
connect(action, &QAction::triggered, [] {
QDesktopServices::openUrl(QUrl(QLatin1String(newsArchiveUrl)));
NewsFeed::instance().markAllRead();
});
auto size = newsFeedMenu->sizeHint();
auto rect = QRect(mapToGlobal(QPoint(width() - size.width(), -size.height())), size);
newsFeedMenu->setGeometry(rect);
newsFeedMenu->exec();
setDown(false);
}
示例15: ShowSpecifiedContextMenu
void game_list_frame::ShowSpecifiedContextMenu(const QPoint &pos, int row)
{
if (row == -1)
{
return; // invalid
}
QPoint globalPos;
if (m_isListLayout)
{
globalPos = gameList->mapToGlobal(pos);
}
else
{
globalPos = m_xgrid->mapToGlobal(pos);
}
QMenu myMenu;
// Make Actions
QAction* boot = myMenu.addAction(tr("&Boot"));
QFont f = boot->font();
f.setBold(true);
boot->setFont(f);
QAction* configure = myMenu.addAction(tr("&Configure"));
myMenu.addSeparator();
QAction* removeGame = myMenu.addAction(tr("&Remove"));
QAction* removeConfig = myMenu.addAction(tr("&Remove Custom Configuration"));
myMenu.addSeparator();
QAction* openGameFolder = myMenu.addAction(tr("&Open Install Folder"));
QAction* openConfig = myMenu.addAction(tr("&Open Config Folder"));
myMenu.addSeparator();
QAction* checkCompat = myMenu.addAction(tr("&Check Game Compatibility"));
connect(boot, &QAction::triggered, [=]() {Boot(row); });
connect(configure, &QAction::triggered, [=]() {
settings_dialog(xgui_settings, m_Render_Creator, this, &m_game_data[row].info).exec();
});
connect(removeGame, &QAction::triggered, [=]() {
if (QMessageBox::question(this, tr("Confirm Delete"), tr("Permanently delete files?")) == QMessageBox::Yes)
{
fs::remove_all(Emu.GetGameDir() + m_game_data[row].info.root);
m_game_data.erase(m_game_data.begin() + row);
Refresh();
}
});
connect(removeConfig, &QAction::triggered, [=]() {RemoveCustomConfiguration(row); });
connect(openGameFolder, &QAction::triggered, [=]() {open_dir(Emu.GetGameDir() + m_game_data[row].info.root); });
connect(openConfig, &QAction::triggered, [=]() {open_dir(fs::get_config_dir() + "data/" + m_game_data[row].info.serial); });
connect(checkCompat, &QAction::triggered, [=]() {
QString serial = qstr(m_game_data[row].info.serial);
QString link = "https://rpcs3.net/compatibility?g=" + serial;
QDesktopServices::openUrl(QUrl(link));
});
//Disable options depending on software category
QString category = qstr(m_game_data[row].info.category);
if (category == category::disc_Game)
{
removeGame->setEnabled(false);
}
else if (category == category::audio_Video)
{
configure->setEnabled(false);
removeConfig->setEnabled(false);
openConfig->setEnabled(false);
checkCompat->setEnabled(false);
}
else if (category == category::home || category == category::game_Data)
{
boot->setEnabled(false), f.setBold(false), boot->setFont(f);
configure->setEnabled(false);
removeConfig->setEnabled(false);
openConfig->setEnabled(false);
checkCompat->setEnabled(false);
}
myMenu.exec(globalPos);
}