early-access version 1255
This commit is contained in:
Executable
+59
@@ -0,0 +1,59 @@
|
||||
// Copyright 2018 yuzu Emulator Project
|
||||
// Licensed under GPLv2 or any later version
|
||||
// Refer to the license.txt file included.
|
||||
|
||||
#include <QDialogButtonBox>
|
||||
#include <QLabel>
|
||||
#include <QLineEdit>
|
||||
#include <QPushButton>
|
||||
#include <QVBoxLayout>
|
||||
#include "yuzu/util/limitable_input_dialog.h"
|
||||
|
||||
LimitableInputDialog::LimitableInputDialog(QWidget* parent) : QDialog{parent} {
|
||||
CreateUI();
|
||||
ConnectEvents();
|
||||
}
|
||||
|
||||
LimitableInputDialog::~LimitableInputDialog() = default;
|
||||
|
||||
void LimitableInputDialog::CreateUI() {
|
||||
setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint);
|
||||
|
||||
text_label = new QLabel(this);
|
||||
text_entry = new QLineEdit(this);
|
||||
buttons = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel, this);
|
||||
|
||||
auto* const layout = new QVBoxLayout;
|
||||
layout->addWidget(text_label);
|
||||
layout->addWidget(text_entry);
|
||||
layout->addWidget(buttons);
|
||||
|
||||
setLayout(layout);
|
||||
}
|
||||
|
||||
void LimitableInputDialog::ConnectEvents() {
|
||||
connect(buttons, &QDialogButtonBox::accepted, this, &QDialog::accept);
|
||||
connect(buttons, &QDialogButtonBox::rejected, this, &QDialog::reject);
|
||||
}
|
||||
|
||||
QString LimitableInputDialog::GetText(QWidget* parent, const QString& title, const QString& text,
|
||||
int min_character_limit, int max_character_limit) {
|
||||
Q_ASSERT(min_character_limit <= max_character_limit);
|
||||
|
||||
LimitableInputDialog dialog{parent};
|
||||
dialog.setWindowTitle(title);
|
||||
dialog.text_label->setText(text);
|
||||
dialog.text_entry->setMaxLength(max_character_limit);
|
||||
|
||||
auto* const ok_button = dialog.buttons->button(QDialogButtonBox::Ok);
|
||||
ok_button->setEnabled(false);
|
||||
connect(dialog.text_entry, &QLineEdit::textEdited, [&](const QString& new_text) {
|
||||
ok_button->setEnabled(new_text.length() >= min_character_limit);
|
||||
});
|
||||
|
||||
if (dialog.exec() != QDialog::Accepted) {
|
||||
return {};
|
||||
}
|
||||
|
||||
return dialog.text_entry->text();
|
||||
}
|
||||
Executable
+31
@@ -0,0 +1,31 @@
|
||||
// Copyright 2018 yuzu Emulator Project
|
||||
// Licensed under GPLv2 or any later version
|
||||
// Refer to the license.txt file included.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <QDialog>
|
||||
|
||||
class QDialogButtonBox;
|
||||
class QLabel;
|
||||
class QLineEdit;
|
||||
|
||||
/// A QDialog that functions similarly to QInputDialog, however, it allows
|
||||
/// restricting the minimum and total number of characters that can be entered.
|
||||
class LimitableInputDialog final : public QDialog {
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit LimitableInputDialog(QWidget* parent = nullptr);
|
||||
~LimitableInputDialog() override;
|
||||
|
||||
static QString GetText(QWidget* parent, const QString& title, const QString& text,
|
||||
int min_character_limit, int max_character_limit);
|
||||
|
||||
private:
|
||||
void CreateUI();
|
||||
void ConnectEvents();
|
||||
|
||||
QLabel* text_label;
|
||||
QLineEdit* text_entry;
|
||||
QDialogButtonBox* buttons;
|
||||
};
|
||||
+40
@@ -0,0 +1,40 @@
|
||||
// Copyright 2018 Citra Emulator Project
|
||||
// Licensed under GPLv2 or any later version
|
||||
// Refer to the license.txt file included.
|
||||
|
||||
#include <QDialogButtonBox>
|
||||
#include <QKeySequenceEdit>
|
||||
#include <QVBoxLayout>
|
||||
#include "yuzu/util/sequence_dialog/sequence_dialog.h"
|
||||
|
||||
SequenceDialog::SequenceDialog(QWidget* parent) : QDialog(parent) {
|
||||
setWindowTitle(tr("Enter a hotkey"));
|
||||
setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint);
|
||||
|
||||
key_sequence = new QKeySequenceEdit;
|
||||
|
||||
auto* const buttons = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel);
|
||||
buttons->setCenterButtons(true);
|
||||
|
||||
auto* const layout = new QVBoxLayout(this);
|
||||
layout->addWidget(key_sequence);
|
||||
layout->addWidget(buttons);
|
||||
|
||||
connect(buttons, &QDialogButtonBox::accepted, this, &QDialog::accept);
|
||||
connect(buttons, &QDialogButtonBox::rejected, this, &QDialog::reject);
|
||||
}
|
||||
|
||||
SequenceDialog::~SequenceDialog() = default;
|
||||
|
||||
QKeySequence SequenceDialog::GetSequence() const {
|
||||
// Only the first key is returned. The other 3, if present, are ignored.
|
||||
return QKeySequence(key_sequence->keySequence()[0]);
|
||||
}
|
||||
|
||||
bool SequenceDialog::focusNextPrevChild(bool next) {
|
||||
return false;
|
||||
}
|
||||
|
||||
void SequenceDialog::closeEvent(QCloseEvent*) {
|
||||
reject();
|
||||
}
|
||||
+24
@@ -0,0 +1,24 @@
|
||||
// Copyright 2018 Citra Emulator Project
|
||||
// Licensed under GPLv2 or any later version
|
||||
// Refer to the license.txt file included.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <QDialog>
|
||||
|
||||
class QKeySequenceEdit;
|
||||
|
||||
class SequenceDialog : public QDialog {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit SequenceDialog(QWidget* parent = nullptr);
|
||||
~SequenceDialog() override;
|
||||
|
||||
QKeySequence GetSequence() const;
|
||||
void closeEvent(QCloseEvent*) override;
|
||||
|
||||
private:
|
||||
QKeySequenceEdit* key_sequence;
|
||||
bool focusNextPrevChild(bool next) override;
|
||||
};
|
||||
Executable
+32
@@ -0,0 +1,32 @@
|
||||
// Copyright 2020 yuzu Emulator Project
|
||||
// Licensed under GPLv2 or any later version
|
||||
// Refer to the license.txt file included.
|
||||
|
||||
#ifdef YUZU_USE_QT_WEB_ENGINE
|
||||
|
||||
#include "yuzu/util/url_request_interceptor.h"
|
||||
|
||||
UrlRequestInterceptor::UrlRequestInterceptor(QObject* p) : QWebEngineUrlRequestInterceptor(p) {}
|
||||
|
||||
UrlRequestInterceptor::~UrlRequestInterceptor() = default;
|
||||
|
||||
void UrlRequestInterceptor::interceptRequest(QWebEngineUrlRequestInfo& info) {
|
||||
const auto resource_type = info.resourceType();
|
||||
|
||||
switch (resource_type) {
|
||||
case QWebEngineUrlRequestInfo::ResourceTypeMainFrame:
|
||||
requested_url = info.requestUrl();
|
||||
emit FrameChanged();
|
||||
break;
|
||||
case QWebEngineUrlRequestInfo::ResourceTypeSubFrame:
|
||||
case QWebEngineUrlRequestInfo::ResourceTypeXhr:
|
||||
emit FrameChanged();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
QUrl UrlRequestInterceptor::GetRequestedURL() const {
|
||||
return requested_url;
|
||||
}
|
||||
|
||||
#endif
|
||||
Executable
+30
@@ -0,0 +1,30 @@
|
||||
// Copyright 2020 yuzu Emulator Project
|
||||
// Licensed under GPLv2 or any later version
|
||||
// Refer to the license.txt file included.
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifdef YUZU_USE_QT_WEB_ENGINE
|
||||
|
||||
#include <QObject>
|
||||
#include <QWebEngineUrlRequestInterceptor>
|
||||
|
||||
class UrlRequestInterceptor : public QWebEngineUrlRequestInterceptor {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit UrlRequestInterceptor(QObject* p = nullptr);
|
||||
~UrlRequestInterceptor() override;
|
||||
|
||||
void interceptRequest(QWebEngineUrlRequestInfo& info) override;
|
||||
|
||||
QUrl GetRequestedURL() const;
|
||||
|
||||
signals:
|
||||
void FrameChanged();
|
||||
|
||||
private:
|
||||
QUrl requested_url;
|
||||
};
|
||||
|
||||
#endif
|
||||
Executable
+40
@@ -0,0 +1,40 @@
|
||||
// Copyright 2015 Citra Emulator Project
|
||||
// Licensed under GPLv2 or any later version
|
||||
// Refer to the license.txt file included.
|
||||
|
||||
#include <array>
|
||||
#include <cmath>
|
||||
#include <QPainter>
|
||||
#include "yuzu/util/util.h"
|
||||
|
||||
QFont GetMonospaceFont() {
|
||||
QFont font(QStringLiteral("monospace"));
|
||||
// Automatic fallback to a monospace font on on platforms without a font called "monospace"
|
||||
font.setStyleHint(QFont::Monospace);
|
||||
font.setFixedPitch(true);
|
||||
return font;
|
||||
}
|
||||
|
||||
QString ReadableByteSize(qulonglong size) {
|
||||
static constexpr std::array units{"B", "KiB", "MiB", "GiB", "TiB", "PiB"};
|
||||
if (size == 0) {
|
||||
return QStringLiteral("0");
|
||||
}
|
||||
|
||||
const int digit_groups = std::min(static_cast<int>(std::log10(size) / std::log10(1024)),
|
||||
static_cast<int>(units.size()));
|
||||
return QStringLiteral("%L1 %2")
|
||||
.arg(size / std::pow(1024, digit_groups), 0, 'f', 1)
|
||||
.arg(QString::fromUtf8(units[digit_groups]));
|
||||
}
|
||||
|
||||
QPixmap CreateCirclePixmapFromColor(const QColor& color) {
|
||||
QPixmap circle_pixmap(16, 16);
|
||||
circle_pixmap.fill(Qt::transparent);
|
||||
QPainter painter(&circle_pixmap);
|
||||
painter.setRenderHint(QPainter::Antialiasing);
|
||||
painter.setPen(color);
|
||||
painter.setBrush(color);
|
||||
painter.drawEllipse({circle_pixmap.width() / 2.0, circle_pixmap.height() / 2.0}, 7.0, 7.0);
|
||||
return circle_pixmap;
|
||||
}
|
||||
Executable
+21
@@ -0,0 +1,21 @@
|
||||
// Copyright 2015 Citra Emulator Project
|
||||
// Licensed under GPLv2 or any later version
|
||||
// Refer to the license.txt file included.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <QFont>
|
||||
#include <QString>
|
||||
|
||||
/// Returns a QFont object appropriate to use as a monospace font for debugging widgets, etc.
|
||||
QFont GetMonospaceFont();
|
||||
|
||||
/// Convert a size in bytes into a readable format (KiB, MiB, etc.)
|
||||
QString ReadableByteSize(qulonglong size);
|
||||
|
||||
/**
|
||||
* Creates a circle pixmap from a specified color
|
||||
* @param color The color the pixmap shall have
|
||||
* @return QPixmap circle pixmap
|
||||
*/
|
||||
QPixmap CreateCirclePixmapFromColor(const QColor& color);
|
||||
Reference in New Issue
Block a user