CafeSync: System Settings and Theme support
Repository
https://github.com/OpenSeedINC
New Features
System Settings
CafeSync, till this release, made assumptions about how a person would interact with the interface. We hard set the amount of days a temporary card would stay on the client (3 Days), The distance the "Area Search" would scan when in that mode (30 miles), and how long a deleted card remained "deleted" even if the user passes by the same person again (1 Day). Though these assumptions are still default the software needed a way to be fine tuned, for and by, the individual. Now they can, within the System Settings dialog:
As you can see from the interface, I didn't stop at Connections but also added event creation options to help the user make the most out of the events system.
Implementation
Pull request 106
For the system settings area I started out by creating the general layout. This was achieved by adding a page toggle element to the top of the interface, shown in the image above. ( reference )
Next using the Profile area as a guide I created the needed columns and rows to build the interface. ( Interface layout )
With the interface complete it was time to link the front end with the back, for this I first had to add the needed database table and ensure that it loads with the rest of the users settings before anything else happens. For this reason I added the next lines of code to the "card_Load" function in main.js under the table name of Settings. Though a bit ugly I took the time to make sure that if these databases didn't exist yet, that they would be filled with the defaults the system already had in place. ( reference )
Once the database had been created I then had to create a function to take note of the chances found in the interface and relay them back to the database, and at the same time ensuring that the new data was reflected in the program. This work is done in the save_Settings function found at the very end of the main.js file. reference
Back in the Setup.qml file the function is called on any event that changed the values of the settings with code similar to this.
onValueChanged: {if(settingFlick.visible == true) {
sT = value;
Scripts.save_setting("tempSupress",sT);
}
Theme Support
Themes have been a mainstay in applications for a very long time. Though mostly implemented in CafeSync it is now much easier to switch between them. In future releases we will have the ability to download new themes as well as changing the ones installed if there is a need. To test the theme setup I created three themes that are distributed in this release.
Default
Pink
PoP!
Implementation
Pull request 106
Having already built most of the interface for the system settings area, I added the lof (Look and Feel) item to the bottom of that Item. reference
It is a very simple ListView setup, however I would like to point out the use of the same "save_Settings" function as before in the lines near the bottom of the element.
MouseArea {
anchors.fill: parent
onClicked: {theme = index;Scripts.save_setting("theme",index);
}
}
With the interface setup we needed to link these settings with the database once more. This time creating a "Themes" table and populating it with the values for the three included themes. ( reference ) Please take note of how I have setup a similar "check" for the themes as I did for settings. If there is no theme set, or if the theme doesn't exist in the database the default hard-coded theme is used.
Once the code was verified working I went through the project to make sure that most if not all the elements used the new theme and looked at "home" in all three themes. This amounted to adding one or two lines of code, in almost every file, where the theme was not yet enabled.
Find out more
Curious about CafeSync and what it does? Check out my other posts here on Utopian and/or SteemIt
Downloads
Thanks for the contribution!
Keep up the good work! It would be great if you added some more comments to your code and also improved the indentation (not sure if it's supposed to be indented that much, but I could be wrong).
Click here to see how your contribution was evaluated.
Need help? Write a ticket on https://support.utopian.io/.
Chat with us on Discord.
[utopian-moderator]
lol, yeah the indents got a little out of hand, the IDE goes a little overboard with auto indention and after months of working with it I've stopped trying to fix it manually.
Internal comments are not my strong suite, but I will try to get better at it. Now knowing others are looking at my code I fell its worth my time.
Hey @bflanagin
Thanks for contributing on Utopian.
We’re already looking forward to your next contribution!
Contributing on Utopian
Learn how to contribute on our website or by watching this tutorial on Youtube.
Want to chat? Join us on Discord https://discord.gg/h52nFrV.
Vote for Utopian Witness!