Qt: Replace some deprecated Qt5 stuff

This commit is contained in:
Megamouse 2022-04-21 20:54:02 +02:00
parent e9af0bb72b
commit 8d781a737b
11 changed files with 29 additions and 31 deletions

View File

@ -55,7 +55,7 @@ protected:
if (isFloating())
{
QStyleOption opt;
opt.init(this);
opt.initFrom(this);
QPainter p(this);
style()->drawPrimitive(QStyle::PE_Widget, &opt, &p, this);
return;

View File

@ -412,7 +412,7 @@ void debugger_frame::keyPressEvent(QKeyEvent* event)
dlg.set_input_font(mono, false);
dlg.set_clear_button_enabled(false);
dlg.set_button_enabled(QDialogButtonBox::StandardButton::Ok, false);
dlg.set_validator(new QRegExpValidator(QRegExp("^[1-9][0-9]*$")));
dlg.set_validator(new QRegularExpressionValidator(QRegularExpression("^[1-9][0-9]*$")));
u32 max = 0;
@ -1010,11 +1010,11 @@ void debugger_frame::ShowGotoAddressDialog()
if (const auto thread = get_cpu(); !thread || thread->id_type() != 2)
{
expression_input->setValidator(new QRegExpValidator(QRegExp("^(0[xX])?0*[a-fA-F0-9]{0,8}$")));
expression_input->setValidator(new QRegularExpressionValidator(QRegularExpression("^(0[xX])?0*[a-fA-F0-9]{0,8}$")));
}
else
{
expression_input->setValidator(new QRegExpValidator(QRegExp("^(0[xX])?0*[a-fA-F0-9]{0,5}$")));
expression_input->setValidator(new QRegularExpressionValidator(QRegularExpression("^(0[xX])?0*[a-fA-F0-9]{0,5}$")));
}
// Ok/Cancel
@ -1058,8 +1058,8 @@ u64 debugger_frame::EvaluateExpression(const QString& expression)
{
bool ok = false;
// Parse expression(or at least used to, was nuked to remove the need for QtJsEngine)
const QString fixed_expression = QRegExp("^[A-Fa-f0-9]+$").exactMatch(expression) ? "0x" + expression : expression;
// Parse expression (or at least used to, was nuked to remove the need for QtJsEngine)
const QString fixed_expression = QRegularExpression(QRegularExpression::anchoredPattern("a .*|^[A-Fa-f0-9]+$")).match(expression).hasMatch() ? "0x" + expression : expression;
const u64 res = static_cast<u64>(fixed_expression.toULong(&ok, 16));
if (ok) return res;

View File

@ -679,7 +679,7 @@ void main_window::InstallPackages(QStringList file_paths)
const auto install_filetype = [&installed_rap_and_edat_count, &file_paths](const std::string extension)
{
const QString pattern = QString(".*\\.%1").arg(QString::fromStdString(extension));
for (const auto& file : file_paths.filter(QRegExp(pattern, Qt::CaseInsensitive)))
for (const auto& file : file_paths.filter(QRegularExpression(pattern, QRegularExpression::PatternOption::CaseInsensitiveOption)))
{
const QFileInfo file_info(file);
const std::string filename = sstr(file_info.fileName());
@ -706,7 +706,7 @@ void main_window::InstallPackages(QStringList file_paths)
}
// Find remaining package files
file_paths = file_paths.filter(QRegExp(".*\\.pkg", Qt::CaseInsensitive));
file_paths = file_paths.filter(QRegularExpression(".*\\.pkg", QRegularExpression::PatternOption::CaseInsensitiveOption));
if (!file_paths.isEmpty())
{
@ -1418,7 +1418,7 @@ void main_window::DecryptSPRXLibraries()
dlg.set_input_font(mono, true, '0');
dlg.set_clear_button_enabled(false);
dlg.set_button_enabled(QDialogButtonBox::StandardButton::Ok, false);
dlg.set_validator(new QRegExpValidator(QRegExp("^[a-fA-F0-9]*$"))); // HEX only
dlg.set_validator(new QRegularExpressionValidator(QRegularExpression("^[a-fA-F0-9]*$"))); // HEX only
connect(&dlg, &input_dialog::text_changed, &dlg, [&dlg](const QString& text)
{
@ -2885,8 +2885,7 @@ main_window::drop_type main_window::IsValidFile(const QMimeData& md, QStringList
for (auto&& url : list) // check each file in url list for valid type
{
const QString path = url.toLocalFile(); // convert url to filepath
const QFileInfo info = path;
const QFileInfo info(path);
// check for directories first, only valid if all other paths led to directories until now.
if (info.isDir())

View File

@ -66,7 +66,6 @@ class main_window : public QMainWindow
QWinThumbnailToolButton *m_thumb_playPause = nullptr;
QWinThumbnailToolButton *m_thumb_stop = nullptr;
QWinThumbnailToolButton *m_thumb_restart = nullptr;
QStringList m_vulkan_adapters;
#endif
enum class drop_type

View File

@ -81,7 +81,7 @@ memory_viewer_panel::memory_viewer_panel(QWidget* parent, u32 addr, std::functio
m_addr_line->setMaxLength(18);
m_addr_line->setFixedWidth(75);
m_addr_line->setFocus();
m_addr_line->setValidator(new QRegExpValidator(QRegExp(m_type == thread_type::spu ? "^(0[xX])?0*[a-fA-F0-9]{0,5}$" : "^(0[xX])?0*[a-fA-F0-9]{0,8}$")));
m_addr_line->setValidator(new QRegularExpressionValidator(QRegularExpression(m_type == thread_type::spu ? "^(0[xX])?0*[a-fA-F0-9]{0,5}$" : "^(0[xX])?0*[a-fA-F0-9]{0,8}$")));
hbox_tools_mem_addr->addWidget(m_addr_line);
tools_mem_addr->setLayout(hbox_tools_mem_addr);

View File

@ -10,7 +10,7 @@
#include <QTextEdit>
#include <QHBoxLayout>
#include <QFormLayout>
#include <QRegExpValidator>
#include <QRegularExpressionValidator>
constexpr auto qstr = QString::fromStdString;
@ -70,7 +70,7 @@ void osk_dialog_frame::Create(const std::string& title, const std::u16string& me
if (prohibit_flags & CELL_OSKDIALOG_NO_SPACE)
{
input->setValidator(new QRegExpValidator(QRegExp("^\\S*$"), this));
input->setValidator(new QRegularExpressionValidator(QRegularExpression("^\\S*$"), this));
}
connect(input, &QLineEdit::textChanged, input_count_label, [input_count_label, charlimit, this](const QString& text)
@ -122,7 +122,7 @@ void osk_dialog_frame::Create(const std::string& title, const std::u16string& me
if (prohibit_flags & CELL_OSKDIALOG_NO_SPACE)
{
int trim_len = text.length();
text.remove(QRegExp("\\s+"));
text.remove(QRegularExpression("\\s+"));
trim_len -= text.length();
cursor_pos -= trim_len;
}

View File

@ -745,8 +745,8 @@ bool patch_manager_dialog::is_valid_file(const QMimeData& md, QStringList* drop_
for (auto&& url : list) // Check each file in url list for valid type
{
const QString path = url.toLocalFile(); // Convert url to filepath
const QFileInfo info = path;
const QString path = url.toLocalFile(); // Convert url to filepath
const QFileInfo info(path);
if (!info.fileName().endsWith("patch.yml"))
{

View File

@ -2,7 +2,7 @@
#include <QHBoxLayout>
#include <QLabel>
#include <QPushButton>
#include <QRegExpValidator>
#include <QRegularExpressionValidator>
#include <QInputDialog>
#include <QGroupBox>
#include <QMenu>
@ -101,7 +101,7 @@ rpcn_account_dialog::rpcn_account_dialog(QWidget* parent)
QLabel* label_npid = new QLabel(tr("NPID (username):"));
m_edit_npid = new QLineEdit();
m_edit_npid->setMaxLength(16);
m_edit_npid->setValidator(new QRegExpValidator(QRegExp("^[a-zA-Z0-9_\\-]*$"), this));
m_edit_npid->setValidator(new QRegularExpressionValidator(QRegularExpression("^[a-zA-Z0-9_\\-]*$"), this));
QLabel* label_pass = new QLabel(tr("Password:"));
QPushButton* btn_chg_pass = new QPushButton(tr("Set Password"));
QLabel* label_token = new QLabel(tr("Token:"));
@ -229,7 +229,7 @@ void rpcn_account_dialog::create_account()
return;
QString email;
const QRegExpValidator simple_email_validator(QRegExp("^[a-zA-Z0-9.!#$%&*+/=?^_`{|}~-]+@[a-zA-Z0-9-]+(?:\\.[a-zA-Z0-9-]+)*$"));
const QRegularExpressionValidator simple_email_validator(QRegularExpression("^[a-zA-Z0-9.!#$%&*+/=?^_`{|}~-]+@[a-zA-Z0-9-]+(?:\\.[a-zA-Z0-9-]+)*$"));
while (true)
{

View File

@ -33,10 +33,10 @@ namespace
[[maybe_unused]] inline std::string sstr(const QString& _in) { return _in.toStdString(); }
QString FormatTimestamp(u64 time)
QString FormatTimestamp(s64 time)
{
QDateTime dateTime;
dateTime.setTime_t(time);
dateTime.setSecsSinceEpoch(time);
return dateTime.toString("yyyy-MM-dd HH:mm:ss");
}

View File

@ -563,12 +563,12 @@ skylander_creator_dialog::skylander_creator_dialog(QWidget* parent)
line->setFrameShadow(QFrame::Sunken);
vbox_panel->addWidget(line);
QHBoxLayout* hbox_idvar = new QHBoxLayout();
QLabel* label_id = new QLabel(tr("ID:"));
QLabel* label_var = new QLabel(tr("Variant:"));
QLineEdit* edit_id = new QLineEdit("0");
QLineEdit* edit_var = new QLineEdit("0");
QRegExpValidator* rxv = new QRegExpValidator(QRegExp("\\d*"), this);
QHBoxLayout* hbox_idvar = new QHBoxLayout();
QLabel* label_id = new QLabel(tr("ID:"));
QLabel* label_var = new QLabel(tr("Variant:"));
QLineEdit* edit_id = new QLineEdit("0");
QLineEdit* edit_var = new QLineEdit("0");
QRegularExpressionValidator* rxv = new QRegularExpressionValidator(QRegularExpression("\\d*"), this);
edit_id->setValidator(rxv);
edit_var->setValidator(rxv);
hbox_idvar->addWidget(label_id);

View File

@ -1,4 +1,4 @@
#include <QRegExpValidator>
#include <QRegularExpressionValidator>
#include <QInputDialog>
#include <QKeyEvent>
#include <QEvent>
@ -250,7 +250,7 @@ bool user_manager_dialog::ValidateUsername(const QString& text_to_validate)
{
// "Entire string (^...$) must be between 3 and 16 characters
// and only consist of letters, numbers, underscores, and hyphens."
const QRegExpValidator validator(QRegExp("^[A-Za-z0-9_-]{3,16}$"));
const QRegularExpressionValidator validator(QRegularExpression("^[A-Za-z0-9_-]{3,16}$"));
int pos = 0;
QString text = text_to_validate;