Skip to content

Commit

Permalink
chore: Drop Windows XP support
Browse files Browse the repository at this point in the history
  • Loading branch information
pktiuk committed May 31, 2024
1 parent 473d6b6 commit da496f8
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 69 deletions.
54 changes: 12 additions & 42 deletions src/gui/mainsettingsdialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -139,24 +139,12 @@ MainSettingsDialog::MainSettingsDialog(AntiMicroSettings *settings, QList<InputD
#ifdef Q_OS_WIN
BaseEventHandler *handler = EventHandlerFactory::getInstance()->handler();

if (QSysInfo::windowsVersion() >= QSysInfo::WV_VISTA)
QFile tempFile(RUNATSTARTUPLOCATION);
if (tempFile.exists())
{
// Handle Windows Vista and later
QFile tempFile(RUNATSTARTUPLOCATION);
if (tempFile.exists())
{
ui->launchAtWinStartupCheckBox->setChecked(true);
}
} else
{
// Handle Windows XP
QSettings autoRunReg(RUNATSTARTUPREGKEY, QSettings::NativeFormat);
QString autoRunEntry = autoRunReg.value("antimicrox", "").toString();
if (!autoRunEntry.isEmpty())
{
ui->launchAtWinStartupCheckBox->setChecked(true);
}
ui->launchAtWinStartupCheckBox->setChecked(true);
}

#else
ui->launchAtWinStartupCheckBox->setVisible(false);

Expand Down Expand Up @@ -566,36 +554,18 @@ void MainSettingsDialog::saveNewSettings()
settings->getLock()->lock();

#ifdef Q_OS_WIN
if (QSysInfo::windowsVersion() >= QSysInfo::WV_VISTA)
{
// Handle Windows Vista and later
QFile tempFile(RUNATSTARTUPLOCATION);
QFile tempFile(RUNATSTARTUPLOCATION);

if (ui->launchAtWinStartupCheckBox->isChecked() && !tempFile.exists())
{
if (tempFile.open(QFile::WriteOnly))
{
QFile currentAppLocation(qApp->applicationFilePath());
currentAppLocation.link(QFileInfo(tempFile).absoluteFilePath());
}
} else if (tempFile.exists() && QFileInfo(tempFile).isWritable())
{
tempFile.remove();
}
} else
if (ui->launchAtWinStartupCheckBox->isChecked() && !tempFile.exists())
{
// Handle Windows XP
QSettings autoRunReg(RUNATSTARTUPREGKEY, QSettings::NativeFormat);
QString autoRunEntry = autoRunReg.value("antimicrox", "").toString();

if (ui->launchAtWinStartupCheckBox->isChecked())
if (tempFile.open(QFile::WriteOnly))
{
QString nativeFilePath = QDir::toNativeSeparators(qApp->applicationFilePath());
autoRunReg.setValue("antimicrox", nativeFilePath);
} else if (!autoRunEntry.isEmpty())
{
autoRunReg.remove("antimicrox");
QFile currentAppLocation(qApp->applicationFilePath());
currentAppLocation.link(QFileInfo(tempFile).absoluteFilePath());
}
} else if (tempFile.exists() && QFileInfo(tempFile).isWritable())
{
tempFile.remove();
}

BaseEventHandler *handler = EventHandlerFactory::getInstance()->handler();
Expand Down
14 changes: 4 additions & 10 deletions src/gui/mainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -191,11 +191,8 @@ MainWindow::MainWindow(QMap<SDL_JoystickID, InputDevice *> *joysticks, CommandLi
{
if (!WinExtras::IsRunningAsAdmin())
{
if (QSysInfo::windowsVersion() >= QSysInfo::WV_VISTA)
{
QIcon uacIcon = QApplication::style()->standardIcon(QStyle::SP_VistaShield);
ui->uacPushButton->setIcon(uacIcon);
}
QIcon uacIcon = QApplication::style()->standardIcon(QStyle::SP_VistaShield);
ui->uacPushButton->setIcon(uacIcon);
connect(ui->uacPushButton, SIGNAL(clicked()), this, SLOT(restartAsElevated()));
} else
{
Expand Down Expand Up @@ -1411,11 +1408,8 @@ void MainWindow::restartAsElevated()
"This is due to permission problems caused by User Account "
"Control (UAC) options in Windows Vista and later."));

if (QSysInfo::windowsVersion() >= QSysInfo::WV_VISTA)
{
QIcon uacIcon = QApplication::style()->standardIcon(QStyle::SP_VistaShield);
msg.button(QMessageBox::Yes)->setIcon(uacIcon);
}
QIcon uacIcon = QApplication::style()->standardIcon(QStyle::SP_VistaShield);
msg.button(QMessageBox::Yes)->setIcon(uacIcon);

int result = msg.exec();
if (result == QMessageBox::Yes)
Expand Down
18 changes: 1 addition & 17 deletions src/winextras.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,6 @@ typedef DWORD(WINAPI *MYPROC)(HANDLE, DWORD, LPWSTR, PDWORD);
static MYPROC pQueryFullProcessImageNameW =
(MYPROC)GetProcAddress(GetModuleHandle(TEXT("kernel32.dll")), "QueryFullProcessImageNameW");

/*static bool isWindowsVistaOrHigher()
{
OSVERSIONINFO osvi;
memset(&osvi, 0, sizeof(osvi));
osvi.dwOSVersionInfoSize = sizeof(osvi);
GetVersionEx(&osvi);
return (osvi.dwPlatformId == VER_PLATFORM_WIN32_NT && osvi.dwMajorVersion >= 6);
}
*/

const unsigned int WinExtras::EXTENDED_FLAG = 0x100;
int WinExtras::originalMouseAccel = 0;

Expand Down Expand Up @@ -270,8 +260,6 @@ QString WinExtras::getForegroundWindowExePath()
if (windowProcess != NULL)
{
WCHAR filename[MAX_PATH];
TCHAR filename_xp[MAX_PATH];
// qDebug() << QString::number(sizeof(filename)/sizeof(TCHAR));
if (pQueryFullProcessImageNameW)
{
// Windows Vista and later
Expand All @@ -283,12 +271,8 @@ QString WinExtras::getForegroundWindowExePath()
exePath = QString::fromWCharArray(filename);
} else
{
// Windows XP
memset(filename_xp, 0, sizeof(filename_xp));
GetModuleFileNameEx(windowProcess, NULL, filename_xp, MAX_PATH * sizeof(TCHAR));
exePath = QString(filename_xp);
qWarning() << "Windows XP is not supported";
}

CloseHandle(windowProcess);
}

Expand Down

0 comments on commit da496f8

Please sign in to comment.