Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
Loading...
Searching...
No Matches
qhaikuservices.cpp
Go to the documentation of this file.
1// Copyright (C) 2015 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com, author Tobias Koenig <tobias.koenig@kdab.com>
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3
4#include "qhaikuservices.h"
5
6#include <QFile>
7#include <QMimeDatabase>
8#include <QString>
9#include <QUrl>
10
11#include <Roster.h>
12
14
16{
17 const QMimeDatabase mimeDatabase;
18
19 const QMimeType mimeType = mimeDatabase.mimeTypeForUrl(url);
20 if (!mimeType.isValid())
21 return false;
22
23 const QByteArray mimeTypeName = mimeType.name().toLatin1();
24 QByteArray urlData = url.toString().toLocal8Bit();
25 char *rawUrlData = urlData.data();
26
27 if (be_roster->Launch(mimeTypeName.constData(), 1, &rawUrlData) != B_OK)
28 return false;
29
30 return true;
31}
32
34{
35 const QByteArray localPath = QFile::encodeName(url.toLocalFile());
36
37 entry_ref ref;
38 if (get_ref_for_path(localPath.constData(), &ref) != B_OK)
39 return false;
40
41 if (be_roster->Launch(&ref) != B_OK)
42 return false;
43
44 return true;
45}
46
48{
49 return QByteArray("Haiku");
50}
51
\inmodule QtCore
Definition qbytearray.h:57
char * data()
\macro QT_NO_CAST_FROM_BYTEARRAY
Definition qbytearray.h:611
const char * constData() const noexcept
Returns a pointer to the const data stored in the byte array.
Definition qbytearray.h:124
static QByteArray encodeName(const QString &fileName)
Converts fileName to an 8-bit encoding that you can use in native APIs.
Definition qfile.h:158
QByteArray desktopEnvironment() const override
QPlatformServices::desktopEnvironment returns the active desktop environment.
bool openDocument(const QUrl &url) override
bool openUrl(const QUrl &url) override
\inmodule QtCore
\inmodule QtCore
Definition qmimetype.h:25
QByteArray toLocal8Bit() const &
Definition qstring.h:638
\inmodule QtCore
Definition qurl.h:94
QString toString(FormattingOptions options=FormattingOptions(PrettyDecoded)) const
Returns a string representation of the URL.
Definition qurl.cpp:2831
QString toLocalFile() const
Returns the path of this URL formatted as a local file path.
Definition qurl.cpp:3425
Combined button and popup list for selecting options.
typedef QByteArray(EGLAPIENTRYP PFNQGSGETDISPLAYSPROC)()
const char * mimeType
GLint ref
QUrl url("example.com")
[constructor-url-reference]