Add infoWindow content

This commit is contained in:
lupoDharkael
2017-05-13 20:09:14 +02:00
parent 87aaf711d1
commit 2de3045288
2 changed files with 71 additions and 0 deletions

View File

@@ -17,12 +17,77 @@
#include "infowindow.h"
#include <QIcon>
#include <QVBoxLayout>
#include <QTableWidget>
#include <QHeaderView>
#include <QLabel>
// 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("<b>Shortcuts</b>", this));
initInfoTable();
layout->addWidget(new QLabel("<b>License</b>", this));
layout->addWidget(new QLabel("GPLv3+", this));
layout->addWidget(new QLabel("<b>License</b>", this));
layout->addWidget(new QLabel("GPLv3+", this));
layout->addWidget(new QLabel("<b>License</b>", this));
layout->addWidget(new QLabel("GPLv3+", this));
// inform about full screen capture when no selection
show();
}
namespace {
QVector<QString> keys = {
"←↓↑→",
"SHIFT + ←↓↑→",
"ESC",
"CTRL + C",
"CTRL + S",
"CTRL + Z"
};
QVector<QString> 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);
}

View File

@@ -20,6 +20,8 @@
#include <QWidget>
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