91 NSURLBookmarkCreationOptions
95 NSString *pathEscaped = [path.toNSString() stringByAddingPercentEncodingWithAllowedCharacters:[NSCharacterSet URLFragmentAllowedCharacterSet]];
96 NSURL *url = [NSURL URLWithString:pathEscaped];
99 if (!refpath.isEmpty()) {
100 NSString *refpathEscaped = [refpath.toNSString() stringByAddingPercentEncodingWithAllowedCharacters:[NSCharacterSet URLFragmentAllowedCharacterSet]];
101 refurl = [NSURL URLWithString:refpathEscaped];
108 NSData *bookmark = [url bookmarkDataWithOptions: options includingResourceValuesForKeys: nil relativeToURL: refurl error:&err];
109 NSString *bookmarkString = [bookmark base64EncodedStringWithOptions: NSDataBase64Encoding64CharacterLineLength];
110 NSLog(
@" path: %@\n err: %@", pathEscaped, err);
113 [url startAccessingSecurityScopedResource];
115 QString base64Data = QString::fromNSString(bookmarkString);
117 const QString configPath = QStandardPaths::writableLocation(QStandardPaths::GenericConfigLocation);
118 QSettings kritarc(configPath + QStringLiteral(
"/securitybookmarkrc"), QSettings::NativeFormat);
125 kritarc.setArrayIndex(size);
126 kritarc.setValue(
"path",path);
127 kritarc.setValue(
"base64", base64Data);
131 m_d->securedFiles[path] = base64Data;
139 const QString configPath = QStandardPaths::writableLocation(QStandardPaths::GenericConfigLocation);
140 QSettings kritarc(configPath + QStringLiteral(
"/securitybookmarkrc"), QSettings::NativeFormat);
143 for (
int i = 0; i < size; i++) {
144 kritarc.setArrayIndex(i);
145 QString key = kritarc.value(
"path").toString();
146 m_d->securedFiles[key] = kritarc.value(
"base64").toString();
186 bool fileSelected =
false;
187 QUrl fileURL = QUrl(path);
189 NSString *nsStdPath = path.toNSString();
191 NSAlert *alert = [[NSAlert alloc] init];
192 [alert setAlertStyle:NSAlertStyleInformational];
193 [alert setMessageText:[NSString stringWithFormat:
@"The file %@ is located in a directory where the application has no permission, please give the permission to the container folder or a higher one to allow krita to save temporary backups next to your file", [nsStdPath lastPathComponent]]];
197 NSOpenPanel *panel = [NSOpenPanel openPanel];
198 panel.canChooseFiles =
false;
199 panel.canChooseDirectories =
true;
200 NSURL *startLoc = [[NSURL alloc] initFileURLWithPath:nsStdPath ];
201 panel.directoryURL = startLoc;
203 if ([panel runModal] == NSModalResponseOK) {
204 static NSURL *fileUrl = [panel URL];
205 NSString *pathString = [fileUrl absoluteString];
207 QString filepath = QString::fromNSString(pathString);
214 msgBox.setText(i18n(
"The file %1 is located in a directory where the application has no permissions, please give krita permission to this directory or a higher one to allow krita to save temporary backups next to your file", fileURL.fileName()));
215 msgBox.setInformativeText(i18n(
"The directory you select will grant krita permissions to all files and directories contained in it"));
216 msgBox.setStandardButtons(QMessageBox::Ok);
217 msgBox.setDefaultButton(QMessageBox::Ok);
218 int ret = msgBox.exec();
220 QUrl dirUrl = QFileDialog::getExistingDirectoryUrl(0, QString(), QUrl(path));
222 if (!dirUrl.isEmpty()) {
223 QString filepath = dirUrl.toDisplayString(QUrl::None);