Qt Editor: Allow opening of user path from welcome page

qteditor
Sven Eberhardt 2016-03-26 14:02:40 -04:00
parent b3712ace97
commit dc7259bb1e
4 changed files with 55 additions and 3 deletions

View File

@ -363,6 +363,7 @@ IDS_ERR_ERRORLOADINGROUNDRESULTS=Fehler beim Laden der Spielergebnisse.
IDS_ERR_ERRORSAVINGROUNDRESULTS=Fehler beim Speichern der Spielergebnisse.
IDS_ERR_ERRORSAVINGTEAMS=Fehler beim Speichern der Teams.
IDS_ERR_ERRORWHILECREATINGJOINDAT=Fehler beim Erstellen der Beitrittsdaten
IDS_ERR_EXPLOREUSERPATH=Fehler beim Starten des Dateimanagers am Benutzerpfad.
IDS_ERR_FAILURE=...fehlgeschlagen.
IDS_ERR_FATAL=FATALER FEHLER: %s
IDS_ERR_FILEEXISTS=Datei mit Namen "%s" existiert bereits.
@ -492,6 +493,7 @@ IDS_MNU_CONTENTS=Inhalt nehmen
IDS_MNU_DEFAULTRESOLUTION=Bildschirm
IDS_MNU_DELETE=Löschen
IDS_MNU_DUPLICATE=Duplizieren
IDS_MNU_EXPLOREUSERPATH=Benutzerpfad anzeigen
IDS_MNU_FILE=Datei
IDS_MNU_FPS=FPS-Anzeige
IDS_MNU_JOIN=Beitritt

View File

@ -363,6 +363,7 @@ IDS_ERR_ERRORLOADINGROUNDRESULTS=Error loading round results.
IDS_ERR_ERRORSAVINGROUNDRESULTS=Error saving round results.
IDS_ERR_ERRORSAVINGTEAMS=Error saving teams.
IDS_ERR_ERRORWHILECREATINGJOINDAT=Error while creating join data
IDS_ERR_EXPLOREUSERPATH=Error starting file manager at user path.
IDS_ERR_FAILURE=...failed.
IDS_ERR_FATAL=FATAL ERROR: %s
IDS_ERR_FILEEXISTS=A file with the name "%s" exists already.
@ -492,6 +493,7 @@ IDS_MNU_CONTENTS=Grab contents
IDS_MNU_DEFAULTRESOLUTION=Screen
IDS_MNU_DELETE=Delete
IDS_MNU_DUPLICATE=Duplicate
IDS_MNU_EXPLOREUSERPATH=Open user path
IDS_MNU_FILE=File
IDS_MNU_FPS=FPS Display
IDS_MNU_JOIN=Join

View File

@ -282,6 +282,22 @@
<property name="indent">
<number>25</number>
</property>
<property name="textInteractionFlags">
<set>Qt::TextBrowserInteraction</set>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="welcomeExploreUserPathLabel">
<property name="text">
<string comment="res">IDS_MNU_EXPLOREUSERPATH</string>
</property>
<property name="indent">
<number>25</number>
</property>
<property name="textInteractionFlags">
<set>Qt::TextBrowserInteraction</set>
</property>
</widget>
</item>
<item>
@ -1325,8 +1341,8 @@
<slot>WelcomeLinkActivated(QString)</slot>
<hints>
<hint type="sourcelabel">
<x>445</x>
<y>218</y>
<x>591</x>
<y>216</y>
</hint>
<hint type="destinationlabel">
<x>477</x>
@ -1339,10 +1355,26 @@
<signal>linkActivated(QString)</signal>
<receiver>MainWindow</receiver>
<slot>WelcomeLinkActivated(QString)</slot>
<hints>
<hint type="sourcelabel">
<x>591</x>
<y>235</y>
</hint>
<hint type="destinationlabel">
<x>477</x>
<y>312</y>
</hint>
</hints>
</connection>
<connection>
<sender>welcomeExploreUserPathLabel</sender>
<signal>linkActivated(QString)</signal>
<receiver>MainWindow</receiver>
<slot>WelcomeLinkActivated(QString)</slot>
<hints>
<hint type="sourcelabel">
<x>445</x>
<y>237</y>
<y>248</y>
</hint>
<hint type="destinationlabel">
<x>477</x>

View File

@ -29,6 +29,11 @@
#include <C4PlayerList.h>
#include <C4Object.h>
#include <C4Viewport.h>
#include <C4Config.h>
#ifdef USE_WIN32_WINDOWS
#include <shellapi.h>
#endif
/* String translation */
@ -367,6 +372,16 @@ void C4ConsoleQtMainWindow::WelcomeLinkActivated(const QString &link)
// Default links
if (link == "new") FileNew();
else if (link == "open") FileOpen();
else if (link == "exploreuserpath")
{
#ifdef USE_WIN32_WINDOWS
StdStrBuf path(::Config.General.UserDataPath);
intptr_t iError = (intptr_t) ::ShellExecute(NULL, L"open", path.GetWideChar(), NULL, path.GetWideChar(), SW_SHOW);
if (iError <= 32) QMessageBox::critical(this, LoadResStr("IDS_MNU_EXPLOREUSERPATH"), LoadResStr("IDS_ERR_EXPLOREUSERPATH"));
#else
TODO explore user path
#endif
}
// Open recent link
else if (link.startsWith("open:"))
{
@ -795,6 +810,7 @@ void C4ConsoleGUIState::InitWelcomeScreen()
// Init links
ui.welcomeNewLabel->setText(QString("<a href=\"new\">%1</a>").arg(ui.welcomeNewLabel->text()));
ui.welcomeOpenLabel->setText(QString("<a href=\"open\">%1</a>").arg(ui.welcomeOpenLabel->text()));
ui.welcomeExploreUserPathLabel->setText(QString("<a href=\"exploreuserpath\">%1</a>").arg(ui.welcomeExploreUserPathLabel->text()));
// Recently opened scenarios
bool any_file = false;
int recent_idx = ui.welcomeScrollLayout->indexOf(ui.welcomeRecentLabel);