2013-07-24 16:41:12 +00:00
|
|
|
/*
|
2024-09-17 19:00:25 +00:00
|
|
|
* Deskflow -- mouse and keyboard sharing utility
|
2025-01-24 00:11:17 +00:00
|
|
|
* SPDX-FileCopyrightText: (C) 2013 - 2016 Symless Ltd.
|
|
|
|
|
* SPDX-License-Identifier: GPL-2.0-only WITH LicenseRef-OpenSSL-Exception
|
2013-07-24 16:41:12 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#include "QUtility.h"
|
|
|
|
|
|
2024-07-02 19:07:06 +00:00
|
|
|
#include "ProcessorArch.h"
|
2015-02-09 15:37:47 +00:00
|
|
|
|
|
|
|
|
#if defined(Q_OS_LINUX)
|
2021-04-06 10:02:25 +00:00
|
|
|
#include <QFile>
|
2024-07-02 19:07:06 +00:00
|
|
|
#include <QProcess>
|
2015-02-09 15:37:47 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
#if defined(Q_OS_WIN)
|
|
|
|
|
#define WIN32_LEAN_AND_MEAN
|
|
|
|
|
#include <Windows.h>
|
|
|
|
|
#endif
|
|
|
|
|
|
2024-10-17 18:04:35 +00:00
|
|
|
void setIndexFromItemData(QComboBox *comboBox, const QVariant &itemData)
|
|
|
|
|
{
|
2024-07-02 19:07:06 +00:00
|
|
|
for (int i = 0; i < comboBox->count(); ++i) {
|
|
|
|
|
if (comboBox->itemData(i) == itemData) {
|
|
|
|
|
comboBox->setCurrentIndex(i);
|
|
|
|
|
return;
|
2016-12-28 11:50:32 +00:00
|
|
|
}
|
2024-07-02 19:07:06 +00:00
|
|
|
}
|
2013-07-24 16:41:12 +00:00
|
|
|
}
|
|
|
|
|
|
2024-10-17 18:04:35 +00:00
|
|
|
QString hash(const QString &string)
|
|
|
|
|
{
|
2024-07-02 19:07:06 +00:00
|
|
|
QByteArray data = string.toUtf8();
|
|
|
|
|
QByteArray hash = QCryptographicHash::hash(data, QCryptographicHash::Md5);
|
|
|
|
|
return hash.toHex();
|
2013-07-24 16:41:12 +00:00
|
|
|
}
|
|
|
|
|
|
2024-10-17 18:04:35 +00:00
|
|
|
qProcessorArch getProcessorArch()
|
|
|
|
|
{
|
2015-02-09 15:37:47 +00:00
|
|
|
#if defined(Q_OS_WIN)
|
2024-07-02 19:07:06 +00:00
|
|
|
SYSTEM_INFO systemInfo;
|
|
|
|
|
GetNativeSystemInfo(&systemInfo);
|
2015-02-09 15:37:47 +00:00
|
|
|
|
2024-07-02 19:07:06 +00:00
|
|
|
switch (systemInfo.wProcessorArchitecture) {
|
|
|
|
|
case PROCESSOR_ARCHITECTURE_INTEL:
|
|
|
|
|
return kProcessorArchWin32;
|
|
|
|
|
case PROCESSOR_ARCHITECTURE_IA64:
|
|
|
|
|
return kProcessorArchWin64;
|
|
|
|
|
case PROCESSOR_ARCHITECTURE_AMD64:
|
|
|
|
|
return kProcessorArchWin64;
|
|
|
|
|
default:
|
|
|
|
|
return kProcessorArchUnknown;
|
|
|
|
|
}
|
2015-05-25 18:41:53 +00:00
|
|
|
#endif
|
2015-02-15 03:25:22 +00:00
|
|
|
|
2015-05-25 18:41:53 +00:00
|
|
|
#if defined(Q_OS_LINUX)
|
|
|
|
|
#ifdef __i386__
|
2024-07-02 19:07:06 +00:00
|
|
|
return kProcessorArchLinux32;
|
2015-05-25 18:41:53 +00:00
|
|
|
#else
|
2024-07-02 19:07:06 +00:00
|
|
|
return kProcessorArchLinux64;
|
2015-02-09 15:37:47 +00:00
|
|
|
#endif
|
2015-05-25 18:41:53 +00:00
|
|
|
#endif
|
|
|
|
|
|
2024-07-02 19:07:06 +00:00
|
|
|
return kProcessorArchUnknown;
|
2015-02-09 15:37:47 +00:00
|
|
|
}
|