11 #include <QStandardPaths>
14 #include <QStyleFactory>
15 #include <QSurfaceFormat>
16 #include <QTextStream>
17 #include <QTranslator>
36 #if (QT_VERSION < QT_VERSION_CHECK(5, 5, 0))
37 #error ACloudViewer does not support versions of Qt prior to 5.5
50 QSurfaceFormat
format = QSurfaceFormat::defaultFormat();
52 format.setSwapBehavior(QSurfaceFormat::DoubleBuffer);
53 format.setStencilBufferSize(0);
55 #ifdef CV_GL_WINDOW_USE_QWINDOW
61 format.setProfile(QSurfaceFormat::CoreProfile);
68 #if (QT_VERSION >= QT_VERSION_CHECK(5, 6, 0)) && \
69 (QT_VERSION < QT_VERSION_CHECK(6, 0, 0))
72 QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
73 QCoreApplication::setAttribute(Qt::AA_UseHighDpiPixmaps);
77 format.setOption(QSurfaceFormat::DebugContext,
true);
79 QSurfaceFormat::setDefaultFormat(
format);
85 QCoreApplication::setAttribute(Qt::AA_ShareOpenGLContexts);
94 c_CommandLine(isCommandLine) {
95 setOrganizationName(
"ECVCorp");
101 setAttribute(Qt::AA_DontShowIconsInMenus);
105 QLocale::setDefault(QLocale::English);
110 setlocale(LC_NUMERIC,
"C");
120 QString styleKey = settings.value(
"style", QString()).toString();
123 if (styleKey.isEmpty()) {
132 if (!styleKey.isEmpty()) {
133 if (styleKey ==
"QDarkStyleSheet::Dark") {
134 QFile f(
":/qdarkstyle/dark/darkstyle.qss");
135 if (f.open(QFile::ReadOnly | QFile::Text)) {
137 setStyleSheet(ts.readAll());
140 }
else if (styleKey ==
"QDarkStyleSheet::Light") {
141 QFile f(
":/qdarkstyle/light/lightstyle.qss");
142 if (f.open(QFile::ReadOnly | QFile::Text)) {
144 setStyleSheet(ts.readAll());
149 QStyle *style = QStyleFactory::create(styleKey);
163 QStringLiteral(
"ACloudViewer"), m_TranslationPath);
166 connect(
this, &ecvApplicationBase::aboutToQuit,
173 QString verStr = c_VersionStr;
175 #if defined(CV_ENV_64)
176 const QString arch(
"64-bit");
177 #elif defined(CV_ENV_32)
178 const QString arch(
"32-bit");
180 const QString arch(
"\?\?-bit");
184 #if defined(CV_WINDOWS)
185 const QString platform(
"Windows");
186 #elif defined(CV_MAC_OS)
187 const QString platform(
"macOS");
188 #elif defined(CV_LINUX)
189 const QString platform(
"Linux");
191 const QString platform(
"Unknown OS");
193 verStr += QStringLiteral(
" [%1 %2]").arg(platform, arch);
195 verStr += QStringLiteral(
" [%1]").arg(arch);
199 verStr += QStringLiteral(
" [DEBUG]");
206 return m_TranslationPath;
209 void ecvApplicationBase::setupPaths() {
210 QDir appDir = QCoreApplication::applicationDirPath();
213 #if defined(Q_OS_MAC)
214 QDir bundleDir = appDir;
216 if (bundleDir.dirName() ==
"MacOS") {
219 m_PluginPaths << (bundleDir.absolutePath() +
"/cvPlugins");
220 m_PluginPaths << (bundleDir.absolutePath() +
"/PlugIns/cvPlugins");
222 #if defined(CV_MAC_DEV_PATHS)
231 m_PluginPaths << (bundleDir.absolutePath() +
"/cvPlugins");
232 m_ShaderPath = (bundleDir.absolutePath() +
"/shaders");
233 m_TranslationPath = (bundleDir.absolutePath() +
"/app/translations");
235 m_ShaderPath = (bundleDir.absolutePath() +
"/Shaders");
236 m_TranslationPath = (bundleDir.absolutePath() +
"/translations");
238 #elif defined(Q_OS_WIN)
239 m_PluginPaths << (appDir.absolutePath() +
"/plugins");
240 m_ShaderPath = (appDir.absolutePath() +
"/shaders");
241 m_TranslationPath = (appDir.absolutePath() +
"/translations");
242 #elif defined(Q_OS_LINUX)
245 QDir theDir = appDir;
247 if (theDir.dirName() ==
"bin") {
249 m_PluginPaths << (theDir.absolutePath() +
"/plugins");
250 m_PluginPaths << (theDir.absolutePath() +
"/bin/plugins");
251 m_PluginPaths << (theDir.absolutePath() +
"/lib/ACloudViewer/plugins");
252 m_ShaderPath = (theDir.absolutePath() +
"/share/ACloudViewer/shaders");
254 (theDir.absolutePath() +
"/share/ACloudViewer/translations");
257 m_PluginPaths <<
"/usr/lib/ACloudViewer/plugins";
258 m_PluginPaths << (theDir.absolutePath() +
"/plugins");
259 m_PluginPaths << (theDir.absolutePath() +
"/bin/plugins");
260 m_PluginPaths << (theDir.absolutePath() +
"/lib/ACloudViewer/plugins");
261 m_ShaderPath =
"/usr/share/ACloudViewer/shaders";
262 m_TranslationPath =
"/usr/share/ACloudViewer/translations";
270 QString binTransPath = (appDir.absolutePath() +
"/translations");
271 if (QDir(binTransPath).exists()) {
272 m_TranslationPath = binTransPath;
282 #warning Need to specify the shader path for this OS.
288 const QStringList appDataPaths =
289 QStandardPaths::standardLocations(QStandardPaths::AppDataLocation);
291 for (
const QString &appDataPath : appDataPaths) {
292 QString
path = appDataPath +
"/plugins";
294 if (!m_PluginPaths.contains(
path))
297 m_PluginPaths <<
path;
304 const auto loadStyleSheet = [
this](
const QString &resourcePath) ->
bool {
305 QFile f(resourcePath);
310 if (!f.open(QFile::ReadOnly | QFile::Text)) {
315 setStyleSheet(ts.readAll());
321 if (styleKey ==
"QDarkStyleSheet::Dark") {
323 if (!loadStyleSheet(
":/qdarkstyle/dark/darkstyle.qss")) {
326 }
else if (styleKey ==
"QDarkStyleSheet::Light") {
328 if (!loadStyleSheet(
":/qdarkstyle/light/lightstyle.qss")) {
333 QStyle *style = QStyleFactory::create(styleKey);
335 CVLog::Warning(QStringLiteral(
"Invalid style key or style couldn't "
344 QStringLiteral(
"Applying application style: %1").arg(styleKey));
filament::Texture::InternalFormat format
static bool Warning(const char *format,...)
Prints out a formatted warning message in console.
static bool Print(const char *format,...)
Prints out a formatted message in console.
static void ReleaseTextures()
Release all texture objects.
static ccPluginManager & get()
void setPaths(const QStringList &paths)
static ccTranslationManager & get()
void registerTranslatorFile(const QString &prefix, const QString &path)
QString versionStr() const
QString versionLongStr(bool includeOS) const
const QString & translationPath() const
ecvApplicationBase(int &argc, char **argv, bool isCommandLine, const QString &version)
bool setAppStyle(const QString &styleKey)
Set the application style.
static const QString AppStyle()
static void setValue(const QString §ion, const QString &key, const QVariant &value)
static const std::string path