42 qreal dpr = QApplication::desktop()->devicePixelRatio();
43 QPixmap pixmap(pointsWide * dpr, pointsHigh * dpr);
44 pixmap.fill(Qt::transparent);
45 QPainter painter(&pixmap);
46 QIcon(svgPath).paint(&painter, 0, 0, pointsWide * dpr, pointsHigh * dpr);
49 QBuffer buffer(&bytes);
50 pixmap.save(&buffer,
"PNG");
51 return QString(
"<img src='data:image/png;base64,")
53 + QString(
"' width=%1 height=%2 />")
85 AuthorizationRef auth = NULL;
86 if (AuthorizationCreate(NULL, kAuthorizationEmptyEnvironment, kAuthorizationFlagDefaults, &auth) == errAuthorizationSuccess)
88 AuthorizationItem right = {kAuthorizationRightExecute, 0, NULL, 0};
89 AuthorizationRights rights = {1, &right};
91 const char *promptString = QObject::tr(
"Vuo wants to create its System Library folder.").toUtf8().constData();
92 AuthorizationItem prompt = {kAuthorizationEnvironmentPrompt, strlen(promptString), (
void *)promptString, 0};
93 AuthorizationEnvironment environment = {1, &prompt};
95 if (AuthorizationCopyRights(auth, &rights, &environment,
96 kAuthorizationFlagDefaults
97 | kAuthorizationFlagInteractionAllowed
98 | kAuthorizationFlagPreAuthorize
99 | kAuthorizationFlagExtendRights,
100 NULL) == errAuthorizationSuccess)
102 const char *args[] = {
"-p", strdup(path.toUtf8().data()), NULL };
104#pragma clang diagnostic push
105#pragma clang diagnostic ignored "-Wdeprecated-declarations"
107 if (AuthorizationExecuteWithPrivileges(auth,
"/bin/mkdir", kAuthorizationFlagDefaults, (
char *
const *)args, &pipe) == errAuthorizationSuccess)
108#pragma clang diagnostic pop
115 bytesRead = read(fileno(pipe), buffer,
sizeof(buffer));
119 free((
char *)args[1]);
122 AuthorizationFree(auth, kAuthorizationFlagDefaults);
127 QDesktopServices::openUrl(QUrl::fromLocalFile(path));
129 QMessageBox::information(NULL, QObject::tr(
"Vuo System Library folder"), QObject::tr(
"Please create this folder if you'd like to install nodes for all users on this computer:\n\n%1").arg(path));
194 map<QString, QString> successorForNodeClass;
195 successorForNodeClass[
"vuo.mesh.make.lines"] =
"vuo.scene.make.lines";
196 successorForNodeClass[
"vuo.mesh.make.lineStrips"] =
"vuo.scene.make.lineStrips";
197 successorForNodeClass[
"vuo.mesh.make.parametric"] =
"vuo.scene.make.parametric";
198 successorForNodeClass[
"vuo.mesh.make.points"] =
"vuo.scene.make.points";
199 successorForNodeClass[
"vuo.mesh.make.sphere"] =
"vuo.scene.make.sphere";
200 successorForNodeClass[
"vuo.mesh.make.square"] =
"vuo.scene.make.square";
201 successorForNodeClass[
"vuo.mesh.make.triangle"] =
"vuo.scene.make.triangle";
204 if (successorForNodeClass[oldNodeClass] == newNodeClass)
210 QString oldSuffix =
"";
211 QString newSuffix =
"";
212 int minLength = qMin(oldNodeClass.length(), newNodeClass.length());
213 for (
int i = 0; (i < minLength); ++i)
215 if (oldNodeClass.at(i) == newNodeClass.at(i))
216 root += oldNodeClass.at(i);
221 oldSuffix = oldNodeClass.right(oldNodeClass.length()-root.length());
222 newSuffix = newNodeClass.right(newNodeClass.length()-root.length());
224 bool oldSuffixIsNumeric =
false;
225 int oldSuffixVal = oldSuffix.toInt(&oldSuffixIsNumeric);
227 bool newSuffixIsNumeric =
false;
228 int newSuffixVal = newSuffix.toInt(&newSuffixIsNumeric);
230 if (newSuffixIsNumeric && (oldSuffix.isEmpty() || (oldSuffixIsNumeric && (newSuffixVal > oldSuffixVal))))
235 bool rootEndsInNumberSegment =
false;
236 for (
int i = root.length()-1; i >= 0; --i)
238 if (root.at(i).isDigit())
242 if (root.at(i) ==
'.')
243 rootEndsInNumberSegment =
true;
248 return !rootEndsInNumberSegment;
259 QList<QMainWindow *> openWindows;
260 for (QWidget *openWidget : QApplication::topLevelWidgets())
262 openWindows.append(
static_cast<QMainWindow *
>(openWidget));
264 std::sort(openWindows.begin(), openWindows.end(), [](
const QMainWindow *window1,
const QMainWindow *window2) {
265 return window1->windowTitle().remove(
"[*]").compare(window2->windowTitle().remove(
"[*]"), Qt::CaseInsensitive) < 0;
291 std::sort(openWindows.begin(), openWindows.end(), [](
const QMainWindow *window1,
const QMainWindow *window2) {
292 id nsView1 = (id)window1->winId();
293 id nsWindow1 = ((id (*)(id, SEL))objc_msgSend)(nsView1, sel_getUid(
"window"));
294 long orderedIndex1 = ((long (*)(id, SEL))objc_msgSend)(nsWindow1, sel_getUid(
"orderedIndex"));
296 id nsView2 = (id)window2->winId();
297 id nsWindow2 = ((id (*)(id, SEL))objc_msgSend)(nsView2, sel_getUid(
"window"));
298 long orderedIndex2 = ((long (*)(id, SEL))objc_msgSend)(nsWindow2, sel_getUid(
"orderedIndex"));
300 return orderedIndex1 < orderedIndex2;