From 61dd862769a186a05a2b0ca7fe7cc470aa383f25 Mon Sep 17 00:00:00 2001 From: Bent Bisballe Nyeng Date: Sat, 6 Oct 2018 14:59:52 +0200 Subject: Add about dialog. --- AUTHORS | 11 ++++ icons/logo.png | Bin 0 -> 39690 bytes src/Makefile.am | 2 + src/aboutdialog.cc | 181 +++++++++++++++++++++++++++++++++++++++++++++++++++++ src/aboutdialog.h | 54 ++++++++++++++++ src/dgedit.qrc | 4 ++ src/mainwindow.cc | 13 ++++ src/mainwindow.h | 1 + 8 files changed, 266 insertions(+) create mode 100644 icons/logo.png create mode 100644 src/aboutdialog.cc create mode 100644 src/aboutdialog.h diff --git a/AUTHORS b/AUTHORS index e69de29..84d9ece 100644 --- a/AUTHORS +++ b/AUTHORS @@ -0,0 +1,11 @@ +Founder and lead developer: + Bent Bisballe Nyeng [deva] (deva@aasimon.org) + +Developer: + Jonas Suhr Christensen [suhr] (jsc@umbraculum.org) + +Developer: + André Nusser [chaot4] + +Developer, Graphics, GUI design and logo: + Lars Muldjord [muldjord] (muldjordlars@gmail.com) diff --git a/icons/logo.png b/icons/logo.png new file mode 100644 index 0000000..d759548 Binary files /dev/null and b/icons/logo.png differ diff --git a/src/Makefile.am b/src/Makefile.am index 43b87e3..26bb475 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -15,6 +15,7 @@ dgedit_TRANSLATIONS = \ dgedit_SOURCES = \ dgedit.cc \ + aboutdialog.cc \ audioextractor.cc \ canvas.cc \ canvastool.cc \ @@ -46,6 +47,7 @@ dgedit_SOURCES = \ zoomslider.cc EXTRA_DIST = \ + aboutdialog.h \ audioextractor.h \ canvas.h \ canvastool.h \ diff --git a/src/aboutdialog.cc b/src/aboutdialog.cc new file mode 100644 index 0000000..179f176 --- /dev/null +++ b/src/aboutdialog.cc @@ -0,0 +1,181 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/*************************************************************************** + * aboutdialog.cc + * + * Sat Oct 6 14:29:56 CEST 2018 + * Copyright 2018 Bent Bisballe Nyeng + * deva@aasimon.org + ****************************************************************************/ + +/* + * This file is part of DrumGizmo. + * + * DrumGizmo 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 2 of the License, or + * (at your option) any later version. + * + * DrumGizmo 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 DrumGizmo; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. + */ +#include "aboutdialog.h" + +#include "stdio.h" + +#include +#include +#include +#include +#include +#include + +#include + +AboutDialog::AboutDialog(QWidget *parent, Qt::WindowFlags f) + : QDialog(parent, f) +{ + setWindowTitle(tr("About DGEdit")); + setFixedSize(590,500); + + // Read AUTHORS data from file + QFile file(":AUTHORS"); + QByteArray authorsText; + if(file.open(QIODevice::ReadOnly)) + { + authorsText = file.readAll(); + file.close(); + } + else + { + printf("ERROR: Couldn't find AUTHORS file at the designated location.\n"); + authorsText = "ERROR: File not found..."; + } + + // Read COPYING data from file + file.setFileName(":COPYING"); + QByteArray gplText; + if(file.open(QIODevice::ReadOnly)) + { + gplText = file.readAll(); + file.close(); + } + else + { + printf("ERROR: Couldn't find COPYING file at the designated location.\n"); + gplText = "ERROR: File not found..."; + } + + QVBoxLayout *layout = new QVBoxLayout(); + + QHBoxLayout *topLayout = new QHBoxLayout(); + QLabel *logo = new QLabel(); + logo->setPixmap(QPixmap(":icons/logo.png")); + QLabel *title = new QLabel; + title->setWordWrap(true); + title->setText(tr("

DGEdit

" + "

v." VERSION "

" + "Copyright (C) 2008-2018 Bent Bisballe Nyeng - Aasimon.org.
" + "This is free software. You may redistribute copies of it " + "under the terms of the GNU General Public License " + "(http://www.gnu.org/licenses/gpl.html). There is NO " + "WARRANTY, to the extent permitted by law.")); + + topLayout->addWidget(logo); + topLayout->addWidget(title); + topLayout->setStretch(1, 1); + topLayout->setStretch(2, 2); + + QLabel *releaseInfo = new QLabel(authorsText); + releaseInfo->setStyleSheet("QLabel { background-color : white; }"); + + QScrollArea *releaseInfoScroll = new QScrollArea(); + releaseInfoScroll->setWidget(releaseInfo); + releaseInfoScroll->setStyleSheet("QScrollArea { background-color : white; }"); + + QLabel *license = new QLabel(gplText); + license->setStyleSheet("QLabel { font-family: monospace; " + "background-color : white; }"); + licenseScroll = new QScrollArea(); + licenseScroll->setStyleSheet("QScrollArea { background-color : white; }"); + licenseScroll->setWidget(license); + + connect(licenseScroll->verticalScrollBar(), SIGNAL(sliderPressed()), + this, SLOT(noMoreScroll())); + tabs = new QTabWidget(); + connect(tabs, SIGNAL(currentChanged(int)), this, SLOT(checkTab(int))); + tabs->addTab(releaseInfoScroll, "Release Info"); + tabs->addTab(licenseScroll, "License"); + + layout->addLayout(topLayout); + layout->addWidget(tabs); + setLayout(layout); + + scrollState = 0; // 0 = initial state + // 1 = initiate scroll + // 2 = scroll 1 step + // 3 = no more scroll + + scrollTimer = new QTimer(); + scrollTimer->setSingleShot(true); + connect(scrollTimer, SIGNAL(timeout()), this, SLOT(scroll())); +} + +void AboutDialog::mousePressEvent(QMouseEvent * event) +{ + if(event) // TODO: Perhaps do a mouse click check on the event + { + accept(); + } +} + +void AboutDialog::scroll() +{ + switch(scrollState) + { + case 0 : // 0 = initial state + scrollState = 1; + scrollTimer->setInterval(5000); + scrollTimer->start(); + break; + case 1 : // 1 = initiate scroll + scrollState = 2; + licenseScroll->verticalScrollBar()->setValue(0); + scrollTimer->setInterval(200); + scrollTimer->start(); + break; + case 2 : // 2 = scroll 1 step + licenseScroll->verticalScrollBar()-> + setValue(licenseScroll->verticalScrollBar()->value() + 2); + if(licenseScroll->verticalScrollBar()->value() >= + licenseScroll->verticalScrollBar()->maximum()) + { + scrollState = 0; + } + scrollTimer->start(); + break; + case 3 : // 3 = no more scroll + scrollTimer->stop(); + break; + } +} + +void AboutDialog::noMoreScroll() +{ + scrollState = 3; +} + +void AboutDialog::checkTab(int tabIndex) +{ + if(tabIndex == 1) + { + scrollState = 0; + scrollTimer->stop(); + scroll(); + } +} diff --git a/src/aboutdialog.h b/src/aboutdialog.h new file mode 100644 index 0000000..f7200a3 --- /dev/null +++ b/src/aboutdialog.h @@ -0,0 +1,54 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/*************************************************************************** + * aboutdialog.h + * + * Sat Oct 6 14:29:56 CEST 2018 + * Copyright 2018 Bent Bisballe Nyeng + * deva@aasimon.org + ****************************************************************************/ + +/* + * This file is part of DrumGizmo. + * + * DrumGizmo 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 2 of the License, or + * (at your option) any later version. + * + * DrumGizmo 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 DrumGizmo; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. + */ +#pragma once + +#include +#include +#include +#include + +class AboutDialog + : public QDialog +{ + Q_OBJECT +public: + AboutDialog(QWidget *parent, Qt::WindowFlags f); + +public slots: + void scroll(); + void noMoreScroll(); + void checkTab(int tabIndex); + +signals: + +private: + void mousePressEvent(QMouseEvent * event); + QScrollArea *licenseScroll; + QTimer *scrollTimer; + int scrollState; + QTabWidget *tabs; +}; diff --git a/src/dgedit.qrc b/src/dgedit.qrc index 1b03641..7523730 100644 --- a/src/dgedit.qrc +++ b/src/dgedit.qrc @@ -1,6 +1,10 @@ + ../AUTHORS + ../COPYING + + ../icons/logo.png ../icons/master.png ../icons/file.png ../icons/instrument.png diff --git a/src/mainwindow.cc b/src/mainwindow.cc index 8cd34ba..68b0d91 100644 --- a/src/mainwindow.cc +++ b/src/mainwindow.cc @@ -47,6 +47,7 @@ #include "projectserialiser.h" #include "instrumentwidget.h" #include "channelswidget.h" +#include "aboutdialog.h" #include "imageeditor.h" @@ -100,6 +101,11 @@ MainWindow::MainWindow(Settings& settings) testMenu->addAction(act_test); connect(act_test, SIGNAL(triggered()), this, SLOT(test())); + QMenu* helpMenu = menuBar()->addMenu(tr("Help")); + QAction* act_about = new QAction(tr("About"), this); + helpMenu->addAction(act_about); + connect(act_about, SIGNAL(triggered()), this, SLOT(showAbout())); + instruments_dock = new QDockWidget(tr("Instruments:"), this); instruments_dock->setObjectName("instruments_dock"); instruments_dock->setAllowedAreas(Qt::LeftDockWidgetArea); @@ -599,3 +605,10 @@ void MainWindow::editProject() dlg.show(); dlg.exec(); } + +void MainWindow::showAbout() +{ + AboutDialog dlg(this, Qt::Dialog); + dlg.show(); + dlg.exec(); +} diff --git a/src/mainwindow.h b/src/mainwindow.h index 067ac0f..eee8f47 100644 --- a/src/mainwindow.h +++ b/src/mainwindow.h @@ -69,6 +69,7 @@ private slots: void test(); void render(); void editProject(); + void showAbout(); protected: void closeEvent(QCloseEvent*); -- cgit v1.2.3