Skip to content

Commit

Permalink
Merge pull request #346 from zomfg/hotfix/qt-5.15-deprecations
Browse files Browse the repository at this point in the history
Qt 5.15 deprecation
  • Loading branch information
psieg authored May 28, 2020
2 parents 258fdeb + b225cf3 commit 2a096d3
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 22 deletions.
20 changes: 14 additions & 6 deletions Software/src/GrabWidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -344,7 +344,7 @@ QRect GrabWidget::resizeAccordingly(QMouseEvent *pe) {
}

bool GrabWidget::snapEdgeToScreenOrClosestFellow(
QRect& newRect,
QRect& newRect,
const QRect& screen,
std::function<void(QRect&,int)> setter,
std::function<int(const QRect&)> getter,
Expand Down Expand Up @@ -384,8 +384,8 @@ void GrabWidget::mouseMoveEvent(QMouseEvent *pe)
DEBUG_HIGH_LEVEL << Q_FUNC_INFO << "pe->pos() =" << pe->pos();

QRect screen = QApplication::desktop()->screenGeometry(this);


if (cmd == NOP ){
checkAndSetCursors(pe);
} else if (cmd == MOVE) {
Expand Down Expand Up @@ -455,7 +455,7 @@ void GrabWidget::mouseMoveEvent(QMouseEvent *pe)
[](const QRect& r) { return r.bottom(); },
[](const QRect& r) { return r.top() - 1; });
}

if (newRect.size() != geometry().size()) {
resize(newRect.size());
}
Expand Down Expand Up @@ -490,8 +490,8 @@ void GrabWidget::wheelEvent(QWheelEvent *pe)
return;
}

if (pe->delta() > 0) m_colorIndex++;
if (pe->delta() < 0) m_colorIndex--;
if (pe->angleDelta().y() > 0) m_colorIndex++;
if (pe->angleDelta().y() < 0) m_colorIndex--;

if (m_colorIndex >= ColorsCount)
{
Expand Down Expand Up @@ -705,7 +705,11 @@ void GrabWidget::onBlueCoef_ValueChanged(double value)

void GrabWidget::setBackgroundColor(QColor color)
{
#if QT_VERSION >= QT_VERSION_CHECK(5, 14, 0)
DEBUG_MID_LEVEL << Q_FUNC_INFO << Qt::hex << color.rgb();
#else
DEBUG_MID_LEVEL << Q_FUNC_INFO << hex << color.rgb();
#endif

m_backgroundColor = color;

Expand All @@ -723,7 +727,11 @@ void GrabWidget::setBackgroundColor(QColor color)

void GrabWidget::setTextColor(QColor color)
{
#if QT_VERSION >= QT_VERSION_CHECK(5, 14, 0)
DEBUG_MID_LEVEL << Q_FUNC_INFO << Qt::hex << color.rgb();
#else
DEBUG_MID_LEVEL << Q_FUNC_INFO << hex << color.rgb();
#endif

setOpenConfigButtonBackground(color);

Expand Down
7 changes: 6 additions & 1 deletion Software/src/LedDeviceLightpack.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,12 @@ LedDeviceLightpack::~LedDeviceLightpack()

void LedDeviceLightpack::setColors(const QList<QRgb> & colors)
{
#if QT_VERSION >= QT_VERSION_CHECK(5, 14, 0)
DEBUG_MID_LEVEL << Q_FUNC_INFO << Qt::hex << (colors.isEmpty() ? -1 : colors.first());
#else
DEBUG_MID_LEVEL << Q_FUNC_INFO << hex << (colors.isEmpty() ? -1 : colors.first());
#endif

#if 0
DEBUG_LOW_LEVEL << Q_FUNC_INFO << "thread id: " << this->thread()->currentThreadId();
#endif
Expand Down Expand Up @@ -355,7 +360,7 @@ bool LedDeviceLightpack::readDataFromDevice()
}

bool LedDeviceLightpack::writeBufferToDevice(int command, hid_device *phid_device)
{
{
DEBUG_MID_LEVEL << Q_FUNC_INFO << command;
#if 0
DEBUG_LOW_LEVEL << Q_FUNC_INFO << "thread id: " << this->thread()->currentThreadId();
Expand Down
19 changes: 14 additions & 5 deletions Software/src/LogWriter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,33 +29,42 @@ int LogWriter::initWith(const QString& logsDirPath)

QDir logsDir(logsDirPath);
if (logsDir.exists() == false) {
cout << "mkdir " << logsDirPath.toStdString() << endl;
std::cout << "mkdir " << logsDirPath.toStdString() << std::endl;
if (logsDir.mkdir(logsDirPath) == false) {
cerr << "Failed mkdir '" << logsDirPath.toStdString() << "' for logs. Exit." << endl;
std::cerr << "Failed mkdir '" << logsDirPath.toStdString() << "' for logs. Exit." << std::endl;
return LightpackApplication::LogsDirecroryCreationFail_ErrorCode;
}
}

if (rotateLogFiles(logsDir) == false)
cerr << "Failed to rotate old log files." << endl;
std::cerr << "Failed to rotate old log files." << std::endl;

const QString logFilePath = logsDirPath + "/Prismatik.0.log";
QScopedPointer<QFile> logFile(new QFile(logFilePath));
if (logFile->open(QIODevice::WriteOnly | QIODevice::Truncate | QIODevice::Text)) {
QMutexLocker locker(&m_mutex);

m_logStream.setDevice(logFile.take());
#if QT_VERSION >= QT_VERSION_CHECK(5, 14, 0)
m_logStream << Qt::endl;
#else
m_logStream << endl;
#endif

const QDateTime currentDateTime(QDateTime::currentDateTime());
m_logStream << currentDateTime.date().toString("yyyy_MM_dd") << " ";
m_logStream << currentDateTime.time().toString("hh:mm:ss:zzz") << " Prismatik " << VERSION_STR << endl;
m_logStream << currentDateTime.time().toString("hh:mm:ss:zzz") << " Prismatik " << VERSION_STR;
#if QT_VERSION >= QT_VERSION_CHECK(5, 14, 0)
m_logStream << Qt::endl;
#else
m_logStream << endl;
#endif

// write the cached log
m_logStream << m_startupLogStore;
m_startupLogStore.clear();
} else {
cerr << "Failed to open logs file: '" << logFilePath.toStdString() << "'. Exit." << endl;
std::cerr << "Failed to open logs file: '" << logFilePath.toStdString() << "'. Exit." << std::endl;
return LightpackApplication::OpenLogsFail_ErrorCode;
}

Expand Down
4 changes: 2 additions & 2 deletions Software/src/Plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,6 @@ void Plugin::Start()
{
DEBUG_LOW_LEVEL << Q_FUNC_INFO << _exec;

QString program = _exec;
//QStringList arguments;
//arguments << "-style" << "fusion";

Expand All @@ -119,7 +118,8 @@ void Plugin::Start()

process->setEnvironment(QProcess::systemEnvironment());
// process->setProcessChannelMode(QProcess::ForwardedChannels);
process->start(program,NULL);
process->setProgram(_exec);
process->start();
}

void Plugin::Stop()
Expand Down
13 changes: 5 additions & 8 deletions Software/src/SettingsWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2249,16 +2249,13 @@ QString SettingsWindow::getPluginName(const Plugin *plugin) const

void SettingsWindow::on_pbRunConfigurationWizard_clicked()
{
const QStringList args("--wizard");
QString cmdLine(QApplication::applicationFilePath());
#ifdef Q_OS_WIN
QString cmdLine;
cmdLine.append("\"");
cmdLine.append(QApplication::applicationFilePath());
cmdLine.append("\"");
cmdLine.append(" --wizard");
QProcess::startDetached(cmdLine);
#else
QProcess::startDetached(QApplication::applicationFilePath().append(" --wizard"));
cmdLine.prepend('"');
cmdLine.append('"');
#endif
QProcess::startDetached(cmdLine, args);

quit();
}
Expand Down

0 comments on commit 2a096d3

Please sign in to comment.