Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051 #include "video_cheatsheet.h"
00052
00053 #include <QtWidgets>
00054 #include <QVideoWidget>
00055 #include <QDebug>
00056 #include <QSize>
00057
00058 HelpVideo::HelpVideo(QWidget *parent)
00059 : QDialog(parent)
00060 {
00061 setWindowTitle("Cheatsheet");
00062 _media_player = new QMediaPlayer(this, QMediaPlayer::VideoSurface);
00063 QVideoWidget *videoWidget = new QVideoWidget;
00064
00065 videoWidget->setAutoFillBackground(true);
00066 auto palette = videoWidget->palette();
00067 palette.setColor( QPalette::Window, Qt::white);
00068 videoWidget->setPalette(palette);
00069 videoWidget->setAttribute(Qt::WA_OpaquePaintEvent, true);
00070
00071 _playlist = new QMediaPlaylist();
00072 QListWidget* list_widget = new QListWidget();
00073 _text = new QLabel("placeholder");
00074
00075 _media_player->setPlaylist(_playlist);
00076
00077 _playlist->setPlaybackMode(QMediaPlaylist::CurrentItemInLoop);
00078
00079 list_widget->setSelectionMode(QAbstractItemView::SingleSelection);
00080
00081 _text->setFixedWidth(600);
00082
00083 videoWidget->setFixedSize( QSize(900,600) );
00084 list_widget->setMinimumWidth(200);
00085
00086 QBoxLayout *videoLayout = new QVBoxLayout;
00087
00088 videoLayout->setMargin(20);
00089 videoLayout->setSpacing(20);
00090 videoLayout->addWidget(_text);
00091 videoLayout->addWidget(videoWidget);
00092 videoLayout->addWidget(new QLabel("If you can't see the videos, install codecs with [sudo apt-get install libqt5multimedia5-plugins]"));
00093
00094 videoLayout->setStretch(0,1);
00095 videoLayout->setStretch(1,0);
00096 videoLayout->setStretch(2,0);
00097
00098 QBoxLayout *layout = new QHBoxLayout;
00099 layout->addWidget(list_widget);
00100 layout->addLayout(videoLayout);
00101
00102 setLayout(layout);
00103
00104 _media_player->setVideoOutput(videoWidget);
00105
00106 connect(_media_player,
00107 static_cast<void(QMediaPlayer::*)(QMediaPlayer::Error)>(&QMediaPlayer::error),
00108 this, &HelpVideo::handleError);
00109
00110 setupHelps();
00111
00112 for(const auto& section: _help_sections)
00113 {
00114 list_widget->addItem( section.title );
00115 _playlist->addMedia( section.video_url );
00116 }
00117
00118 _text->setWordWrap(true);
00119
00120 connect( list_widget, &QListWidget::currentRowChanged, this, [this](int row)
00121 {
00122 _playlist->setCurrentIndex(row);
00123 QString label_text = QString("<h2>%1</h2>%2").arg(_help_sections[row].title, _help_sections[row].text);
00124 _text->setText( label_text );
00125 _media_player->play();
00126 });
00127
00128 list_widget->item(0)->setSelected(true);
00129 }
00130
00131 HelpVideo::~HelpVideo()
00132 {
00133 }
00134
00135
00136 void HelpVideo::setupHelps()
00137 {
00138 _help_sections.push_back( {"Add timeseries to plot",
00139 "Drag and Drop timeseries from the the list on the left side"
00140 " using the <b>Left Mouse</b> button.",
00141 QUrl("qrc:/cheatsheet/video/cheatsheet-drag-drop.mp4")});
00142
00143 _help_sections.push_back( {"Create XY plots",
00144 "Using two timeseries, sharing the same time axis, it is possible"
00145 " to create a XY plot. Drag and Drop the Y axis as usual, using the"
00146 " <b>Left Mouse</b> and the X axis with the <b>Right Mouse</b>.",
00147 QUrl("qrc:/cheatsheet/video/cheatsheet-xy.mp4")});
00148
00149 _help_sections.push_back( {"Pan view",
00150 "To pan the plot area, either use the <b>Middle Mouse</b> button or"
00151 " <b>CTRL + Left Mouse</b>.",
00152 QUrl("qrc:/cheatsheet/video/cheatsheet-pan-view.mp4")});
00153
00154 _help_sections.push_back( {"Remove Columns/Rows",
00155 "To remove entire columns or/and rows, you must first clear all the curves.",
00156 QUrl("qrc:/cheatsheet/video/cheatsheet-remove-column.mp4")});
00157
00158 _help_sections.push_back( {"Resize Fonts",
00159 "To change the size of the fonts used in the legend or the list of timeseries"
00160 " on the left side, use <b>CTRL + Mouse Wheel</b>",
00161 QUrl("qrc:/cheatsheet/video/cheatsheet-resize-font.mp4")});
00162
00163 _help_sections.push_back( {"Swap Plots",
00164 "Swap two plots using <b>CTRL + Right Mouse</b>.",
00165 QUrl("qrc:/cheatsheet/video/cheatsheet-swap.mp4")});
00166
00167 _help_sections.push_back( {"Time tracker",
00168 "The time tracker is a vertical line that is helpful to visualize the"
00169 " value of the timeseries at a given time.<br>"
00170 "Furthermore, it is connected to the Publishers plugins: every time the time"
00171 " tracker is activated, all the active publisher are called."
00172 " Move the tracker either using the <b>Slider</b> at the bottom or pressing"
00173 "<b> SHIFT + Left Mouse</b>.",
00174 QUrl("qrc:/cheatsheet/video/cheatsheet-tracker.mp4")});
00175
00176
00177 _help_sections.push_back( {"Zoom Area",
00178 "Click with the <b>Left Mouse</b> button on the plot area"
00179 " and select the rectangle to zoom in.",
00180 QUrl("qrc:/cheatsheet/video/cheatsheet-zoom-area.mp4")});
00181
00182 _help_sections.push_back( {"Zoom In and Out",
00183 "Use the <b>Mouse Wheel</b> to zoom in or out.<br>"
00184 "Additionally, you can zoom a single axis moving the mouse cursor"
00185 " either on the bottom X scale (<b>zoom horizontally only</b>) or on the left"
00186 " Y scale (<b>zoom vertically only</b>).",
00187 QUrl("qrc:/cheatsheet/video/cheatsheet-zoom-in-out.mp4")});
00188 }
00189
00190
00191
00192 void HelpVideo::handleError(QMediaPlayer::Error)
00193 {
00194
00195 const QString errorString = _media_player->errorString();
00196 QString message = "Error: ";
00197 if (errorString.isEmpty())
00198 message += " #" + QString::number(int(_media_player->error()));
00199 else
00200 message += errorString;
00201 qDebug() << message;
00202 }