diff --git a/src/Gui/DlgEditorImp.cpp b/src/Gui/DlgEditorImp.cpp index 7d8b247a77..7cf4ec8f02 100644 --- a/src/Gui/DlgEditorImp.cpp +++ b/src/Gui/DlgEditorImp.cpp @@ -39,7 +39,7 @@ namespace Gui { namespace Dialog { struct DlgSettingsEditorP { - QVector > colormap; // Color map + QVector > colormap; // Color map }; } // namespace Dialog } // namespace Gui @@ -60,70 +60,70 @@ DlgSettingsEditorImp::DlgSettingsEditorImp( QWidget* parent ) d = new DlgSettingsEditorP(); QColor col; col = Qt::black; - unsigned long lText = (col.red() << 24) | (col.green() << 16) | (col.blue() << 8); - d->colormap.push_back(QPair + unsigned int lText = (col.red() << 24) | (col.green() << 16) | (col.blue() << 8); + d->colormap.push_back(QPair (QString::fromLatin1(QT_TR_NOOP("Text")), lText)); col = Qt::cyan; - unsigned long lBookmarks = (col.red() << 24) | (col.green() << 16) | (col.blue() << 8); - d->colormap.push_back(QPair + unsigned int lBookmarks = (col.red() << 24) | (col.green() << 16) | (col.blue() << 8); + d->colormap.push_back(QPair (QString::fromLatin1(QT_TR_NOOP("Bookmark")), lBookmarks)); col = Qt::red; - unsigned long lBreakpnts = (col.red() << 24) | (col.green() << 16) | (col.blue() << 8); - d->colormap.push_back(QPair + unsigned int lBreakpnts = (col.red() << 24) | (col.green() << 16) | (col.blue() << 8); + d->colormap.push_back(QPair (QString::fromLatin1(QT_TR_NOOP("Breakpoint")), lBreakpnts)); col = Qt::blue; - unsigned long lKeywords = (col.red() << 24) | (col.green() << 16) | (col.blue() << 8); - d->colormap.push_back(QPair + unsigned int lKeywords = (col.red() << 24) | (col.green() << 16) | (col.blue() << 8); + d->colormap.push_back(QPair (QString::fromLatin1(QT_TR_NOOP("Keyword")), lKeywords)); col.setRgb(0, 170, 0); - unsigned long lComments = (col.red() << 24) | (col.green() << 16) | (col.blue() << 8); - d->colormap.push_back(QPair + unsigned int lComments = (col.red() << 24) | (col.green() << 16) | (col.blue() << 8); + d->colormap.push_back(QPair (QString::fromLatin1(QT_TR_NOOP("Comment")), lComments)); col.setRgb(160, 160, 164); - unsigned long lBlockCom = (col.red() << 24) | (col.green() << 16) | (col.blue() << 8); - d->colormap.push_back(QPair + unsigned int lBlockCom = (col.red() << 24) | (col.green() << 16) | (col.blue() << 8); + d->colormap.push_back(QPair (QString::fromLatin1(QT_TR_NOOP("Block comment")), lBlockCom)); col = Qt::blue; - unsigned long lNumbers = (col.red() << 24) | (col.green() << 16) | (col.blue() << 8); - d->colormap.push_back(QPair + unsigned int lNumbers = (col.red() << 24) | (col.green() << 16) | (col.blue() << 8); + d->colormap.push_back(QPair (QString::fromLatin1(QT_TR_NOOP("Number")), lNumbers)); col = Qt::red; - unsigned long lStrings = (col.red() << 24) | (col.green() << 16) | (col.blue() << 8); - d->colormap.push_back(QPair + unsigned int lStrings = (col.red() << 24) | (col.green() << 16) | (col.blue() << 8); + d->colormap.push_back(QPair (QString::fromLatin1(QT_TR_NOOP("String")), lStrings)); col = Qt::red; - unsigned long lCharacter = (col.red() << 24) | (col.green() << 16) | (col.blue() << 8); - d->colormap.push_back(QPair + unsigned int lCharacter = (col.red() << 24) | (col.green() << 16) | (col.blue() << 8); + d->colormap.push_back(QPair (QString::fromLatin1(QT_TR_NOOP("Character")), lCharacter)); col.setRgb(255, 170, 0); - unsigned long lClass = (col.red() << 24) | (col.green() << 16) | (col.blue() << 8); - d->colormap.push_back(QPair + unsigned int lClass = (col.red() << 24) | (col.green() << 16) | (col.blue() << 8); + d->colormap.push_back(QPair (QString::fromLatin1(QT_TR_NOOP("Class name")), lClass)); col.setRgb(255, 170, 0); - unsigned long lDefine = (col.red() << 24) | (col.green() << 16) | (col.blue() << 8); - d->colormap.push_back(QPair + unsigned int lDefine = (col.red() << 24) | (col.green() << 16) | (col.blue() << 8); + d->colormap.push_back(QPair (QString::fromLatin1(QT_TR_NOOP("Define name")), lDefine)); col.setRgb(160, 160, 164); - unsigned long lOperat = (col.red() << 24) | (col.green() << 16) | (col.blue() << 8); - d->colormap.push_back(QPair + unsigned int lOperat = (col.red() << 24) | (col.green() << 16) | (col.blue() << 8); + d->colormap.push_back(QPair (QString::fromLatin1(QT_TR_NOOP("Operator")), lOperat)); col.setRgb(170, 170, 127); - unsigned long lPyOutput = (col.red() << 24) | (col.green() << 16) | (col.blue() << 8); - d->colormap.push_back(QPair + unsigned int lPyOutput = (col.red() << 24) | (col.green() << 16) | (col.blue() << 8); + d->colormap.push_back(QPair (QString::fromLatin1(QT_TR_NOOP("Python output")), lPyOutput)); col = Qt::red; - unsigned long lPyError = (col.red() << 24) | (col.green() << 16) | (col.blue() << 8); - d->colormap.push_back(QPair + unsigned int lPyError = (col.red() << 24) | (col.green() << 16) | (col.blue() << 8); + d->colormap.push_back(QPair (QString::fromLatin1(QT_TR_NOOP("Python error")), lPyError)); col.setRgb(224, 224, 224); - unsigned long lCLine = (col.red() << 24) | (col.green() << 16) | (col.blue() << 8); - d->colormap.push_back(QPair + unsigned int lCLine = (col.red() << 24) | (col.green() << 16) | (col.blue() << 8); + d->colormap.push_back(QPair (QString::fromLatin1(QT_TR_NOOP("Current line highlight")), lCLine)); QStringList labels; labels << tr("Items"); this->displayItems->setHeaderLabels(labels); this->displayItems->header()->hide(); - for (QVector >::ConstIterator it = d->colormap.begin(); it != d->colormap.end(); ++it) { + for (QVector >::ConstIterator it = d->colormap.begin(); it != d->colormap.end(); ++it) { QTreeWidgetItem* item = new QTreeWidgetItem(this->displayItems); item->setText(0, tr((*it).first.toLatin1())); } @@ -146,7 +146,7 @@ DlgSettingsEditorImp::~DlgSettingsEditorImp() void DlgSettingsEditorImp::on_displayItems_currentItemChanged(QTreeWidgetItem *item) { int index = displayItems->indexOfTopLevelItem(item); - unsigned long col = d->colormap[index].second; + unsigned int col = d->colormap[index].second; colorButton->setColor(QColor((col >> 24) & 0xff, (col >> 16) & 0xff, (col >> 8) & 0xff)); } @@ -154,7 +154,7 @@ void DlgSettingsEditorImp::on_displayItems_currentItemChanged(QTreeWidgetItem *i void DlgSettingsEditorImp::on_colorButton_changed() { QColor col = colorButton->color(); - unsigned long lcol = (col.red() << 24) | (col.green() << 16) | (col.blue() << 8); + unsigned int lcol = (col.red() << 24) | (col.green() << 16) | (col.blue() << 8); int index = displayItems->indexOfTopLevelItem(displayItems->currentItem()); d->colormap[index].second = lcol; @@ -172,8 +172,10 @@ void DlgSettingsEditorImp::saveSettings() // Saves the color map ParameterGrp::handle hGrp = WindowParameter::getDefaultParameter()->GetGroup("Editor"); - for (QVector >::ConstIterator it = d->colormap.begin(); it != d->colormap.end(); ++it) - hGrp->SetUnsigned((*it).first.toLatin1(), (*it).second); + for (QVector >::ConstIterator it = d->colormap.begin(); it != d->colormap.end(); ++it) { + unsigned long col = static_cast((*it).second); + hGrp->SetUnsigned((*it).first.toLatin1(), col); + } hGrp->SetInt( "FontSize", fontSize->value() ); hGrp->SetASCII( "Font", fontFamily->currentText().toLatin1() ); @@ -202,9 +204,10 @@ void DlgSettingsEditorImp::loadSettings() // Restores the color map ParameterGrp::handle hGrp = WindowParameter::getDefaultParameter()->GetGroup("Editor"); - for (QVector >::Iterator it = d->colormap.begin(); it != d->colormap.end(); ++it){ - unsigned long col = hGrp->GetUnsigned((*it).first.toLatin1(), (*it).second); - (*it).second = col; + for (QVector >::Iterator it = d->colormap.begin(); it != d->colormap.end(); ++it){ + unsigned long col = static_cast((*it).second); + col = hGrp->GetUnsigned((*it).first.toLatin1(), col); + (*it).second = static_cast(col); QColor color; color.setRgb((col >> 24) & 0xff, (col >> 16) & 0xff, (col >> 8) & 0xff); pythonSyntax->setColor( (*it).first, color ); @@ -235,7 +238,7 @@ void DlgSettingsEditorImp::changeEvent(QEvent *e) { if (e->type() == QEvent::LanguageChange) { int index = 0; - for (QVector >::ConstIterator it = d->colormap.begin(); it != d->colormap.end(); ++it) + for (QVector >::ConstIterator it = d->colormap.begin(); it != d->colormap.end(); ++it) this->displayItems->topLevelItem(index++)->setText(0, tr((*it).first.toLatin1())); this->retranslateUi(this); } else { diff --git a/src/Gui/PrefWidgets.cpp b/src/Gui/PrefWidgets.cpp index 8aad82aeec..f4b431e2e7 100644 --- a/src/Gui/PrefWidgets.cpp +++ b/src/Gui/PrefWidgets.cpp @@ -429,12 +429,14 @@ void PrefColorButton::restorePreferences() QColor col = color(); - unsigned long lcol = (col.red() << 24) | (col.green() << 16) | (col.blue() << 8); + unsigned int icol = (col.red() << 24) | (col.green() << 16) | (col.blue() << 8); + unsigned long lcol = static_cast(icol); lcol = getWindowParameter()->GetUnsigned( entryName(), lcol ); - int r = (lcol >> 24)&0xff; - int g = (lcol >> 16)&0xff; - int b = (lcol >> 8)&0xff; + icol = static_cast(lcol); + int r = (icol >> 24)&0xff; + int g = (icol >> 16)&0xff; + int b = (icol >> 8)&0xff; setColor(QColor(r,g,b)); } @@ -449,9 +451,8 @@ void PrefColorButton::savePreferences() QColor col = color(); // (r,g,b,a) with a = 255 (opaque) - unsigned long lcol = (static_cast (col.red()) << 24) - | (static_cast (col.green()) << 16) - | (static_cast (col.blue()) << 8) | 255; + unsigned int icol = (col.red() << 24) | (col.green() << 16) | (col.blue() << 8) | 255; + unsigned long lcol = static_cast(icol); getWindowParameter()->SetUnsigned( entryName(), lcol ); } diff --git a/src/Gui/PythonConsole.cpp b/src/Gui/PythonConsole.cpp index cb9d387a8f..d478474747 100644 --- a/src/Gui/PythonConsole.cpp +++ b/src/Gui/PythonConsole.cpp @@ -514,8 +514,10 @@ void PythonConsole::OnChange( Base::Subject &rCaller,const char* sR QMap::ConstIterator it = d->colormap.find(QString::fromLatin1(sReason)); if (it != d->colormap.end()) { QColor color = it.value(); - unsigned long col = (color.red() << 24) | (color.green() << 16) | (color.blue() << 8); - col = hPrefGrp->GetUnsigned( sReason, col); + unsigned int col = (color.red() << 24) | (color.green() << 16) | (color.blue() << 8); + unsigned long value = static_cast(col); + value = hPrefGrp->GetUnsigned(sReason, value); + col = static_cast(value); color.setRgb((col>>24)&0xff, (col>>16)&0xff, (col>>8)&0xff); pythonSyntax->setColor(QString::fromLatin1(sReason), color); } @@ -929,10 +931,11 @@ void PythonConsole::changeEvent(QEvent *e) else if (e->type() == QEvent::StyleChange) { QPalette pal = palette(); QColor color = pal.windowText().color(); - unsigned long text = (color.red() << 24) | (color.green() << 16) | (color.blue() << 8); + unsigned int text = (color.red() << 24) | (color.green() << 16) | (color.blue() << 8); + unsigned long value = static_cast(text); // if this parameter is not already set use the style's window text color - text = getWindowParameter()->GetUnsigned("Text", text); - getWindowParameter()->SetUnsigned("Text", text); + value = getWindowParameter()->GetUnsigned("Text", value); + getWindowParameter()->SetUnsigned("Text", value); } TextEdit::changeEvent(e); } diff --git a/src/Gui/ReportView.cpp b/src/Gui/ReportView.cpp index 05afad8f27..79b7d24f63 100644 --- a/src/Gui/ReportView.cpp +++ b/src/Gui/ReportView.cpp @@ -378,10 +378,11 @@ void ReportOutput::changeEvent(QEvent *ev) if (ev->type() == QEvent::StyleChange) { QPalette pal = palette(); QColor color = pal.windowText().color(); - unsigned long text = (color.red() << 24) | (color.green() << 16) | (color.blue() << 8); + unsigned int text = (color.red() << 24) | (color.green() << 16) | (color.blue() << 8); + unsigned long value = static_cast(text); // if this parameter is not already set use the style's window text color - text = getWindowParameter()->GetUnsigned("colorText", text); - getWindowParameter()->SetUnsigned("colorText", text); + value = getWindowParameter()->GetUnsigned("colorText", value); + getWindowParameter()->SetUnsigned("colorText", value); } QTextEdit::changeEvent(ev); } diff --git a/src/Gui/TextEdit.cpp b/src/Gui/TextEdit.cpp index 932c2f7dc2..8844f08a12 100644 --- a/src/Gui/TextEdit.cpp +++ b/src/Gui/TextEdit.cpp @@ -273,9 +273,11 @@ void TextEditor::highlightCurrentLine() if (!isReadOnly()) { QTextEdit::ExtraSelection selection; QColor lineColor = d->colormap[QLatin1String("Current line highlight")]; - unsigned long col = (lineColor.red() << 24) | (lineColor.green() << 16) | (lineColor.blue() << 8); + unsigned int col = (lineColor.red() << 24) | (lineColor.green() << 16) | (lineColor.blue() << 8); ParameterGrp::handle hPrefGrp = getWindowParameter(); - col = hPrefGrp->GetUnsigned( "Current line highlight", col); + unsigned long value = static_cast(col); + value = hPrefGrp->GetUnsigned( "Current line highlight", value); + col = static_cast(value); lineColor.setRgb((col>>24)&0xff, (col>>16)&0xff, (col>>8)&0xff); selection.format.setBackground(lineColor); selection.format.setProperty(QTextFormat::FullWidthSelection, true); @@ -434,8 +436,10 @@ void TextEditor::OnChange(Base::Subject &rCaller,const char* sReaso QMap::ConstIterator it = d->colormap.find(QString::fromLatin1(sReason)); if (it != d->colormap.end()) { QColor color = it.value(); - unsigned long col = (color.red() << 24) | (color.green() << 16) | (color.blue() << 8); - col = hPrefGrp->GetUnsigned( sReason, col); + unsigned int col = (color.red() << 24) | (color.green() << 16) | (color.blue() << 8); + unsigned long value = static_cast(col); + value = hPrefGrp->GetUnsigned(sReason, value); + col = static_cast(value); color.setRgb((col>>24)&0xff, (col>>16)&0xff, (col>>8)&0xff); if (this->highlighter) this->highlighter->setColor(QLatin1String(sReason), color);