Browse Source

UI: Add Help -> Crash Reports submenu

Adds the ability to upload crash reports, making it easier for users to
give us crash data.  This should be considered a temporarily solution,
as automated crash reporting should be the ideal solution as soon as
time permits.
jp9000 7 năm trước cách đây
mục cha
commit
3b64610717
6 tập tin đã thay đổi với 58 bổ sung1 xóa
  1. 3 0
      UI/data/locale/en-US.ini
  2. 20 1
      UI/forms/OBSBasic.ui
  3. 9 0
      UI/obs-app.cpp
  4. 2 0
      UI/obs-app.hpp
  5. 21 0
      UI/window-basic-main.cpp
  6. 3 0
      UI/window-basic-main.hpp

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

@@ -535,6 +535,9 @@ Basic.MainMenu.Help.Logs.UploadCurrentLog="Upload &Current Log File"
 Basic.MainMenu.Help.Logs.UploadLastLog="Upload &Last Log File"
 Basic.MainMenu.Help.Logs.ViewCurrentLog="&View Current Log"
 Basic.MainMenu.Help.CheckForUpdates="Check For Updates"
+Basic.MainMenu.Help.CrashLogs="Crash &Reports"
+Basic.MainMenu.Help.CrashLogs.ShowLogs="&Show Crash Reports"
+Basic.MainMenu.Help.CrashLogs.UploadLastLog="Upload &Last Crash Report"
 
 # basic mode settings dialog
 Basic.Settings.ProgramRestart="The program must be restarted for these settings to take effect."

+ 20 - 1
UI/forms/OBSBasic.ui

@@ -137,10 +137,19 @@
      <addaction name="actionUploadLastLog"/>
      <addaction name="actionViewCurrentLog"/>
     </widget>
+    <widget class="QMenu" name="menuCrashLogs">
+     <property name="title">
+      <string>Basic.MainMenu.Help.CrashLogs</string>
+     </property>
+     <addaction name="actionShowCrashLogs"/>
+     <addaction name="actionUploadLastCrashLog"/>
+    </widget>
     <addaction name="actionHelpPortal"/>
     <addaction name="actionWebsite"/>
     <addaction name="separator"/>
     <addaction name="menuLogFiles"/>
+    <addaction name="menuCrashLogs"/>
+    <addaction name="separator"/>
     <addaction name="actionCheckForUpdates"/>
    </widget>
    <widget class="QMenu" name="menuBasic_MainMenu_Edit">
@@ -185,7 +194,7 @@
      <addaction name="actionScaleCanvas"/>
      <addaction name="actionScaleOutput"/>
     </widget>
-    <action name="actionCopySource">    
+    <action name="actionCopySource">
      <property name="text">
       <string>Copy</string>
      </property>
@@ -1582,6 +1591,16 @@
     <string>Basic.MainMenu.Help.HelpPortal</string>
    </property>
   </action>
+  <action name="actionShowCrashLogs">
+   <property name="text">
+    <string>Basic.MainMenu.Help.CrashLogs.ShowLogs</string>
+   </property>
+  </action>
+  <action name="actionUploadLastCrashLog">
+   <property name="text">
+    <string>Basic.MainMenu.Help.CrashLogs.UploadLastLog</string>
+   </property>
+  </action>
  </widget>
  <customwidgets>
   <customwidget>

+ 9 - 0
UI/obs-app.cpp

@@ -60,6 +60,7 @@ static log_handler_t def_log_handler;
 
 static string currentLogFile;
 static string lastLogFile;
+static string lastCrashLogFile;
 
 bool portable_mode = false;
 static bool multi = false;
@@ -1051,6 +1052,11 @@ const char *OBSApp::GetCurrentLog() const
 	return currentLogFile.c_str();
 }
 
+const char *OBSApp::GetLastCrashLog() const
+{
+	return lastCrashLogFile.c_str();
+}
+
 bool OBSApp::TranslateString(const char *lookupVal, const char **out) const
 {
 	for (obs_frontend_translate_ui_cb cb : translatorHooks) {
@@ -1249,6 +1255,9 @@ static void create_log_file(fstream &logFile)
 	stringstream dst;
 
 	get_last_log(false, "obs-studio/logs", lastLogFile);
+#ifdef _WIN32
+	get_last_log(true, "obs-studio/crashes", lastCrashLogFile);
+#endif
 
 	currentLogFile = GenerateTimeDateFilename("txt");
 	dst << "obs-studio/logs/" << currentLogFile.c_str();

+ 2 - 0
UI/obs-app.hpp

@@ -116,6 +116,8 @@ public:
 	const char *GetLastLog() const;
 	const char *GetCurrentLog() const;
 
+	const char *GetLastCrashLog() const;
+
 	std::string GetVersionString() const;
 	bool IsPortableMode();
 

+ 21 - 0
UI/window-basic-main.cpp

@@ -1655,7 +1655,13 @@ void OBSBasic::OBSInit()
 			this, SLOT(OpenMultiviewWindow()));
 
 #if !defined(_WIN32) && !defined(__APPLE__)
+	delete ui->actionShowCrashLogs;
+	delete ui->actionUploadLastCrashLog;
+	delete ui->menuCrashLogs;
 	delete ui->actionCheckForUpdates;
+	ui->actionShowCrashLogs = nullptr;
+	ui->actionUploadLastCrashLog = nullptr;
+	ui->menuCrashLogs = nullptr;
 	ui->actionCheckForUpdates = nullptr;
 #endif
 }
@@ -4317,6 +4323,21 @@ void OBSBasic::on_actionViewCurrentLog_triggered()
 	QDesktopServices::openUrl(url);
 }
 
+void OBSBasic::on_actionShowCrashLogs_triggered()
+{
+	char logDir[512];
+	if (GetConfigPath(logDir, sizeof(logDir), "obs-studio/crashes") <= 0)
+		return;
+
+	QUrl url = QUrl::fromLocalFile(QT_UTF8(logDir));
+	QDesktopServices::openUrl(url);
+}
+
+void OBSBasic::on_actionUploadLastCrashLog_triggered()
+{
+	UploadLog("obs-studio/crashes", App()->GetLastCrashLog());
+}
+
 void OBSBasic::on_actionCheckForUpdates_triggered()
 {
 	CheckForUpdates(true);

+ 3 - 0
UI/window-basic-main.hpp

@@ -589,6 +589,9 @@ private slots:
 	void on_actionViewCurrentLog_triggered();
 	void on_actionCheckForUpdates_triggered();
 
+	void on_actionShowCrashLogs_triggered();
+	void on_actionUploadLastCrashLog_triggered();
+
 	void on_actionEditTransform_triggered();
 	void on_actionCopyTransform_triggered();
 	void on_actionPasteTransform_triggered();