OSDN Git Service

3a124a0175976c61a235a90a19c6716f09e3ec01
[csp-qt/common_source_project-fm7.git] / source / src / qt / gui / display_about.cpp
1 /*
2  * Common Source Project/ Qt
3  * (C) 2015 K.Ohta <whatisthis.sowhat _at_ gmail.com>
4  *  Qt: Menu->Help->About Dialog
5  *  History: Oct 28, 2015 : Initial
6  */
7
8
9 #include <QFile>
10 #include <QString>
11 #include <QByteArray>
12 #include <QIODevice>
13 #include <QStringList>
14
15 #include "display_about.h"
16 #include "menu_flags.h"
17
18 //extern USING_FLAGS *using_flags;
19
20 Dlg_AboutCSP::Dlg_AboutCSP(USING_FLAGS *p, QWidget *parent) : QWidget(parent)
21 {
22         QByteArray tmps;
23         QFile f_credits(":/credits.html");
24         QFile f_rev(":/revision.txt");
25         QString credits;
26         QString rev;
27         QImage image;
28         QUrl url;
29         QStringList pathes;
30         
31         parent_widget = parent;
32         using_flags = p;
33         // Credits
34         credits.clear();
35         if(f_credits.open(QIODevice::ReadOnly | QIODevice::Text)) {
36                 tmps = f_credits.readAll();
37                 if(!tmps.isEmpty()) {
38                         credits = tmps;
39                 }
40                 f_credits.close();
41         }
42         //credits = QString::fromUtf8("file:::/credits.html");
43         //url = QUrl::fromEncoded("file://:/credits.html");
44         TextBox = new QTextBrowser();
45         TextBox->setStyleSheet("font: 12pt \"Sans\";");
46         TextBox->setHtml(credits);
47         TextBox->setMinimumSize(640, 420);
48         TextBox->setOpenExternalLinks(true);
49
50         pathes << QString::fromUtf8(":/");
51         TextBox->setSearchPaths(pathes);
52         
53         image.load(":/default.ico");
54
55         iconarea = new QLabel(parent);
56         iconarea->setPixmap(QPixmap::fromImage(image));
57         iconarea->setFixedSize(image.width() + 5, image.height() + 5);
58
59         QString name;
60         titlearea = new QLabel(parent);
61         name = QString::fromUtf8("<div align=left><B><FONT SIZE=+1>Common Source Code Project</B></div>");
62         name.append(QString::fromUtf8("<div align=center>for&nbsp;&nbsp;<FONT SIZE=+1><B>"));
63         name.append(using_flags->get_device_name());
64         name.append(QString::fromUtf8("</B></FONT></div>"));
65         titlearea->setText(name);
66         titlearea->setAlignment(Qt::AlignRight);
67         titlearea->setStyleSheet("font: 12pt \"Sans\";");
68    
69         rev.clear();
70         if(f_rev.open(QIODevice::ReadOnly | QIODevice::Text)) {
71                 tmps = f_rev.readAll();
72                 if(!tmps.isEmpty()) {
73                         rev = tmps;
74                 }
75                 f_rev.close();
76         }
77         revarea = new QLabel(parent);
78         revarea->setText(rev);
79         revarea->setAlignment(Qt::AlignRight);
80    
81         HBox1 = new QHBoxLayout;
82         HBox1->addWidget(iconarea);
83         HBox1->addWidget(titlearea);
84
85         //BoxTitle = new QGroupBox();
86         BoxTitle = new QWidget(this);
87         BoxTitle->setLayout(HBox1);
88
89         VBox = new QVBoxLayout;
90         VBox->addWidget(BoxTitle);
91         VBox->addWidget(revarea);
92         VBox->addWidget(TextBox);
93         this->setLayout(VBox);
94
95         QString title;
96         title = QString::fromUtf8("About emu");
97         title.append(using_flags->get_config_name());
98         if(parent == NULL) this->setWindowTitle(title);
99 }
100
101 Dlg_AboutCSP::~Dlg_AboutCSP()
102 {
103
104 }