📄 evausersetting.cpp
字号:
std::list<sysMessage>srclist; while(!stream.atEnd()){ sysMessage m; stream>>msgType; stream>>type; stream>>from; stream>>to; stream>>commander; stream>>internalQunID; stream>>len; if(len){ tmp = new unsigned char[len+1]; stream.readRawBytes( (char *)(tmp), len); tmp[len] = 0x00; message = QString::fromUtf8((char *)(tmp), len); delete [] tmp; m.message = message; } //stream>>message; stream>>len; if(len){ tmp = new unsigned char[len]; stream.readRawBytes( (char *)(tmp), len); m.setCode( tmp, len); delete []tmp; } stream>>len; if(len){ tmp = new unsigned char[len]; stream.readRawBytes( (char *)(tmp), len); m.setToken( tmp, len); delete []tmp; } //printf("loading type: %d, from: %d, to: %d, cmder: %d, msg: %s\n", type, from, to, commander, m.message.local8Bit().data()); m.messageType = msgType; m.type = type; m.from = from; m.to = to; m.commander = commander; m.internalQunID = internalQunID; srclist.push_back(m); } file.close(); srclist.reverse(); std::list<sysMessage>::iterator iter; int current=0; int start = page * pageSize; int end = start + pageSize; // note that this value is always one more than we want for(iter=srclist.begin(); iter!=srclist.end(); iter++){ if(current >= end) break; if(current>=start && current < end){ list.push_back(*iter); } current++; } return list;}EvaUserSetting::sysMessage EvaUserSetting::getLastSysMessage(){ sysMessage m; m.type = 0; m.from = 0; if(!sysStack.empty()){ m = sysStack.top(); sysStack.pop(); } return m;}const bool EvaUserSetting::saveSettings(){ if(!isDirExisted(getEvaUserDir())){ QDir d; if(!d.mkdir(getEvaUserDir())) return false; } KConfig *cfg = new KConfig(getEvaUserDir() + "/" + userConfigFileName); KConfigGroupSaver *groupSaver = new KConfigGroupSaver(cfg, "General"); cfg->writeEntry("DISPLAY_QQ_BROADCAST", showQQBroadcast); cfg->writeEntry("DISPLAY_QQ_NEWS", m_ShowQQNews); cfg->writeEntry("DISPLAY_TIP_MESSAGE_TIP_WINDOW", showMessageTipWindow); cfg->writeEntry("DISPLAY_BUDDY_ONLINE_NOTIFY", showBudyOnlineNotifyWindow); cfg->writeEntry("DISPLAY_ONLINE_BUDDIES", showOnlineUsers); cfg->writeEntry("SEND_KEY", isSendKeyEnter); cfg->writeEntry("PLAY_SOUND", playSound); cfg->writeEntry("SHOW_SMILEY_IN_NICK", m_ShowSmileyInNickName); cfg->writeEntry("SHOW_SIG_IN_SEPERATE_LINE", m_ShowSignatureInSeperateLine); delete groupSaver; groupSaver = new KConfigGroupSaver(cfg, "Font"); cfg->writeEntry("BUDDY_NAME_COLOR", m_BuddyNameColor); cfg->writeEntry("BUDDY_NAME_FONT_B", m_BuddyNameFontB); cfg->writeEntry("BUDDY_NAME_FONT_U", m_BuddyNameFontU); cfg->writeEntry("BUDDY_NAME_FONT_I", m_BuddyNameFontI); cfg->writeEntry("BUDDY_SIGNATURE_COLOR", m_BuddySigColor); cfg->writeEntry("BUDDY_SIGNATURE_FONT_B", m_BuddySigFontB); cfg->writeEntry("BUDDY_SIGNATURE_FONT_U", m_BuddySigFontU); cfg->writeEntry("BUDDY_SIGNATURE_FONT_I", m_BuddySigFontI); cfg->writeEntry("BUDDY_FLASH_COLOR", m_BuddyFlashColor); cfg->writeEntry("BUDDY_FLASH_FONT_B", m_BuddyFlashFontB); cfg->writeEntry("BUDDY_FLASH_FONT_U", m_BuddyFlashFontU); cfg->writeEntry("BUDDY_FLASH_FONT_I", m_BuddyFlashFontI); // save Qun font settings cfg->writeEntry("QUN_NAME_COLOR", m_QunNameColor); cfg->writeEntry("QUN_NAME_FONT_B", m_QunNameFontB); cfg->writeEntry("QUN_NAME_FONT_U", m_QunNameFontU); cfg->writeEntry("QUN_NAME_FONT_I", m_QunNameFontI); cfg->writeEntry("QUN_FLASH_COLOR", m_QunFlashColor); cfg->writeEntry("QUN_FLASH_FONT_B", m_QunFlashFontB); cfg->writeEntry("QUN_FLASH_FONT_U", m_QunFlashFontU); cfg->writeEntry("QUN_FLASH_FONT_I", m_QunFlashFontI); // save group font settings cfg->writeEntry("GROUP_NAME_COLOR", m_GroupNameColor); cfg->writeEntry("GROUP_NAME_FONT_B", m_GroupNameFontB); cfg->writeEntry("GROUP_NAME_FONT_U", m_GroupNameFontU); cfg->writeEntry("GROUP_NAME_FONT_I", m_GroupNameFontI); cfg->writeEntry("GROUP_ONLINE_COUNT_COLOR", m_GroupCountColor); cfg->writeEntry("GROUP_ONLINE_COUNT_FONT_B", m_GroupOnlineCountFontB); cfg->writeEntry("GROUP_ONLINE_COUNT_FONT_U", m_GroupOnlineCountFontU); cfg->writeEntry("GROUP_ONLINE_COUNT_FONT_I", m_GroupOnlineCountFontI); cfg->writeEntry("GROUP_FLASH_COLOR", m_GroupFlashColor); cfg->writeEntry("GROUP_FLASH_FONT_B", m_GroupFlashFontB); cfg->writeEntry("GROUP_FLASH_FONT_U", m_GroupFlashFontU); cfg->writeEntry("GROUP_FLASH_FONT_I", m_GroupFlashFontI); delete groupSaver; groupSaver = new KConfigGroupSaver(cfg, "Theme"); cfg->writeEntry("THEME_DIR", themeDir); cfg->writeEntry("SOUND_DIR", soundDir); delete groupSaver; groupSaver = new KConfigGroupSaver(cfg, "Reply"); cfg->writeEntry("AUTO_REPLY_SELECTED_INDEX", autoSelectedIndex); std::list<QString>::iterator iter; QStringList strList; for(iter = autoList.begin(); iter!=autoList.end(); ++iter){ strList += (*iter); } cfg->writeEntry("AUTO_REPLY", strList, '\255'); strList.clear(); for(iter = quickList.begin(); iter!=quickList.end(); ++iter){ strList += (*iter); } cfg->writeEntry("QUICK_REPLY", strList, '\255'); delete groupSaver; groupSaver = new KConfigGroupSaver(cfg, "Others"); cfg->writeEntry("FACE_SIZE", faceSize); cfg->writeEntry("MESSAGE_PAGE_SIZE", pageSize); cfg->writeEntry("MESSAGE_SHORTCUT", shortcut.toString()); cfg->writeEntry("WIN_GEOMETRY_POINT", m_WinLeftTop); cfg->writeEntry("WIN_GEOMETRY_SIZE", m_WinSize); cfg->writeEntry("MAX_IDLE_TIME", idleMaxTime); delete groupSaver; groupSaver = new KConfigGroupSaver(cfg, "Cached_ToBeAdded_Buddies"); cfg->writeEntry("NUM_BUDDIES", m_CachedToBeAddedBuddy.size()); std::map<unsigned int, QString>::iterator itr; int num = 0; for(itr = m_CachedToBeAddedBuddy.begin(); itr!=m_CachedToBeAddedBuddy.end(); ++itr){ cfg->writeEntry(QString("QQ_%1").arg(num++), itr->second); } delete groupSaver; groupSaver = new KConfigGroupSaver(cfg, "Reject_Forever"); cfg->writeEntry("QQ_REJECT_LIST_SIZE", m_RejectForever.size()); std::list<unsigned int>::iterator rejectIter; num = 0; for(rejectIter = m_RejectForever.begin(); rejectIter!=m_RejectForever.end(); ++rejectIter){ cfg->writeEntry(QString("QQ_%1").arg(num++), (unsigned int)(*rejectIter)); } delete groupSaver; groupSaver = new KConfigGroupSaver(cfg, "Qun_Reject_Forever"); cfg->writeEntry("QUN_REJECT_LIST_SIZE", m_QunRejectForever.size()); std::map<unsigned int, std::list<unsigned int> >::iterator qunRejectIter; num = 0; for(qunRejectIter = m_QunRejectForever.begin(); qunRejectIter!=m_QunRejectForever.end(); ++qunRejectIter){ cfg->writeEntry(QString("Qun_%1").arg(num++), qunRejectIter->first); cfg->writeEntry("QUN_REJECT_MEMBER_SIZE", (qunRejectIter->second).size()); int memberCount = 0; for(rejectIter = qunRejectIter->second.begin(); rejectIter!= qunRejectIter->second.end(); ++rejectIter){ cfg->writeEntry(QString("Qun_QQ_%1").arg(memberCount++), (unsigned int)(*rejectIter)); } } delete groupSaver; //cfg->sync(); delete cfg; return true;}const bool EvaUserSetting::loadSettings(){ if(!isDirExisted(getEvaUserDir())){ return false; } QString fullName = getEvaUserDir() + "/" + userProfileFileName; QDir d; if(d.exists(fullName)){ loadOldProfile(); QFile::remove(fullName); saveSettings(); } KConfig *cfg = new KConfig(getEvaUserDir() + "/" + userConfigFileName); KConfigGroupSaver *groupSaver = new KConfigGroupSaver(cfg, "General"); showQQBroadcast = cfg->readBoolEntry("DISPLAY_QQ_BROADCAST", true); m_ShowQQNews = cfg->readBoolEntry("DISPLAY_QQ_NEWS", true); showMessageTipWindow = cfg->readBoolEntry("DISPLAY_TIP_MESSAGE_TIP_WINDOW", true); showBudyOnlineNotifyWindow = cfg->readBoolEntry("DISPLAY_BUDDY_ONLINE_NOTIFY", true); showOnlineUsers = cfg->readBoolEntry("DISPLAY_ONLINE_BUDDIES", false); isSendKeyEnter = cfg->readBoolEntry("SEND_KEY", false); playSound = cfg->readBoolEntry("PLAY_SOUND", true); m_ShowSmileyInNickName = cfg->readBoolEntry("SHOW_SMILEY_IN_NICK", false); m_ShowSignatureInSeperateLine = cfg->readBoolEntry("SHOW_SIG_IN_SEPERATE_LINE", false); delete groupSaver; groupSaver = new KConfigGroupSaver(cfg, "Font"); m_BuddyNameColor = cfg->readColorEntry("BUDDY_NAME_COLOR", &Qt::black); m_BuddyNameFontB = cfg->readBoolEntry("BUDDY_NAME_FONT_B", false); m_BuddyNameFontU = cfg->readBoolEntry("BUDDY_NAME_FONT_U", false); m_BuddyNameFontI = cfg->readBoolEntry("BUDDY_NAME_FONT_I", false); m_BuddySigColor = cfg->readColorEntry("BUDDY_SIGNATURE_COLOR", &Qt::gray); m_BuddySigFontB = cfg->readBoolEntry("BUDDY_SIGNATURE_FONT_B", false); m_BuddySigFontU = cfg->readBoolEntry("BUDDY_SIGNATURE_FONT_U", false); m_BuddySigFontI = cfg->readBoolEntry("BUDDY_SIGNATURE_FONT_I", false); m_BuddyFlashColor = cfg->readColorEntry("BUDDY_FLASH_COLOR", &Qt::red); m_BuddyFlashFontB = cfg->readBoolEntry("BUDDY_FLASH_FONT_B", false); m_BuddyFlashFontU = cfg->readBoolEntry("BUDDY_FLASH_FONT_U", false); m_BuddyFlashFontI = cfg->readBoolEntry("BUDDY_FLASH_FONT_I", false); m_QunNameColor = cfg->readColorEntry("QUN_NAME_COLOR", &Qt::black); m_QunNameFontB = cfg->readBoolEntry("QUN_NAME_FONT_B", false); m_QunNameFontU = cfg->readBoolEntry("QUN_NAME_FONT_U", false); m_QunNameFontI = cfg->readBoolEntry("QUN_NAME_FONT_I", false); m_QunFlashColor = cfg->readColorEntry("QUN_FLASH_COLOR", &Qt::red); m_QunFlashFontB = cfg->readBoolEntry("QUN_FLASH_FONT_B", false); m_QunFlashFontU = cfg->readBoolEntry("QUN_FLASH_FONT_U", false); m_QunFlashFontI = cfg->readBoolEntry("QUN_FLASH_FONT_I", false); m_GroupNameColor = cfg->readColorEntry("GROUP_NAME_COLOR", &Qt::black); m_GroupNameFontB = cfg->readBoolEntry("GROUP_NAME_FONT_B", false); m_GroupNameFontU = cfg->readBoolEntry("GROUP_NAME_FONT_U", false); m_GroupNameFontI = cfg->readBoolEntry("GROUP_NAME_FONT_I", false); m_GroupCountColor = cfg->readColorEntry("GROUP_ONLINE_COUNT_COLOR", &Qt::blue); m_GroupOnlineCountFontB = cfg->readBoolEntry("GROUP_ONLINE_COUNT_FONT_B", false); m_GroupOnlineCountFontU = cfg->readBoolEntry("GROUP_ONLINE_COUNT_FONT_U", false); m_GroupOnlineCountFontI = cfg->readBoolEntry("GROUP_ONLINE_COUNT_FONT_I", false); m_GroupFlashColor = cfg->readColorEntry("GROUP_FLASH_COLOR", &Qt::red); m_GroupFlashFontB = cfg->readBoolEntry("GROUP_FLASH_FONT_B", false); m_GroupFlashFontU = cfg->readBoolEntry("GROUP_FLASH_FONT_U", false); m_GroupFlashFontI = cfg->readBoolEntry("GROUP_FLASH_FONT_I", false); delete groupSaver; groupSaver = new KConfigGroupSaver(cfg, "Theme"); themeDir = cfg->readEntry("THEME_DIR"); soundDir = cfg->readEntry("SOUND_DIR"); delete groupSaver; autoList.clear(); quickList.clear(); groupSaver = new KConfigGroupSaver(cfg, "Reply"); autoSelectedIndex = cfg->readNumEntry("AUTO_REPLY_SELECTED_INDEX"); QStringList strList; strList = cfg->readListEntry("AUTO_REPLY", '\255'); if(strList.size()){ for(QStringList::Iterator iter = strList.begin(); iter != strList.end(); ++iter) autoList.push_back(*iter); } else { autoList.push_back(QString(i18n("sorry, I am working."))); autoList.push_back(QString(i18n("having dinner now./fa"))); autoList.push_back(QString(i18n("I am not available now, sorry"))); } strList.clear(); strList = cfg->readListEntry("QUICK_REPLY", '\255'); if(strList.size()){ for(QStringList::Iterator iter = strList.begin(); iter != strList.end(); ++iter) quickList.push_back(*iter); } else { quickList.push_back(QString(i18n("oh."))); quickList.push_back(QString(i18n("ok, ok, I got u."))); quickList.push_back(QString(i18n("/jy ,really?"))); } delete groupSaver; groupSaver = new KConfigGroupSaver(cfg, "Others"); QSize size(16, 16); faceSize = cfg->readSizeEntry("FACE_SIZE", &size); pageSize = cfg->readNumEntry("MESSAGE_PAGE_SIZE", 25); QString shortkey = cfg->readEntry("MESSAGE_SHORTCUT") ; if(shortkey.isEmpty()) shortcut.init(Qt::CTRL + Qt::ALT + Qt::Key_Z); else{ if(!shortcut.init(shortkey)) shortcut.init(Qt::CTRL + Qt::ALT + Qt::Key_Z); } QPoint p(600, 100); m_WinLeftTop = cfg->readPointEntry("WIN_GEOMETRY_POINT", &p); QSize winSize(195, 376); m_WinSize = cfg->readSizeEntry("WIN_GEOMETRY_SIZE", &winSize); idleMaxTime = cfg->readNumEntry("MAX_IDLE_TIME", 5); delete groupSaver; m_CachedToBeAddedBuddy.clear(); groupSaver = new KConfigGroupSaver(cfg, "Cached_ToBeAdded_Buddies"); int num = cfg->readNumEntry("NUM_BUDDIES", 0); QString buddyInfo; QStringList items; bool ok; for(int i = 0; i< num; i++){ buddyInfo = cfg->readEntry(QString("QQ_%1").arg(i)); if(!buddyInfo.isEmpty()){ items = QStringList::split(",", buddyInfo); unsigned int id = items[0].toUInt(&ok); if(ok) m_CachedToBeAddedBuddy[id] = buddyInfo; } } delete groupSaver; m_RejectForever.clear(); groupSaver = new KConfigGroupSaver(cfg, "Reject_Forever"); num = cfg->readNumEntry("QQ_REJECT_LIST_SIZE", 0); unsigned int id = 0; for(int i = 0; i< num; i++){ id = cfg->readUnsignedNumEntry( QString("QQ_%1").arg(i)); printf("read id: %d\n", id); if(id){ m_RejectForever.push_back(id); } } delete groupSaver; m_QunRejectForever.clear(); unsigned int tmpQun, tmpQQ; int memberCount; groupSaver = new KConfigGroupSaver(cfg, "Qun_Reject_Forever"); num = cfg->readNumEntry("QUN_REJECT_LIST_SIZE", 0); for(int q = 0; q < num; q++){ tmpQun = cfg->readNumEntry(QString("Qun_%1").arg(q), 0); memberCount = cfg->readNumEntry("QUN_REJECT_MEMBER_SIZE", 0); std::list<unsigned int> members; for(int i = 0; i < memberCount; i++){ tmpQQ = cfg->readNumEntry( QString("Qun_QQ_%1").arg(i), 0); members.push_back(tmpQQ); } m_QunRejectForever[tmpQun] = members; } delete groupSaver; //cfg->sync(); delete cfg; return true; }bool EvaUserSetting::loadOldProfile(){ if(!isDirExisted(getEvaUserDir())){ return false; } QString fullName = getEvaUserDir() + "/" + userProfileFileName; QDir d; if(!d.exists(fullName)){ loadDefaultSettings(); return true; } QFile file(fullName); if(!file.open(IO_ReadOnly)){ return false; } autoList.clear(); quickList.clear(); QString line; QStringList lineList; QTextStream stream(&file); while(!stream.atEnd()){ line = stream.readLine().stripWhiteSpace(); lineList = QStringList::split(":", line); if(lineList.size() != 2) continue; lineList[0].stripWhiteSpace(); lineList[1].stripWhiteSpace(); if(lineList[0] == "THEME_DIR"){ themeDir = lineList[1]; } if(lineList[0] == "SOUND_DIR"){ soundDir = lineList[1]; }
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -