XDG compliant config location on Linux

Better way to detect APPDATA path on Windows
Optimize global include file

git-svn-id: https://svn.code.sf.net/p/keepassx/code/trunk@282 b624d157-de02-0410-bad0-e51aec6abb33
This commit is contained in:
sniperbeamer
2009-03-13 12:40:15 +00:00
parent c614192a48
commit c6fbc412be
6 changed files with 81 additions and 24 deletions

View File

@@ -18,10 +18,8 @@
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
***************************************************************************/
#include "WaitAnimationWidget.h"
WaitAnimationWidget::WaitAnimationWidget(QWidget* parent):QWidget(parent){
speed=60;
setRefreshRate(25);
@@ -94,4 +92,3 @@ void WaitAnimationWidget::resizeEvent(QResizeEvent* event){
CircPositions[i].setY((r-10)*sin(-2.0*3.14159265*(0.16666667*i))+r);
}
}

View File

@@ -363,3 +363,32 @@ QList<Translation> getAllTranslations(){
qSort(translations.begin(), translations.end());
return translations;
}
// from src/corelib/qsettings.cpp:
#ifdef Q_OS_WIN
QString qtWindowsConfigPath(int type)
{
QString result;
QLibrary library(QLatin1String("shell32"));
QT_WA( {
typedef BOOL (WINAPI*GetSpecialFolderPath)(HWND, LPTSTR, int, BOOL);
GetSpecialFolderPath SHGetSpecialFolderPath = (GetSpecialFolderPath)library.resolve("SHGetSpecialFolderPathW");
if (SHGetSpecialFolderPath) {
TCHAR path[MAX_PATH];
SHGetSpecialFolderPath(0, path, type, FALSE);
result = QString::fromUtf16((ushort*)path);
}
} , {
typedef BOOL (WINAPI*GetSpecialFolderPath)(HWND, char*, int, BOOL);
GetSpecialFolderPath SHGetSpecialFolderPath = (GetSpecialFolderPath)library.resolve("SHGetSpecialFolderPathA");
if (SHGetSpecialFolderPath) {
char path[MAX_PATH];
SHGetSpecialFolderPath(0, path, type, FALSE);
result = QString::fromLocal8Bit(path);
}
} );
return result;
}
#endif // Q_OS_WIN

View File

@@ -19,8 +19,6 @@
#ifndef TOOLS_H
#define TOOLS_H
#define CSTR(x)(x.toLocal8Bit().constData())
class IEntryHandle;
enum tKeyType {PASSWORD=0,KEYFILE=1,BOTH=2};
@@ -32,10 +30,15 @@ struct Translation {
};
bool operator<(const Translation& t1, const Translation& t2);
inline const char* CSTR(const QString& str) {
return QTextCodec::codecForLocale()->fromUnicode(str).constData();
}
const QIcon& getIcon(const QString& name);
const QPixmap* getPixmap(const QString& name);
void createBanner(QPixmap* Pixmap, const QPixmap* IconAlpha,const QString& Text,int Width);
void createBanner(QPixmap* Pixmap, const QPixmap* IconAlpha,const QString& Text,int Width, QColor Color1, QColor Color2, QColor TextColor);
void createBanner(QPixmap* Pixmap, const QPixmap* IconAlpha,const QString& Text,int Width,
QColor Color1, QColor Color2, QColor TextColor);
void openBrowser(const QString& UrlString);
void openBrowser(IEntryHandle* entry);
void showErrMsg(const QString& msg,QWidget* parent=NULL);
@@ -48,5 +51,11 @@ bool unlockPage(void* addr, int len);
void installTranslator();
bool isTranslationActive();
QList<Translation> getAllTranslations();
#ifdef Q_OS_WIN
#ifndef CSIDL_APPDATA
#define CSIDL_APPDATA 0x001a // <username>\Application Data
#endif
QString qtWindowsConfigPath(int type);
#endif
#endif //TOOLS_H