storageLocation

Discuss anything related to product development
Post Reply
seasoned_geek
Posts: 254
Joined: Thu Jun 11 2020 12:18 pm

storageLocation

Post by seasoned_geek »

All,

From Qt 4.4 forward QDesktopServices provided storageLocation()

https://doc.qt.io/archives/qt-4.8/qdesktopservices.html#storageLocation

This was supposed to make cross platform good. It certainly helped. We now had a list of standard locations we could relegate to Qt.

QDesktopServices::DesktopLocation 0 Returns the user's desktop directory.
QDesktopServices::DocumentsLocation 1 Returns the user's document.
QDesktopServices::FontsLocation 2 Returns the user's fonts.
QDesktopServices::ApplicationsLocation 3 Returns the user's applications.
QDesktopServices::MusicLocation 4 Returns the users music.
QDesktopServices::MoviesLocation 5 Returns the user's movies.
QDesktopServices::PicturesLocation 6 Returns the user's pictures.
QDesktopServices::TempLocation 7 Returns the system's temporary directory.
QDesktopServices::HomeLocation 8 Returns the user's home directory.
QDesktopServices::DataLocation 9 Returns a directory location where persistent application data can be stored. QCoreApplication::applicationName and QCoreApplication::organizationName should work on all platforms.
QDesktopServices::CacheLocation 10 Returns a directory location where user-specific non-essential (cached) data should be written.

While QDir has home(), homePath(), temp(), and tempPath) I can't find in the CopperSpice documentation an equiv for DataLocation. This was very handy for identifying where to put things. We no longer had to have ugly conditionally compiled code in our base just to figure out where the OS wanted us to put a config file. We just had to have one really long line.

Code: Select all

   QDir storLoc( QDesktopServices::storageLocation( QDesktopServices::DataLocation);

   storLoc.mkPath( QCoreApplication::applicationName());
   storLoc.cd( QCoreApplication::applicationName());
I did not test that for compile, just typed in from memory. This was nice because when you wanted to store your config files your application could instantly know where they go. No messy canonical path building and no condition compilation for the various Windows XP forward directory changes.

Did this just get skipped or is it in some other part of the library I cannot find via searching the on-line doc?
seasoned_geek
Posts: 254
Joined: Thu Jun 11 2020 12:18 pm

Re: storageLocation

Post by seasoned_geek »

Finally found it!

https://www.copperspice.com/docs/cs_api/class_qstandardpaths.html

Man was that obscure. Had to back into what to search for by reading the source code for qdesktopservices.cpp. there is nothing in the doc when searching for storageLocation. There should at least be some kind of note that gets picked up by the indexing that QDesktopServices::storageLocation() is now implemented by QStandardPaths.
barbara
Posts: 446
Joined: Sat Apr 04 2015 2:32 am
Contact:

Re: storageLocation

Post by barbara »

There should at least be some kind of note that gets picked up by the indexing that QDesktopServices::storageLocation() is now implemented by QStandardPaths.
Thanks for letting us know. Any time we can improve our documentation we will do so.

I have added a notation in the detailed description of the QDesktopServices class.
Post Reply