X-Git-Url: https://git.sur5r.net/?p=minitube;a=blobdiff_plain;f=src%2Fglobal.h;h=d2aad7a0c6571103cb1791934e7d3f5c2b0c3dd6;hp=2285b17351f491ecca9bad2d3850445ce34df5b3;hb=a8e005af0aa72f809f823bbd741bb3d0def00ced;hpb=2c530dd73ae4db20945c152334ab9897ec9b91af diff --git a/src/global.h b/src/global.h index 2285b17..d2aad7a 100644 --- a/src/global.h +++ b/src/global.h @@ -8,23 +8,18 @@ #include #include #include "networkaccess.h" +#include "diskcache.h" namespace The { - static QMap *g_actions = 0; - - QMap* globalActions() { - if (!g_actions) - g_actions = new QMap; - return g_actions; + QHash* globalActions() { + static QHash *actions = new QHash; + return actions; } - static QMap *g_menus = 0; - - QMap* globalMenus() { - if (!g_menus) - g_menus = new QMap; - return g_menus; + QHash* globalMenus() { + static QHash *menus = new QHash; + return menus; } void maybeSetSystemProxy() { @@ -123,24 +118,24 @@ namespace The { } } - static QNetworkAccessManager *nam = 0; - QNetworkAccessManager* networkAccessManager() { + static QNetworkAccessManager *nam = 0; if (!nam) { networkHttpProxySetting(); maybeSetSystemProxy(); nam = new QNetworkAccessManager(); + QNetworkDiskCache *cache = new DiskCache(); + QString cacheLocation = QDesktopServices::storageLocation( + QDesktopServices::DataLocation); + cache->setCacheDirectory(cacheLocation); + nam->setCache(cache); } return nam; } - static NetworkAccess *g_http = 0; NetworkAccess* http() { - if (!g_http) { - // qDebug() << "Creating NetworkAccess"; - g_http = new NetworkAccess(); - } - return g_http; + static NetworkAccess *na = new NetworkAccess(); + return na; } }