diff --git a/infowindow.cpp b/infowindow.cpp index 099a272c..4cb52c86 100644 --- a/infowindow.cpp +++ b/infowindow.cpp @@ -17,12 +17,77 @@ #include "infowindow.h" #include +#include +#include +#include +#include // InfoWindow show basic information about the usage of Flameshot InfoWindow::InfoWindow(QWidget *parent) : QWidget(parent) { setAttribute(Qt::WA_DeleteOnClose); + setFixedSize(400, 260); + setWindowFlags(Qt::Dialog | Qt::MSWindowsFixedSizeDialogHint); setWindowIcon(QIcon(":img/flameshot.svg")); setWindowTitle(tr("About")); + + layout = new QVBoxLayout(this); + layout->addWidget(new QLabel("Shortcuts", this)); + initInfoTable(); + layout->addWidget(new QLabel("License", this)); + layout->addWidget(new QLabel("GPLv3+", this)); + layout->addWidget(new QLabel("License", this)); + layout->addWidget(new QLabel("GPLv3+", this)); + layout->addWidget(new QLabel("License", this)); + layout->addWidget(new QLabel("GPLv3+", this)); + + // inform about full screen capture when no selection + show(); } + +namespace { + QVector keys = { + "←↓↑→", + "SHIFT + ←↓↑→", + "ESC", + "CTRL + C", + "CTRL + S", + "CTRL + Z" + }; + + QVector description = { + "Move selection 1px", + "Resize selection 1px", + "Quit capture", + "Copy to clipboard", + "Save selection as a file", + "Undo the last modification" + }; +} + +void InfoWindow::initInfoTable() { + QTableWidget *table = new QTableWidget(this); + layout->addWidget(table); + + table->setColumnCount(2); + table->setRowCount(keys.size()); + table->setSelectionMode(QAbstractItemView::NoSelection); + table->setFocusPolicy(Qt::NoFocus); + table->verticalHeader()->hide(); + table->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); + // header creation + QStringList names; + names << "Key" << "Description"; + table->setHorizontalHeaderLabels(names); + //add content + for (int i= 0; i < keys.size(); ++i){ + table->setItem(i, 0, new QTableWidgetItem(keys.at(i))); + table->setItem(i, 1, new QTableWidgetItem(description.at(i))); + } + // adjust size + table->resizeColumnsToContents(); + table->resizeRowsToContents(); + table->horizontalHeader()->setSectionResizeMode(1, QHeaderView::Stretch); + table->horizontalHeader()->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); +} diff --git a/infowindow.h b/infowindow.h index 4b30343a..5a98cd98 100644 --- a/infowindow.h +++ b/infowindow.h @@ -20,6 +20,8 @@ #include +class QVBoxLayout; + class InfoWindow : public QWidget { Q_OBJECT public: @@ -28,6 +30,10 @@ public: signals: public slots: + +private: + void initInfoTable(); + QVBoxLayout *layout; }; #endif // INFOWINDOW_H