| 1 |
// Copyright (C) 2016 The Qt Company Ltd. |
| 2 |
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause |
| 3 |
|
| 4 |
#include "car.h" |
| 5 |
#include "car_adaptor.h" |
| 6 |
#include <QtWidgets/QApplication> |
| 7 |
#include <QtWidgets/QGraphicsView> |
| 8 |
#include <QtWidgets/QGraphicsScene> |
| 9 |
#include <QtDBus/QDBusConnection> |
| 10 |
|
| 11 |
int main(int argc, char *argv[]) |
| 12 |
{ |
| 13 |
QApplication app(argc, argv); |
| 14 |
|
| 15 |
QGraphicsScene scene; |
| 16 |
scene.setSceneRect(-500, -500, 1000, 1000); |
| 17 |
scene.setItemIndexMethod(QGraphicsScene::NoIndex); |
| 18 |
|
| 19 |
auto car = new Car(); |
| 20 |
scene.addItem(car); |
| 21 |
|
| 22 |
QGraphicsView view(&scene); |
| 23 |
view.setRenderHint(QPainter::Antialiasing); |
| 24 |
view.setBackgroundBrush(Qt::darkGray); |
| 25 |
view.setWindowTitle(QT_TRANSLATE_NOOP(QGraphicsView, "Qt DBus Controlled Car")); |
| 26 |
view.resize(view.sizeHint()); |
| 27 |
view.show(); |
| 28 |
|
| 29 |
new CarInterfaceAdaptor(car); |
| 30 |
auto connection = QDBusConnection::sessionBus(); |
| 31 |
connection.registerObject("/Car", car); |
| 32 |
connection.registerService("org.example.CarExample"); |
| 33 |
|
| 34 |
return app.exec(); |
| 35 |
} |