本文整理汇总了C++中QDBusPendingReply::argumentAt方法的典型用法代码示例。如果您正苦于以下问题:C++ QDBusPendingReply::argumentAt方法的具体用法?C++ QDBusPendingReply::argumentAt怎么用?C++ QDBusPendingReply::argumentAt使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QDBusPendingReply
的用法示例。
在下文中一共展示了QDBusPendingReply::argumentAt方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: QString
CreationResult *AccountsWorker::createAccountInternal(const User *user)
{
CreationResult *result = new CreationResult;
// validate username
QDBusPendingReply<bool, QString, int> reply = m_accountsInter->IsUsernameValid(user->name());
reply.waitForFinished();
if (reply.isError()) {
result->setType(CreationResult::UserNameError);
result->setMessage(reply.error().message());
return result;
}
bool validation = reply.argumentAt(0).toBool();
if (!validation) {
result->setType(CreationResult::UserNameError);
result->setMessage(dgettext("dde-daemon", reply.argumentAt(1).toString().toUtf8().data()));
return result;
}
// validate password
if (user->password() != user->repeatPassword()) {
result->setType(CreationResult::PasswordMatchError);
result->setMessage(tr("Password not match"));
return result;
}
// default FullName is empty string
QDBusObjectPath path = m_accountsInter->CreateUser(user->name(), QString(), 1);
const QString userPath = path.path();
if (userPath.isEmpty() || userPath.isNull()) {
result->setType(CreationResult::UnknownError);
result->setMessage("no method call result on CreateUser");
return result;
}
AccountsUser *userDBus = new AccountsUser("com.deepin.daemon.Accounts", userPath, QDBusConnection::systemBus(), this);
if (!userDBus->isValid()) {
result->setType(CreationResult::UnknownError);
result->setMessage("user dbus is still not valid.");
return result;
}
//TODO(hualet): better to check all the call results.
bool sifResult = !userDBus->SetIconFile(user->currentAvatar()).isError();
bool spResult = !userDBus->SetPassword(cryptUserPassword(user->password())).isError();
if (!sifResult || !spResult) {
result->setType(CreationResult::UnknownError);
if (!sifResult) result->setMessage("set icon file for new created user failed.");
if (!spResult) result->setMessage("set password for new created user failed");
return result;
}
return result;
}
示例2: inhibitShutdown
void ShutDownFrame::inhibitShutdown() {
m_login1Inter = new DBusLogin1Manager("org.freedesktop.login1", "/org/freedesktop/login1", QDBusConnection::systemBus(), this);
QString reminder_tooltip = QString();
if (m_login1Inter->isValid()) {
qDebug() << "m_login1Inter is valid!";
QDBusPendingReply<InhibitorsList> reply = m_login1Inter->ListInhibitors();
reply.waitForFinished();
if (!reply.isError()){
InhibitorsList inhibitList = qdbus_cast<InhibitorsList>(reply.argumentAt(0));
qDebug() << "inhibitList:" << inhibitList.count();
for(int i = 0; i < inhibitList.count();i++) {
if (inhibitList.at(i).what == "shutdown" && inhibitList.at(i).dosome == "block") {
reminder_tooltip = inhibitList.at(i).why;
}
}
qDebug() << "shutdown Reason!" << reminder_tooltip;
showTips(reminder_tooltip);
} else {
reminder_tooltip = "";
qDebug() << reply.error().message();
}
} else {
qDebug() << "shutdown login1Manager error!";
reminder_tooltip = "";
}
}
示例3: testNewNameJob
void FileManagerClient::testNewNameJob(const QString &oldFile, const QString &newFile)
{
QDBusPendingReply<DBusInfoRet> reply = m_fileOperationInterface->NewRenameJob(oldFile, newFile);
reply.waitForFinished();
if (reply.isFinished()){
DBusInfoRet result = qdbus_cast<DBusInfoRet>(reply.argumentAt(0));
qDebug() << result;
RenameJobInterface* renamejobInterface = new RenameJobInterface(result.ServicePath, result.InterfacePath.path(), QDBusConnection::systemBus());
renamejobInterface->Execute();
}else{
}
}
示例4: dropEvent
void MainItem::dropEvent(QDropEvent *event)
{
updateIcon(false);
if (event->source())
return;
if (event->mimeData()->formats().indexOf("RequestDock") != -1){ //from desktop or launcher
QJsonObject dataObj = QJsonDocument::fromJson(event->mimeData()->data("RequestDock")).object();
if (!dataObj.isEmpty()){
QString appKey = dataObj.value("appKey").toString();
QString appName = dataObj.value("appName").toString();
if (appKey.isEmpty())
return;
event->ignore();
ConfirmUninstallDialog *dialog = new ConfirmUninstallDialog;
//TODO: need real icon name
dialog->setIcon(getThemeIconPath(appKey));
QString message = tr("Are you sure to uninstall %1?").arg(appName);
dialog->setMessage(message);
connect(dialog, &ConfirmUninstallDialog::buttonClicked, [=](int key){
dialog->deleteLater();
if (key == 1){
qWarning() << "Uninstall application:" << appKey << appName;
m_launcher->RequestUninstall(appKey, true);
}
});
dialog->exec();
}
}
else//File or Dirctory
{
QStringList files;
foreach (QUrl fileUrl, event->mimeData()->urls())
files << fileUrl.path();
QDBusPendingReply<QString, QDBusObjectPath, QString> tmpReply = m_dfo->NewTrashJob(files, false, "", "", "");
QDBusObjectPath op = tmpReply.argumentAt(1).value<QDBusObjectPath>();
DBusTrashJob * dtj = new DBusTrashJob(op.path(), this);
connect(dtj, &DBusTrashJob::Done, dtj, &DBusTrashJob::deleteLater);
connect(dtj, &DBusTrashJob::Done, [=](){
updateIcon(false);
});
if (dtj->isValid())
dtj->Execute();
qWarning()<< op.path() << "Move files to trash: "<< files;
}
}
示例5: trashFiles
void MainItem::trashFiles(const QList<QUrl> &files)
{
QStringList normalFiles;
for (QUrl url : files) {
//try to uninstall app by .desktop file
if (url.fileName().endsWith(".desktop")) {
QSettings ds(url.path(), QSettings::IniFormat);
ds.setIniCodec(QTextCodec::codecForName("UTF-8"));
ds.beginGroup("Desktop Entry");
QString appKey = ds.value("X-Deepin-AppID").toString();
if (!appKey.isEmpty()) {
QString l(qgetenv(QString("LANGUAGE").toUtf8().data()));
QString appName = ds.value(QString("Name[%1]").arg(l)).toString();
appName = appName.isEmpty() ? ds.value("Name").toString() : appName;
execUninstall(appKey, appName, ds.value("Icon").toString());
}
else {
normalFiles << url.path();
}
ds.endGroup();
}
else {
normalFiles << url.path();
}
}
//remove normal files
QDBusPendingReply<QString, QDBusObjectPath, QString> tmpReply = m_dfo->NewTrashJob(normalFiles, false, "", "", "");
QDBusObjectPath op = tmpReply.argumentAt(1).value<QDBusObjectPath>();
DBusTrashJob * dtj = new DBusTrashJob(op.path(), this);
connect(dtj, &DBusTrashJob::Done, dtj, &DBusTrashJob::deleteLater);
connect(dtj, &DBusTrashJob::Done, [=](){
updateIcon(false);
});
if (dtj->isValid())
dtj->Execute();
qWarning()<< op.path() << "Move files to trash: "<< normalFiles;
}
示例6: emptyTrash
void MainItem::emptyTrash()
{
ClearTrashDialog *dialog = new ClearTrashDialog;
dialog->setIcon(getThemeIconPath("user-trash-full"));
connect(dialog, &ClearTrashDialog::buttonClicked, [=](int key){
dialog->deleteLater();
if (key == 1){
qWarning() << "Clear trash...";
QDBusPendingReply<QString, QDBusObjectPath, QString> tmpReply = m_dfo->NewEmptyTrashJob(false, "", "", "");
QDBusObjectPath op = tmpReply.argumentAt(1).value<QDBusObjectPath>();
DBusEmptyTrashJob * detj = new DBusEmptyTrashJob(op.path(), this);
connect(detj, &DBusEmptyTrashJob::Done, detj, &DBusEmptyTrashJob::deleteLater);
connect(detj, &DBusEmptyTrashJob::Done, [=](){
updateIcon(false);
});
if (detj->isValid())
detj->Execute();
}
});
dialog->exec();
}
示例7: showMenu
void PanelMenu::showMenu(int x, int y)
{
if (m_menuManager && m_menuManager->isValid()){
QDBusPendingReply<QDBusObjectPath> pr = m_menuManager->RegisterMenu();
if (pr.count() == 1)
{
QDBusObjectPath op = pr.argumentAt(0).value<QDBusObjectPath>();
m_menuInterfacePath = op.path();
DBusMenu *m_menu = new DBusMenu(m_menuInterfacePath,this);
connect(m_menu,&DBusMenu::MenuUnregistered,m_menu,&DBusMenu::deleteLater);
connect(m_menu,&DBusMenu::ItemInvoked,this,&PanelMenu::onItemInvoked);
QJsonObject targetObj;
targetObj.insert("x",QJsonValue(x));
targetObj.insert("y",QJsonValue(y));
targetObj.insert("isDockMenu",QJsonValue(false));
QJsonArray contentArry;
contentArry.append(createRadioItemObj(tr("Fashion mode"),ToFashionMode,DockModeGroup,m_dockModeData->getDockMode() == Dock::FashionMode));
contentArry.append(createRadioItemObj(tr("Efficient mode"),ToEfficientMode,DockModeGroup,m_dockModeData->getDockMode() == Dock::EfficientMode));
contentArry.append(createRadioItemObj(tr("Classic mode"),ToClassicMode,DockModeGroup,m_dockModeData->getDockMode() == Dock::ClassicMode));
contentArry.append(createItemObj("",OperationType(-1)));
contentArry.append(createRadioItemObj(tr("Keep showing"),ToKeepShowing,HideModeGroup,m_dockModeData->getHideMode() == Dock::KeepShowing));
contentArry.append(createRadioItemObj(tr("Keep hidden"),ToKeepHidden,HideModeGroup,m_dockModeData->getHideMode() == Dock::KeepHidden));
contentArry.append(createRadioItemObj(tr("Smart hide"),ToSmartHide,HideModeGroup,m_dockModeData->getHideMode() == Dock::SmartHide));
contentArry.append(createItemObj("",OperationType(-1)));
contentArry.append(createItemObj(tr("Notification area settings"),ToPluginSetting));
QJsonObject contentObj;
contentObj.insert("items",contentArry);
targetObj.insert("menuJsonContent",QString(QJsonDocument(contentObj).toJson()));
m_menu->ShowMenu(QString(QJsonDocument(targetObj).toJson()));
}
}
}