mirror of
https://github.com/RPCSX/rpcsx.git
synced 2026-04-20 22:05:12 +00:00
GUI: Improve PS3 decryption tool
This commit is contained in:
parent
fb47d1f788
commit
ba03df8511
6 changed files with 169 additions and 33 deletions
|
|
@ -1,9 +1,14 @@
|
|||
#include "input_dialog.h"
|
||||
#include "qt_utils.h"
|
||||
|
||||
#include <QVBoxLayout>
|
||||
#include <QDialogButtonBox>
|
||||
#include <QLineEdit>
|
||||
#include <QPushButton>
|
||||
#include <QValidator>
|
||||
#include <QLabel>
|
||||
|
||||
constexpr auto qstr = QString::fromStdString;
|
||||
|
||||
input_dialog::input_dialog(int max_length, const QString& text, const QString& title, const QString& label, const QString& placeholder, QWidget *parent, Qt::WindowFlags f)
|
||||
: QDialog(parent, f)
|
||||
|
|
@ -12,21 +17,21 @@ input_dialog::input_dialog(int max_length, const QString& text, const QString& t
|
|||
|
||||
m_label = new QLabel(label);
|
||||
|
||||
QLineEdit* input = new QLineEdit();
|
||||
input->setPlaceholderText(placeholder);
|
||||
input->setText(text);
|
||||
input->setMaxLength(max_length);
|
||||
input->setClearButtonEnabled(true);
|
||||
connect(input, &QLineEdit::textChanged, this, &input_dialog::text_changed);
|
||||
m_input = new QLineEdit();
|
||||
m_input->setPlaceholderText(placeholder);
|
||||
m_input->setText(text);
|
||||
m_input->setMaxLength(max_length);
|
||||
m_input->setClearButtonEnabled(true);
|
||||
connect(m_input, &QLineEdit::textChanged, this, &input_dialog::text_changed);
|
||||
|
||||
QDialogButtonBox* button_box = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel);
|
||||
connect(button_box, &QDialogButtonBox::accepted, this, &QDialog::accept);
|
||||
connect(button_box, &QDialogButtonBox::rejected, this, &QDialog::reject);
|
||||
m_button_box = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel);
|
||||
connect(m_button_box, &QDialogButtonBox::accepted, this, &QDialog::accept);
|
||||
connect(m_button_box, &QDialogButtonBox::rejected, this, &QDialog::reject);
|
||||
|
||||
QVBoxLayout* layout = new QVBoxLayout();
|
||||
layout->addWidget(m_label);
|
||||
layout->addWidget(input);
|
||||
layout->addWidget(button_box);
|
||||
layout->addWidget(m_input);
|
||||
layout->addWidget(m_button_box);
|
||||
setLayout(layout);
|
||||
|
||||
setFixedHeight(sizeHint().height());
|
||||
|
|
@ -36,7 +41,41 @@ input_dialog::~input_dialog()
|
|||
{
|
||||
}
|
||||
|
||||
void input_dialog::set_clear_button_enabled(bool enabled)
|
||||
{
|
||||
m_input->setClearButtonEnabled(enabled);
|
||||
}
|
||||
|
||||
void input_dialog::set_input_font(const QFont& font, bool fix_width, char sample)
|
||||
{
|
||||
if (int max = m_input->maxLength(); max > 0 && fix_width && std::isprint(static_cast<uchar>(sample)))
|
||||
{
|
||||
const QString str = qstr(std::string(static_cast<std::size_t>(max), sample));
|
||||
m_input->setFixedWidth(gui::utils::get_label_width(str, &font));
|
||||
}
|
||||
|
||||
m_input->setFont(font);
|
||||
}
|
||||
|
||||
void input_dialog::set_validator(const QValidator* validator)
|
||||
{
|
||||
m_input->setValidator(validator);
|
||||
}
|
||||
|
||||
void input_dialog::set_button_enabled(QDialogButtonBox::StandardButton id, bool enabled)
|
||||
{
|
||||
if (QPushButton* button = m_button_box->button(id))
|
||||
{
|
||||
button->setEnabled(enabled);
|
||||
}
|
||||
}
|
||||
|
||||
void input_dialog::set_label_text(const QString& text)
|
||||
{
|
||||
m_label->setText(text);
|
||||
}
|
||||
|
||||
QString input_dialog::get_input_text() const
|
||||
{
|
||||
return m_input->text();
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue