VirtualBox

source: vbox/trunk/src/VBox/Frontends/VirtualBox/src/platform/x11/UIDesktopServices_x11.cpp@ 74942

Last change on this file since 74942 was 74942, checked in by vboxsync, 6 years ago

FE/Qt: bugref:9261: fixed variable names and doxygen description according to code guidlines

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 2.6 KB
Line 
1/* $Id: UIDesktopServices_x11.cpp 74942 2018-10-19 12:51:20Z vboxsync $ */
2/** @file
3 * VBox Qt GUI - Qt GUI - Utility Classes and Functions specific to X11..
4 */
5
6/*
7 * Copyright (C) 2010-2017 Oracle Corporation
8 *
9 * This file is part of VirtualBox Open Source Edition (OSE), as
10 * available from http://www.virtualbox.org. This file is free software;
11 * you can redistribute it and/or modify it under the terms of the GNU
12 * General Public License (GPL) as published by the Free Software
13 * Foundation, in version 2 as it comes in the "COPYING" file of the
14 * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
15 * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
16 */
17
18#ifdef VBOX_WITH_PRECOMPILED_HEADERS
19# include <precomp.h>
20#else /* !VBOX_WITH_PRECOMPILED_HEADERS */
21
22/* VBox includes */
23# include "UIDesktopServices.h"
24
25/* Qt includes */
26# include <QCoreApplication>
27# include <QDesktopServices>
28# include <QDir>
29# include <QFile>
30# include <QTextStream>
31# include <QUrl>
32
33#endif /* !VBOX_WITH_PRECOMPILED_HEADERS */
34
35
36bool UIDesktopServices::createMachineShortcut(const QString & /* strSrcFile */, const QString &strDstPath, const QString &strName, const QUuid &uUuid)
37{
38 QFile link(strDstPath + QDir::separator() + strName + ".desktop");
39 if (link.open(QFile::WriteOnly | QFile::Truncate))
40 {
41 QTextStream out(&link);
42 out.setCodec("UTF-8");
43 /* Create a link which starts VirtualBox with the machine uuid. */
44 out << "[Desktop Entry]" << endl
45 << "Encoding=UTF-8" << endl
46 << "Version=1.0" << endl
47 << "Name=" << strName << endl
48 << "Comment=Starts the VirtualBox machine " << strName << endl
49 << "Type=Application" << endl
50 << "Exec=" << QCoreApplication::applicationFilePath() << " --comment \"" << strName << "\" --startvm \"" << uUuid.toString() << "\"" << endl
51 << "Icon=virtualbox-vbox.png" << endl;
52 /* This would be a real file link entry, but then we could also simply
53 * use a soft link (on most UNIX fs):
54 out << "[Desktop Entry]" << endl
55 << "Encoding=UTF-8" << endl
56 << "Version=1.0" << endl
57 << "Name=" << strName << endl
58 << "Type=Link" << endl
59 << "Icon=virtualbox-vbox.png" << endl
60 */
61 link.setPermissions(link.permissions() | QFile::ExeOwner);
62 return true;
63 }
64 return false;
65}
66
67bool UIDesktopServices::openInFileManager(const QString &strFile)
68{
69 QFileInfo fi(strFile);
70 return QDesktopServices::openUrl(QUrl("file://" + QDir::toNativeSeparators(fi.absolutePath()), QUrl::TolerantMode));
71}
72
Note: See TracBrowser for help on using the repository browser.

© 2023 Oracle
ContactPrivacy policyTerms of Use