本文整理汇总了C++中QScopedPointer::addAction方法的典型用法代码示例。如果您正苦于以下问题:C++ QScopedPointer::addAction方法的具体用法?C++ QScopedPointer::addAction怎么用?C++ QScopedPointer::addAction使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QScopedPointer
的用法示例。
在下文中一共展示了QScopedPointer::addAction方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: onFileDropWidgetContextMenuRequested
void MainWindow::onFileDropWidgetContextMenuRequested(const QPoint &pos)
{
QScopedPointer<QMenu> menu;
QScopedPointer<QAction> downloadThumbnailAction;
QScopedPointer<QAction> addEntryAction;
QScopedPointer<QAction> addFilesAction;
QScopedPointer<QAction> addFolderAction;
QScopedPointer<QAction> editAction;
QScopedPointer<QAction> deleteAction;
QPointer<QAction> selectedAction;
QPoint cursorPos = QCursor::pos();
QHash<QString, QString> contentHash = getCurrentContentHash();
bool specialPlaylist = currentPlaylistIsSpecial();
bool allPlaylist = currentPlaylistIsAll();
bool actionsAdded = false;
if (m_browserAndPlaylistTabWidget->tabText(m_browserAndPlaylistTabWidget->currentIndex()) != msg_hash_to_str(MENU_ENUM_LABEL_VALUE_QT_TAB_PLAYLISTS))
return;
menu.reset(new QMenu(this));
if (!specialPlaylist)
{
downloadThumbnailAction.reset(new QAction(QString(msg_hash_to_str(MENU_ENUM_LABEL_VALUE_QT_DOWNLOAD_THUMBNAIL)), this));
menu->addAction(downloadThumbnailAction.data());
}
if (!allPlaylist)
{
addEntryAction.reset(new QAction(QString(msg_hash_to_str(MENU_ENUM_LABEL_VALUE_QT_ADD_ENTRY)), this));
menu->addAction(addEntryAction.data());
addFilesAction.reset(new QAction(QString(msg_hash_to_str(MENU_ENUM_LABEL_VALUE_QT_ADD_FILES)), this));
menu->addAction(addFilesAction.data());
addFolderAction.reset(new QAction(QString(msg_hash_to_str(MENU_ENUM_LABEL_VALUE_QT_ADD_FOLDER)), this));
menu->addAction(addFolderAction.data());
editAction.reset(new QAction(QString(msg_hash_to_str(MENU_ENUM_LABEL_VALUE_QT_EDIT)), this));
deleteAction.reset(new QAction(QString(msg_hash_to_str(MENU_ENUM_LABEL_VALUE_QT_DELETE)), this));
if (!contentHash.isEmpty())
{
menu->addAction(editAction.data());
menu->addAction(deleteAction.data());
}
actionsAdded = true;
}
if (actionsAdded)
selectedAction = menu->exec(cursorPos);
if (!selectedAction)
return;
if (!specialPlaylist)
{
if (selectedAction == downloadThumbnailAction.data())
{
QHash<QString, QString> hash = getCurrentContentHash();
QString system = QFileInfo(getCurrentPlaylistPath()).completeBaseName();
QString title = hash.value("label");
if (!title.isEmpty())
{
if (m_pendingThumbnailDownloadTypes.isEmpty())
{
m_pendingThumbnailDownloadTypes.append(THUMBNAIL_BOXART);
m_pendingThumbnailDownloadTypes.append(THUMBNAIL_SCREENSHOT);
m_pendingThumbnailDownloadTypes.append(THUMBNAIL_TITLE);
downloadThumbnail(system, title);
}
else
{
showMessageBox(msg_hash_to_str(MENU_ENUM_LABEL_VALUE_QT_DOWNLOAD_ALREADY_IN_PROGRESS), MainWindow::MSGBOX_TYPE_ERROR, Qt::ApplicationModal, false);
}
}
}
}
if (!allPlaylist)
{
if (selectedAction == addFilesAction.data())
{
QStringList filePaths = QFileDialog::getOpenFileNames(this, msg_hash_to_str(MENU_ENUM_LABEL_VALUE_QT_SELECT_FILES));
if (!filePaths.isEmpty())
addFilesToPlaylist(filePaths);
}
else if (selectedAction == addEntryAction.data())
{
addFilesToPlaylist(QStringList());
}
else if (selectedAction == addFolderAction.data())
{
QString dirPath = QFileDialog::getExistingDirectory(this, msg_hash_to_str(MENU_ENUM_LABEL_VALUE_QT_SELECT_FOLDER), QString(), QFileDialog::ShowDirsOnly);
if (!dirPath.isEmpty())
addFilesToPlaylist(QStringList() << dirPath);
//.........这里部分代码省略.........
示例2: onPlaylistWidgetContextMenuRequested
void MainWindow::onPlaylistWidgetContextMenuRequested(const QPoint&)
{
settings_t *settings = config_get_ptr();
QScopedPointer<QMenu> menu;
QScopedPointer<QMenu> associateMenu;
QScopedPointer<QMenu> hiddenPlaylistsMenu;
QScopedPointer<QAction> hideAction;
QScopedPointer<QAction> newPlaylistAction;
QScopedPointer<QAction> deletePlaylistAction;
QPointer<QAction> selectedAction;
QPoint cursorPos = QCursor::pos();
QListWidgetItem *selectedItem = m_listWidget->itemAt(m_listWidget->viewport()->mapFromGlobal(cursorPos));
QDir playlistDir(settings->paths.directory_playlist);
QString playlistDirAbsPath = playlistDir.absolutePath();
QString currentPlaylistDirPath;
QString currentPlaylistPath;
QString currentPlaylistFileName;
QFile currentPlaylistFile;
QByteArray currentPlaylistFileNameArray;
QFileInfo currentPlaylistFileInfo;
QMap<QString, const core_info_t*> coreList;
core_info_list_t *core_info_list = NULL;
union string_list_elem_attr attr = {0};
struct string_list *stnames = NULL;
struct string_list *stcores = NULL;
unsigned i = 0;
int j = 0;
size_t found = 0;
const char *currentPlaylistFileNameData = NULL;
char new_playlist_names[PATH_MAX_LENGTH];
char new_playlist_cores[PATH_MAX_LENGTH];
bool specialPlaylist = false;
bool foundHiddenPlaylist = false;
new_playlist_names[0] = new_playlist_cores[0] = '\0';
stnames = string_split(settings->arrays.playlist_names, ";");
stcores = string_split(settings->arrays.playlist_cores, ";");
if (selectedItem)
{
currentPlaylistPath = selectedItem->data(Qt::UserRole).toString();
currentPlaylistFile.setFileName(currentPlaylistPath);
currentPlaylistFileInfo = QFileInfo(currentPlaylistPath);
currentPlaylistFileName = currentPlaylistFileInfo.fileName();
currentPlaylistDirPath = currentPlaylistFileInfo.absoluteDir().absolutePath();
currentPlaylistFileNameArray.append(currentPlaylistFileName);
currentPlaylistFileNameData = currentPlaylistFileNameArray.constData();
}
menu.reset(new QMenu(this));
menu->setObjectName("menu");
hiddenPlaylistsMenu.reset(new QMenu(msg_hash_to_str(MENU_ENUM_LABEL_VALUE_QT_HIDDEN_PLAYLISTS), this));
newPlaylistAction.reset(new QAction(QString(msg_hash_to_str(MENU_ENUM_LABEL_VALUE_QT_NEW_PLAYLIST)) + "...", this));
hiddenPlaylistsMenu->setObjectName("hiddenPlaylistsMenu");
menu->addAction(newPlaylistAction.data());
if (currentPlaylistFile.exists())
{
deletePlaylistAction.reset(new QAction(QString(msg_hash_to_str(MENU_ENUM_LABEL_VALUE_QT_DELETE_PLAYLIST)) + "...", this));
menu->addAction(deletePlaylistAction.data());
}
if (selectedItem)
{
hideAction.reset(new QAction(msg_hash_to_str(MENU_ENUM_LABEL_VALUE_QT_HIDE), this));
menu->addAction(hideAction.data());
}
for (j = 0; j < m_listWidget->count(); j++)
{
QListWidgetItem *item = m_listWidget->item(j);
bool hidden = m_listWidget->isItemHidden(item);
if (hidden)
{
QAction *action = hiddenPlaylistsMenu->addAction(item->text());
action->setProperty("row", j);
action->setProperty("core_path", item->data(Qt::UserRole).toString());
foundHiddenPlaylist = true;
}
}
if (!foundHiddenPlaylist)
{
QAction *action = hiddenPlaylistsMenu->addAction(msg_hash_to_str(MENU_ENUM_LABEL_VALUE_NONE));
action->setProperty("row", -1);
}
menu->addMenu(hiddenPlaylistsMenu.data());
if (currentPlaylistDirPath != playlistDirAbsPath)
{
/* special playlists like history etc. can't have an association */
specialPlaylist = true;
//.........这里部分代码省略.........