-
Notifications
You must be signed in to change notification settings - Fork 279
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
#177 Save and Load shortcut list #1276
#177 Save and Load shortcut list #1276
Conversation
app/src/shortcutspage.cpp
Outdated
void ShortcutsPage::saveShortcutsButtonClicked() | ||
{ | ||
QSettings settings( PENCIL2D, PENCIL2D ); | ||
QString fDir = settings.value("LastSavePath/Animation").toString(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As far as I can see you never set the "LastSavePath/Animation" value anywhere so the string will always be empty.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's set here I think:
pencil/app/src/filedialogex.cpp
Lines 123 to 125 in 220a27a
setting.beginGroup( "LastSavePath" ); | |
setting.setValue( toSettingKey( fileType ), savePath ); |
Having said that, it definitely could still be empty, which should be checked so that it doesn't try to write to the root directory.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm that looks like a different value to me, I'd expect that what you posted should equal a string "Animation" not LastSavePath/Animation
edit: or does it simply interpret that from beginGroup? anyhow I can't seem to get a value from the setting, that's why I mentioned it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As I understand it, if you think of the LastSavePath/Animation as a path, then beginGroup is like cd (or more accurately pushd).
Looks like it's set alright for me. if you're looking directly at the settings file, it will look like this:
[LastSavePath]
Animation=<some_path>
Take this with a grain of salt as I have not actually tested this branch yet.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It works as expected from loadShortcutsButtonClicked but in saveShortcutsButtonClicked I never get a path. I've also debugged it a bit because the code is slightly different.
this in the load method will work:
QSettings settings( PENCIL2D, PENCIL2D );
QString fDir = settings.value("LastSavePath/Animation").toString();
While this in the save method will not.
settings.beginGroup( "LastSavePath" );
QString fDir = settings.value("LastSavePath/Animation").toString();
If you however change the above to
settings.beginGroup( "LastSavePath" );
QString fDir = settings.value("Animation").toString();
Then I get the expected behaviour.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe that's what is not working in Ubuntu, but is working on Win and iOS. As explained in another comment, I have som odd behavior on my Ubuntu. I'll test it when I get home.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks good, I've only made one observation that seems strange to me.
I have a comment on the extension name though, to try to stay a little more consistent with our previous extension names, I think it would be better to call it *.pclshortcuts but it's a minor thing.
Great work. I understand the need for descriptive names, but If possible let's try not to exceed the 3~6 character range for filename extensions. I know it's not 1980 but it's better to make it short for mnemonics and simplicity. We already have *.vec, *.pcl, *.xml, etc so hopefully we can continue being coherent. Nevertheless here are some varied proposals:
|
I have tested it thoroughly, and it finds the last animation path as expected. |
The file is actually in INI format, so call it *.ini is legit, too. |
Yes, it is the INI format, but it's content is not a typical ini-file, so I would not support that. If the others support it, iI will of course follow the majority. |
With some help I go the path problem solved. Everything works as expected in my tests now. |
Fix path wrong setting lookup
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM 👍
Do we need further discussion on the extension name? I have no requirements aside from making it obvious that it's a pencil format.. eg. pcl should be included. I would be okay with pclkey if @Jose-Moreno wants to keep it short.
I think the same as @candyface that it should be related to the software using pre-existing format keywords . Although I would certainly like it to be shorter, if it's not possible or usable then just go with |
I can't understand why *.pclkeymap, *.pclkeys or *.pclkeylist is better than *.pclshortcut, when it comes to a file that contains nothing but information on shortcuts. |
Sorry, I just wanted to understand and suggest an appropriate name, so let me analyze this last piece here then. Is In that sense I honestly don't really mind if it's renamed as Either way I see there is no possibility we can have both a descriptive name and short name for the extension, so, let's go with the shortcuts one and let this PR be finalized under the assumption that: a. This is a file type that will be directly manipulated by the end user and read by Pencil2D |
More error checking and reporting (debug only) for shortcut loading. Also used beginGroup to prevent the possible manipulation of other keys.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I thought that it would be more appropriate to use the built-in QSettings to write the ini file in addition to reading it. I also thought just by reading the code that any setting could be replaced by including in the shortcut file which would be bad, however in testing I found that this doesn't actually happen unless the program is killed or crashes because the preference manager overwrites any other settings, still I think we should prevent that anyway.
I fixed these things and also added also altered the loading behavior slightly: it will check for formatting errors, and it will not delete all shortcuts, only overwrite them so that any shortcut keys that are not in the file you are loading are not deleted from the settings. Let me know what you think of that in particular. Setting a key to the default value if not found would also be a reasonable behavior, but I like this more because it theoretically allows you to only alter some settings.
I meant to push these changes to my fork, but accidentally pushed them to yours @davidlamhauge 😱. Please review it and let me know if it's good. If not it can always be removed or changed. Sorry about that!
The code looks good aside from what I have already noted/fixed. I don't like how long |
I haven't tested it @scribblemaniac , but it looks good. What now? I can't see that I can merge it, since it's not a PR. |
You don't have to do anything if you're good with it since it was already push to your repository. You'll want to run
We could still change it. We would still have to allow opening .xml files but we could write all new files with a different extension at least. |
I don't mind Regarding I've always entertained the idea of allowing software like Harmony, Synfig, GIMP, Krita, etc to import the Pencil2D palette back and forth. Changing this file format name to something specific might confuse other people trying to get the information out of pencil2d. That said, if we leave the capability of having both, the Don't know what the others think about the latter idea, but if you guys want to change the palette format either way you have my blessing 😋 |
I've tested it @scribblemaniac , and it works fine, except line 152 and 154. With these lines in the code, the odd behaviour explained 4 days ago, and solved by @candyface , comes back, so I've deleted these lines. It's tested on Ubuntu, so I wonder why you didn't have the same odd behaviour? |
I think basically the opposite, that it should primarily be a internal format and a more widely recognized format like the GIMP palette format should be used for interchange. Anyway, as @davidlamhauge said, this can be discussed elsewhere.
Huh? Line 152 was added by @candyface to fix the issue in the first place, and 154 is after the setting is retrieved so it should not affect that at all. |
@scribblemaniac It still yielded some strange behaviour on my Ubuntu, so now I've done what I probably should have done from the beginning. I've added Shortcuts to LastSavePath in Preferences. |
I think that *.pcls is too close to the project file format, even if it's for internal use only I still think the extension should be somewhat descriptive and separated from other potential name clashes. I'd rather have *.pclkmap, *.pclkeymap or *.pclkeys |
My favourite office suite, LibreOffice, uses the odf format. Writer documents are called *.odt, Spreadsheets are called *.ods and Presentations are called *.odp. I have never heard anyone complain about mixing them up. |
This PR addresses a user request from 2013.
The more you use Pencil2D, the more you know what you need from shortcuts. It is important that you can save your favourite shortcuts, so they can easily be re-instated, if they are messed up, or someone accidentally pressed 'Reset to default'.
The shortcuts are save as a text-file, and I've given them the suffix '*.p2shortcut' . It could be altered if you want to, but I prefer special and descriptive suffixes for special files.
This closes #177 .