void DialogPreferences::on_listAdvancedOptions_itemChanged(QTreeWidgetItem* item, int col) { if (col != CN_CURVALUE) return; onSettingChanged(); std::string curval = Q2S(item->text(CN_CURVALUE)); bool isvalid = false; try { std::string normval = settings->getVariable(Q2S(item->text(CN_KEY)))->isValid(curval); if (curval != normval) { item->setText(CN_CURVALUE, S2Q(normval)); return; } isvalid = true; } catch (...) {}; bool bold = item->text(CN_CURVALUE) != item->text(CN_DEFAULT); QFont tfont = item->font(CN_DEFAULT); tfont.setBold(bold); item->setFont(CN_CURVALUE, tfont); item->setFont(CN_KEY , tfont); QColor tcolor = item->textColor(CN_DEFAULT); if (!isvalid) tcolor = QColor("red"); item->setTextColor(CN_CURVALUE, tcolor); item->setTextColor(CN_KEY , tcolor); }
void EasyTrace::WriteLog(int nLevel, const char *szFormat, ...) { m_mutex.lock(); LPRecode lpRecodeMessage = new LogRecode(); int len = 0; va_list args; va_start(args, szFormat); len = _vscprintf(szFormat, args) + 1; lpRecodeMessage->nlevel = nLevel; lpRecodeMessage->buffer = new char[len * sizeof(char)]; memset(lpRecodeMessage->buffer,0x00, sizeof lpRecodeMessage->buffer ); //vsprintf_s(lpRecodeMessage->buffer, len, szFormat, args); vsprintf(lpRecodeMessage->buffer, szFormat, args); va_end(args); //::GetModuleFileNameA((HMODULE)AfxGetStaticModuleState()->m_hCurrentInstanceHandle, // lpRecodeMessage->sModulName,sizeof lpRecodeMessage->sModulName); QString strModuleFileName = __GetModuleFileName((void*)&EasyTrace::WriteLog); //注意此处只能这样用,且在该类中调用的方法不能再调用LOGERRORE等输出日志,只能调用qt系统日志进行输出(如:qDebug之类),防止死循环 QString strFileName= QCoreApplication::applicationFilePath(); QString strCurPath = QDir::currentPath(); memcpy(lpRecodeMessage->sModulName, Q2S(strModuleFileName), strModuleFileName.length()); DllEasyLog::WriteLogFunc(lpRecodeMessage ); delete[] lpRecodeMessage->buffer; lpRecodeMessage->buffer = NULL; delete lpRecodeMessage; lpRecodeMessage = NULL; m_mutex.unlock(); }
void DialogPreferences::scanWidgets(QObject* obj) { QVariant settingkey = obj->property("settingkey"); if (settingkey.isValid()) { std::string skey = Q2S(settingkey.toString()); if (!skey.empty()) widgets[skey] = obj; } BOOST_FOREACH(QObject* c, obj->children()) scanWidgets(c); }