Skip to content

Commit

Permalink
Part 1.
Browse files Browse the repository at this point in the history
  • Loading branch information
KuzemkoA committed May 27, 2024
1 parent e1d91bf commit 0635a42
Show file tree
Hide file tree
Showing 14 changed files with 162 additions and 162 deletions.
2 changes: 1 addition & 1 deletion src/App/Branding.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ Branding::XmlConfig Branding::getUserDefines() const
if (!root.isNull()) {
child = root.firstChildElement();
while (!child.isNull()) {
std::string name = child.localName().toLatin1().constData();
std::string name = child.localName().toUtf8().constData();
std::string value = child.text().toUtf8().constData();
if (std::find(filter.begin(), filter.end(), name) != filter.end())
cfg[name] = value;
Expand Down
6 changes: 3 additions & 3 deletions src/Base/Uuid.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,22 +63,22 @@ std::string Uuid::createUuid()
QString uuid = QUuid::createUuid().toString();
uuid = uuid.mid(1);
uuid.chop(1);
Uuid = uuid.toLatin1().constData();
Uuid = uuid.toUtf8().constData();
return Uuid;
}

void Uuid::setValue(const char* sString)
{
if (sString) {
QUuid uuid(QString::fromLatin1(sString));
QUuid uuid(QString::fromUtf8(sString));
if (uuid.isNull()) {
throw std::runtime_error("invalid uuid");
}
// remove curly braces
QString id = uuid.toString();
id = id.mid(1);
id.chop(1);
_uuid = id.toLatin1().constData();
_uuid = id.toUtf8().constData();
}
}

Expand Down
36 changes: 18 additions & 18 deletions src/Gui/Action.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ Action::Action (Command* pcCmd, QObject * parent)
, _action(new QAction( this ))
, _pcCmd(pcCmd)
{
_action->setObjectName(QString::fromLatin1(_pcCmd->getName()));
_action->setObjectName(QString::fromUtf8(_pcCmd->getName()));
_connection = connect(_action, &QAction::triggered, this, &Action::onActivated);
}

Expand All @@ -86,7 +86,7 @@ Action::Action (Command* pcCmd, QAction* action, QObject * parent)
, _pcCmd(pcCmd)
{
_action->setParent(this);
_action->setObjectName(QString::fromLatin1(_pcCmd->getName()));
_action->setObjectName(QString::fromUtf8(_pcCmd->getName()));
_connection = connect(_action, &QAction::triggered, this, &Action::onActivated);
}

Expand Down Expand Up @@ -331,23 +331,23 @@ QString Action::createToolTip(QString helpText,
helpText.resize(helpText.size() - shortcut.size());
}
if (!shortcut.isEmpty()) {
shortcut = QString::fromLatin1(" (%1)").arg(shortcut);
shortcut = QStringLiteral(" (%1)").arg(shortcut);
}

QString tooltip = QString::fromLatin1(
QString tooltip = QStringLiteral(
"<p style='white-space:pre; margin-bottom:0.5em;'><b>%1</b>%2</p>").arg(
text.toHtmlEscaped(), shortcut.toHtmlEscaped());

QString cmdName;
if (command && command->getName()) {
cmdName = QString::fromLatin1(command->getName());
cmdName = QString::fromUtf8(command->getName());
if (auto groupcmd = dynamic_cast<const GroupCommand*>(command)) {
if (auto act = command->getAction()) {
int idx = act->property("defaultAction").toInt();
auto cmd = groupcmd->getCommand(idx);
if (cmd && cmd->getName()) {
cmdName = QStringLiteral("%1 (%2:%3)")
.arg(QString::fromLatin1(cmd->getName()), cmdName)
.arg(QString::fromUtf8(cmd->getName()), cmdName)
.arg(idx);
}
}
Expand All @@ -371,12 +371,12 @@ QString Action::createToolTip(QString helpText,
return tooltip + helpText + cmdName;
}

tooltip += QString::fromLatin1(
tooltip += QStringLiteral(
"<p style='white-space:pre; margin:0;'>");

// If the user supplied tooltip contains line break, we shall honour it.
if (helpText.indexOf(QLatin1Char('\n')) >= 0) {
tooltip += helpText.toHtmlEscaped() + QString::fromLatin1("</p>") ;
tooltip += helpText.toHtmlEscaped() + QStringLiteral("</p>") ;
}
else {
// If not, try to end the non wrapping paragraph at some pre defined
Expand All @@ -385,7 +385,7 @@ QString Action::createToolTip(QString helpText,
QFontMetrics fm(font);
int width = QtTools::horizontalAdvance(fm, helpText);
if (width <= tipWidth) {
tooltip += helpText.toHtmlEscaped() + QString::fromLatin1("</p>") ;
tooltip += helpText.toHtmlEscaped() + QStringLiteral("</p>") ;
}
else {
int index = tipWidth / width * helpText.size();
Expand All @@ -396,7 +396,7 @@ QString Action::createToolTip(QString helpText,
}
}
tooltip += helpText.left(index).toHtmlEscaped()
+ QString::fromLatin1("</p>")
+ QStringLiteral("</p>")
+ helpText.right(helpText.size()-index).trimmed().toHtmlEscaped();
}
}
Expand Down Expand Up @@ -475,7 +475,7 @@ void ActionGroup::addTo(QWidget *widget)
widget->addAction(action());
QToolButton* tb = widget->findChildren<QToolButton*>().constLast();
tb->setPopupMode(QToolButton::MenuButtonPopup);
tb->setObjectName(QString::fromLatin1("qt_toolbutton_menubutton"));
tb->setObjectName(QStringLiteral("qt_toolbutton_menubutton"));
QList<QAction*> acts = groupAction()->actions();
auto menu = new QMenu(tb);
menu->addActions(acts);
Expand Down Expand Up @@ -864,7 +864,7 @@ void RecentFilesAction::setFiles(const QStringList& files)
int numRecentFiles = std::min<int>(recentFiles.count(), files.count());
for (int index = 0; index < numRecentFiles; index++) {
QFileInfo fi(files[index]);
recentFiles[index]->setText(QString::fromLatin1("%1 %2").arg(index+1).arg(fi.fileName()));
recentFiles[index]->setText(QStringLiteral("%1 %2").arg(index+1).arg(fi.fileName()));
recentFiles[index]->setStatusTip(tr("Open file %1").arg(files[index]));
recentFiles[index]->setToolTip(files[index]); // set the full name that we need later for saving
recentFiles[index]->setData(QVariant(index));
Expand Down Expand Up @@ -918,7 +918,7 @@ void RecentFilesAction::activateFile(int id)
// invokes appendFile()
SelectModule::Dict dict = SelectModule::importHandler(filename);
for (SelectModule::Dict::iterator it = dict.begin(); it != dict.end(); ++it) {
Application::Instance->open(it.key().toUtf8(), it.value().toLatin1());
Application::Instance->open(it.key().toUtf8(), it.value().toUtf8());
break;
}
}
Expand Down Expand Up @@ -969,12 +969,12 @@ void RecentFilesAction::save()
QList<QAction*> recentFiles = groupAction()->actions();
int num = std::min<int>(count, recentFiles.count());
for (int index = 0; index < num; index++) {
QString key = QString::fromLatin1("MRU%1").arg(index);
QString key = QStringLiteral("MRU%1").arg(index);
QString value = recentFiles[index]->toolTip();
if (value.isEmpty()) {
break;
}
hGrp->SetASCII(key.toLatin1(), value.toUtf8());
hGrp->SetASCII(key.toUtf8(), value.toUtf8());
}

Base::StateLocker guard(_pimpl->updating);
Expand Down Expand Up @@ -1032,7 +1032,7 @@ void RecentMacrosAction::setFiles(const QStringList& files)
auto accel_col = QString::fromStdString(shortcut_modifiers);
for (int index = 0; index < numRecentFiles; index++) {
QFileInfo fi(files[index]);
recentFiles[index]->setText(QString::fromLatin1("%1 %2").arg(index+1).arg(fi.completeBaseName()));
recentFiles[index]->setText(QStringLiteral("%1 %2").arg(index+1).arg(fi.completeBaseName()));
recentFiles[index]->setToolTip(files[index]); // set the full name that we need later for saving
recentFiles[index]->setData(QVariant(index));
QString accel(tr("none"));
Expand Down Expand Up @@ -1184,12 +1184,12 @@ void RecentMacrosAction::save()
QList<QAction*> recentFiles = groupAction()->actions();
int num = std::min<int>(count, recentFiles.count());
for (int index = 0; index < num; index++) {
QString key = QString::fromLatin1("MRU%1").arg(index);
QString key = QStringLiteral("MRU%1").arg(index);
QString value = recentFiles[index]->toolTip();
if (value.isEmpty()) {
break;
}
hGrp->SetASCII(key.toLatin1(), value.toUtf8());
hGrp->SetASCII(key.toUtf8(), value.toUtf8());
}

hGrp->SetInt("RecentMacros", count); // restore
Expand Down
36 changes: 18 additions & 18 deletions src/Gui/Application.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -365,7 +365,7 @@ Application::Application(bool GUIenabled)
hPGrp = hPGrp->GetGroup("Preferences")->GetGroup("General");
QString lang = QLocale::languageToString(QLocale().language());
Translator::instance()->activateLanguage(
hPGrp->GetASCII("Language", (const char*)lang.toLatin1()).c_str());
hPGrp->GetASCII("Language", (const char*)lang.toUtf8()).c_str());
GetWidgetFactorySupplier();

// Coin3d disabled VBO support for all Intel drivers but in the meantime they have improved
Expand Down Expand Up @@ -1435,7 +1435,7 @@ bool Application::activateWorkbench(const char* name)
ok = true; // already active
// now try to create and activate the matching workbench object
else if (WorkbenchManager::instance()->activate(name, type)) {
getMainWindow()->activateWorkbench(QString::fromLatin1(name));
getMainWindow()->activateWorkbench(QString::fromUtf8(name));
this->signalActivateWorkbench(name);
ok = true;
}
Expand Down Expand Up @@ -1519,7 +1519,7 @@ QPixmap Application::workbenchIcon(const QString& wb) const
{
Base::PyGILStateLocker lock;
// get the python workbench object from the dictionary
PyObject* pcWorkbench = PyDict_GetItemString(_pcWorkbenchDictionary, wb.toLatin1());
PyObject* pcWorkbench = PyDict_GetItemString(_pcWorkbenchDictionary, wb.toUtf8());
// test if the workbench exists
if (pcWorkbench) {
// make a unique icon name
Expand Down Expand Up @@ -1593,7 +1593,7 @@ QString Application::workbenchToolTip(const QString& wb) const
{
// get the python workbench object from the dictionary
Base::PyGILStateLocker lock;
PyObject* pcWorkbench = PyDict_GetItemString(_pcWorkbenchDictionary, wb.toLatin1());
PyObject* pcWorkbench = PyDict_GetItemString(_pcWorkbenchDictionary, wb.toUtf8());
// test if the workbench exists
if (pcWorkbench) {
// get its ToolTip member if possible
Expand All @@ -1617,7 +1617,7 @@ QString Application::workbenchMenuText(const QString& wb) const
{
// get the python workbench object from the dictionary
Base::PyGILStateLocker lock;
PyObject* pcWorkbench = PyDict_GetItemString(_pcWorkbenchDictionary, wb.toLatin1());
PyObject* pcWorkbench = PyDict_GetItemString(_pcWorkbenchDictionary, wb.toUtf8());
// test if the workbench exists
if (pcWorkbench) {
// get its ToolTip member if possible
Expand Down Expand Up @@ -1648,7 +1648,7 @@ QStringList Application::workbenches() const
const char* start = (st != config.end() ? st->second.c_str() : "<none>");
QStringList hidden, extra;
if (ht != config.end()) {
QString items = QString::fromLatin1(ht->second.c_str());
QString items = QString::fromUtf8(ht->second.c_str());
#if QT_VERSION >= QT_VERSION_CHECK(5,15,0)
hidden = items.split(QLatin1Char(';'), Qt::SkipEmptyParts);
#else
Expand All @@ -1658,7 +1658,7 @@ QStringList Application::workbenches() const
hidden.push_back(QLatin1String(""));
}
if (et != config.end()) {
QString items = QString::fromLatin1(et->second.c_str());
QString items = QString::fromUtf8(et->second.c_str());
#if QT_VERSION >= QT_VERSION_CHECK(5,15,0)
extra = items.split(QLatin1Char(';'), Qt::SkipEmptyParts);
#else
Expand All @@ -1678,18 +1678,18 @@ QStringList Application::workbenches() const
// add only allowed workbenches
bool ok = true;
if (!extra.isEmpty()&&ok) {
ok = (extra.indexOf(QString::fromLatin1(wbName)) != -1);
ok = (extra.indexOf(QString::fromUtf8(wbName)) != -1);
}
if (!hidden.isEmpty()&&ok) {
ok = (hidden.indexOf(QString::fromLatin1(wbName)) == -1);
ok = (hidden.indexOf(QString::fromUtf8(wbName)) == -1);
}

// okay the item is visible
if (ok)
wb.push_back(QString::fromLatin1(wbName));
wb.push_back(QString::fromUtf8(wbName));
// also allow start workbench in case it is hidden
else if (strcmp(wbName, start) == 0)
wb.push_back(QString::fromLatin1(wbName));
wb.push_back(QString::fromUtf8(wbName));
}

return wb;
Expand Down Expand Up @@ -1830,7 +1830,7 @@ void messageHandlerCoin(const SoError * error, void * /*userdata*/)
}
#ifdef FC_OS_WIN32
if (old_qtmsg_handler)
(*old_qtmsg_handler)(QtDebugMsg, QMessageLogContext(), QString::fromLatin1(msg));
(*old_qtmsg_handler)(QtDebugMsg, QMessageLogContext(), QString::fromUtf8(msg));
#endif
}
else if (error) {
Expand Down Expand Up @@ -2270,13 +2270,13 @@ QString Application::replaceVariablesInQss(QString qssText)

//convert them to hex.
//Note: the ulong contains alpha channels so 8 hex characters when we need 6 here.
QString accentColor1 = QString::fromLatin1("#%1").arg(longAccentColor1, 8, 16, QLatin1Char('0')).toUpper().mid(0, 7);
QString accentColor2 = QString::fromLatin1("#%1").arg(longAccentColor2, 8, 16, QLatin1Char('0')).toUpper().mid(0, 7);
QString accentColor3 = QString::fromLatin1("#%1").arg(longAccentColor3, 8, 16, QLatin1Char('0')).toUpper().mid(0, 7);
QString accentColor1 = QStringLiteral("#%1").arg(longAccentColor1, 8, 16, QLatin1Char('0')).toUpper().mid(0, 7);
QString accentColor2 = QStringLiteral("#%1").arg(longAccentColor2, 8, 16, QLatin1Char('0')).toUpper().mid(0, 7);
QString accentColor3 = QStringLiteral("#%1").arg(longAccentColor3, 8, 16, QLatin1Char('0')).toUpper().mid(0, 7);

qssText = qssText.replace(QString::fromLatin1("@ThemeAccentColor1"), accentColor1);
qssText = qssText.replace(QString::fromLatin1("@ThemeAccentColor2"), accentColor2);
qssText = qssText.replace(QString::fromLatin1("@ThemeAccentColor3"), accentColor3);
qssText = qssText.replace(QStringLiteral("@ThemeAccentColor1"), accentColor1);
qssText = qssText.replace(QStringLiteral("@ThemeAccentColor2"), accentColor2);
qssText = qssText.replace(QStringLiteral("@ThemeAccentColor3"), accentColor3);

//Base::Console().Warning("%s\n", qssText.toStdString());
return qssText;
Expand Down
6 changes: 3 additions & 3 deletions src/Gui/ApplicationPy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -617,7 +617,7 @@ PyObject* Application::sOpen(PyObject * /*self*/, PyObject *args)
FileHandler handler(fileName);
if (!handler.openFile()) {
QString ext = handler.extension();
Base::Console().Error("File type '%s' not supported\n", ext.toLatin1().constData());
Base::Console().Error("File type '%s' not supported\n", ext.toUtf8().constData());
}
}
PY_CATCH;
Expand All @@ -640,7 +640,7 @@ PyObject* Application::sInsert(PyObject * /*self*/, PyObject *args)
FileHandler handler(fileName);
if (!handler.importFile(std::string(DocName ? DocName : ""))) {
QString ext = handler.extension();
Base::Console().Error("File type '%s' not supported\n", ext.toLatin1().constData());
Base::Console().Error("File type '%s' not supported\n", ext.toUtf8().constData());
}
} PY_CATCH;

Expand Down Expand Up @@ -730,7 +730,7 @@ PyObject* Application::sExport(PyObject * /*self*/, PyObject *args)
}
}
else {
Base::Console().Error("File type '%s' not supported\n", ext.toLatin1().constData());
Base::Console().Error("File type '%s' not supported\n", ext.toUtf8().constData());
}
} PY_CATCH;

Expand Down
4 changes: 2 additions & 2 deletions src/Gui/AutoSaver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ void AutoSaver::saveDocument(const std::string& name, AutoSaveProperty& saver)
saver.dirName = dirName;

// Write recovery meta file
QFile file(QString::fromLatin1("%1/fc_recovery_file.xml")
QFile file(QString::fromUtf8("%1/fc_recovery_file.xml")
.arg(QString::fromUtf8(doc->TransientDir.getValue())));
if (file.open(QFile::WriteOnly)) {
QTextStream str(&file);
Expand Down Expand Up @@ -333,7 +333,7 @@ class RecoveryRunnable : public QRunnable

dirName = QString::fromUtf8(dir);
fileName = QString::fromUtf8(file);
tmpName = QString::fromLatin1("%1.tmp%2").arg(fileName).arg(rand());
tmpName = QString::fromUtf8("%1.tmp%2").arg(fileName).arg(rand());
writer.putNextEntry(tmpName.toUtf8().constData());
}
~RecoveryRunnable() override
Expand Down
Loading

0 comments on commit 0635a42

Please sign in to comment.