Skip to content

Commit

Permalink
Part 2.
Browse files Browse the repository at this point in the history
  • Loading branch information
KuzemkoA committed May 27, 2024
1 parent 0635a42 commit c96ca62
Show file tree
Hide file tree
Showing 23 changed files with 178 additions and 178 deletions.
12 changes: 6 additions & 6 deletions src/Gui/Command.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -609,7 +609,7 @@ void Command::setGroupName(const char* s)
QString Command::translatedGroupName() const
{
QString text = qApp->translate(className(), getGroupName());
if (text == QString::fromLatin1(getGroupName()))
if (text == QString::fromUtf8(getGroupName()))
text = qApp->translate("CommandGroup", getGroupName());
return text;
}
Expand Down Expand Up @@ -1075,11 +1075,11 @@ Action * GroupCommand::createAction() {
pcAction->setExclusive(isExclusive());
pcAction->setCheckable(isCheckable());
pcAction->setRememberLast(doesRememberLast());
pcAction->setWhatsThis(QString::fromLatin1(sWhatsThis));
pcAction->setWhatsThis(QString::fromUtf8(sWhatsThis));

for(auto &v : cmds) {
if(!v.first)
pcAction->addAction(QString::fromLatin1(""))->setSeparator(true);
pcAction->addAction(QStringLiteral(""))->setSeparator(true);
else
v.first->addToGroup(pcAction);
}
Expand Down Expand Up @@ -1175,7 +1175,7 @@ void MacroCommand::activated(int iMsg)
d = QDir(QString::fromUtf8(cMacroPath.c_str()));
}
else {
QString dirstr = QString::fromStdString(App::Application::getHomePath()) + QString::fromLatin1("Macro");
QString dirstr = QString::fromStdString(App::Application::getHomePath()) + QStringLiteral("Macro");
d = QDir(dirstr);
}

Expand Down Expand Up @@ -1991,7 +1991,7 @@ const Command* Gui::CommandManager::checkAcceleratorForConflicts(const char* acc
if (!accel || accel[0] == '\0')
return nullptr;

QString newCombo = QString::fromLatin1(accel);
QString newCombo = QString::fromUtf8(accel);
if (newCombo.isEmpty())
return nullptr;
auto newSequence = QKeySequence::fromString(newCombo);
Expand All @@ -2012,7 +2012,7 @@ const Command* Gui::CommandManager::checkAcceleratorForConflicts(const char* acc
// 2) The new command is a one-char combo that overrides an existing two-char combo
// 3) The old command is a one-char combo that overrides the new command

QString existingCombo = QString::fromLatin1(existingAccel);
QString existingCombo = QString::fromUtf8(existingAccel);
if (existingCombo.isEmpty())
continue;
auto existingSequence = QKeySequence::fromString(existingCombo);
Expand Down
18 changes: 9 additions & 9 deletions src/Gui/CommandLink.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -97,11 +97,11 @@ Action * StdCmdLinkMakeGroup::createAction()
// add the action items
QAction* action = nullptr;
action = pcAction->addAction(QObject::tr("Simple group"));
action->setWhatsThis(QString::fromLatin1(getWhatsThis()));
action->setWhatsThis(QString::fromUtf8(getWhatsThis()));
action = pcAction->addAction(QObject::tr("Group with links"));
action->setWhatsThis(QString::fromLatin1(getWhatsThis()));
action->setWhatsThis(QString::fromUtf8(getWhatsThis()));
action = pcAction->addAction(QObject::tr("Group with transform links"));
action->setWhatsThis(QString::fromLatin1(getWhatsThis()));
action->setWhatsThis(QString::fromUtf8(getWhatsThis()));
return pcAction;
}

Expand Down Expand Up @@ -193,7 +193,7 @@ void StdCmdLinkMakeGroup::activated(int option) {
Command::commitCommand();
} catch (const Base::Exception& e) {
QMessageBox::critical(getMainWindow(), QObject::tr("Create link group failed"),
QString::fromLatin1(e.what()));
QString::fromUtf8(e.what()));
Command::abortCommand();
e.ReportException();
}
Expand Down Expand Up @@ -259,7 +259,7 @@ void StdCmdLinkMake::activated(int) {
} catch (const Base::Exception& e) {
Command::abortCommand();
QMessageBox::critical(getMainWindow(), QObject::tr("Create link failed"),
QString::fromLatin1(e.what()));
QString::fromUtf8(e.what()));
e.ReportException();
}
}
Expand Down Expand Up @@ -334,7 +334,7 @@ void StdCmdLinkMakeRelative::activated(int) {
} catch (const Base::Exception& e) {
Command::abortCommand();
QMessageBox::critical(getMainWindow(), QObject::tr("Failed to create relative link"),
QString::fromLatin1(e.what()));
QString::fromUtf8(e.what()));
e.ReportException();
}
return;
Expand Down Expand Up @@ -462,7 +462,7 @@ static void linkConvert(bool unlink) {
} catch (const Base::Exception& e) {
Command::abortCommand();
auto title = unlink?QObject::tr("Unlink failed"):QObject::tr("Replace link failed");
QMessageBox::critical(getMainWindow(), title, QString::fromLatin1(e.what()));
QMessageBox::critical(getMainWindow(), title, QString::fromUtf8(e.what()));
e.ReportException();
return;
}
Expand Down Expand Up @@ -592,7 +592,7 @@ void StdCmdLinkImport::activated(int) {
}catch (const Base::Exception& e) {
Command::abortCommand();
QMessageBox::critical(getMainWindow(), QObject::tr("Failed to import links"),
QString::fromLatin1(e.what()));
QString::fromUtf8(e.what()));
e.ReportException();
}
}
Expand Down Expand Up @@ -631,7 +631,7 @@ void StdCmdLinkImportAll::activated(int) {
Command::commitCommand();
} catch (const Base::Exception& e) {
QMessageBox::critical(getMainWindow(), QObject::tr("Failed to import all links"),
QString::fromLatin1(e.what()));
QString::fromUtf8(e.what()));
Command::abortCommand();
e.ReportException();
}
Expand Down
4 changes: 2 additions & 2 deletions src/Gui/CommandMacro.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,8 @@ void StdCmdDlgMacroRecord::activated(int iMsg)
getGuiApplication()->macroManager()->commit();
if (getAction()) {
getAction()->setIcon(Gui::BitmapFactory().iconFromTheme("media-record"));
getAction()->setText(QString::fromLatin1(sMenuText));
getAction()->setToolTip(QString::fromLatin1(sToolTipText));
getAction()->setText(QString::fromUtf8(sMenuText));
getAction()->setToolTip(QString::fromUtf8(sToolTipText));
}
}
}
Expand Down
6 changes: 3 additions & 3 deletions src/Gui/CommandPyImp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -100,9 +100,9 @@ PyObject* CommandPy::listByShortcut(PyObject *args)
for (Command* c : cmds) {
Action* action = c->getAction();
if (action) {
QString spc = QString::fromLatin1(" ");
QString spc = QStringLiteral(" ");
if (Base::asBoolean(bIsRegularExp)) {
QRegularExpression re(QString::fromLatin1(shortcut_to_find), QRegularExpression::CaseInsensitiveOption);
QRegularExpression re(QString::fromUtf8(shortcut_to_find), QRegularExpression::CaseInsensitiveOption);
if (!re.isValid()) {
std::stringstream str;
str << "Invalid regular expression:" << ' ' << shortcut_to_find;
Expand All @@ -114,7 +114,7 @@ PyObject* CommandPy::listByShortcut(PyObject *args)
}
}
else if (action->shortcut().toString().remove(spc).toUpper() ==
QString::fromLatin1(shortcut_to_find).remove(spc).toUpper()) {
QString::fromUtf8(shortcut_to_find).remove(spc).toUpper()) {
matches.emplace_back(c->getName());
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/Gui/CommandTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,8 @@ void Std_TestQM::activated(int iMsg)
{
Q_UNUSED(iMsg);
QStringList files = QFileDialog::getOpenFileNames(getMainWindow(),
QString::fromLatin1("Test translation"), QString(),
QString::fromLatin1("Translation (*.qm)"));
QStringLiteral("Test translation"), QString(),
QStringLiteral("Translation (*.qm)"));
if (!files.empty()) {
Translator::instance()->activateLanguage("English");
QList<QTranslator*> i18n = qApp->findChildren<QTranslator*>();
Expand Down
2 changes: 1 addition & 1 deletion src/Gui/DAGView/DAGFilter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
using namespace Gui;
using namespace DAG;

FilterBase::FilterBase() : name(QString::fromLatin1("empty name"))
FilterBase::FilterBase() : name(QStringLiteral("empty name"))
{

}
Expand Down
2 changes: 1 addition & 1 deletion src/Gui/DAGView/DAGModel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -872,7 +872,7 @@ void Model::updateStates()
else
(*theGraph)[currentVertex].stateIcon->setPixmap(pendingPixmap);
}
(*theGraph)[currentVertex].stateIcon->setToolTip(QString::fromLatin1(record.DObject->getStatusString()));
(*theGraph)[currentVertex].stateIcon->setToolTip(QString::fromUtf8(record.DObject->getStatusString()));
(*theGraph)[currentVertex].lastFeatureState = currentFeatureState;
}
}
Expand Down
12 changes: 6 additions & 6 deletions src/Gui/DlgAddProperty.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,12 +59,12 @@ DlgAddProperty::DlgAddProperty(QWidget* parent,
std::sort(types.begin(), types.end(), [](Base::Type a, Base::Type b) { return strcmp(a.getName(), b.getName()) < 0; });

for(const auto& type : types) {
ui->comboType->addItem(QString::fromLatin1(type.getName()));
ui->comboType->addItem(QString::fromUtf8(type.getName()));
if(type == defType)
ui->comboType->setCurrentIndex(ui->comboType->count()-1);
}

ui->edtGroup->setText(QString::fromLatin1(
ui->edtGroup->setText(QString::fromUtf8(
hGrp->GetASCII("NewPropertyGroup","Base").c_str()));
ui->chkAppend->setChecked(hGrp->GetBool("NewPropertyAppend",true));
}
Expand Down Expand Up @@ -111,13 +111,13 @@ void DlgAddProperty::accept()
QMessageBox::critical(getMainWindow(),
QObject::tr("Invalid name"),
QObject::tr("The property '%1' already exists in '%2'").arg(
QString::fromLatin1(name.c_str()),
QString::fromLatin1(containerName(c).c_str())));
QString::fromUtf8(name.c_str()),
QString::fromUtf8(containerName(c).c_str())));
return;
}
}

std::string type = ui->comboType->currentText().toLatin1().constData();
std::string type = ui->comboType->currentText().toUtf8().constData();

for(auto it=containers.begin();it!=containers.end();++it) {
try {
Expand All @@ -135,7 +135,7 @@ void DlgAddProperty::accept()
QMessageBox::critical(getMainWindow(),
QObject::tr("Add property"),
QObject::tr("Failed to add property to '%1': %2").arg(
QString::fromLatin1(containerName(*it).c_str()),
QString::fromUtf8(containerName(*it).c_str()),
QString::fromUtf8(e.what())));
return;
}
Expand Down
4 changes: 2 additions & 2 deletions src/Gui/DlgCheckableMessageBox.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@ namespace Gui {
namespace Dialog {
QByteArray toParamEntry(QString name)
{
name.replace(QString::fromLatin1(" "), QString::fromLatin1("_"));
return name.toLatin1();
name.replace(QStringLiteral(" "), QStringLiteral("_"));
return name.toUtf8();
}

QPixmap getStandardIcon(QWidget* widget, QStyle::StandardPixmap standardPixmap)
Expand Down
4 changes: 2 additions & 2 deletions src/Gui/DlgCheckableMessageBox.h
Original file line number Diff line number Diff line change
Expand Up @@ -104,11 +104,11 @@ class GuiExport DlgCheckableMessageBox : public QDialog
/// It shows a dialog with header and message provided and a checkbox in check state with the message provided.
/// It uses a parameter in path "User parameter:BaseApp/CheckMessages" derived from the header test, defaulting to false,
/// to store the status of the checkbox, when the user exits the modal dialog.
static void showMessage(const QString& header, const QString& message, bool check = false, const QString& checkText = QString::fromLatin1("Don't show me again"));
static void showMessage(const QString& header, const QString& message, bool check = false, const QString& checkText = QStringLiteral("Don't show me again"));

/// Same as showMessage above, but it checks the specific preference path and parameter provided, defaulting to entryDefault value if the parameter is not present.
static void showMessage(const QString& header, const QString& message, const QString& prefPath, const QString& paramEntry, bool entryDefault = false,
bool check = false, const QString& checkText = QString::fromLatin1("Don't show me again"));
bool check = false, const QString& checkText = QStringLiteral("Don't show me again"));

private Q_SLOTS:
void slotClicked(QAbstractButton *b);
Expand Down
2 changes: 1 addition & 1 deletion src/Gui/DlgCustomizeImp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ DlgCustomizeImp::DlgCustomizeImp(QWidget* parent, Qt::WindowFlags fl)
customLayout->addLayout( layout, 1, 0 );

tabWidget = new QTabWidget( this );
tabWidget->setObjectName(QString::fromLatin1("Gui__Dialog__TabWidget"));//so we can find it in DlgMacroExecuteImp
tabWidget->setObjectName(QStringLiteral("Gui__Dialog__TabWidget"));//so we can find it in DlgMacroExecuteImp

// make sure that pages are ready to create
GetWidgetFactorySupplier();
Expand Down
24 changes: 12 additions & 12 deletions src/Gui/DlgCustomizeSpaceball.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ void ButtonModel::insertButtonRows(int number)
{
QString groupName;
groupName.setNum(index);
Base::Reference<ParameterGrp> newGroup = spaceballButtonGroup()->GetGroup(groupName.toLatin1());//builds the group.
Base::Reference<ParameterGrp> newGroup = spaceballButtonGroup()->GetGroup(groupName.toUtf8());//builds the group.
newGroup->SetASCII("Command", "");
newGroup->SetASCII("Description", "");
}
Expand All @@ -238,14 +238,14 @@ void ButtonModel::insertButtonRows(int number)
void ButtonModel::setCommand(int row, QString command)
{
GroupVector groupVector = spaceballButtonGroup()->GetGroups();
groupVector.at(row)->SetASCII("Command", command.toLatin1());
groupVector.at(row)->SetASCII("Command", command.toUtf8());
}

void ButtonModel::goButtonPress(int number)
{
QString numberString;
numberString.setNum(number);
if (!spaceballButtonGroup()->HasGroup(numberString.toLatin1()))
if (!spaceballButtonGroup()->HasGroup(numberString.toUtf8()))
insertButtonRows(number);
}

Expand Down Expand Up @@ -279,7 +279,7 @@ QString ButtonModel::getLabel(const int &number) const
QString numberString;
numberString.setNum(number);
QString desc = QString::fromStdString(spaceballButtonGroup()->
GetGroup(numberString.toLatin1())->
GetGroup(numberString.toUtf8())->
GetASCII("Description",""));
if (desc.length())
desc = QString::fromUtf8(" \"") + desc + QString::fromUtf8("\"");
Expand Down Expand Up @@ -447,19 +447,19 @@ QVariant CommandModel::data(const QModelIndex &index, int role) const
if (role == Qt::UserRole)
{
if (node->nodeType == CommandNode::CommandType)
return {QString::fromLatin1(node->aCommand->getName())};
return {QString::fromUtf8(node->aCommand->getName())};
if (node->nodeType == CommandNode::GroupType)
{
if (node->children.empty())
return {};
CommandNode *childNode = node->children.at(0);
return {QString::fromLatin1(childNode->aCommand->getGroupName())};
return {QString::fromUtf8(childNode->aCommand->getGroupName())};
}
return {};
}
if (role == Qt::ToolTipRole) {
if (node->nodeType == CommandNode::CommandType)
return {QString::fromLatin1(node->aCommand->getToolTipText())};
return {QString::fromUtf8(node->aCommand->getToolTipText())};
}
return {};
}
Expand Down Expand Up @@ -492,15 +492,15 @@ CommandNode* CommandModel::nodeFromIndex(const QModelIndex &index) const

void CommandModel::goAddMacro(const QByteArray &macroName)
{
QModelIndexList indexList(this->match(this->index(0,0), Qt::UserRole, QVariant(QString::fromLatin1("Macros")),
QModelIndexList indexList(this->match(this->index(0,0), Qt::UserRole, QVariant(QStringLiteral("Macros")),
1, Qt::MatchWrap | Qt::MatchRecursive));
QModelIndex macrosIndex;
if (indexList.empty())
{
//this is the first macro and we have to add the Macros item.
//figure out where to insert it. Should be in the command groups now.
QStringList groups = orderedGroups();
int location(groups.indexOf(QString::fromLatin1("Macros")));
int location(groups.indexOf(QStringLiteral("Macros")));
if (location == -1)
location = groups.size();
//add row
Expand Down Expand Up @@ -533,7 +533,7 @@ void CommandModel::goAddMacro(const QByteArray &macroName)

void CommandModel::goRemoveMacro(const QByteArray &macroName)
{
QModelIndexList macroList(this->match(this->index(0,0), Qt::UserRole, QVariant(QString::fromLatin1(macroName.data())),
QModelIndexList macroList(this->match(this->index(0,0), Qt::UserRole, QVariant(QString::fromUtf8(macroName.data())),
1, Qt::MatchWrap | Qt::MatchRecursive));
if (macroList.isEmpty())
return;
Expand Down Expand Up @@ -573,7 +573,7 @@ void CommandModel::groupCommands(const QString& groupName)
auto parentNode = new CommandNode(CommandNode::GroupType);
parentNode->parent = rootNode;
rootNode->children.push_back(parentNode);
std::vector <Command*> commands = Application::Instance->commandManager().getGroupCommands(groupName.toLatin1());
std::vector <Command*> commands = Application::Instance->commandManager().getGroupCommands(groupName.toUtf8());
for (const auto & command : commands)
{
auto childNode = new CommandNode(CommandNode::CommandType);
Expand All @@ -589,7 +589,7 @@ QStringList CommandModel::orderedGroups()
std::vector <Command*> commands = Application::Instance->commandManager().getAllCommands();
for (const auto & command : commands)
{
QString groupName(QString::fromLatin1(command->getGroupName()));
QString groupName(QString::fromUtf8(command->getGroupName()));
if (!groups.contains(groupName))
groups << groupName;
}
Expand Down
2 changes: 1 addition & 1 deletion src/Gui/DlgExpressionInput.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ void NumberRange::throwIfOutOfRange(const Base::Quantity& value) const
QString valStr = value.getUserString();
QString minStr = minVal.getUserString();
QString maxStr = maxVal.getUserString();
QString error = QString::fromLatin1("Value out of range (%1 out of [%2, %3])").arg(valStr, minStr, maxStr);
QString error = QString::fromUtf8("Value out of range (%1 out of [%2, %3])").arg(valStr, minStr, maxStr);

throw Base::ValueError(error.toStdString());
}
Expand Down
Loading

0 comments on commit c96ca62

Please sign in to comment.