Skip to content

Commit

Permalink
Qt6 upgrades
Browse files Browse the repository at this point in the history
  • Loading branch information
gzotti committed Jun 8, 2022
1 parent 9d027d0 commit d87f9d2
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ TelescopeClientDirectLx200::TelescopeClientDirectLx200 (const QString &name, con
//end_of_timeout = -0x8000000000000000LL;

#ifdef Q_OS_WIN
if(serialDeviceName.rightRef(serialDeviceName.size() - 3).toInt() > 9)
if(serialDeviceName.right(serialDeviceName.size() - 3).toInt() > 9)
serialDeviceName = "\\\\.\\" + serialDeviceName;//"\\.\COMxx", not sure if it will work
#endif //Q_OS_WIN

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ TelescopeClientDirectNexStar::TelescopeClientDirectNexStar(const QString &name,
//end_of_timeout = -0x8000000000000000LL;

#ifdef Q_OS_WIN
if(serialDeviceName.rightRef(serialDeviceName.size() - 3).toInt() > 9)
if(serialDeviceName.right(serialDeviceName.size() - 3).toInt() > 9)
serialDeviceName = "\\\\.\\" + serialDeviceName; // "\\.\COMxx", not sure if it will work
#endif //Q_OS_WIN

Expand Down
6 changes: 5 additions & 1 deletion plugins/TelescopeControl/src/common/SerialPort.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ SerialPort::SerialPort(Server &server, const char *serial_device)
#endif
{
#ifdef Q_OS_WIN
handle = CreateFile(serial_device, GENERIC_READ|GENERIC_WRITE, 0, Q_NULLPTR, OPEN_EXISTING, 0, Q_NULLPTR);
handle = CreateFile(LPCWSTR(serial_device), GENERIC_READ|GENERIC_WRITE, 0, Q_NULLPTR, OPEN_EXISTING, 0, Q_NULLPTR);
if (handle == INVALID_HANDLE_VALUE)
{
*log_file << Now() << "SerialPort::SerialPort(" << serial_device << "): "
Expand Down Expand Up @@ -70,7 +70,11 @@ SerialPort::SerialPort(Server &server, const char *serial_device)
DCB dcb;
memset(&dcb, 0, sizeof(dcb));
dcb.DCBlength = sizeof(dcb);
#if (QT_VERSION>=QT_VERSION_CHECK(6,0,0))
if (!BuildCommDCB(LPCWSTR("9600,n,8,1"), &dcb))
#else
if (!BuildCommDCB("9600,n,8,1", &dcb))
#endif
{
*log_file << Now() << "SerialPort::SerialPort(" << serial_device << "): "
"BuildCommDCB() failed: " << GetLastError() << StelUtils::getEndLineChar();
Expand Down
12 changes: 12 additions & 0 deletions plugins/TelescopeControl/src/gui/TelescopeConfigurationDialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,11 @@ void TelescopeConfigurationDialog::initConfigurationDialog()
QStringList* plist = listSerialPorts();
ui->comboSerialPort->clear();
ui->comboSerialPort->addItems(*plist);
#if (QT_VERSION>=QT_VERSION_CHECK(6,0,0))
ui->comboSerialPort->textActivated(plist->value(0));
#else
ui->comboSerialPort->activated(plist->value(0));
#endif
ui->comboSerialPort->setEditText(plist->value(0));
delete (plist);

Expand Down Expand Up @@ -311,7 +315,11 @@ void TelescopeConfigurationDialog::initExistingTelescopeConfiguration(int slot)
ui->comboBoxDeviceModel->setCurrentIndex(index);

// Initialize the serial port value
#if (QT_VERSION>=QT_VERSION_CHECK(6,0,0))
ui->comboSerialPort->textActivated(serialPortName);
#else
ui->comboSerialPort->activated(serialPortName);
#endif
ui->comboSerialPort->setEditText(serialPortName);
}
else if (connectionType == ConnectionRemote)
Expand Down Expand Up @@ -386,7 +394,11 @@ void TelescopeConfigurationDialog::toggleTypeLocal(bool isChecked)
// Re-initialize values that may have been changed
ui->comboBoxDeviceModel->setCurrentIndex(0);
QStringList* plist = listSerialPorts();
#if (QT_VERSION>=QT_VERSION_CHECK(6,0,0))
ui->comboSerialPort->textActivated(plist->value(0));
#else
ui->comboSerialPort->activated(plist->value(0));
#endif
ui->comboSerialPort->setEditText(plist->value(0));
delete (plist);
ui->lineEditHostName->setText("localhost");
Expand Down

0 comments on commit d87f9d2

Please sign in to comment.