Skip to content

Commit

Permalink
adjust to qt 5.12 for sierra, fix file opening on macOS
Browse files Browse the repository at this point in the history
  • Loading branch information
Chunosov committed Feb 10, 2022
1 parent 03065e4 commit 3723b48
Show file tree
Hide file tree
Showing 8 changed files with 47 additions and 8 deletions.
7 changes: 6 additions & 1 deletion src/HelpSystem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,12 @@ void HelpSystem::checkUpdates()
_updateChecker = nullptr;
versionReceived(versionData);
});
connect(_updateReply, QOverload<QNetworkReply::NetworkError>::of(&QNetworkReply::errorOccurred), [this](QNetworkReply::NetworkError){
#if (QT_VERSION >= QT_VERSION_CHECK(5, 15, 0))
connect(_updateReply, QOverload<QNetworkReply::NetworkError>::of(&QNetworkReply::errorOccurred),
#else
connect(_updateReply, QOverload<QNetworkReply::NetworkError>::of(&QNetworkReply::error),
#endif
[this](QNetworkReply::NetworkError){
auto errorMsg =_updateReply->errorString();
qCritical() << "Network error" << errorMsg;
_updateReply->deleteLater();
Expand Down
6 changes: 6 additions & 0 deletions src/MemoWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,11 @@ struct MemoTextFormat
{
QTextCharFormat f;
if (!_fontFamily.isEmpty())
#if (QT_VERSION >= QT_VERSION_CHECK(5, 15, 0))
f.setFontFamilies({_fontFamily});
#else
f.setFontFamily(_fontFamily);
#endif
if (!_colorName.isEmpty())
f.setForeground(QColor(_colorName));
if (_bold)
Expand Down Expand Up @@ -675,7 +679,9 @@ void MemoWindow::insertTable()
fmt.setCellSpacing(0);
fmt.setBorderBrush(Qt::black);
fmt.setBorderStyle(QTextFrameFormat::BorderStyle_Solid);
#if (QT_VERSION >= QT_VERSION_CHECK(5, 15, 0))
fmt.setBorderCollapse(true);
#endif
_editor->textCursor().insertTable(rows->value(), cols->value(), fmt);
}
}
Expand Down
14 changes: 13 additions & 1 deletion src/ProjectOperations.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -118,11 +118,23 @@ void ProjectOperations::openSchemaFile(const QString& fileName, const OpenFileOp
if (!schema()->state().isNew())
{
QStringList args;
#ifdef Q_OS_MAC
QString exe = qApp->applicationFilePath();
if (opts.isExample)
args << "--example";
args << fileName;
bool ok = QProcess::startDetached(exe, args);
if (!ok)
qWarning() << "Unable to start another instance" << exe << args.join(' ');
#else
args << qApp->applicationFilePath();
if (opts.isExample)
args << "--example";
args << " \"" + fileName + "\"";
QProcess::startDetached(args.join(' '), {});
bool ok = QProcess::startDetached(args.join(' '), {});
if (!ok)
qWarning() << "Unable to start another instance" << args.join(' ');
#endif
return;
}

Expand Down
5 changes: 3 additions & 2 deletions src/core/ElementFormula.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#include "ElementFormula.h"

#include "Utils.h"
#include "LuaHelper.h"

#include <QApplication>
Expand Down Expand Up @@ -152,7 +153,7 @@ void ElemFormula::moveParamUp(Z::Parameter* param)
_params.append(param);
}
else
_params.swapItemsAt(index, index-1);
swapItems(_params, index, index-1);
}

void ElemFormula::moveParamDown(Z::Parameter* param)
Expand All @@ -169,7 +170,7 @@ void ElemFormula::moveParamDown(Z::Parameter* param)
_params.insert(0, param);
}
else
_params.swapItemsAt(index, index+1);
swapItems(_params, index, index+1);
}

void ElemFormula::assign(const ElemFormula* other)
Expand Down
4 changes: 2 additions & 2 deletions src/core/Schema.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -391,7 +391,7 @@ void Schema::shiftElement(int index, const std::function<int(int)>& getTargetInd
{
if (!isValid(index)) return;
if (_items.size() == 1) return;
_items.swapItemsAt(index, getTargetIndex(index));
swapItems(_items, index, getTargetIndex(index));
relinkInterfaces();
_events.raise(SchemaEvents::Rebuilt, "Schema: shiftElement");
_events.raise(SchemaEvents::RecalRequred, "Schema: shiftElement");
Expand All @@ -416,7 +416,7 @@ void Schema::flip()
int size = _items.size();
if (size < 2) return;
for (int i = 0; i < size / 2; i++)
_items.swapItemsAt(i, size - 1 - i);
swapItems(_items, i, size - 1 - i);
relinkInterfaces();
_events.raise(SchemaEvents::Rebuilt, "Schema: flip");
_events.raise(SchemaEvents::RecalRequred, "Schema: flip");
Expand Down
10 changes: 10 additions & 0 deletions src/core/Utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,4 +51,14 @@ template <typename T> struct Optional {

} // namespace Z

template <typename TList> void swapItems(TList& list, int i, int j)
{
#if (QT_VERSION >= QT_VERSION_CHECK(5, 15, 0))
list.swapItemsAt(i, j);
#else
list.swap(i, j);
#endif
}


#endif // Z_UTILS_H
4 changes: 4 additions & 0 deletions src/tests/test_UnitWidgets.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,11 @@ namespace UnitWidgetsTests {

template <typename T> QSet<T> listToSet(const QList<T>& list)
{
#if (QT_VERSION >= QT_VERSION_CHECK(5, 15, 0))
return QSet<T>(list.begin(), list.end());
#else
return list.toSet();
#endif
}

//------------------------------------------------------------------------------
Expand Down
5 changes: 3 additions & 2 deletions src/widgets/ParamsEditor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#include "helpers/OriLayouts.h"
#include "widgets/OriInfoPanel.h"
#include "widgets/OriValueEdit.h"
#include "../core/Utils.h"

//------------------------------------------------------------------------------
// ParamsEditor
Expand Down Expand Up @@ -242,7 +243,7 @@ void ParamsEditor::moveEditorUp(Z::Parameter* param)
else
{
_paramsLayout->insertWidget(i-1, editor);
_editors.swapItemsAt(i, i-1);
swapItems(_editors, i, i-1);
}
break;
}
Expand All @@ -267,7 +268,7 @@ void ParamsEditor::moveEditorDown(Z::Parameter* param)
else
{
_paramsLayout->insertWidget(i+1, editor);
_editors.swapItemsAt(i, i+1);
swapItems(_editors, i, i+1);
}
break;
}
Expand Down

0 comments on commit 3723b48

Please sign in to comment.