19 #include <QDesktopServices>
37 #elif defined(Q_OS_MAC)
59 QgsDebugMsg( QStringLiteral(
"Invalid action cannot be run" ) );
71 QFileInfo finfo( expandedAction );
72 if ( finfo.exists() && finfo.isFile() )
73 QDesktopServices::openUrl( QUrl::fromLocalFile( expandedAction ) );
75 QDesktopServices::openUrl( QUrl( expandedAction, QUrl::TolerantMode ) );
102 QDomElement actionElement = actionNode.toElement();
103 QDomNodeList actionScopeNodes = actionElement.elementsByTagName( QStringLiteral(
"actionScope" ) );
105 if ( actionScopeNodes.isEmpty() )
108 << QStringLiteral(
"Canvas" )
109 << QStringLiteral(
"Field" )
110 << QStringLiteral(
"Feature" );
114 for (
int j = 0; j < actionScopeNodes.length(); ++j )
116 QDomElement actionScopeElem = actionScopeNodes.item( j ).toElement();
117 mActionScopes << actionScopeElem.attribute( QStringLiteral(
"id" ) );
121 mType =
static_cast< QgsAction::ActionType >( actionElement.attributeNode( QStringLiteral(
"type" ) ).value().toInt() );
122 mDescription = actionElement.attributeNode( QStringLiteral(
"name" ) ).value();
123 mCommand = actionElement.attributeNode( QStringLiteral(
"action" ) ).value();
124 mIcon = actionElement.attributeNode( QStringLiteral(
"icon" ) ).value();
125 mCaptureOutput = actionElement.attributeNode( QStringLiteral(
"capture" ) ).value().toInt() != 0;
126 mShortTitle = actionElement.attributeNode( QStringLiteral(
"shortTitle" ) ).value();
127 mNotificationMessage = actionElement.attributeNode( QStringLiteral(
"notificationMessage" ) ).value();
128 mIsEnabledOnlyWhenEditable = actionElement.attributeNode( QStringLiteral(
"isEnabledOnlyWhenEditable" ) ).value().toInt() != 0;
129 mId = QUuid( actionElement.attributeNode( QStringLiteral(
"id" ) ).value() );
131 mId = QUuid::createUuid();
136 QDomElement actionSetting = actionsNode.ownerDocument().createElement( QStringLiteral(
"actionsetting" ) );
137 actionSetting.setAttribute( QStringLiteral(
"type" ), mType );
138 actionSetting.setAttribute( QStringLiteral(
"name" ), mDescription );
139 actionSetting.setAttribute( QStringLiteral(
"shortTitle" ), mShortTitle );
140 actionSetting.setAttribute( QStringLiteral(
"icon" ), mIcon );
141 actionSetting.setAttribute( QStringLiteral(
"action" ), mCommand );
142 actionSetting.setAttribute( QStringLiteral(
"capture" ), mCaptureOutput );
143 actionSetting.setAttribute( QStringLiteral(
"notificationMessage" ), mNotificationMessage );
144 actionSetting.setAttribute( QStringLiteral(
"isEnabledOnlyWhenEditable" ), mIsEnabledOnlyWhenEditable );
145 actionSetting.setAttribute( QStringLiteral(
"id" ), mId.toString() );
147 const auto constMActionScopes = mActionScopes;
148 for (
const QString &scope : constMActionScopes )
150 QDomElement actionScopeElem = actionsNode.ownerDocument().createElement( QStringLiteral(
"actionScope" ) );
151 actionScopeElem.setAttribute( QStringLiteral(
"id" ), scope );
152 actionSetting.appendChild( actionScopeElem );
155 actionsNode.appendChild( actionSetting );
160 mExpressionContextScope = scope;
165 return mExpressionContextScope;