Pencil2D Animation
Download Community News Docs Contribute
  • Overview
  • Articles
  • Code
  •  
  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members
  • File List
Loading...
Searching...
No Matches
  • core_lib
  • src
  • util
pencilerror.cpp
1/*
2
3Pencil2D - Traditional Animation Software
4Copyright (C) 2005-2007 Patrick Corrieri & Pascal Naidon
5Copyright (C) 2012-2020 Matthew Chiawen Chang
6
7This program is free software; you can redistribute it and/or
8modify it under the terms of the GNU General Public License
9as published by the Free Software Foundation; version 2 of the License.
10
11This program is distributed in the hope that it will be useful,
12but WITHOUT ANY WARRANTY; without even the implied warranty of
13MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14GNU General Public License for more details.
15
16*/
17
18#include "pencilerror.h"
19#include <map>
20#include <QSysInfo>
21#include <QLocale>
22
23DebugDetails::DebugDetails()
24{
25}
26
27void DebugDetails::collect(const DebugDetails& d)
28{
29 for (const QString& s : d.mDetails)
30 {
31 mDetails.append("&nbsp;&nbsp;" + s);
32 }
33}
34
35QString DebugDetails::str()
36{
37 appendSystemInfo();
38 return mDetails.join("\n");
39}
40
41QString DebugDetails::html()
42{
43 appendSystemInfo();
44 return mDetails.join("<br>");
45}
46
47DebugDetails& DebugDetails::operator<<(const QString& s)
48{
49 mDetails.append(s);
50 return *this;
51}
52
53void DebugDetails::appendSystemInfo()
54{
55 if (mDetails.empty() || mDetails.last() == "end")
56 return;
57
58 mDetails << "\n[System Info]\n";
59 QString version(APP_VERSION);
60 if (version.startsWith("99.0.0")) {
61 mDetails << "&nbsp;&nbsp;Pencil2D version: " APP_VERSION " (nightly)";
62 } else if (version == "0.0.0.0") {
63 mDetails << "&nbsp;&nbsp;Pencil2D version: " APP_VERSION " (dev)";
64 } else {
65 mDetails << "&nbsp;&nbsp;Pencil2D version: " APP_VERSION " (stable)";
66 }
67
68#if defined(GIT_EXISTS)
69 mDetails << "&nbsp;&nbsp;Commit: " S__GIT_COMMIT_HASH;
70#endif
71 mDetails << "&nbsp;&nbsp;Build ABI: " + QSysInfo::buildAbi();
72 mDetails << "&nbsp;&nbsp;Kernel: " + QSysInfo::kernelType() + ", " + QSysInfo::kernelVersion();
73 mDetails << "&nbsp;&nbsp;Operating System: " + QSysInfo::prettyProductName();
74 mDetails << "&nbsp;&nbsp;Language: " + QLocale::system().name();
75}
76
77Status::Status(ErrorCode code)
78 : mCode(code)
79{
80}
81
82Status::Status(const ErrorCode code, const QString& description)
83 : mCode(code)
84 , mDescription(description)
85{
86}
87
88Status::Status(Status::ErrorCode eCode, const DebugDetails& detailsList)
89 : mCode(eCode)
90 , mDetails(detailsList)
91{
92}
93
94Status::Status(Status::ErrorCode eCode, const DebugDetails& detailsList, QString title, QString description)
95 : mCode(eCode)
96 , mTitle(title)
97 , mDescription(description)
98 , mDetails(detailsList)
99{
100}
101
102
103QString Status::msg() const
104{
105 static std::map<ErrorCode, QString> msgMap =
106 {
107 // error messages.
108 { OK, tr("Everything ok.") },
109 { FAIL, tr("Ooops, Something went wrong.") },
110 { FILE_NOT_FOUND, tr("File doesn't exist.") },
111 { ERROR_FILE_CANNOT_OPEN, tr("Cannot open file.") },
112 { ERROR_INVALID_XML_FILE, tr("The file is not a valid xml document.") },
113 { ERROR_INVALID_PENCIL_FILE, tr("The file is not valid pencil document.") },
114 };
115
116 auto it = msgMap.find(mCode);
117 if (it == msgMap.end())
118 {
119 return msgMap[FAIL];
120 }
121 return msgMap[mCode];
122}
123
124bool Status::operator==(Status::ErrorCode code) const
125{
126 return (mCode == code);
127}
128
129bool Status::operator!=(Status::ErrorCode code) const
130{
131 return (mCode != code);
132}
DebugDetails
Definition: pencilerror.h:25
QLocale::name
QString name() const const
QLocale::system
QLocale system()
QString
QStringList::join
QString join(const QString &separator) const const
QSysInfo::buildAbi
QString buildAbi()
QSysInfo::kernelType
QString kernelType()
QSysInfo::kernelVersion
QString kernelVersion()
QSysInfo::prettyProductName
QString prettyProductName()
Generated on Fri Feb 27 2026 07:33:50 for Pencil2D by doxygen 1.9.6 based on revision e1e2bc04715617e3bb4d4796f67a4493290639ca