OSDN Git Service

[BUILD] Set SOVERSION and GIT hash automatically.
[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 #include "mainwidget_base.h"
18
19 //extern USING_FLAGS *using_flags;
20
21 Dlg_AboutCSP::Dlg_AboutCSP(USING_FLAGS *p, QWidget *parent) : QWidget(NULL)
22 {
23         QByteArray tmps;
24         QFile f_credits(":/credits.html");
25         QFile f_rev(":/revision.txt");
26         QString credits;
27         QString rev;
28         QImage image;
29         QUrl url;
30         QStringList pathes;
31         
32         parent_widget = parent;
33         using_flags = p;
34         // Credits
35         credits.clear();
36         printf("%x\n",parent_widget);
37         if(f_credits.open(QIODevice::ReadOnly | QIODevice::Text)) {
38                 tmps = f_credits.readAll();
39                 if(!tmps.isEmpty()) {
40                         QString ss;
41                         QString bs;
42                         ss.clear();
43                         QString ns = QString::fromUtf8(tmps);
44                         if(parent != NULL) {
45                                 ss = static_cast<Ui_MainWindowBase *>(parent)->get_system_version();
46                                 bs = static_cast<Ui_MainWindowBase *>(parent)->get_build_date();
47                         }
48                         QString reps = QString::fromUtf8("@@RevisionString@@");
49                         int ni = ns.indexOf(reps);
50                         if(ni >= 0) {
51                                 ns.replace(ni, reps.length(), ss);
52                         }
53                         reps = QString::fromUtf8("@@BuildDateAt@@");
54                         ni = ns.indexOf(reps);
55                         if(ni >= 0) {
56                                 ns.replace(ni, reps.length(), bs);
57                         }
58                         
59                         credits = ns;
60                 }
61                 f_credits.close();
62         }
63         //credits = QString::fromUtf8("file:::/credits.html");
64         //url = QUrl::fromEncoded("file://:/credits.html");
65         TextBox = new QTextBrowser();
66         TextBox->setStyleSheet("font: 12pt \"Sans\";");
67         TextBox->setHtml(credits);
68         TextBox->setMinimumSize(640, 420);
69         TextBox->setOpenExternalLinks(true);
70
71         pathes << QString::fromUtf8(":/");
72         TextBox->setSearchPaths(pathes);
73         
74         image.load(":/default.ico");
75
76         iconarea = new QLabel(parent);
77         iconarea->setPixmap(QPixmap::fromImage(image));
78         iconarea->setFixedSize(image.width() + 5, image.height() + 5);
79
80         QString name;
81         titlearea = new QLabel(parent);
82         name = QString::fromUtf8("<div align=left><B><FONT SIZE=+1>Common Source Code Project</B></div>");
83         name.append(QString::fromUtf8("<div align=center>for&nbsp;&nbsp;<FONT SIZE=+1><B>"));
84         name.append(using_flags->get_device_name());
85         name.append(QString::fromUtf8("</B></FONT></div>"));
86         titlearea->setText(name);
87         titlearea->setAlignment(Qt::AlignRight);
88         titlearea->setStyleSheet("font: 12pt \"Sans\";");
89    
90         rev.clear();
91         if(f_rev.open(QIODevice::ReadOnly | QIODevice::Text)) {
92                 tmps = f_rev.readAll();
93                 if(!tmps.isEmpty()) {
94                         rev = tmps;
95                 }
96                 f_rev.close();
97         }
98         revarea = new QLabel(parent);
99         revarea->setText(rev);
100         revarea->setAlignment(Qt::AlignRight);
101    
102         HBox1 = new QHBoxLayout;
103         HBox1->addWidget(iconarea);
104         HBox1->addWidget(titlearea);
105
106         //BoxTitle = new QGroupBox();
107         BoxTitle = new QWidget(this);
108         BoxTitle->setLayout(HBox1);
109
110         VBox = new QVBoxLayout;
111         VBox->addWidget(BoxTitle);
112         VBox->addWidget(revarea);
113         VBox->addWidget(TextBox);
114         this->setLayout(VBox);
115
116         QString title;
117         title = QString::fromUtf8("About emu");
118         title.append(using_flags->get_config_name());
119         if(parent == NULL) this->setWindowTitle(title);
120 }
121
122 Dlg_AboutCSP::~Dlg_AboutCSP()
123 {
124
125 }       
126