Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. [solved] QDesktopServices::storageLocation substituion in Qt 5
Forum Updated to NodeBB v4.3 + New Features

[solved] QDesktopServices::storageLocation substituion in Qt 5

Scheduled Pinned Locked Moved General and Desktop
14 Posts 4 Posters 18.0k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • V Offline
    V Offline
    Violet Giraffe
    wrote on last edited by
    #3

    [quote author="Terence" date="1356185483"]You can use "QStandardPaths":http://qt-project.org/doc/qt-5.0/qtcore/qstandardpaths.html (from the QtCore module) as a replacement for QDesktopServices.[/quote]

    Thanks a lot!

    1 Reply Last reply
    0
    • M Offline
      M Offline
      MaximAlien
      wrote on last edited by
      #4

      Thanks for suggestion Terence.

      1 Reply Last reply
      0
      • C Offline
        C Offline
        ctsiitmail
        wrote on last edited by
        #5

        Please help me for my one program to create, I have some code that created QT 4.8 now i open in QT 5.2 but facing some problem, please see the code & give me solution.

        --------------------------------------------Thax--------------------------------------------------

        #ifndef STDLOCATION_H
        #define STDLOCATION_H

        #include <QDir>
        #include <QFileInfo>
        #include <QDesktopServices>
        #include <QDateTime>
        #include "settings.h"

        #define SL_TRANSFERHISTORY "transfers.lst"
        #define SL_FILESTORAGEDIR "Received Files"
        #define SL_CACHEDIR "cache"
        #define SL_RESOURCE "lmc.rcc"
        #define SL_LANGDIR "lang"
        #define SL_THEMEDIR "themes"
        #define SL_GROUPFILE "group.cfg"
        #define SL_AVATARFILE "avt_local.png"
        #define SL_LOGDIR "logs"
        #define SL_TEMPCONFIG "lmctmpconf.ini"

        class StdLocation {
        public:
        static QString transferHistory(void) {
        return QDir::toNativeSeparators(QDesktopServices::storageLocation(
        QDesktopServices::DataLocation) + "/"SL_TRANSFERHISTORY);
        }

        static QString fileStorageDir(void) {
        lmcSettings settings;

        QString path = QDir::toNativeSeparators(QDesktopServices::storageLocation(
        QDesktopServices::DocumentsLocation) + "/"SL_FILESTORAGEDIR);
        path = settings.value(IDS_FILESTORAGEPATH, path).toString();
        return path;
        }

        static QString cacheDir(void) {
        return QDir::toNativeSeparators(QDesktopServices::storageLocation(
        QDesktopServices::DataLocation) + "/"SL_CACHEDIR);
        }

        static QString libDir(void) {
        return QDir::toNativeSeparators(QDir::currentPath());
        }

        static QString resourceFile(void) {
        return QDir::toNativeSeparators(QDir::current().absoluteFilePath(SL_RESOURCE));
        }

        static QString resLangDir(void) {
        return ":/"SL_LANGDIR;
        }

        static QString sysLangDir(void) {
        return QDir::toNativeSeparators(QDir::currentPath() + "/"SL_LANGDIR);
        }

        static QString userLangDir(void) {
        return QDir::toNativeSeparators(QDesktopServices::storageLocation(
        QDesktopServices::DataLocation) + "/"SL_LANGDIR);
        }

        static QString resThemeDir(void) {
        return ":/"SL_THEMEDIR;
        }

        static QString sysThemeDir(void) {
        return QDir::toNativeSeparators(QDir::currentPath() + "/"SL_THEMEDIR);
        }

        static QString userThemeDir(void) {
        return QDir::toNativeSeparators(QDesktopServices::storageLocation(
        QDesktopServices::DataLocation) + "/"SL_THEMEDIR);
        }

        static QString groupFile(void) {
        return QDir::toNativeSeparators(QDesktopServices::storageLocation(
        QDesktopServices::DataLocation) + "/"SL_GROUPFILE);
        }

        static QString avatarFile(void) {
        return QDir::toNativeSeparators(QDesktopServices::storageLocation(
        QDesktopServices::DataLocation) + "/"SL_AVATARFILE);
        }

        static QString logDir(void) {
        return QDir::toNativeSeparators(QDesktopServices::storageLocation(
        QDesktopServices::DataLocation) + "/"SL_LOGDIR);
        }

        static QString freeLogFile(void) {
        QString fileName = "lmc_" +
        QString::number(QDateTime::currentDateTimeUtc().toMSecsSinceEpoch()) + ".log";
        return QDir::toNativeSeparators(logDir() + "/" + fileName);
        }

        static QString tempConfigFile(void) {
        return QDir::toNativeSeparators(QDesktopServices::storageLocation(
        QDesktopServices::TempLocation) + "/"SL_TEMPCONFIG);
        }
        };

        #endif // STDLOCATION_H

        1 Reply Last reply
        0
        • M Offline
          M Offline
          MaximAlien
          wrote on last edited by
          #6

          Instead of using
          @QString QDesktopServices::storageLocation ( StandardLocation type ) [static]@

          in Qt4 use: @QStandardPaths::standardLocations(StandardLocation type) [static]@ in Qt5. Check documentation "here":http://qt-project.org/doc/qt-5.0/qtcore/qstandardpaths.html#standardLocations.

          1 Reply Last reply
          0
          • C Offline
            C Offline
            ctsiitmail
            wrote on last edited by
            #7

            Please help me.
            How can i convert QT 4.8 code - To - QT 5.2 code that i indeed.
            --------------------------------------------Thax--------------------------------------------------

            #ifndef STDLOCATION_H
            #define STDLOCATION_H

            #include <QDir>
            #include <QFileInfo>
            #include <QDesktopServices>
            #include <QDateTime>
            #include "settings.h"

            #define SL_TRANSFERHISTORY "transfers.lst"
            #define SL_FILESTORAGEDIR "Received Files"
            #define SL_CACHEDIR "cache"
            #define SL_RESOURCE "lmc.rcc"
            #define SL_LANGDIR "lang"
            #define SL_THEMEDIR "themes"
            #define SL_GROUPFILE "group.cfg"
            #define SL_AVATARFILE "avt_local.png"
            #define SL_LOGDIR "logs"
            #define SL_TEMPCONFIG "lmctmpconf.ini"

            class StdLocation {
            public:

            static QString transferHistory(void) {
            return QDir::toNativeSeparators(QDesktopServices::storageLocation(
            QDesktopServices::DataLocation) + "/"SL_TRANSFERHISTORY);
            }

            static QString fileStorageDir(void) {
            lmcSettings settings;

            QString path = QDir::toNativeSeparators(QDesktopServices::storageLocation(
            QDesktopServices::DocumentsLocation) + "/"SL_FILESTORAGEDIR);
            path = settings.value(IDS_FILESTORAGEPATH, path).toString();
            return path;
            }

            static QString cacheDir(void) {
            return QDir::toNativeSeparators(QDesktopServices::storageLocation(
            QDesktopServices::DataLocation) + "/"SL_CACHEDIR);
            }

            static QString libDir(void) {
            return QDir::toNativeSeparators(QDir::currentPath());
            }

            static QString resourceFile(void) {
            return QDir::toNativeSeparators(QDir::current().absoluteFilePath(SL_RESOURCE));
            }

            static QString resLangDir(void) {
            return ":/"SL_LANGDIR;
            }

            static QString sysLangDir(void) {
            return QDir::toNativeSeparators(QDir::currentPath() + "/"SL_LANGDIR);
            }

            static QString userLangDir(void) {
            return QDir::toNativeSeparators(QDesktopServices::storageLocation(
            QDesktopServices::DataLocation) + "/"SL_LANGDIR);
            }

            static QString resThemeDir(void) {
            return ":/"SL_THEMEDIR;
            }

            static QString sysThemeDir(void) {
            return QDir::toNativeSeparators(QDir::currentPath() + "/"SL_THEMEDIR);
            }

            static QString userThemeDir(void) {
            return QDir::toNativeSeparators(QDesktopServices::storageLocation(
            QDesktopServices::DataLocation) + "/"SL_THEMEDIR);
            }

            static QString groupFile(void) {
            return QDir::toNativeSeparators(QDesktopServices::storageLocation(
            QDesktopServices::DataLocation) + "/"SL_GROUPFILE);
            }

            static QString avatarFile(void) {
            return QDir::toNativeSeparators(QDesktopServices::storageLocation(
            QDesktopServices::DataLocation) + "/"SL_AVATARFILE);
            }

            static QString logDir(void) {
            return QDir::toNativeSeparators(QDesktopServices::storageLocation(
            QDesktopServices::DataLocation) + "/"SL_LOGDIR);
            }

            static QString freeLogFile(void) {
            QString fileName = "lmc_" +
            QString::number(QDateTime::currentDateTimeUtc().toMSecsSinceEpoch()) + ".log";
            return QDir::toNativeSeparators(logDir() + "/" + fileName);
            }

            static QString tempConfigFile(void) {
            return QDir::toNativeSeparators(QDesktopServices::storageLocation(
            QDesktopServices::TempLocation) + "/"SL_TEMPCONFIG);
            }
            };

            #endif // STDLOCATION_H

            1 Reply Last reply
            0
            • C Offline
              C Offline
              ctsiitmail
              wrote on last edited by
              #8

              Please explain sir

              Waiting for your kind information.

              Thank you

              1 Reply Last reply
              0
              • M Offline
                M Offline
                MaximAlien
                wrote on last edited by
                #9

                I wrote you my answer. What else you want me to explain you? I think with minimum effort you can fix this problem yourself.

                1 Reply Last reply
                0
                • C Offline
                  C Offline
                  ctsiitmail
                  wrote on last edited by
                  #10

                  Sir,
                  Please solved this code. then i'll try to solve alone another script(code)
                  Thank you.

                  static QString transferHistory(void) {
                  return QDir::toNativeSeparators(QDesktopServices::storageLocation(
                  QDesktopServices::DataLocation) + "/"SL_TRANSFERHISTORY);
                  }

                  1 Reply Last reply
                  0
                  • M Offline
                    M Offline
                    MaximAlien
                    wrote on last edited by
                    #11

                    @#include <QtCore/QDir>
                    #include <QtCore/QStandardPaths>

                    static QString transferHistory(void)
                    {
                    return QDir::toNativeSeparators(QStandardPaths::standardLocations(QStandardPaths::DataLocation).at(0));
                    }@

                    1 Reply Last reply
                    0
                    • C Offline
                      C Offline
                      ctsiitmail
                      wrote on last edited by
                      #12

                      where is missing script?

                      #define SL_TRANSFERHISTORY "transfers.lst"

                      "/"SL_TRANSFERHISTORY

                      1 Reply Last reply
                      0
                      • C Offline
                        C Offline
                        ctsiitmail
                        wrote on last edited by
                        #13

                        Please help me with header define script solved qt 5.2

                        thax & thax

                        #define SL_FILESTORAGEDIR

                        static QString fileStorageDir(void) {
                        lmcSettings settings;

                        QString path = QDir::toNativeSeparators(QDesktopServices::storageLocation(
                        QDesktopServices::DocumentsLocation) + "/"SL_FILESTORAGEDIR);
                        path = settings.value(IDS_FILESTORAGEPATH, path).toString();
                        return path;
                        }

                        1 Reply Last reply
                        0
                        • C Offline
                          C Offline
                          ctsiitmail
                          wrote on last edited by
                          #14

                          Thanks advanced, please...

                          1 Reply Last reply
                          0

                          • Login

                          • Login or register to search.
                          • First post
                            Last post
                          0
                          • Categories
                          • Recent
                          • Tags
                          • Popular
                          • Users
                          • Groups
                          • Search
                          • Get Qt Extensions
                          • Unsolved