Implement about this program window based on nana's implementation.
This commit is contained in:
parent
520b9fc2e1
commit
92e4f52eb4
5 changed files with 143 additions and 2 deletions
|
@ -17,9 +17,11 @@
|
|||
|
||||
#include "memoserv_win.hpp"
|
||||
#include "app_config.h"
|
||||
#include "version_info_win.hpp"
|
||||
#include <QMenu>
|
||||
#include <QMenuBar>
|
||||
#include <QApplication>
|
||||
|
||||
#include <iostream>
|
||||
|
||||
class QApplication;
|
||||
|
@ -52,6 +54,11 @@ void MemoservWin::create_menu(QApplication* app) {
|
|||
}
|
||||
|
||||
QMenu* const help_menu = menuBar()->addMenu(tr("&Help"));
|
||||
{
|
||||
const auto version_info_act = new QAction(tr("Version &info..."), this);
|
||||
help_menu->addAction(version_info_act);
|
||||
connect(version_info_act, &QAction::triggered, this, &MemoservWin::show_version_info);
|
||||
}
|
||||
{
|
||||
help_menu->addAction(tr("About &Qt..."), app, &QApplication::aboutQt);
|
||||
}
|
||||
|
@ -61,4 +68,11 @@ void MemoservWin::open() {
|
|||
std::cout << "MemoservWin::open()\n";
|
||||
}
|
||||
|
||||
void MemoservWin::show_version_info() {
|
||||
std::cout << "MemoservWin::show_version_info()\n";
|
||||
VersionInfoWin vinfo(this);
|
||||
vinfo.setWindowModality(Qt::WindowModality::WindowModal);
|
||||
vinfo.exec();
|
||||
}
|
||||
|
||||
} //namespace duck
|
||||
|
|
|
@ -33,6 +33,7 @@ public:
|
|||
|
||||
private:
|
||||
void create_menu(QApplication*);
|
||||
void show_version_info();
|
||||
|
||||
void open();
|
||||
};
|
||||
|
|
|
@ -2,10 +2,13 @@ cpp = meson.get_compiler('cpp')
|
|||
fslib_dep = cpp.find_library('stdc++fs', required: false)
|
||||
|
||||
qt5 = import('qt5')
|
||||
qt5_dep = dependency('qt5', modules: ['Core', 'Gui', 'Widgets'])
|
||||
qt5_dep = dependency('qt5', modules: ['Core', 'Gui', 'Widgets'], version: '>=5.14')
|
||||
inc = include_directories('includes')
|
||||
moc_files = qt5.preprocess(
|
||||
moc_headers: 'memoserv_win.hpp',
|
||||
moc_headers: [
|
||||
'memoserv_win.hpp',
|
||||
'version_info_win.hpp',
|
||||
],
|
||||
#ui_files: 'main_window.ui',
|
||||
moc_extra_arguments: ['-DMAKES_MY_MOC_HEADER_COMPILE'],
|
||||
include_directories: inc,
|
||||
|
@ -25,7 +28,12 @@ config_file = configure_file(
|
|||
executable(app_name,
|
||||
'main.cpp',
|
||||
'memoserv_win.cpp',
|
||||
'version_info_win.cpp',
|
||||
moc_files,
|
||||
config_file,
|
||||
project_config_file,
|
||||
gitrev_config_file,
|
||||
include_directories: inc,
|
||||
dependencies: [qt5_dep, fslib_dep],
|
||||
install: true,
|
||||
)
|
||||
|
|
89
src/qt/version_info_win.cpp
Normal file
89
src/qt/version_info_win.cpp
Normal file
|
@ -0,0 +1,89 @@
|
|||
/* Copyright 2020, Michele Santullo
|
||||
* This file is part of memoserv.
|
||||
*
|
||||
* Memoserv is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Memoserv is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Memoserv. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "version_info_win.hpp"
|
||||
#include "app_config.h"
|
||||
#include "config.h"
|
||||
#include "git_version.h"
|
||||
#include <QLabel>
|
||||
#include <QHBoxLayout>
|
||||
#include <QVBoxLayout>
|
||||
#include <memory>
|
||||
#include <QPushButton>
|
||||
|
||||
namespace duck {
|
||||
namespace {
|
||||
const constexpr char g_gpl_text[] =
|
||||
APP_SHORT_DESC "\n"
|
||||
"Copyright (C) " COPYRIGHT_YEAR " Michele Santullo\n"
|
||||
"\n"
|
||||
"This program is free software: you can redistribute it and/or modify\n"
|
||||
"it under the terms of the GNU General Public License as published by\n"
|
||||
"the Free Software Foundation, either version 3 of the License, or\n"
|
||||
"(at your option) any later version.\n"
|
||||
"\n"
|
||||
"This program is distributed in the hope that it will be useful,\n"
|
||||
"but WITHOUT ANY WARRANTY; without even the implied warranty of\n"
|
||||
"MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n"
|
||||
"GNU General Public License for more details.\n"
|
||||
"\n"
|
||||
"You should have received a copy of the GNU General Public License\n"
|
||||
"along with this program. If not, see <https://www.gnu.org/licenses/>.\n"
|
||||
;
|
||||
|
||||
void add_centered_md_label (const std::unique_ptr<QVBoxLayout>& lay, const QString& text) {
|
||||
auto label = std::make_unique<QLabel>();
|
||||
label->setTextFormat(Qt::TextFormat::MarkdownText);
|
||||
label->setText(text);
|
||||
lay->addWidget(label.release(), 0, Qt::AlignCenter);
|
||||
}
|
||||
} //unnamed namespace
|
||||
|
||||
VersionInfoWin::VersionInfoWin (QWidget* parent) :
|
||||
QDialog(parent)
|
||||
{
|
||||
this->setWindowTitle(tr("Version info") + " " + APP_NAME);
|
||||
|
||||
auto main_lay = std::make_unique<QVBoxLayout>();
|
||||
|
||||
add_centered_md_label(main_lay, QString("**") + APP_NAME + "**");
|
||||
add_centered_md_label(main_lay, tr("is part of") + " **" + PROJECT_NAME + "** v" + project_ver());
|
||||
|
||||
if constexpr (sizeof(PROJECT_GIT_SHA1) > 1) {
|
||||
add_centered_md_label(main_lay, tr("git revision") + " [" + PROJECT_GIT_SHA1 + "](" + PROJECT_REPO_URL + "/commit/" + PROJECT_GIT_SHA1 + ")");
|
||||
}
|
||||
add_centered_md_label(main_lay, tr("Official source code repository is available here:"));
|
||||
add_centered_md_label(main_lay, QString("[") + PROJECT_REPO_URL + "](" + PROJECT_REPO_URL + ")");
|
||||
|
||||
{
|
||||
auto txt = std::make_unique<QLabel>();
|
||||
txt->setFrameStyle(QFrame::Panel | QFrame::Sunken);
|
||||
txt->setText(g_gpl_text);
|
||||
main_lay->addWidget(txt.release());
|
||||
}
|
||||
|
||||
{
|
||||
auto close = std::make_unique<QPushButton>();
|
||||
close->setText(tr("&Close"));
|
||||
close->setDefault(true);
|
||||
connect(close.get(), &QPushButton::clicked, [this](){this->close();});
|
||||
main_lay->addWidget(close.release(), 0, Qt::AlignRight);
|
||||
}
|
||||
|
||||
setLayout(main_lay.release());
|
||||
}
|
||||
} //namespace duck
|
29
src/qt/version_info_win.hpp
Normal file
29
src/qt/version_info_win.hpp
Normal file
|
@ -0,0 +1,29 @@
|
|||
/* Copyright 2020, Michele Santullo
|
||||
* This file is part of memoserv.
|
||||
*
|
||||
* Memoserv is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Memoserv is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Memoserv. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <QDialog>
|
||||
|
||||
namespace duck {
|
||||
class VersionInfoWin : public QDialog {
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit VersionInfoWin (QWidget* parent);
|
||||
private:
|
||||
};
|
||||
} //namespace duck
|
Loading…
Add table
Reference in a new issue