From 9924d39668aa5eb5bbe12faf904ac5e9a4bb6f74 Mon Sep 17 00:00:00 2001 From: Christian Hohnstaedt Date: Sat, 14 Aug 2010 11:01:31 +0200 Subject: [PATCH] set sane start dir for PKCS#11 lib selection --- lib/func.cpp | 16 ++++++++++++++++ lib/func.h | 1 + macdeployqt/Makefile | 1 + widgets/Options.cpp | 3 ++- 4 files changed, 20 insertions(+), 1 deletion(-) diff --git a/lib/func.cpp b/lib/func.cpp index 16f4bc53..326b7424 100644 --- a/lib/func.cpp +++ b/lib/func.cpp @@ -111,6 +111,22 @@ QString getHomeDir() return hd; } +QString getLibDir() +{ + QString hd; +#ifdef WIN32 + LPITEMIDLIST pidl = NULL; + TCHAR buf[255] = ""; + if (SUCCEEDED(SHGetSpecialFolderLocation(NULL, CSIDL_SYSTEM, &pidl))) { + SHGetPathFromIDList(pidl, buf); + } + hd = buf; +#else + hd = QString("/usr/lib"); +#endif + return hd; +} + QString getDocDir() { #if defined(WIN32) || defined (Q_WS_MAC) diff --git a/lib/func.h b/lib/func.h index 7da7dc96..45c1ab3f 100644 --- a/lib/func.h +++ b/lib/func.h @@ -18,6 +18,7 @@ class Validity; QPixmap *loadImg(const char *name); QString getPrefix(); QString getHomeDir(); +QString getLibDir(); QString getDocDir(); QString getUserSettingsDir(); QString getFullFilename(const QString &filename, const QString &selectedFilter); diff --git a/macdeployqt/Makefile b/macdeployqt/Makefile index f1cf7048..88f401d9 100644 --- a/macdeployqt/Makefile +++ b/macdeployqt/Makefile @@ -13,5 +13,6 @@ Makefile.qt: macdeployqt.pro clean: rm -f *.o Makefile.qt macdeployqt +distclean: clean include $(TOPDIR)/Local.mak diff --git a/widgets/Options.cpp b/widgets/Options.cpp index 941161b5..12a7c2e4 100644 --- a/widgets/Options.cpp +++ b/widgets/Options.cpp @@ -5,6 +5,7 @@ * All rights reserved. */ +#include "lib/func.h" #include "Options.h" #include "lib/pki_scard.h" #include @@ -81,7 +82,7 @@ void Options::on_addButton_clicked(void) QString fname, status; fname = QFileDialog::getOpenFileName(this, l.caption, - QString(), l.filter); + getLibDir(), l.filter); if (fname.isEmpty() || pkcs11::get_lib(fname)) return;