Qt: add move up/down button for shader passes

This commit is contained in:
Brad Parker 2018-08-18 17:39:37 -04:00
parent ea946b5c97
commit 380cd7ac53
6 changed files with 131 additions and 4 deletions

View File

@ -3756,3 +3756,7 @@ MSG_HASH(MENU_ENUM_LABEL_VALUE_QT_MENU_HELP_ABOUT_CONTRIBUTORS,
"作成者")
MSG_HASH(MENU_ENUM_LABEL_VALUE_QT_CURRENT_SHADER,
"現在のシェーダー")
MSG_HASH(MENU_ENUM_LABEL_VALUE_QT_SHADER_MOVE_DOWN,
"下へ移動")
MSG_HASH(MENU_ENUM_LABEL_VALUE_QT_SHADER_MOVE_UP,
"上へ移動")

View File

@ -4258,3 +4258,7 @@ MSG_HASH(MENU_ENUM_LABEL_VALUE_QT_MENU_HELP_ABOUT_CONTRIBUTORS,
"Contributors")
MSG_HASH(MENU_ENUM_LABEL_VALUE_QT_CURRENT_SHADER,
"Current shader")
MSG_HASH(MENU_ENUM_LABEL_VALUE_QT_SHADER_MOVE_DOWN,
"Move Down")
MSG_HASH(MENU_ENUM_LABEL_VALUE_QT_SHADER_MOVE_UP,
"Move Up")

View File

@ -1980,6 +1980,8 @@ enum msg_hash_enums
MENU_ENUM_LABEL_VALUE_QT_UPDATE_RETROARCH_FINISHED,
MENU_ENUM_LABEL_VALUE_QT_UPDATE_RETROARCH_FAILED,
MENU_ENUM_LABEL_VALUE_QT_CURRENT_SHADER,
MENU_ENUM_LABEL_VALUE_QT_SHADER_MOVE_DOWN,
MENU_ENUM_LABEL_VALUE_QT_SHADER_MOVE_UP,
MENU_LABEL(MIDI_INPUT),
MENU_LABEL(MIDI_OUTPUT),

View File

@ -9,6 +9,7 @@
#include <QDoubleSpinBox>
#include <QCheckBox>
#include <QComboBox>
#include <QPushButton>
#include "shaderparamsdialog.h"
#include "../ui_qt.h"
@ -281,6 +282,98 @@ void ShaderParamsDialog::onScaleComboBoxIndexChanged(int)
}
}
void ShaderParamsDialog::onShaderPassMoveDownClicked()
{
QPushButton *button = qobject_cast<QPushButton*>(sender());
QVariant passVariant;
struct video_shader *menu_shader = NULL;
struct video_shader *video_shader = NULL;
int pass = 0;
bool ok = false;
getShaders(&menu_shader, &video_shader);
if (!button)
return;
passVariant = button->property("pass");
if (!passVariant.isValid())
return;
pass = passVariant.toInt(&ok);
if (!ok)
return;
if (pass < 0)
return;
if (video_shader)
{
if (pass >= static_cast<int>(video_shader->passes) - 1)
return;
std::swap(video_shader->pass[pass], video_shader->pass[pass + 1]);
}
if (menu_shader)
{
if (pass >= static_cast<int>(menu_shader->passes) - 1)
return;
std::swap(menu_shader->pass[pass], menu_shader->pass[pass + 1]);
}
command_event(CMD_EVENT_SHADERS_APPLY_CHANGES, NULL);
}
void ShaderParamsDialog::onShaderPassMoveUpClicked()
{
QPushButton *button = qobject_cast<QPushButton*>(sender());
QVariant passVariant;
struct video_shader *menu_shader = NULL;
struct video_shader *video_shader = NULL;
int pass = 0;
bool ok = false;
getShaders(&menu_shader, &video_shader);
if (!button)
return;
passVariant = button->property("pass");
if (!passVariant.isValid())
return;
pass = passVariant.toInt(&ok);
if (!ok)
return;
if (pass <= 0)
return;
if (video_shader)
{
if (pass > static_cast<int>(video_shader->passes) - 1)
return;
std::swap(video_shader->pass[pass - 1], video_shader->pass[pass]);
}
if (menu_shader)
{
if (pass > static_cast<int>(menu_shader->passes) - 1)
return;
std::swap(menu_shader->pass[pass - 1], menu_shader->pass[pass]);
}
command_event(CMD_EVENT_SHADERS_APPLY_CHANGES, NULL);
}
void ShaderParamsDialog::reload()
{
struct video_shader *menu_shader = NULL;
@ -325,11 +418,29 @@ void ShaderParamsDialog::reload()
QHBoxLayout *filterScaleHBoxLayout = NULL;
QComboBox *filterComboBox = new QComboBox();
QComboBox *scaleComboBox = new QComboBox();
QPushButton *moveDownButton = NULL;
QPushButton *moveUpButton = NULL;
unsigned j = 0;
filterComboBox->setProperty("pass", i);
scaleComboBox->setProperty("pass", i);
/* Can't move down if we're already at the bottom. */
if (i < static_cast<int>(video_shader->passes) - 1)
{
moveDownButton = new QPushButton(msg_hash_to_str(MENU_ENUM_LABEL_VALUE_QT_SHADER_MOVE_DOWN));
moveDownButton->setProperty("pass", i);
connect(moveDownButton, SIGNAL(clicked()), this, SLOT(onShaderPassMoveDownClicked()));
}
/* Can't move up if we're already at the top. */
if (i > 0)
{
moveUpButton = new QPushButton(msg_hash_to_str(MENU_ENUM_LABEL_VALUE_QT_SHADER_MOVE_UP));
moveUpButton->setProperty("pass", i);
connect(moveUpButton, SIGNAL(clicked()), this, SLOT(onShaderPassMoveUpClicked()));
}
for (;;)
{
QString filterLabel = getFilterLabel(j);
@ -371,11 +482,17 @@ void ShaderParamsDialog::reload()
m_layout->addWidget(groupBox);
filterScaleHBoxLayout = new QHBoxLayout();
filterScaleHBoxLayout->addWidget(new QLabel(msg_hash_to_str(MENU_ENUM_LABEL_VALUE_FILTER)));
filterScaleHBoxLayout->addWidget(new QLabel(QString(msg_hash_to_str(MENU_ENUM_LABEL_VALUE_FILTER)) + ":"));
filterScaleHBoxLayout->addWidget(filterComboBox);
filterScaleHBoxLayout->addWidget(new QLabel(msg_hash_to_str(MENU_ENUM_LABEL_VALUE_SCALE)));
filterScaleHBoxLayout->addWidget(new QLabel(QString(msg_hash_to_str(MENU_ENUM_LABEL_VALUE_SCALE)) + ":"));
filterScaleHBoxLayout->addWidget(scaleComboBox);
if (moveUpButton)
filterScaleHBoxLayout->addWidget(moveUpButton);
if (moveDownButton)
filterScaleHBoxLayout->addWidget(moveDownButton);
form->addRow("", filterScaleHBoxLayout);
for (j = 0; j < video_shader->num_parameters; j++)

View File

@ -27,6 +27,8 @@ private slots:
void onShaderParamDoubleSpinBoxValueChanged(double value);
void onFilterComboBoxIndexChanged(int index);
void onScaleComboBoxIndexChanged(int index);
void onShaderPassMoveDownClicked();
void onShaderPassMoveUpClicked();
private:
QString getFilterLabel(unsigned filter);
void addShaderParam(struct video_shader_parameter *param, int parameter, QFormLayout *form);

View File

@ -223,7 +223,6 @@ CoreInfoWidget::CoreInfoWidget(CoreInfoLabel *label, QWidget *parent) :
,m_label(label)
,m_scrollArea(new QScrollArea(this))
{
//m_scrollArea->setFrameShape(QFrame::NoFrame);
m_scrollArea->setWidgetResizable(true);
m_scrollArea->setWidget(m_label);
}
@ -601,7 +600,6 @@ void MainWindow::onGridItemClicked(ThumbnailWidget *widget)
if (m_currentGridWidget)
{
m_currentGridWidget->setObjectName("thumbnailWidget");
//m_currentGridWidget->setFrameStyle(QFrame::Plain);
m_currentGridWidget->style()->unpolish(m_currentGridWidget);
m_currentGridWidget->style()->polish(m_currentGridWidget);
}