Marble

TourControlEditWidget.cpp
1// SPDX-License-Identifier: LGPL-2.1-or-later
2//
3// SPDX-FileCopyrightText: 2013 Mihail Ivchenko <ematirov@gmail.com>
4// SPDX-FileCopyrightText: 2014 Sanjiban Bairagya <sanjiban22393@gmail.com>
5// SPDX-FileCopyrightText: 2014 Illya Kovalevskyy <illya.kovalevskyy@gmail.com>
6//
7
8#include "TourControlEditWidget.h"
9
10#include <QHBoxLayout>
11#include <QLabel>
12#include <QRadioButton>
13#include <QToolButton>
14
15#include "GeoDataTourControl.h"
16#include "MarblePlacemarkModel.h"
17
18namespace Marble
19{
20
21TourControlEditWidget::TourControlEditWidget(const QModelIndex &index, QWidget *parent)
22 : QWidget(parent)
23 , m_index(index)
24 , m_radio_play(new QRadioButton(this))
25 , m_radio_pause(new QRadioButton(this))
26 , m_button(new QToolButton(this))
27{
28 auto layout = new QHBoxLayout(this);
29 layout->setSpacing(5);
30
31 auto iconLabel = new QLabel(this);
32 iconLabel->setPixmap(QPixmap(QStringLiteral(":/marble/media-playback-pause.png")));
33 layout->addWidget(iconLabel);
34
35 layout->addWidget(m_radio_play);
36 m_radio_play->setText(tr("Play"));
37
38 layout->addWidget(m_radio_pause);
39 m_radio_pause->setText(tr("Pause"));
40
41 if (tourControlElement()->playMode() == GeoDataTourControl::Play) {
42 m_radio_play->setChecked(true);
43 } else {
44 m_radio_pause->setChecked(true);
45 }
46
47 m_button->setIcon(QIcon(QStringLiteral(":/marble/document-save.png")));
48 connect(m_button, &QAbstractButton::clicked, this, &TourControlEditWidget::save);
49 layout->addWidget(m_button);
50}
51
52bool TourControlEditWidget::editable() const
53{
54 return m_button->isEnabled();
55}
56
57void TourControlEditWidget::setEditable(bool editable)
58{
59 m_button->setEnabled(editable);
60}
61
62void TourControlEditWidget::save()
63{
64 if (m_radio_play->isChecked()) {
65 tourControlElement()->setPlayMode(GeoDataTourControl::Play);
66 } else {
67 tourControlElement()->setPlayMode(GeoDataTourControl::Pause);
68 }
69 Q_EMIT editingDone(m_index);
70}
71
72GeoDataTourControl *TourControlEditWidget::tourControlElement()
73{
74 auto object = qvariant_cast<GeoDataObject *>(m_index.data(MarblePlacemarkModel::ObjectPointerRole));
75 Q_ASSERT(object);
76 auto tourControl = geodata_cast<GeoDataTourControl>(object);
77 Q_ASSERT(tourControl);
78 return tourControl;
79}
80
81} // namespace Marble
82
83#include "moc_TourControlEditWidget.cpp"
Binds a QML item to a specific geodetic location in screen coordinates.
void clicked(bool checked)
QFuture< ArgsType< Signal > > connect(Sender *sender, Signal signal)
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Sat Dec 21 2024 17:04:14 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.