54 #include <QVideoWidget> 61 setWindowTitle(
"Cheatsheet");
62 _media_player =
new QMediaPlayer(
this, QMediaPlayer::VideoSurface);
63 QVideoWidget *videoWidget =
new QVideoWidget;
65 videoWidget->setAutoFillBackground(
true);
66 auto palette = videoWidget->palette();
67 palette.setColor( QPalette::Window, Qt::white);
68 videoWidget->setPalette(palette);
69 videoWidget->setAttribute(Qt::WA_OpaquePaintEvent,
true);
72 QListWidget* list_widget =
new QListWidget();
73 _text =
new QLabel(
"placeholder");
77 _playlist->setPlaybackMode(QMediaPlaylist::CurrentItemInLoop);
79 list_widget->setSelectionMode(QAbstractItemView::SingleSelection);
81 _text->setFixedWidth(600);
83 videoWidget->setFixedSize( QSize(900,600) );
84 list_widget->setMinimumWidth(200);
86 QBoxLayout *videoLayout =
new QVBoxLayout;
88 videoLayout->setMargin(20);
89 videoLayout->setSpacing(20);
90 videoLayout->addWidget(
_text);
91 videoLayout->addWidget(videoWidget);
92 videoLayout->addWidget(
new QLabel(
"If you can't see the videos, install codecs with [sudo apt-get install libqt5multimedia5-plugins]"));
94 videoLayout->setStretch(0,1);
95 videoLayout->setStretch(1,0);
96 videoLayout->setStretch(2,0);
98 QBoxLayout *layout =
new QHBoxLayout;
99 layout->addWidget(list_widget);
100 layout->addLayout(videoLayout);
107 static_cast<void(QMediaPlayer::*)(QMediaPlayer::Error)
>(&QMediaPlayer::error),
114 list_widget->addItem( section.title );
115 _playlist->addMedia( section.video_url );
118 _text->setWordWrap(
true);
120 connect( list_widget, &QListWidget::currentRowChanged,
this, [
this](
int row)
123 QString label_text = QString(
"<h2>%1</h2>%2").arg(_help_sections[row].title, _help_sections[row].text);
124 _text->setText( label_text );
128 list_widget->item(0)->setSelected(
true);
139 "Drag and Drop timeseries from the the list on the left side" 140 " using the <b>Left Mouse</b> button.",
141 QUrl(
"qrc:/cheatsheet/video/cheatsheet-drag-drop.mp4")});
144 "Using two timeseries, sharing the same time axis, it is possible" 145 " to create a XY plot. Drag and Drop the Y axis as usual, using the" 146 " <b>Left Mouse</b> and the X axis with the <b>Right Mouse</b>.",
147 QUrl(
"qrc:/cheatsheet/video/cheatsheet-xy.mp4")});
150 "To pan the plot area, either use the <b>Middle Mouse</b> button or" 151 " <b>CTRL + Left Mouse</b>.",
152 QUrl(
"qrc:/cheatsheet/video/cheatsheet-pan-view.mp4")});
155 "To remove entire columns or/and rows, you must first clear all the curves.",
156 QUrl(
"qrc:/cheatsheet/video/cheatsheet-remove-column.mp4")});
159 "To change the size of the fonts used in the legend or the list of timeseries" 160 " on the left side, use <b>CTRL + Mouse Wheel</b>",
161 QUrl(
"qrc:/cheatsheet/video/cheatsheet-resize-font.mp4")});
164 "Swap two plots using <b>CTRL + Right Mouse</b>.",
165 QUrl(
"qrc:/cheatsheet/video/cheatsheet-swap.mp4")});
168 "The time tracker is a vertical line that is helpful to visualize the" 169 " value of the timeseries at a given time.<br>" 170 "Furthermore, it is connected to the Publishers plugins: every time the time" 171 " tracker is activated, all the active publisher are called." 172 " Move the tracker either using the <b>Slider</b> at the bottom or pressing" 173 "<b> SHIFT + Left Mouse</b>.",
174 QUrl(
"qrc:/cheatsheet/video/cheatsheet-tracker.mp4")});
178 "Click with the <b>Left Mouse</b> button on the plot area" 179 " and select the rectangle to zoom in.",
180 QUrl(
"qrc:/cheatsheet/video/cheatsheet-zoom-area.mp4")});
183 "Use the <b>Mouse Wheel</b> to zoom in or out.<br>" 184 "Additionally, you can zoom a single axis moving the mouse cursor" 185 " either on the bottom X scale (<b>zoom horizontally only</b>) or on the left" 186 " Y scale (<b>zoom vertically only</b>).",
187 QUrl(
"qrc:/cheatsheet/video/cheatsheet-zoom-in-out.mp4")});
196 QString message =
"Error: ";
197 if (errorString.isEmpty())
198 message +=
" #" + QString::number(
int(
_media_player->error()));
200 message += errorString;
HelpVideo(QWidget *parent=nullptr)
std::vector< HelpSection > _help_sections
void handleError(QMediaPlayer::Error)
QMediaPlayer * _media_player
QMediaPlaylist * _playlist