Browse Source

Merge pull request #3284 from WizardCM/open-log-button

UI: Provide Open button in the Log Viewer
Jim 5 years ago
parent
commit
b31f04c92a
3 changed files with 23 additions and 0 deletions
  1. 1 0
      UI/data/locale/en-US.ini
  2. 21 0
      UI/log-viewer.cpp
  3. 1 0
      UI/log-viewer.hpp

+ 1 - 0
UI/data/locale/en-US.ini

@@ -97,6 +97,7 @@ AspectRatio="Aspect Ratio <b>%1:%2</b>"
 LockVolume="Lock Volume"
 LockVolume="Lock Volume"
 LogViewer="Log Viewer"
 LogViewer="Log Viewer"
 ShowOnStartup="Show on startup"
 ShowOnStartup="Show on startup"
+OpenFile="Open file"
 
 
 # warning if program already open
 # warning if program already open
 AlreadyRunning.Title="OBS is already running"
 AlreadyRunning.Title="OBS is already running"

+ 21 - 0
UI/log-viewer.cpp

@@ -6,6 +6,7 @@
 #include <QPushButton>
 #include <QPushButton>
 #include <QCheckBox>
 #include <QCheckBox>
 #include <QLayout>
 #include <QLayout>
+#include <QDesktopServices>
 #include <string>
 #include <string>
 
 
 #include "log-viewer.hpp"
 #include "log-viewer.hpp"
@@ -29,6 +30,9 @@ OBSLogViewer::OBSLogViewer(QWidget *parent) : QDialog(parent)
 	QPushButton *clearButton = new QPushButton(QTStr("Clear"));
 	QPushButton *clearButton = new QPushButton(QTStr("Clear"));
 	connect(clearButton, &QPushButton::clicked, this,
 	connect(clearButton, &QPushButton::clicked, this,
 		&OBSLogViewer::ClearText);
 		&OBSLogViewer::ClearText);
+	QPushButton *openButton = new QPushButton(QTStr("OpenFile"));
+	connect(openButton, &QPushButton::clicked, this,
+		&OBSLogViewer::OpenFile);
 	QPushButton *closeButton = new QPushButton(QTStr("Close"));
 	QPushButton *closeButton = new QPushButton(QTStr("Close"));
 	connect(closeButton, &QPushButton::clicked, this, &QDialog::hide);
 	connect(closeButton, &QPushButton::clicked, this, &QDialog::hide);
 
 
@@ -40,6 +44,7 @@ OBSLogViewer::OBSLogViewer(QWidget *parent) : QDialog(parent)
 	buttonLayout->addSpacing(10);
 	buttonLayout->addSpacing(10);
 	buttonLayout->addWidget(showStartup);
 	buttonLayout->addWidget(showStartup);
 	buttonLayout->addStretch();
 	buttonLayout->addStretch();
+	buttonLayout->addWidget(openButton);
 	buttonLayout->addWidget(clearButton);
 	buttonLayout->addWidget(clearButton);
 	buttonLayout->addWidget(closeButton);
 	buttonLayout->addWidget(closeButton);
 	buttonLayout->addSpacing(10);
 	buttonLayout->addSpacing(10);
@@ -145,3 +150,19 @@ void OBSLogViewer::ClearText()
 {
 {
 	textArea->clear();
 	textArea->clear();
 }
 }
+
+void OBSLogViewer::OpenFile()
+{
+	char logDir[512];
+	if (GetConfigPath(logDir, sizeof(logDir), "obs-studio/logs") <= 0)
+		return;
+
+	const char *log = App()->GetCurrentLog();
+
+	std::string path = logDir;
+	path += "/";
+	path += log;
+
+	QUrl url = QUrl::fromLocalFile(QT_UTF8(path.c_str()));
+	QDesktopServices::openUrl(url);
+}

+ 1 - 0
UI/log-viewer.hpp

@@ -15,6 +15,7 @@ private slots:
 	void AddLine(int type, const QString &text);
 	void AddLine(int type, const QString &text);
 	void ClearText();
 	void ClearText();
 	void ToggleShowStartup(bool checked);
 	void ToggleShowStartup(bool checked);
+	void OpenFile();
 
 
 public:
 public:
 	OBSLogViewer(QWidget *parent = 0);
 	OBSLogViewer(QWidget *parent = 0);