mirror of
https://gitlab.com/mbunkus/mkvtoolnix.git
synced 2025-01-09 03:31:41 +00:00
GUI: open local, translated mkvmerge docs before online if available
This commit is contained in:
parent
7b889333ce
commit
c7a00dc052
@ -10,6 +10,7 @@
|
||||
#include <QVBoxLayout>
|
||||
|
||||
#include "common/fs_sys_helpers.h"
|
||||
#include "common/locale_string.h"
|
||||
#include "common/qt.h"
|
||||
#include "common/version.h"
|
||||
#include "mkvtoolnix-gui/app.h"
|
||||
@ -117,7 +118,7 @@ MainWindow::setupMenu() {
|
||||
|
||||
connect(ui->actionHelpFAQ, &QAction::triggered, this, &MainWindow::visitHelpURL);
|
||||
connect(ui->actionHelpKnownProblems, &QAction::triggered, this, &MainWindow::visitHelpURL);
|
||||
connect(ui->actionHelpMkvmergeDocumentation, &QAction::triggered, this, &MainWindow::visitHelpURL);
|
||||
connect(ui->actionHelpMkvmergeDocumentation, &QAction::triggered, this, &MainWindow::visitMkvmergeDocumentation);
|
||||
connect(ui->actionHelpWebSite, &QAction::triggered, this, &MainWindow::visitHelpURL);
|
||||
connect(ui->actionHelpReportBug, &QAction::triggered, this, &MainWindow::visitHelpURL);
|
||||
|
||||
@ -455,6 +456,41 @@ MainWindow::visitHelpURL() {
|
||||
QDesktopServices::openUrl(m_helpURLs[sender()]);
|
||||
}
|
||||
|
||||
void
|
||||
MainWindow::visitMkvmergeDocumentation() {
|
||||
auto appDirPath = App::applicationDirPath();
|
||||
auto potentialPaths = QStringList{};
|
||||
|
||||
try {
|
||||
auto localeStr = locale_string_c{to_utf8(Util::Settings::get().localeToUse())};
|
||||
|
||||
potentialPaths << Q("%1/doc/%2").arg(appDirPath).arg(Q(localeStr.str(locale_string_c::full)));
|
||||
potentialPaths << Q("%1/doc/%2").arg(appDirPath).arg(Q(localeStr.str(static_cast<locale_string_c::eval_type_e>(locale_string_c::language | locale_string_c::territory))));
|
||||
potentialPaths << Q("%1/doc/%2").arg(appDirPath).arg(Q(localeStr.str(locale_string_c::language)));
|
||||
|
||||
} catch (mtx::locale_string_format_x const &) {
|
||||
}
|
||||
|
||||
potentialPaths << Q("%1/doc/en").arg(appDirPath);
|
||||
|
||||
auto url = QUrl{};
|
||||
|
||||
for (auto const &path : potentialPaths) {
|
||||
auto fileName = Q("%1/mkvmerge.html").arg(path);
|
||||
|
||||
if (QFileInfo{fileName}.exists()) {
|
||||
url.setScheme(Q("file"));
|
||||
url.setPath(fileName);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (url.isEmpty())
|
||||
url = m_helpURLs[ui->actionHelpMkvmergeDocumentation];
|
||||
|
||||
QDesktopServices::openUrl(url);
|
||||
}
|
||||
|
||||
void
|
||||
MainWindow::showEvent(QShowEvent *event) {
|
||||
emit windowShown();
|
||||
|
@ -91,6 +91,7 @@ public slots:
|
||||
virtual void toolChanged(int index);
|
||||
virtual void editPreferences();
|
||||
virtual void visitHelpURL();
|
||||
virtual void visitMkvmergeDocumentation();
|
||||
virtual void setToolSelectorVisibility();
|
||||
virtual void raiseAndActivate();
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user