Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Disable saving of decks when the deck is empty #3384

Merged
merged 9 commits into from
Sep 21, 2018

Conversation

leestran1995
Copy link
Contributor

Related Ticket(s)

Short roundup of the initial problem

  • Empty decks are able to be saved

What will change with this Pull Request?

  • The "save" and "save as" options will be greyed out when the deck is empty
  • Code for checking the size of the deck is borrowed from the actExportDeckDecklist() function

Screenshots

1

DeckLoader *const deck = deckModel->getDeckList();
QString decklistUrlString;
if (deck) {
decklistUrlString = deck->exportDeckToDecklist();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I know this is only run when a card is removed, but it looks to me like a lot of wasted cpu cycles.
Why not use deck->isEmpty()?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because I couldn't find it, but I see it now! Will update the branch with the suggested change

Copy link
Member

@tooomm tooomm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The basics do work in-client! 👍

I stumbled upon these cases that are not covered yet:

  • New deck and Load deck... doesn't change the status of the menu options yet.

Not covered by the initial issue, but highly related would be to take care of the
Save deck to clipboard option as well.

aSaveDeck->setEnabled(false);
aSaveDeckAs->setEnabled(false);
}
else {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tiny code style error left ❤️

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll get on all that stuff right away!

Speaking of style errors, I noticed a lot of if/else statements omitting braces for single-statements which goes against the code style guide. Would there be any utility to refactoring them to match the style guide?

Copy link
Member

@tooomm tooomm Sep 3, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Normally clang-format should catch and report those. It can also fix them with a simple command, that's why we use it. :)
Speaking about that, we still have no description setup on how to properly use it... we point to the CONTRIBUTING file from within the error reported in travis, but there is no endpoint yet. (--> #3065)

Maybe somebody else know what's up with the if/else style you mentioned.
Config got added and discussed in #3028 by the way.

In the meantime can you point to 1-2 examples?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

image

This if/else block contradicts the Braces section in the contributing guide in that the braces are not on their own line.

image

This also contradicts the Braces section of the Contributing guide since the braces are omitted.

I think maybe it's the contributing guide that should be updated to reflect the way the automatic code review bots enforce the code styling?

@tooomm
Copy link
Member

tooomm commented Sep 3, 2018

New deck works now, too 👍


The sub-options of Save deck to clipboard do correctly change as well:
clipboard
But what do you think about disabling the top menu option itself instead? I feel like that would be preferable, if possible.

@berserkingyadis
Copy link
Contributor

What about print deck and send deck to online service? Shouldnt they be disabled too?

@@ -988,6 +995,13 @@ void TabDeckEditor::actRemoveCard()
if (!currentIndex.isValid() || deckModel->hasChildren(currentIndex))
return;
deckModel->removeRow(currentIndex.row(), currentIndex.parent());

DeckLoader *const deck = deckModel->getDeckList();
if (deck->isEmpty()) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can simplify to setSaveStatus(!deck->isEmpty())

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Of course! I'll commit that ASAP

Copy link
Contributor

@ctrlaltca ctrlaltca left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Caveat: if i load a deck from clipboard, i can't save/print/analyze it

Copy link
Contributor

@ctrlaltca ctrlaltca left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good now! 👍

@ctrlaltca
Copy link
Contributor

@tooomm are you ok with this? Shall we merge?

@tooomm
Copy link
Member

tooomm commented Sep 5, 2018

Can check tomorrow again.

@tooomm
Copy link
Member

tooomm commented Sep 7, 2018

Right after loading a deck, the options shouldn't be disabled.

Example workflows which are not possible due to the current behavior:
Load deck --> print or send to online service or save copy

@tooomm
Copy link
Member

tooomm commented Sep 19, 2018

Any news here @leestran1995?

@leestran1995
Copy link
Contributor Author

@tooomm aaahhhh very sorry, I've had a busy couple weeks. I'll get to this tomorrow and get those last fixes in!

@tooomm
Copy link
Member

tooomm commented Sep 19, 2018

No worries, great! 🎉

Copy link
Member

@tooomm tooomm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that's it now 😉 :shipit:

@Daenyth
Copy link
Member

Daenyth commented Sep 20, 2018

@ctrlaltca do you know what's up with the appveyor failures?

Copy link
Member

@Daenyth Daenyth left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks reasonable. Not a fan of the imperative approach but it should work 👍

@tooomm
Copy link
Member

tooomm commented Sep 21, 2018

@Daenyth see #3378 for the failure on 32bit builds currently

@Daenyth
Copy link
Member

Daenyth commented Sep 21, 2018

@ZeldaZach ready to go :)

@ZeldaZach
Copy link
Member

It technically works, so I'll get this in :)

@ZeldaZach ZeldaZach merged commit eb4b1e7 into Cockatrice:master Sep 21, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants