Anoncoin  0.9.4
P2P Digital Currency
utilitydialog.cpp
Go to the documentation of this file.
1 // Copyright (c) 2011-2014 The Bitcoin developers
2 // Copyright (c) 2013-2015 The Anoncoin Core developers
3 // Distributed under the MIT/X11 software license, see the accompanying
4 // file COPYING or http://www.opensource.org/licenses/mit-license.php.
5 
6 #include "utilitydialog.h"
7 
8 #include "ui_aboutdialog.h"
9 #include "ui_helpmessagedialog.h"
10 
11 #include "anoncoingui.h"
12 #include "clientmodel.h"
13 #include "guiutil.h"
14 
15 #include "clientversion.h"
16 #include "init.h"
17 #include "util.h"
18 
19 #include <QLabel>
20 #include <QVBoxLayout>
21 
23 AboutDialog::AboutDialog(QWidget *parent) :
24  QDialog(parent),
25  ui(new Ui::AboutDialog)
26 {
27  ui->setupUi(this);
28 
29  // Set current copyright year for all the crypos we're involved in mining and algos from...
30  ui->copyrightLabel->setText(tr("Copyright") + QString(" &copy; 2013-%1 ").arg(COPYRIGHT_YEAR) + tr("The Anoncoin Core developers")
31  + QString("<br>") + tr("Copyright") + QString(" &copy; 2009-%1 ").arg(2015) + tr("The Bitcoin Core developers")
32  + QString("<br>") + tr("Copyright") + QString(" &copy; 2011-%1 ").arg(2014) + tr("The Litecoin Core developers")
33  + QString("<br>") + tr("Copyright") + QString(" &copy; 2013 ") + tr("The Primecoin developers"));
34 }
35 
37 {
38  if(model)
39  {
40  QString version = model->formatFullVersion();
41  /* On x86 add a bit specifier to the version so that users can distinguish between
42  * 32 and 64 bit builds. On other architectures, 32/64 bit may be more ambigious.
43  */
44 #if defined(__x86_64__)
45  version += " " + tr("(%1-bit)").arg(64);
46 #elif defined(__i386__ )
47  version += " " + tr("(%1-bit)").arg(32);
48 #endif
49  ui->versionLabel->setText(version);
50  }
51 }
52 
54 {
55  delete ui;
56 }
57 
59 {
60  close();
61 }
62 
65  QDialog(parent),
66  ui(new Ui::HelpMessageDialog)
67 {
68  ui->setupUi(this);
69  GUIUtil::restoreWindowGeometry("nHelpMessageDialogWindow", this->size(), this);
70 
71  header = tr("Anoncoin Core") + " " + tr("version") + " " +
72  QString::fromStdString(FormatFullVersion()) + "\n\n" +
73  tr("Usage:") + "\n" +
74  " anoncoin-qt [" + tr("command-line options") + "] " + "\n";
75 
76  coreOptions = QString::fromStdString(HelpMessage(HMM_ANONCOIN_QT));
77 
78  uiOptions = tr("UI options") + ":\n" +
79  " -choosedatadir " + tr("Choose data directory on startup (default: 0)") + "\n" +
80  " -lang=<lang> " + tr("Set language, for example \"de_DE\" (default: system locale)") + "\n" +
81  " -min " + tr("Start minimized") + "\n" +
82  " -rootcertificates=<file> " + tr("Set SSL root certificates for payment request (default: -system-)") + "\n" +
83  " -splash " + tr("Show splash screen on startup (default: 1)");
84 
86 
87  // Set help message text
88  ui->helpMessageLabel->setText(header + "\n" + coreOptions + "\n" + uiOptions);
89 }
90 
92 {
93  GUIUtil::saveWindowGeometry("nHelpMessageDialogWindow", this);
94  delete ui;
95 }
96 
98 {
99  // On other operating systems, the expected action is to print the message to the console.
100  QString strUsage = header + "\n" + coreOptions + "\n" + uiOptions + "\n";
101  fprintf(stdout, "%s", strUsage.toStdString().c_str());
102 }
103 
105 {
106 #if defined(WIN32)
107  // On Windows, show a message box, as there is no stderr/stdout in windowed applications
108  exec();
109 #else
110  // On other operating systems, print help text to console
111  printToConsole();
112 #endif
113 }
114 
116 {
117  close();
118 }
119 
120 
123 {
124  if (!window)
125  return;
126 
127  // Show a simple window indicating shutdown status
128  QWidget *shutdownWindow = new QWidget();
129  QVBoxLayout *layout = new QVBoxLayout();
130  layout->addWidget(new QLabel(
131  tr("Anoncoin Core is shutting down...") + "<br /><br />" +
132  tr("Do not shut down the computer until this window disappears.")));
133  shutdownWindow->setLayout(layout);
134  shutdownWindow->setWindowTitle(window->windowTitle());
135 
136  // Center shutdown window at where main window was
137  const QPoint global = window->mapToGlobal(window->rect().center());
138  shutdownWindow->move(global.x() - shutdownWindow->width() / 2, global.y() - shutdownWindow->height() / 2);
139  shutdownWindow->show();
140 }
void on_buttonBox_accepted()
Anoncoin GUI main class.
Definition: anoncoingui.h:47
static void showShutdownWindow(AnoncoinGUI *window)
"Shutdown" window
std::string HelpMessage(HelpMessageMode hmm)
Definition: init.cpp:197
HelpMessageDialog(QWidget *parent)
"Help message" dialog box
void setupUi(QDialog *HelpMessageDialog)
void saveWindowGeometry(const QString &strSetting, QWidget *parent)
Save window size and position.
Definition: guiutil.cpp:738
Ui::AboutDialog * ui
Definition: utilitydialog.h:32
"About" dialog box
Definition: utilitydialog.h:21
#define COPYRIGHT_YEAR
Copyright year (2013-this) Todo: update this when changing our copyright comments in the source...
Definition: clientversion.h:36
QFont anoncoinAddressFont()
Definition: guiutil.cpp:85
void restoreWindowGeometry(const QString &strSetting, const QSize &defaultSize, QWidget *parent)
Restore window size and position.
Definition: guiutil.cpp:745
Model for Anoncoin network client.
Definition: clientmodel.h:45
std::string FormatFullVersion()
Ui::HelpMessageDialog * ui
Definition: utilitydialog.h:51
QLabel * versionLabel
QLabel * copyrightLabel
"Help message" dialog box
Definition: utilitydialog.h:39
AboutDialog(QWidget *parent)
"About" dialog box
QString formatFullVersion() const
void setupUi(QDialog *AboutDialog)
void setModel(ClientModel *model)