#include <typeinfo>
#include <QDebug>
+#include <QDir>
+#include <QLibraryInfo>
+#include <QMessageBox>
+#include <QWidget>
#include <boost/version.hpp>
#include <libsigrokdecode/libsigrokdecode.h>
#endif
+#include <pv/exprtk.hpp>
+
#include "application.hpp"
#include "config.h"
#include "globalsettings.hpp"
setOrganizationDomain("sigrok.org");
}
+const QStringList Application::get_languages() const
+{
+ const QStringList files = QDir(":/l10n/").entryList(QStringList("*.qm"), QDir::Files);
+
+ QStringList result;
+ result << "en"; // Add default language to the set
+
+ // Remove file extensions
+ for (const QString& file : files)
+ result << file.split(".").front();
+
+ result.sort(Qt::CaseInsensitive);
+
+ return result;
+}
+
+const QString Application::get_language_editors(const QString& language) const
+{
+ if (language == "de") return "Sören Apel, Uwe Hermann";
+ if (language == "es_mx") return "Carlos Diaz";
+
+ return QString();
+}
+
void Application::switch_language(const QString& language)
{
removeTranslator(&app_translator_);
removeTranslator(&qt_translator_);
+ removeTranslator(&qtbase_translator_);
if ((language != "C") && (language != "en")) {
// Application translations
qWarning() << "Translation resource" << resource << "not found";
// Qt translations
- resource = ":/l10n/qtbase_" + language +".qm";
- if (qt_translator_.load(resource))
+#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
+ QString tr_path(QLibraryInfo::path(QLibraryInfo::TranslationsPath));
+#else
+ QString tr_path(QLibraryInfo::location(QLibraryInfo::TranslationsPath));
+#endif
+
+ if (qt_translator_.load("qt_" + language, tr_path))
installTranslator(&qt_translator_);
else
- qWarning() << "Translation resource" << resource << "not found";
+ qWarning() << "QT translations for" << language << "not found at" <<
+ tr_path << ", Qt translations package is probably missing";
+
+ // Qt base translations
+ if (qtbase_translator_.load("qtbase_" + language, tr_path))
+ installTranslator(&qtbase_translator_);
+ else
+ qWarning() << "QT base translations for" << language << "not found at" <<
+ tr_path << ", Qt translations package is probably missing";
+ }
+
+ if (!topLevelWidgets().empty()) {
+ // Force all windows to update
+ for (QWidget *widget : topLevelWidgets())
+ widget->update();
+
+ QMessageBox msg(topLevelWidgets().front());
+ msg.setText(tr("Some parts of the application may still " \
+ "use the previous language. Re-opening the affected windows or " \
+ "restarting the application will remedy this."));
+ msg.setStandardButtons(QMessageBox::Ok);
+ msg.setIcon(QMessageBox::Information);
+ msg.exec();
}
}
switch_language(value.toString());
}
-void Application::collect_version_info(shared_ptr<sigrok::Context> context)
+void Application::collect_version_info(pv::DeviceManager &device_manager)
{
// Library versions and features
version_info_.emplace_back(applicationName(), applicationVersion());
version_info_.emplace_back("Qt", qVersion());
version_info_.emplace_back("glibmm", PV_GLIBMM_VERSION);
version_info_.emplace_back("Boost", BOOST_LIB_VERSION);
+ version_info_.emplace_back("exprtk", QString::fromUtf8(exprtk::information::date));
version_info_.emplace_back("libsigrok", QString("%1/%2 (rt: %3/%4)")
.arg(SR_PACKAGE_VERSION_STRING, SR_LIB_VERSION_STRING,
#endif
// Device drivers
- for (auto& entry : context->drivers())
- driver_list_.emplace_back(QString::fromUtf8(entry.first.c_str()),
- QString::fromUtf8(entry.second->long_name().c_str()));
+ for (auto& entry : device_manager.context()->drivers())
+ if (device_manager.driver_supported(entry.second))
+ driver_list_.emplace_back(QString::fromUtf8(entry.first.c_str()),
+ QString::fromUtf8(entry.second->long_name().c_str()));
// Input formats
- for (auto& entry : context->input_formats())
+ for (auto& entry : device_manager.context()->input_formats())
input_format_list_.emplace_back(QString::fromUtf8(entry.first.c_str()),
QString::fromUtf8(entry.second->description().c_str()));
// Output formats
- for (auto& entry : context->output_formats())
+ for (auto& entry : device_manager.context()->output_formats())
output_format_list_.emplace_back(QString::fromUtf8(entry.first.c_str()),
QString::fromUtf8(entry.second->description().c_str()));