Took 28 minutes
This commit is contained in:
Lukas Brübach 2025-11-08 23:25:20 +01:00
parent 6943e35951
commit fb1f4659ba
2 changed files with 7 additions and 1 deletions

View file

@ -564,15 +564,22 @@ void AbstractTabDeckEditor::exportToDecklistWebsite(DeckLoader::DecklistWebsite
{
if (DeckLoader *const deck = getDeckList()) {
QString decklistUrlString = deck->exportDeckToDecklist(website);
// Check to make sure the string isn't empty.
if (decklistUrlString.isEmpty()) {
// Show an error if the deck is empty, and return.
QMessageBox::critical(this, tr("Error"), tr("There are no cards in your deck to be exported"));
return;
}
// Encode the string recieved from the model to make sure all characters are encoded.
// first we put it into a qurl object
QUrl decklistUrl = QUrl(decklistUrlString);
// we get the correctly encoded url.
decklistUrlString = decklistUrl.toEncoded();
// We open the url in the user's default browser
QDesktopServices::openUrl(decklistUrlString);
} else {
// if there's no deck loader object, return an error
QMessageBox::critical(this, tr("Error"), tr("No deck was selected to be exported."));
}
}

View file

@ -3,7 +3,6 @@
* @brief Defines the AbstractTabDeckEditor class, which provides a base for
* deck editor tabs in the application.
*
*/
#ifndef TAB_GENERIC_DECK_EDITOR_H