File indexing completed on 2024-12-15 04:00:59

0001 /*
0002  * SPDX-FileCopyrightText: 2019-2023 Mattia Basaglia <dev@dragon.best>
0003  *
0004  * SPDX-License-Identifier: GPL-3.0-or-later
0005  */
0006 
0007 #include "help_dialog.hpp"
0008 
0009 #include <QScrollArea>
0010 #include <QLabel>
0011 #include <QGridLayout>
0012 #include <QFrame>
0013 
0014 #include "io/io_registry.hpp"
0015 #include "style/scroll_area_event_filter.hpp"
0016 #include "glaxnimate_app.hpp"
0017 
0018 glaxnimate::android::HelpDialog::HelpDialog(QWidget *parent)
0019     : BaseDialog(parent)
0020 {
0021     QGridLayout* ml = new QGridLayout(this);
0022     ml->setMargin(0);
0023     setLayout(ml);
0024 
0025     QScrollArea* area = new QScrollArea(this);
0026     ml->addWidget(area, 0, 0);
0027     (new gui::ScrollAreaEventFilter(area))->setParent(area);
0028     area->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
0029     area->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
0030     area->setWidgetResizable(true);
0031 
0032     QWidget* wid = new QWidget(area);
0033     area->setWidget(wid);
0034 
0035     QGridLayout* lay = new QGridLayout(wid);
0036     lay->setMargin(0);
0037     wid->setLayout(lay);
0038 
0039     QString supported_formats_import;
0040     for ( const auto& fmt : io::IoRegistry::instance().importers() )
0041     {
0042         if ( fmt->slug() == "raster" )
0043             continue;
0044         if ( !supported_formats_import.isEmpty() )
0045             supported_formats_import += "\n";
0046         supported_formats_import += " - " + fmt->name();
0047     }
0048     QString supported_formats_export = supported_formats_import;
0049     supported_formats_import += "\n - PNG (Needs to be traced into vector)";
0050 
0051     const std::vector<std::pair<QString, QString>> buttons = {
0052         {
0053             "document-new",
0054             i18n("Clears the current document and creates a new empty one")
0055         },
0056         {
0057             "document-open",
0058             i18n("Prompts the user to select a document to open.\nCurrently the following formats are supported:\n%1", supported_formats_import)
0059         },
0060         {
0061             "document-import",
0062             i18n("Prompts the user to select a document to append as an object to the current one.")
0063         },
0064         {
0065             "document-save",
0066             i18n("Save the current document, prompting to select a file for new documents")
0067         },
0068         {
0069             "document-save-as",
0070             i18n("Save the current document, always prompting to select a file.")
0071         },
0072         {
0073             "document-export",
0074             i18n("Save a copy of current document, prompting to select a format and a file.\nCurrently the following formats are supported:\n%1", supported_formats_export)
0075         },
0076         {
0077             "view-preview",
0078             i18n("Saves the current frame as a still image")
0079         },
0080         {
0081             "telegram",
0082             i18n("Creates a sticker pack to export to Telegram.\nNote that only recent version of Telegram support this.\nIf your Telegram version is too old, you can Export the file to TGS and upload that on Telegram.")
0083         },
0084         {
0085             "edit-cut",
0086             i18n("Cuts the selection into the clipboard.")
0087         },
0088         {
0089             "edit-copy",
0090             i18n("Copies the selection into the clipboard.")
0091         },
0092         {
0093             "edit-paste",
0094             i18n("Pastes from the clipboard into the current document.")
0095         },
0096         {
0097             "edit-delete",
0098             i18n("Removes the selected item.")
0099         },
0100         {
0101             "edit-undo",
0102             i18n("Undoes the last action.")
0103         },
0104         {
0105             "edit-redo",
0106             i18n("Redoes the last undone action.")
0107         },
0108         {
0109             "document-properties",
0110             i18n("Opens the side pane used to change the advanced properties for the selected object.")
0111         },
0112         {
0113             "player-time",
0114             i18n("Shows the timeline and playback controls.")
0115         },
0116         {
0117             "fill-color",
0118             i18n("Opens the side pane used to select the fill color.")
0119         },
0120         {
0121             "object-stroke-style",
0122             i18n("Opens the side pane used to select the stroke color and style.")
0123         },
0124         {
0125             "question",
0126             i18n("Shows this help.")
0127         },
0128         {
0129             "edit-select",
0130             i18n("Select tool, you can use it to select objects and change their transform.")
0131         },
0132         {
0133             "edit-node",
0134             i18n("Edit tool, used to edit existing items (eg: moving, bezier nodes, setting rounded corners on a rectangle, etc.)")
0135         },
0136         {
0137             "draw-brush",
0138             i18n("Shows a tray with the curve drawing tools.")
0139         },
0140         {
0141             "draw-bezier-curves",
0142             i18n("Create Bezier curves using nodes and handles.")
0143         },
0144         {
0145             "draw-freehand",
0146             i18n("Draw curves freehand.")
0147         },
0148         {
0149             "shapes",
0150             i18n("Shows a tray with the shape drawing tools.")
0151         },
0152         {
0153             "draw-rectangle",
0154             i18n("Draws rectangles.")
0155         },
0156         {
0157             "draw-ellipse",
0158             i18n("Draws ellipses.")
0159         },
0160         {
0161             "draw-polygon-star",
0162             i18n("Draws a star, after it's been created you can change it into a regular polygon and change the number of sides from the properties pane.")
0163         },
0164         {
0165             "draw-text",
0166             i18n("Create and edit text shapes.")
0167         },
0168         {
0169             "overflow-menu",
0170             i18n("Toggles the menu showing non-drawing buttons.")
0171         },
0172         {
0173             "media-playback-start",
0174             i18n("Starts playback.")
0175         },
0176         {
0177             "media-playlist-repeat",
0178             i18n("Toggles looping for the playback (on by default).")
0179         },
0180         {
0181             "go-first",
0182             i18n("Jumps to the first frame.")
0183         },
0184         {
0185             "go-previous",
0186             i18n("Goes to the previous frame.")
0187         },
0188         {
0189             "go-next",
0190             i18n("Goes to the next frame.")
0191         },
0192         {
0193             "go-last",
0194             i18n("Jumps to the last frame.")
0195         },
0196         {
0197             "keyframe-record",
0198             i18n("When enabled (which is the default) whenever you change an object property, a new keyframe is added for that property.")
0199         },
0200         {
0201             "layer-lower",
0202             i18n("Push the selection further back.")
0203         },
0204         {
0205             "layer-raise",
0206             i18n("Brings the selection further to the front.")
0207         },
0208     };
0209 
0210     QSize pix_size(128, 128);
0211 
0212     int row = 0;
0213 
0214     QLabel* logo = new QLabel(wid);
0215     logo->setPixmap(QIcon(gui::GlaxnimateApp::instance()->data_file("images/splash.svg")).pixmap(pix_size * 2));
0216     logo->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred);
0217     lay->addWidget(logo, row++, 0, 1, 2, Qt::AlignCenter);
0218 
0219     QLabel* global_desc = new QLabel(wid);
0220     global_desc->setText(tr(R"(
0221 Glaxnimate is a vector animation program.
0222 You can use it to create and modify Animated SVG, Telegram Animated Stickers, and Lottie animations.
0223 Follows a guide of the main icons and what they do.
0224 )"));
0225     global_desc->setWordWrap(true);
0226     lay->addWidget(global_desc, row++, 0, 1, 2);
0227 
0228     for ( const auto& p : buttons )
0229     {
0230         QFrame *line = new QFrame(wid);
0231         line->setFrameShape(QFrame::HLine);
0232         line->setFrameShadow(QFrame::Sunken);
0233         lay->addWidget(line, row++, 0, 1, 2);
0234 
0235         QLabel* preview = new QLabel(wid);
0236         preview->setPixmap(QIcon::fromTheme(p.first).pixmap(pix_size));
0237         preview->setMinimumSize(pix_size);
0238         preview->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred);
0239         lay->addWidget(preview, row, 0, Qt::AlignTop|Qt::AlignHCenter);
0240 
0241         QLabel* desc = new QLabel(wid);
0242         desc->setText(p.second);
0243         desc->setMinimumSize(pix_size);
0244         desc->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Minimum);
0245         desc->setWordWrap(true);
0246         lay->addWidget(desc, row, 1);
0247 
0248         row++;
0249     }
0250 }