ossp-pkg/as/as-gui/as_assist.cpp 1.39 -> 1.40
--- as_assist.cpp 2002/12/03 17:05:11 1.39
+++ as_assist.cpp 2002/12/03 18:46:25 1.40
@@ -29,6 +29,13 @@
// titassist.cpp: ISO C++ implementation
//
+// For username research
+#if defined(Q_WS_WIN)
+#include <lmcons.h>
+#else
+#include <unistd.h>
+#endif
+
// Qt style headers
#include <qcdestyle.h>
#include <qsgistyle.h>
@@ -68,8 +75,29 @@
//
void Titraqform::setupPrefs(void)
{
+ QString Username;
+
+// Start the show by getting the username
+#if defined(Q_WS_WIN)
+ DWORD winUserNameSize = sizeof(winUserName);
+#if defined(UNICODE)
+ TCHAR winUserName[UNLEN + 1]; // UNLEN is defined in lmcons.h
+ GetUserName(winUserName, &winUserNameSize);
+ userName = qt_winQString(winUserName);
+#endif // #if defined(UNICODE)
+ char winUserName[UNLEN + 1]; // UNLEN is defined in lmcons.h
+ GetUserNameA(winUserName, &winUserNameSize);
+ userName = QString::fromLocal8Bit(winUserName);
+#else // #if defined(Q_WS_WIN)
+ Username = QString::fromLocal8Bit(getlogin());
+#endif
+
m_pPrefs = new Preferences(TITRAQ_PREFNAME, TITRAQ_APPTITLE, TITRAQ_PREFVER);
- if (!m_pPrefs->fileState()) { // No file was found, so assume a null state
+ if (!m_pPrefs->fileState()) { // No file was found, so assume a null state
+ if (!Username.isEmpty())
+ m_pPrefs->setString(TITRAQ_PREFUSER, Username);
+ else
+ m_pPrefs->setString(TITRAQ_PREFUSER, TITRAQ_DEFUSER);
m_pPrefs->setString(TITRAQ_PREFASFILE, TITRAQ_DEFASFILE);
m_pPrefs->setNumber(TITRAQ_PREFSTYLE, TITRAQ_STYLECDE);
m_pPrefs->setString(TITRAQ_PREFVIEW, TITRAQ_DEFVIEW);
|
|