[Qt] style adjustments 3

rename some members and clean headers
This commit is contained in:
Megamouse 2017-09-06 19:00:49 +02:00 committed by Ani
parent 0cbbd3a5b1
commit a95e01290e
8 changed files with 127 additions and 136 deletions

View file

@ -14,12 +14,13 @@ memory_viewer_panel::memory_viewer_panel(QWidget* parent)
m_addr = 0;
m_colcount = 16;
m_rowcount = 16;
pSize = 10;
int pSize = 10;
//Font and Colors
mono = QFontDatabase::systemFont(QFontDatabase::FixedFont);
QFont mono = QFontDatabase::systemFont(QFontDatabase::FixedFont);
mono.setPointSize(pSize);
fontMetrics = new QFontMetrics(mono);
m_fontMetrics = new QFontMetrics(mono);
QPalette pal_bg;
pal_bg.setColor(QPalette::Background, QColor(240, 240, 240));
setPalette(pal_bg);
@ -36,19 +37,19 @@ memory_viewer_panel::memory_viewer_panel(QWidget* parent)
//Tools: Memory Viewer Options: Address
QGroupBox* tools_mem_addr = new QGroupBox(tr("Address"));
QHBoxLayout* hbox_tools_mem_addr = new QHBoxLayout();
t_addr = new QLineEdit(this);
t_addr->setPlaceholderText("00000000");
t_addr->setFont(mono);
t_addr->setMaxLength(8);
t_addr->setFixedWidth(75);
t_addr->setFocus();
hbox_tools_mem_addr->addWidget(t_addr);
m_addr_line = new QLineEdit(this);
m_addr_line->setPlaceholderText("00000000");
m_addr_line->setFont(mono);
m_addr_line->setMaxLength(8);
m_addr_line->setFixedWidth(75);
m_addr_line->setFocus();
hbox_tools_mem_addr->addWidget(m_addr_line);
tools_mem_addr->setLayout(hbox_tools_mem_addr);
//Tools: Memory Viewer Options: Bytes
QGroupBox* tools_mem_bytes = new QGroupBox(tr("Bytes"));
QHBoxLayout* hbox_tools_mem_bytes = new QHBoxLayout();
sb_bytes = new QSpinBox(this);
QSpinBox* sb_bytes = new QSpinBox(this);
sb_bytes->setRange(1, 16);
sb_bytes->setValue(16);
hbox_tools_mem_bytes->addWidget(sb_bytes);
@ -89,8 +90,8 @@ memory_viewer_panel::memory_viewer_panel(QWidget* parent)
QGroupBox* tools_img_size = new QGroupBox(tr("Size"));
QHBoxLayout* hbox_tools_img_size = new QHBoxLayout();
QLabel* l_x = new QLabel(" x ");
sb_img_size_x = new QSpinBox(this);
sb_img_size_y = new QSpinBox(this);
QSpinBox* sb_img_size_x = new QSpinBox(this);
QSpinBox* sb_img_size_y = new QSpinBox(this);
sb_img_size_x->setRange(1, 8192);
sb_img_size_y->setRange(1, 8192);
sb_img_size_x->setValue(256);
@ -103,7 +104,7 @@ memory_viewer_panel::memory_viewer_panel(QWidget* parent)
//Tools: Raw Image Preview Options: Mode
QGroupBox* tools_img_mode = new QGroupBox(tr("Mode"));
QHBoxLayout* hbox_tools_img_mode = new QHBoxLayout();
cbox_img_mode = new QComboBox(this);
QComboBox* cbox_img_mode = new QComboBox(this);
cbox_img_mode->addItem("RGB");
cbox_img_mode->addItem("ARGB");
cbox_img_mode->addItem("RGBA");
@ -136,48 +137,48 @@ memory_viewer_panel::memory_viewer_panel(QWidget* parent)
QHBoxLayout* hbox_mem_panel = new QHBoxLayout();
//Memory Panel: Address Panel
t_mem_addr = new QLabel("");
t_mem_addr->setFont(mono);
t_mem_addr->setAutoFillBackground(true);
t_mem_addr->setTextInteractionFlags(Qt::TextSelectableByMouse | Qt::TextSelectableByKeyboard);
QPalette palette_addr = t_mem_addr->palette();
palette_addr.setColor(t_mem_addr->backgroundRole(), QColor(240, 240, 240));
palette_addr.setColor(t_mem_addr->foregroundRole(), QColor(75, 135, 150));
t_mem_addr->setPalette(palette_addr);
m_mem_addr = new QLabel("");
m_mem_addr->setFont(mono);
m_mem_addr->setAutoFillBackground(true);
m_mem_addr->setTextInteractionFlags(Qt::TextSelectableByMouse | Qt::TextSelectableByKeyboard);
QPalette palette_addr = m_mem_addr->palette();
palette_addr.setColor(m_mem_addr->backgroundRole(), QColor(240, 240, 240));
palette_addr.setColor(m_mem_addr->foregroundRole(), QColor(75, 135, 150));
m_mem_addr->setPalette(palette_addr);
//Memory Panel: Hex Panel
t_mem_hex = new QLabel("");
t_mem_hex->setFont(mono);
t_mem_hex->setAutoFillBackground(true);
t_mem_hex->setTextInteractionFlags(Qt::TextSelectableByMouse | Qt::TextSelectableByKeyboard);
QPalette palette_hex = t_mem_hex->palette();
palette_hex.setColor(t_mem_hex->backgroundRole(), QColor(240, 240, 240));
palette_hex.setColor(t_mem_hex->foregroundRole(), Qt::black);
t_mem_hex->setPalette(palette_hex);
m_mem_hex = new QLabel("");
m_mem_hex->setFont(mono);
m_mem_hex->setAutoFillBackground(true);
m_mem_hex->setTextInteractionFlags(Qt::TextSelectableByMouse | Qt::TextSelectableByKeyboard);
QPalette palette_hex = m_mem_hex->palette();
palette_hex.setColor(m_mem_hex->backgroundRole(), QColor(240, 240, 240));
palette_hex.setColor(m_mem_hex->foregroundRole(), Qt::black);
m_mem_hex->setPalette(palette_hex);
//Memory Panel: ASCII Panel
t_mem_ascii = new QLabel("");
t_mem_ascii->setFont(mono);
t_mem_ascii->setAutoFillBackground(true);
t_mem_ascii->setTextInteractionFlags(Qt::TextSelectableByMouse | Qt::TextSelectableByKeyboard);
QPalette palette_ascii = t_mem_ascii->palette();
palette_ascii.setColor(t_mem_ascii->backgroundRole(), QColor(240, 240, 240));
palette_ascii.setColor(t_mem_ascii->foregroundRole(), Qt::black);
t_mem_ascii->setPalette(palette_ascii);
m_mem_ascii = new QLabel("");
m_mem_ascii->setFont(mono);
m_mem_ascii->setAutoFillBackground(true);
m_mem_ascii->setTextInteractionFlags(Qt::TextSelectableByMouse | Qt::TextSelectableByKeyboard);
QPalette palette_ascii = m_mem_ascii->palette();
palette_ascii.setColor(m_mem_ascii->backgroundRole(), QColor(240, 240, 240));
palette_ascii.setColor(m_mem_ascii->foregroundRole(), Qt::black);
m_mem_ascii->setPalette(palette_ascii);
//Merge Memory Panel:
hbox_mem_panel->setAlignment(Qt::AlignLeft);
hbox_mem_panel->addSpacing(20);
hbox_mem_panel->addWidget(t_mem_addr);
hbox_mem_panel->addWidget(m_mem_addr);
hbox_mem_panel->addSpacing(10);
hbox_mem_panel->addWidget(t_mem_hex);
hbox_mem_panel->addWidget(m_mem_hex);
hbox_mem_panel->addSpacing(10);
hbox_mem_panel->addWidget(t_mem_ascii);
hbox_mem_panel->addWidget(m_mem_ascii);
hbox_mem_panel->addSpacing(10);
//Memory Panel: Set size of the QTextEdits
t_mem_hex->setFixedSize(QSize(pSize * 3 * m_colcount + 6, 228));
t_mem_ascii->setFixedSize(QSize(pSize * m_colcount + 6, 228));
m_mem_hex->setFixedSize(QSize(pSize * 3 * m_colcount + 6, 228));
m_mem_ascii->setFixedSize(QSize(pSize * m_colcount + 6, 228));
//Set Margins to adjust WindowSize
vbox_panel->setContentsMargins(0, 0, 0, 0);
@ -201,16 +202,18 @@ memory_viewer_panel::memory_viewer_panel(QWidget* parent)
setLayout(vbox_panel);
//Events
connect(t_addr, &QLineEdit::returnPressed, [=](){
connect(m_addr_line, &QLineEdit::returnPressed, [=]
{
bool ok;
m_addr = t_addr->text().toULong(&ok, 16);
t_addr->setText(QString("%1").arg(m_addr, 8, 16, QChar('0'))); // get 8 digits in input line
m_addr = m_addr_line->text().toULong(&ok, 16);
m_addr_line->setText(QString("%1").arg(m_addr, 8, 16, QChar('0'))); // get 8 digits in input line
ShowMemory();
});
connect(sb_bytes, static_cast<void (QSpinBox::*)(int)>(&QSpinBox::valueChanged), [=](){
connect(sb_bytes, static_cast<void (QSpinBox::*)(int)>(&QSpinBox::valueChanged), [=]
{
m_colcount = sb_bytes->value();
t_mem_hex->setFixedSize(QSize(pSize * 3 * m_colcount + 6, 228));
t_mem_ascii->setFixedSize(QSize(pSize * m_colcount + 6, 228));
m_mem_hex->setFixedSize(QSize(pSize * 3 * m_colcount + 6, 228));
m_mem_ascii->setFixedSize(QSize(pSize * m_colcount + 6, 228));
ShowMemory();
});
@ -246,7 +249,7 @@ void memory_viewer_panel::wheelEvent(QWheelEvent *event)
QPoint numSteps = event->angleDelta() / 8 / 15; // http://doc.qt.io/qt-5/qwheelevent.html#pixelDelta
m_addr -= stepSize * m_colcount * numSteps.y();
t_addr->setText(qstr(fmt::format("%08x", m_addr)));
m_addr_line->setText(qstr(fmt::format("%08x", m_addr)));
ShowMemory();
}
@ -289,19 +292,19 @@ void memory_viewer_panel::ShowMemory()
}
}
t_mem_addr->setText(t_mem_addr_str);
t_mem_hex->setText(t_mem_hex_str);
t_mem_ascii->setText(t_mem_ascii_str);
m_mem_addr->setText(t_mem_addr_str);
m_mem_hex->setText(t_mem_hex_str);
m_mem_ascii->setText(t_mem_ascii_str);
// Adjust Text Boxes
textSize = fontMetrics->size(0, t_mem_addr->text());
t_mem_addr->setFixedSize(textSize.width() + 10, textSize.height() + 10);
QSize textSize = m_fontMetrics->size(0, m_mem_addr->text());
m_mem_addr->setFixedSize(textSize.width() + 10, textSize.height() + 10);
textSize = fontMetrics->size(0, t_mem_hex->text());
t_mem_hex->setFixedSize(textSize.width() + 10, textSize.height() + 10);
textSize = m_fontMetrics->size(0, m_mem_hex->text());
m_mem_hex->setFixedSize(textSize.width() + 10, textSize.height() + 10);
textSize = fontMetrics->size(0, t_mem_ascii->text());
t_mem_ascii->setFixedSize(textSize.width() + 10, textSize.height() + 10);
textSize = m_fontMetrics->size(0, m_mem_ascii->text());
m_mem_ascii->setFixedSize(textSize.width() + 10, textSize.height() + 10);
}
void memory_viewer_panel::SetPC(const uint pc)