Add minor visual improvements to the menu widgets

This commit is contained in:
lupoDharkael
2017-08-01 13:21:39 +02:00
parent ebd5272dd9
commit 3daeab9b66
6 changed files with 39 additions and 23 deletions

View File

@@ -30,22 +30,14 @@ InfoWindow::InfoWindow(QWidget *parent) : QWidget(parent) {
setWindowIcon(QIcon(":img/flameshot.png"));
setWindowTitle(tr("About"));
layout = new QVBoxLayout(this);
layout->addWidget(new QLabel(tr("<b>Shortcuts</b>"), this));
m_layout = new QVBoxLayout(this);
initLabels();
initInfoTable();
layout->addWidget(new QLabel(tr("<b>License</b>"), this));
auto imgGPL = new QLabel(this);
imgGPL->setStyleSheet("background: white; border-color: black; border-width: 2px");
imgGPL->setPixmap(QPixmap(":img/gplv3.png"));
imgGPL->setFixedWidth(imgGPL->pixmap()->width());
layout->addWidget(imgGPL);
show();
}
QVector<const char *> InfoWindow::keys = {
QVector<const char *> InfoWindow::m_keys = {
"←↓↑→",
"SHIFT + ←↓↑→",
"ESC",
@@ -55,7 +47,7 @@ QVector<const char *> InfoWindow::keys = {
QT_TR_NOOP("Right Click")
};
QVector<const char *> InfoWindow::description = {
QVector<const char *> InfoWindow::m_description = {
QT_TR_NOOP("Move selection 1px"),
QT_TR_NOOP("Resize selection 1px"),
QT_TR_NOOP("Quit capture"),
@@ -70,10 +62,10 @@ void InfoWindow::initInfoTable() {
QTableWidget *table = new QTableWidget(this);
table->setToolTip(tr("Available shorcuts in the screen capture mode."));
layout->addWidget(table);
m_layout->addWidget(table);
table->setColumnCount(2);
table->setRowCount(keys.size());
table->setRowCount(m_keys.size());
table->setSelectionMode(QAbstractItemView::NoSelection);
table->setFocusPolicy(Qt::NoFocus);
table->verticalHeader()->hide();
@@ -82,9 +74,9 @@ void InfoWindow::initInfoTable() {
names << tr("Key") << tr("Description");
table->setHorizontalHeaderLabels(names);
//add content
for (int i= 0; i < keys.size(); ++i){
table->setItem(i, 0, new QTableWidgetItem(tr(keys.at(i))));
table->setItem(i, 1, new QTableWidgetItem(tr(description.at(i))));
for (int i= 0; i < m_keys.size(); ++i){
table->setItem(i, 0, new QTableWidgetItem(tr(m_keys.at(i))));
table->setItem(i, 1, new QTableWidgetItem(tr(m_description.at(i))));
}
// adjust size
table->resizeColumnsToContents();
@@ -96,6 +88,29 @@ void InfoWindow::initInfoTable() {
QSizePolicy::Expanding);
}
void InfoWindow::initLabels() {
m_layout->addStretch();
QLabel *licenseTitleLabel = new QLabel(tr("<b>License</b>"), this);
licenseTitleLabel->setAlignment(Qt::AlignHCenter);
m_layout->addWidget(licenseTitleLabel);
QLabel *licenseLabel = new QLabel("GPLv3+", this);
licenseLabel->setAlignment(Qt::AlignHCenter);
m_layout->addWidget(licenseLabel);
m_layout->addStretch();
QLabel *versionTitleLabel = new QLabel(tr("<b>Version</b>"), this);
versionTitleLabel->setAlignment(Qt::AlignHCenter);
m_layout->addWidget(versionTitleLabel);
QLabel *versionLabel = new QLabel(APP_VERSION, this);
versionLabel->setAlignment(Qt::AlignHCenter);
m_layout->addWidget(versionLabel);
m_layout->addStretch();
m_layout->addSpacing(10);
QLabel *shortcutsTitleLabel = new QLabel(tr("<b>Shortcuts</b>"), this);
shortcutsTitleLabel->setAlignment(Qt::AlignHCenter);;
m_layout->addWidget(shortcutsTitleLabel);
}
void InfoWindow::keyPressEvent(QKeyEvent *e) {
if (e->key() == Qt::Key_Escape) {
close();