ui : License Menu
3rd Party Licenses in Menu Help -> Licenses
This commit is contained in:
@@ -91,6 +91,8 @@ add_files(
|
||||
qt/view/QtViewWidgetWrapper.cpp
|
||||
qt/view/QtViewWidgetWrapper.h
|
||||
|
||||
qt/window/QtAboutLicense.cpp
|
||||
qt/window/QtAboutLicense.h
|
||||
qt/window/QtApplicationSettingsScreen.cpp
|
||||
qt/window/QtApplicationSettingsScreen.h
|
||||
qt/window/QtMainWindow.cpp
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
#ifndef LICENSES_H
|
||||
#define LICENSES_H
|
||||
|
||||
// This File(licenses.h) is generated with CMake
|
||||
|
||||
struct ThirdPartyLicense {
|
||||
const char* name;
|
||||
const char* url;
|
||||
const char* license;
|
||||
|
||||
ThirdPartyLicense() : name(0), url(0), license(0) {}
|
||||
ThirdPartyLicense(const char* name, const char* url, const char* license)
|
||||
: name(name), url(url), license(license) {}
|
||||
bool isEmpty() const { return (name == 0 && url == 0 && license == 0); }
|
||||
};
|
||||
|
||||
// License Textfiles
|
||||
@LICENSES@
|
||||
|
||||
static const ThirdPartyLicense licenses3rdParties[] = {
|
||||
@LICENSE_ARRAY@
|
||||
};
|
||||
|
||||
#endif //LICENSES_H
|
||||
@@ -0,0 +1,73 @@
|
||||
#include "qt/window/QtAboutLicense.h"
|
||||
|
||||
#include <QComboBox>
|
||||
#include <QFormLayout>
|
||||
#include <QLineEdit>
|
||||
#include <QLabel>
|
||||
#include <QTextBrowser>
|
||||
#include <QTextBlock>
|
||||
#include <QTextEdit>
|
||||
|
||||
#include "licenses.h"
|
||||
|
||||
QtAboutLicense::QtAboutLicense(QWidget *parent)
|
||||
: QtSettingsWindow(parent)
|
||||
{
|
||||
raise();
|
||||
}
|
||||
|
||||
QSize QtAboutLicense::sizeHint() const
|
||||
{
|
||||
return QSize(600,600);
|
||||
}
|
||||
|
||||
void QtAboutLicense::setup()
|
||||
{
|
||||
setupForm();
|
||||
|
||||
updateTitle("3rd Party Licenses");
|
||||
updateDoneButton("Ok");
|
||||
hideCancelButton(true);
|
||||
}
|
||||
|
||||
void QtAboutLicense::populateForm(QFormLayout* layout)
|
||||
{
|
||||
int minimumWidthForSecondCol = 360;
|
||||
|
||||
for(ThirdPartyLicense license : licenses3rdParties)
|
||||
{
|
||||
QLabel* licenseName = new QLabel();
|
||||
licenseName->setText( QString::fromLatin1(license.name));
|
||||
QFont _font = licenseName->font();
|
||||
_font.setPixelSize(36);
|
||||
licenseName->setFont(_font);
|
||||
layout->addWidget(licenseName);
|
||||
|
||||
QLabel* licenseURL = new QLabel();
|
||||
licenseURL->setText(QString::fromLatin1("(<a href=\"%1\">Website</a>)")
|
||||
.arg(QString::fromLatin1(license.url)));
|
||||
licenseURL->setOpenExternalLinks(true);
|
||||
layout->addWidget(licenseURL);
|
||||
|
||||
QLabel* licenseText = new QLabel();
|
||||
licenseText->setFixedWidth(450);
|
||||
licenseText->setWordWrap(true);
|
||||
licenseText->setText(QString::fromLatin1(license.license));
|
||||
layout->addWidget(licenseText);
|
||||
}
|
||||
}
|
||||
|
||||
void QtAboutLicense::handleCancelButtonPress()
|
||||
{
|
||||
emit canceled();
|
||||
}
|
||||
|
||||
void QtAboutLicense::handleUpdateButtonPress()
|
||||
{
|
||||
close();
|
||||
}
|
||||
|
||||
void QtAboutLicense::handleDoneButtonPress()
|
||||
{
|
||||
close();
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
#ifndef QT_ABOUT_LICENSE_H
|
||||
#define QT_ABOUT_LICENSE_H
|
||||
|
||||
#include <QPushButton>
|
||||
#include <QWidget>
|
||||
|
||||
#include "qt/window/QtSettingsWindow.h"
|
||||
|
||||
class QtAboutLicense
|
||||
: public QtSettingsWindow
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
QtAboutLicense(QWidget* parent = 0);
|
||||
QSize sizeHint() const Q_DECL_OVERRIDE;
|
||||
|
||||
virtual void setup() override;
|
||||
protected:
|
||||
virtual void populateForm(QFormLayout* layout) override;
|
||||
|
||||
private slots:
|
||||
void handleCancelButtonPress();
|
||||
void handleUpdateButtonPress();
|
||||
void handleDoneButtonPress();
|
||||
|
||||
private:
|
||||
QPushButton* m_cancelButton;
|
||||
QPushButton* m_updateButton;
|
||||
|
||||
};
|
||||
|
||||
#endif //QT_ABOUT_LICENSE_H
|
||||
@@ -24,6 +24,7 @@
|
||||
#include "utility/messaging/type/MessageZoom.h"
|
||||
#include "version.h"
|
||||
|
||||
|
||||
QtMainWindow::QtMainWindow()
|
||||
: m_startScreenWasVisible(false)
|
||||
{
|
||||
@@ -182,6 +183,11 @@ void QtMainWindow::hideScreens()
|
||||
{
|
||||
m_newProjectDialog->hide();
|
||||
}
|
||||
|
||||
if(m_licenseWindow)
|
||||
{
|
||||
m_licenseWindow->hide();
|
||||
}
|
||||
}
|
||||
|
||||
void QtMainWindow::closeScreens()
|
||||
@@ -365,10 +371,12 @@ void QtMainWindow::setupProjectMenu()
|
||||
menu->addAction(tr("E&xit"), QCoreApplication::instance(), SLOT(quit()), QKeySequence::Quit);
|
||||
}
|
||||
|
||||
void QtMainWindow::showLicences()
|
||||
void QtMainWindow::showLicenses()
|
||||
{
|
||||
//TODO: Licences
|
||||
//QMessageBox::information()
|
||||
hideScreens();
|
||||
m_licenseWindow = std::make_shared<QtAboutLicense>(this);
|
||||
m_licenseWindow->setup();
|
||||
m_licenseWindow->show();
|
||||
}
|
||||
|
||||
void QtMainWindow::setupEditMenu()
|
||||
@@ -399,8 +407,7 @@ void QtMainWindow::setupHelpMenu()
|
||||
menuBar()->addMenu(menu);
|
||||
|
||||
menu->addAction(tr("&About"), this, SLOT(about()));
|
||||
menu->addAction(tr("About &Qt"), QCoreApplication::instance(), SLOT(aboutQt()));
|
||||
//menu->addAction(tr("Licences"), QCoreApplication::instance(), SLOT(showLicences()));
|
||||
menu->addAction(tr("Licences"), this, SLOT(showLicenses()));
|
||||
menu->addAction(tr("Preferences..."), this, SLOT(openSettings()));
|
||||
}
|
||||
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
#include "qt/window/QtApplicationSettingsScreen.h"
|
||||
#include "qt/window/QtStartScreen.h"
|
||||
#include "qt/window/QtProjectSetupScreen.h"
|
||||
#include "qt/window/QtAboutLicense.h"
|
||||
|
||||
class QDockWidget;
|
||||
class View;
|
||||
@@ -56,7 +57,7 @@ public slots:
|
||||
void saveProject();
|
||||
void saveAsProject();
|
||||
|
||||
void showLicences();
|
||||
void showLicenses();
|
||||
|
||||
void undo();
|
||||
void redo();
|
||||
@@ -79,6 +80,7 @@ private:
|
||||
std::shared_ptr<QtApplicationSettingsScreen> m_applicationSettingsScreen;
|
||||
std::shared_ptr<QtStartScreen> m_startScreen;
|
||||
std::shared_ptr<QtProjectSetupScreen> m_newProjectDialog;
|
||||
std::shared_ptr<QtAboutLicense> m_licenseWindow;
|
||||
|
||||
std::vector<std::pair<View*, QDockWidget*>> m_dockWidgets;
|
||||
|
||||
|
||||
@@ -181,3 +181,11 @@ void QtSettingsWindow::updateDoneButton(QString text)
|
||||
m_doneButton->setText(text);
|
||||
}
|
||||
}
|
||||
|
||||
void QtSettingsWindow::hideCancelButton(bool hidden)
|
||||
{
|
||||
if(m_cancelButton)
|
||||
{
|
||||
m_cancelButton->setVisible(!hidden);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -36,6 +36,7 @@ protected:
|
||||
|
||||
void updateTitle(QString title);
|
||||
void updateDoneButton(QString text);
|
||||
void hideCancelButton(bool hidden);
|
||||
|
||||
QWidget* m_window;
|
||||
|
||||
|
||||
@@ -1,4 +1,9 @@
|
||||
#ifndef COATI_VERSION_H
|
||||
#define COATI_VERSION_H
|
||||
|
||||
#define GIT_BRANCH "@GIT_BRANCH@"
|
||||
#define GIT_VERSION_NUMBER "@GIT_VERSION_NUMBER@"
|
||||
#define GIT_COMMIT_HASH "@GIT_COMMIT_HASH@"
|
||||
#define GIT_COMMIT_TIME "@GIT_COMMIT_TIME@"
|
||||
|
||||
#endif // COATI_VERSION_H
|
||||
|
||||
Reference in New Issue
Block a user