1
0
Fork 0

Merge pull request #3083 from torusrxxx/patch000000db

Set proper default style for example text in appearance dialog
This commit is contained in:
Duncan Ogilvie 2023-05-07 15:33:52 +02:00 committed by GitHub
commit fbff8ac5aa
Signed by: GitHub
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 86 additions and 145 deletions

View File

@ -182,9 +182,13 @@ void AppearanceDialog::on_editBackgroundColor_textChanged(const QString & arg1)
GuiUpdateAllViews(); GuiUpdateAllViews();
} }
if(QColor(ui->editColor->text()).isValid()) if(QColor(ui->editColor->text()).isValid())
ui->exampleText->setStyleSheet(QString("color: %1").arg(ui->editColor->text())); text = ui->editColor->text();
else else
ui->exampleText->setStyleSheet(QString("color: black")); text = "black";
if(ConfigColor(colorInfoList.at(colorInfoIndex).defaultBackgroundColorName).alpha())
ui->exampleText->setStyleSheet(QString("color: %1; background-color: %2").arg(text).arg(ConfigColor(colorInfoList.at(colorInfoIndex).defaultBackgroundColorName).name()));
else
ui->exampleText->setStyleSheet(QString("color: %1").arg(text));
} }
else else
{ {
@ -206,6 +210,7 @@ void AppearanceDialog::on_editBackgroundColor_textChanged(const QString & arg1)
if(colorMap->contains(id)) if(colorMap->contains(id))
ui->buttonSave->setEnabled(false); //we cannot save with an invalid color ui->buttonSave->setEnabled(false); //we cannot save with an invalid color
} }
// Update the styles of example text
if(ui->editBackgroundColor->isEnabled()) if(ui->editBackgroundColor->isEnabled())
{ {
if(QColor(ui->editColor->text()).isValid()) if(QColor(ui->editColor->text()).isValid())
@ -220,7 +225,7 @@ void AppearanceDialog::on_editBackgroundColor_textChanged(const QString & arg1)
else else
ui->exampleText->setStyleSheet(QString("color: black")); ui->exampleText->setStyleSheet(QString("color: black"));
} }
ui->exampleText->setFont(ConfigFont("AbstractTableView")); ui->exampleText->setFont(ConfigFont(colorInfoList.at(colorInfoIndex).defaultFontName));
} }
ui->buttonBackgroundColor->setStyleSheet(styleSheet); ui->buttonBackgroundColor->setStyleSheet(styleSheet);
} }
@ -252,11 +257,18 @@ void AppearanceDialog::on_editColor_textChanged(const QString & arg1)
emit Config()->colorsUpdated(); emit Config()->colorsUpdated();
GuiUpdateAllViews(); GuiUpdateAllViews();
} }
// Update the styles of example text
if(QColor(ui->editBackgroundColor->text()).isValid() && ui->editBackgroundColor->isEnabled()) if(QColor(ui->editBackgroundColor->text()).isValid() && ui->editBackgroundColor->isEnabled())
ui->exampleText->setStyleSheet(QString("color: %1; background-color: %2").arg(arg1).arg(ui->editBackgroundColor->text())); ui->exampleText->setStyleSheet(QString("color: %1; background-color: %2").arg(arg1).arg(ui->editBackgroundColor->text()));
else if((!ui->editBackgroundColor->isEnabled() || ui->editBackgroundColor->text() == "#XXXXXX") && ConfigColor(colorInfoList.at(colorInfoIndex).defaultBackgroundColorName).alpha())
{
//GuiAddLogMessage(colorInfoList.at(colorInfoIndex).defaultBackgroundColorName.toUtf8().constData());
//GuiAddLogMessage(ConfigColor(colorInfoList.at(colorInfoIndex).defaultBackgroundColorName).name().toUtf8().constData());
ui->exampleText->setStyleSheet(QString("color: %1; background-color: %2").arg(ui->editColor->text()).arg(ConfigColor(colorInfoList.at(colorInfoIndex).defaultBackgroundColorName).name()));
}
else else
ui->exampleText->setStyleSheet(QString("color: %1").arg(arg1)); ui->exampleText->setStyleSheet(QString("color: %1").arg(arg1));
ui->exampleText->setFont(ConfigFont("AbstractTableView")); ui->exampleText->setFont(ConfigFont(colorInfoList.at(colorInfoIndex).defaultFontName));
} }
else else
{ {
@ -297,11 +309,7 @@ void AppearanceDialog::on_listColorNames_itemSelectionChanged()
defaultValueAction->setEnabled(true); defaultValueAction->setEnabled(true);
currentSettingAction->setEnabled(true); currentSettingAction->setEnabled(true);
QColor color = (*colorMap)[id]; ui->editColor->setText(colorToString((*colorMap)[id]));
QString colorText = color.name().toUpper();
if(!color.alpha())
colorText = "#XXXXXX";
ui->editColor->setText(colorText);
} }
else else
ui->editColor->setText("#FFFFFF"); ui->editColor->setText("#FFFFFF");
@ -319,11 +327,7 @@ void AppearanceDialog::on_listColorNames_itemSelectionChanged()
defaultValueAction->setEnabled(true); defaultValueAction->setEnabled(true);
currentSettingAction->setEnabled(true); currentSettingAction->setEnabled(true);
QColor color = (*colorMap)[id]; ui->editBackgroundColor->setText(colorToString((*colorMap)[id]));
QString colorText = color.name().toUpper();
if(!color.alpha())
colorText = "#XXXXXX";
ui->editBackgroundColor->setText(colorText);
} }
else else
ui->editBackgroundColor->setText("#FFFFFF"); ui->editBackgroundColor->setText("#FFFFFF");
@ -349,11 +353,7 @@ void AppearanceDialog::defaultValueSlot()
QString id = info.colorName; QString id = info.colorName;
if(Config()->defaultColors.contains(id)) if(Config()->defaultColors.contains(id))
{ {
QColor color = Config()->defaultColors[id]; ui->editColor->setText(colorToString(Config()->defaultColors[id]));
QString colorText = color.name().toUpper();
if(!color.alpha())
colorText = "#XXXXXX";
ui->editColor->setText(colorText);
} }
} }
if(info.backgroundColorName.length()) if(info.backgroundColorName.length())
@ -361,11 +361,7 @@ void AppearanceDialog::defaultValueSlot()
QString id = info.backgroundColorName; QString id = info.backgroundColorName;
if(Config()->defaultColors.contains(id)) if(Config()->defaultColors.contains(id))
{ {
QColor color = Config()->defaultColors[id]; ui->editBackgroundColor->setText(colorToString(Config()->defaultColors[id]));
QString colorText = color.name().toUpper();
if(!color.alpha())
colorText = "#XXXXXX";
ui->editBackgroundColor->setText(colorText);
} }
} }
} }
@ -378,11 +374,7 @@ void AppearanceDialog::currentSettingSlot()
QString id = info.colorName; QString id = info.colorName;
if(colorBackupMap.contains(id)) if(colorBackupMap.contains(id))
{ {
QColor color = colorBackupMap[id]; ui->editColor->setText(colorToString(colorBackupMap[id]));
QString colorText = color.name().toUpper();
if(!color.alpha())
colorText = "#XXXXXX";
ui->editColor->setText(colorText);
} }
} }
if(info.backgroundColorName.length()) if(info.backgroundColorName.length())
@ -390,21 +382,19 @@ void AppearanceDialog::currentSettingSlot()
QString id = info.backgroundColorName; QString id = info.backgroundColorName;
if(colorBackupMap.contains(id)) if(colorBackupMap.contains(id))
{ {
QColor color = colorBackupMap[id]; ui->editBackgroundColor->setText(colorToString(colorBackupMap[id]));
QString colorText = color.name().toUpper();
if(!color.alpha())
colorText = "#XXXXXX";
ui->editBackgroundColor->setText(colorText);
} }
} }
} }
void AppearanceDialog::colorInfoListCategory(QString categoryName) void AppearanceDialog::colorInfoListCategory(QString categoryName, const QString & currentBackgroundColorName, const QString & currentFontName)
{ {
// Remove the (now) redundant colon // Remove the (now) redundant colon
while(categoryName[categoryName.length() - 1] == ':') while(categoryName[categoryName.length() - 1] == ':')
categoryName.resize(categoryName.length() - 1); categoryName.resize(categoryName.length() - 1);
currentCategory = new QTreeWidgetItem(QList<QString>({ categoryName })); currentCategory = new QTreeWidgetItem(QList<QString>({ categoryName }));
this->currentBackgroundColorName = currentBackgroundColorName;
this->currentFontName = currentFontName;
ui->listColorNames->addTopLevelItem(currentCategory); ui->listColorNames->addTopLevelItem(currentCategory);
} }
@ -414,6 +404,8 @@ void AppearanceDialog::colorInfoListAppend(QString propertyName, QString colorNa
info.propertyName = propertyName; info.propertyName = propertyName;
info.colorName = colorName; info.colorName = colorName;
info.backgroundColorName = backgroundColorName; info.backgroundColorName = backgroundColorName;
info.defaultBackgroundColorName = currentBackgroundColorName;
info.defaultFontName = currentFontName;
colorInfoList.append(info); colorInfoList.append(info);
auto item = new QTreeWidgetItem(currentCategory, QList<QString>({ propertyName })); auto item = new QTreeWidgetItem(currentCategory, QList<QString>({ propertyName }));
item->setData(0, Qt::UserRole, QVariant(colorInfoIndex)); item->setData(0, Qt::UserRole, QVariant(colorInfoIndex));
@ -426,7 +418,7 @@ void AppearanceDialog::colorInfoListInit()
//clear list //clear list
colorInfoIndex = 1; colorInfoIndex = 1;
colorInfoList.clear(); colorInfoList.clear();
colorInfoList.append(ColorInfo({"", "", ""})); // default, not editable colorInfoList.append(ColorInfo({"", "", "", "AbstractTableViewBackgroundColor", "AbstractTableView"})); // default, not editable
//list entries //list entries
// Guide lines for entry order: // Guide lines for entry order:
@ -436,7 +428,7 @@ void AppearanceDialog::colorInfoListInit()
// 2. others are sorted by read direction (Top to down / left to right) // 2. others are sorted by read direction (Top to down / left to right)
// Example: "Header Text", "Addresses", "Text",... // Example: "Header Text", "Addresses", "Text",...
// //
colorInfoListCategory(tr("General Tables:")); colorInfoListCategory(tr("General Tables:"), "AbstractTableViewBackgroundColor", "AbstractTableView");
colorInfoListAppend(tr("Background"), "AbstractTableViewBackgroundColor", ""); colorInfoListAppend(tr("Background"), "AbstractTableViewBackgroundColor", "");
colorInfoListAppend(tr("Selection"), "AbstractTableViewSelectionColor", ""); colorInfoListAppend(tr("Selection"), "AbstractTableViewSelectionColor", "");
colorInfoListAppend(tr("Header Text"), "AbstractTableViewHeaderTextColor", ""); colorInfoListAppend(tr("Header Text"), "AbstractTableViewHeaderTextColor", "");
@ -444,7 +436,7 @@ void AppearanceDialog::colorInfoListInit()
colorInfoListAppend(tr("Separators"), "AbstractTableViewSeparatorColor", ""); colorInfoListAppend(tr("Separators"), "AbstractTableViewSeparatorColor", "");
colorInfoListCategory(tr("Disassembly:")); colorInfoListCategory(tr("Disassembly:"), "DisassemblyBackgroundColor", "Disassembly");
colorInfoListAppend(tr("Background"), "DisassemblyBackgroundColor", ""); colorInfoListAppend(tr("Background"), "DisassemblyBackgroundColor", "");
colorInfoListAppend(tr("Selection"), "DisassemblySelectionColor", ""); colorInfoListAppend(tr("Selection"), "DisassemblySelectionColor", "");
colorInfoListAppend(ArchValue(tr("EIP"), tr("RIP")), "DisassemblyCipColor", "DisassemblyCipBackgroundColor"); colorInfoListAppend(ArchValue(tr("EIP"), tr("RIP")), "DisassemblyCipColor", "DisassemblyCipBackgroundColor");
@ -469,7 +461,7 @@ void AppearanceDialog::colorInfoListInit()
colorInfoListAppend(tr("Loop Lines"), "DisassemblyLoopColor", ""); colorInfoListAppend(tr("Loop Lines"), "DisassemblyLoopColor", "");
colorInfoListCategory(tr("SideBar:")); colorInfoListCategory(tr("SideBar:"), "SideBarBackgroundColor", "Disassembly");
colorInfoListAppend(tr("Background"), "SideBarBackgroundColor", ""); colorInfoListAppend(tr("Background"), "SideBarBackgroundColor", "");
colorInfoListAppend(tr("Register Labels"), "SideBarCipLabelColor", "SideBarCipLabelBackgroundColor"); colorInfoListAppend(tr("Register Labels"), "SideBarCipLabelColor", "SideBarCipLabelBackgroundColor");
colorInfoListAppend(tr("Conditional Jump Lines (jump)"), "SideBarConditionalJumpLineTrueColor", ""); colorInfoListAppend(tr("Conditional Jump Lines (jump)"), "SideBarConditionalJumpLineTrueColor", "");
@ -487,7 +479,7 @@ void AppearanceDialog::colorInfoListInit()
colorInfoListAppend(tr("Bookmark bullets"), "SideBarBulletBookmarkColor", ""); colorInfoListAppend(tr("Bookmark bullets"), "SideBarBulletBookmarkColor", "");
colorInfoListCategory(tr("Registers:")); colorInfoListCategory(tr("Registers:"), "RegistersBackgroundColor", "Registers");
colorInfoListAppend(tr("Background"), "RegistersBackgroundColor", ""); colorInfoListAppend(tr("Background"), "RegistersBackgroundColor", "");
colorInfoListAppend(tr("Selection"), "RegistersSelectionColor", ""); colorInfoListAppend(tr("Selection"), "RegistersSelectionColor", "");
colorInfoListAppend(tr("Register Names"), "RegistersLabelColor", ""); colorInfoListAppend(tr("Register Names"), "RegistersLabelColor", "");
@ -500,7 +492,7 @@ void AppearanceDialog::colorInfoListInit()
colorInfoListAppend(tr("Extra Information"), "RegistersExtraInfoColor", ""); colorInfoListAppend(tr("Extra Information"), "RegistersExtraInfoColor", "");
colorInfoListCategory(tr("Instructions:")); colorInfoListCategory(tr("Instructions:"), "DisassemblyBackgroundColor", "Disassembly");
colorInfoListAppend(tr("Mnemonics"), "InstructionMnemonicColor", "InstructionMnemonicBackgroundColor"); colorInfoListAppend(tr("Mnemonics"), "InstructionMnemonicColor", "InstructionMnemonicBackgroundColor");
colorInfoListAppend(tr("Push/Pops"), "InstructionPushPopColor", "InstructionPushPopBackgroundColor"); colorInfoListAppend(tr("Push/Pops"), "InstructionPushPopColor", "InstructionPushPopBackgroundColor");
colorInfoListAppend(tr("Calls"), "InstructionCallColor", "InstructionCallBackgroundColor"); colorInfoListAppend(tr("Calls"), "InstructionCallColor", "InstructionCallBackgroundColor");
@ -535,7 +527,7 @@ void AppearanceDialog::colorInfoListInit()
colorInfoListAppend(tr("Highlighting"), "InstructionHighlightColor", "InstructionHighlightBackgroundColor"); colorInfoListAppend(tr("Highlighting"), "InstructionHighlightColor", "InstructionHighlightBackgroundColor");
colorInfoListCategory(tr("HexDump:")); colorInfoListCategory(tr("HexDump:"), "HexDumpBackgroundColor", "HexDump");
colorInfoListAppend(tr("Background"), "HexDumpBackgroundColor", ""); colorInfoListAppend(tr("Background"), "HexDumpBackgroundColor", "");
colorInfoListAppend(tr("Selection"), "HexDumpSelectionColor", ""); colorInfoListAppend(tr("Selection"), "HexDumpSelectionColor", "");
colorInfoListAppend(tr("Addresses"), "HexDumpAddressColor", "HexDumpAddressBackgroundColor"); colorInfoListAppend(tr("Addresses"), "HexDumpAddressColor", "HexDumpAddressBackgroundColor");
@ -555,7 +547,7 @@ void AppearanceDialog::colorInfoListInit()
colorInfoListAppend(tr("Unknown Data Pointer Highlight Color"), "HexDumpUnknownDataPointerHighlightColor", ""); colorInfoListAppend(tr("Unknown Data Pointer Highlight Color"), "HexDumpUnknownDataPointerHighlightColor", "");
colorInfoListCategory(tr("Stack:")); colorInfoListCategory(tr("Stack:"), "StackBackgroundColor", "Stack");
colorInfoListAppend(tr("Background"), "StackBackgroundColor", ""); colorInfoListAppend(tr("Background"), "StackBackgroundColor", "");
colorInfoListAppend(ArchValue(tr("ESP"), tr("RSP")), "StackCspColor", "StackCspBackgroundColor"); colorInfoListAppend(ArchValue(tr("ESP"), tr("RSP")), "StackCspColor", "StackCspBackgroundColor");
colorInfoListAppend(tr("Addresses"), "StackAddressColor", "StackAddressBackgroundColor"); colorInfoListAppend(tr("Addresses"), "StackAddressColor", "StackAddressBackgroundColor");
@ -570,14 +562,14 @@ void AppearanceDialog::colorInfoListInit()
colorInfoListAppend(tr("SEH Chain Comment"), "StackSEHChainColor", ""); colorInfoListAppend(tr("SEH Chain Comment"), "StackSEHChainColor", "");
colorInfoListCategory(tr("HexEdit:")); colorInfoListCategory(tr("HexEdit:"), "HexEditBackgroundColor", "HexEdit");
colorInfoListAppend(tr("Background"), "HexEditBackgroundColor", ""); colorInfoListAppend(tr("Background"), "HexEditBackgroundColor", "");
colorInfoListAppend(tr("Selection"), "HexEditSelectionColor", ""); colorInfoListAppend(tr("Selection"), "HexEditSelectionColor", "");
colorInfoListAppend(tr("Text"), "HexEditTextColor", ""); colorInfoListAppend(tr("Text"), "HexEditTextColor", "");
colorInfoListAppend(tr("Wildcards"), "HexEditWildcardColor", ""); colorInfoListAppend(tr("Wildcards"), "HexEditWildcardColor", "");
colorInfoListCategory(tr("Graph:")); colorInfoListCategory(tr("Graph:"), "GraphBackgroundColor", "Disassembly");
colorInfoListAppend(tr("Background"), "GraphBackgroundColor", ""); colorInfoListAppend(tr("Background"), "GraphBackgroundColor", "");
colorInfoListAppend(ArchValue(tr("EIP"), tr("RIP")), "GraphCipColor", ""); colorInfoListAppend(ArchValue(tr("EIP"), tr("RIP")), "GraphCipColor", "");
colorInfoListAppend(tr("Breakpoint"), "GraphBreakpointColor", ""); colorInfoListAppend(tr("Breakpoint"), "GraphBreakpointColor", "");
@ -590,10 +582,12 @@ void AppearanceDialog::colorInfoListInit()
colorInfoListAppend(tr("True branch line"), "GraphBrtrueColor", ""); colorInfoListAppend(tr("True branch line"), "GraphBrtrueColor", "");
colorInfoListAppend(tr("False branch line"), "GraphBrfalseColor", ""); colorInfoListAppend(tr("False branch line"), "GraphBrfalseColor", "");
colorInfoListCategory(tr("Log:"), "LogBackgroundColor", "Log");
colorInfoListCategory(tr("Other:")); colorInfoListAppend(tr("Log"), "LogColor", "LogBackgroundColor");
colorInfoListAppend(tr("Background Flicker Color"), "BackgroundFlickerColor", "");
colorInfoListAppend(tr("Log Link Color") + "*", "LogLinkColor", "LogLinkBackgroundColor"); colorInfoListAppend(tr("Log Link Color") + "*", "LogLinkColor", "LogLinkBackgroundColor");
colorInfoListCategory(tr("Other:"), "AbstractTableViewBackgroundColor", "AbstractTableView");
colorInfoListAppend(tr("Background Flicker Color"), "BackgroundFlickerColor", "");
colorInfoListAppend(tr("Search Highlight Color"), "SearchListViewHighlightColor", "SearchListViewHighlightBackgroundColor"); colorInfoListAppend(tr("Search Highlight Color"), "SearchListViewHighlightColor", "SearchListViewHighlightBackgroundColor");
colorInfoListAppend(tr("Patch located in relocation region"), "PatchRelocatedByteHighlightColor", ""); colorInfoListAppend(tr("Patch located in relocation region"), "PatchRelocatedByteHighlightColor", "");
colorInfoListAppend(tr("Current Thread"), "ThreadCurrentColor", "ThreadCurrentBackgroundColor"); colorInfoListAppend(tr("Current Thread"), "ThreadCurrentColor", "ThreadCurrentBackgroundColor");
@ -649,107 +643,39 @@ void AppearanceDialog::colorInfoListInit()
ui->listColorNames->addAction(currentSettingAction); ui->listColorNames->addAction(currentSettingAction);
} }
static void fontInitHelper(const QFont & font, QFontComboBox & fontSelector, QComboBox & style, QComboBox & sizes)
{
fontSelector.setCurrentFont(QFont(font.family()));
if(font.bold() && font.italic())
style.setCurrentIndex(3);
else if(font.italic())
style.setCurrentIndex(2);
else if(font.bold())
style.setCurrentIndex(1);
else
style.setCurrentIndex(0);
int index = sizes.findText(QString("%1").arg(font.pointSize()));
if(index != -1)
sizes.setCurrentIndex(index);
}
void AppearanceDialog::fontInit() void AppearanceDialog::fontInit()
{ {
isInit = true; isInit = true;
//AbstractTableView //AbstractTableView
QFont font = fontMap->find("AbstractTableView").value(); fontInitHelper(fontMap->find("AbstractTableView").value(), *ui->fontAbstractTables, *ui->fontAbstractTablesStyle, *ui->fontAbstractTablesSize);
ui->fontAbstractTables->setCurrentFont(QFont(font.family()));
if(font.bold() && font.italic())
ui->fontAbstractTablesStyle->setCurrentIndex(3);
else if(font.italic())
ui->fontAbstractTablesStyle->setCurrentIndex(2);
else if(font.bold())
ui->fontAbstractTablesStyle->setCurrentIndex(1);
else
ui->fontAbstractTablesStyle->setCurrentIndex(0);
int index = ui->fontAbstractTablesSize->findText(QString("%1").arg(font.pointSize()));
if(index != -1)
ui->fontAbstractTablesSize->setCurrentIndex(index);
//Disassembly //Disassembly
font = fontMap->find("Disassembly").value(); fontInitHelper(fontMap->find("Disassembly").value(), *ui->fontDisassembly, *ui->fontDisassemblyStyle, *ui->fontDisassemblySize);
ui->fontDisassembly->setCurrentFont(QFont(font.family()));
if(font.bold() && font.italic())
ui->fontDisassemblyStyle->setCurrentIndex(3);
else if(font.italic())
ui->fontDisassemblyStyle->setCurrentIndex(2);
else if(font.bold())
ui->fontDisassemblyStyle->setCurrentIndex(1);
else
ui->fontDisassemblyStyle->setCurrentIndex(0);
index = ui->fontDisassemblySize->findText(QString("%1").arg(font.pointSize()));
if(index != -1)
ui->fontDisassemblySize->setCurrentIndex(index);
//HexDump //HexDump
font = fontMap->find("HexDump").value(); fontInitHelper(fontMap->find("HexDump").value(), *ui->fontHexDump, *ui->fontHexDumpStyle, *ui->fontHexDumpSize);
ui->fontHexDump->setCurrentFont(QFont(font.family()));
if(font.bold() && font.italic())
ui->fontHexDumpStyle->setCurrentIndex(3);
else if(font.italic())
ui->fontHexDumpStyle->setCurrentIndex(2);
else if(font.bold())
ui->fontHexDumpStyle->setCurrentIndex(1);
else
ui->fontHexDumpStyle->setCurrentIndex(0);
index = ui->fontHexDumpSize->findText(QString("%1").arg(font.pointSize()));
if(index != -1)
ui->fontHexDumpSize->setCurrentIndex(index);
//Stack //Stack
font = fontMap->find("Stack").value(); fontInitHelper(fontMap->find("Stack").value(), *ui->fontStack, *ui->fontStackStyle, *ui->fontStackSize);
ui->fontStack->setCurrentFont(QFont(font.family()));
if(font.bold() && font.italic())
ui->fontStackStyle->setCurrentIndex(3);
else if(font.italic())
ui->fontStackStyle->setCurrentIndex(2);
else if(font.bold())
ui->fontStackStyle->setCurrentIndex(1);
else
ui->fontStackStyle->setCurrentIndex(0);
index = ui->fontStackSize->findText(QString("%1").arg(font.pointSize()));
if(index != -1)
ui->fontStackSize->setCurrentIndex(index);
//Registers //Registers
font = fontMap->find("Registers").value(); fontInitHelper(fontMap->find("Registers").value(), *ui->fontRegisters, *ui->fontRegistersStyle, *ui->fontRegistersSize);
ui->fontRegisters->setCurrentFont(QFont(font.family()));
if(font.bold() && font.italic())
ui->fontRegistersStyle->setCurrentIndex(3);
else if(font.italic())
ui->fontRegistersStyle->setCurrentIndex(2);
else if(font.bold())
ui->fontRegistersStyle->setCurrentIndex(1);
else
ui->fontRegistersStyle->setCurrentIndex(0);
index = ui->fontRegistersSize->findText(QString("%1").arg(font.pointSize()));
if(index != -1)
ui->fontRegistersSize->setCurrentIndex(index);
//HexEdit //HexEdit
font = fontMap->find("HexEdit").value(); fontInitHelper(fontMap->find("HexEdit").value(), *ui->fontHexEdit, *ui->fontHexEditStyle, *ui->fontHexEditSize);
ui->fontHexEdit->setCurrentFont(QFont(font.family()));
if(font.bold() && font.italic())
ui->fontHexEditStyle->setCurrentIndex(3);
else if(font.italic())
ui->fontHexEditStyle->setCurrentIndex(2);
else if(font.bold())
ui->fontHexEditStyle->setCurrentIndex(1);
else
ui->fontHexEditStyle->setCurrentIndex(0);
index = ui->fontHexEditSize->findText(QString("%1").arg(font.pointSize()));
if(index != -1)
ui->fontHexEditSize->setCurrentIndex(index);
//Log //Log
font = fontMap->find("Log").value(); fontInitHelper(fontMap->find("Log").value(), *ui->fontLog, *ui->fontLogStyle, *ui->fontLogSize);
ui->fontLog->setCurrentFont(QFont(font.family()));
if(font.bold() && font.italic())
ui->fontLogStyle->setCurrentIndex(3);
else if(font.italic())
ui->fontLogStyle->setCurrentIndex(2);
else if(font.bold())
ui->fontLogStyle->setCurrentIndex(1);
else
ui->fontLogStyle->setCurrentIndex(0);
index = ui->fontLogSize->findText(QString("%1").arg(font.pointSize()));
if(index != -1)
ui->fontLogSize->setCurrentIndex(index);
//Application //Application
ui->labelApplicationFont->setText(fontMap->find("Application").value().family()); ui->labelApplicationFont->setText(fontMap->find("Application").value().family());
isInit = false; isInit = false;
@ -811,7 +737,7 @@ QString AppearanceDialog::colorToString(const QColor & color)
{ {
if(!color.alpha()) if(!color.alpha())
return "#XXXXXX"; return "#XXXXXX";
return color.name(); return color.name().toUpper();
} }
void AppearanceDialog::on_fontAbstractTables_currentFontChanged(const QFont & f) void AppearanceDialog::on_fontAbstractTables_currentFontChanged(const QFont & f)

View File

@ -89,6 +89,8 @@ private:
QString propertyName; QString propertyName;
QString colorName; QString colorName;
QString backgroundColorName; QString backgroundColorName;
QString defaultBackgroundColorName;
QString defaultFontName;
}; };
QList<ColorInfo> colorInfoList; QList<ColorInfo> colorInfoList;
@ -101,10 +103,12 @@ private:
QAction* defaultValueAction; QAction* defaultValueAction;
QAction* currentSettingAction; QAction* currentSettingAction;
QTreeWidgetItem* currentCategory; QTreeWidgetItem* currentCategory;
QString currentBackgroundColorName;
QString currentFontName;
bool isInit; bool isInit;
void colorInfoListCategory(QString categoryName); void colorInfoListCategory(QString categoryName, const QString & currentBackgroundColorName, const QString & currentFontName);
void colorInfoListAppend(QString propertyName, QString colorName, QString backgroundColorName); void colorInfoListAppend(QString propertyName, QString colorName, QString backgroundColorName);
void colorInfoListInit(); void colorInfoListInit();
void fontInit(); void fontInit();

View File

@ -64,7 +64,7 @@ LogView::~LogView()
void LogView::updateStyle() void LogView::updateStyle()
{ {
setFont(ConfigFont("Log")); setFont(ConfigFont("Log"));
setStyleSheet(QString("QTextEdit { color: %1; background-color: %2 }").arg(ConfigColor("AbstractTableViewTextColor").name(), ConfigColor("AbstractTableViewBackgroundColor").name())); setStyleSheet(QString("QTextEdit { color: %1; background-color: %2 }").arg(ConfigColor("LogColor").name(), ConfigColor("LogBackgroundColor").name()));
QColor LogLinkBackgroundColor = ConfigColor("LogLinkBackgroundColor"); QColor LogLinkBackgroundColor = ConfigColor("LogLinkBackgroundColor");
this->document()->setDefaultStyleSheet(QString("a {color: %1; background-color: %2 }").arg(ConfigColor("LogLinkColor").name(), LogLinkBackgroundColor == Qt::transparent ? "transparent" : LogLinkBackgroundColor.name())); this->document()->setDefaultStyleSheet(QString("a {color: %1; background-color: %2 }").arg(ConfigColor("LogLinkColor").name(), LogLinkBackgroundColor == Qt::transparent ? "transparent" : LogLinkBackgroundColor.name()));

View File

@ -533,7 +533,8 @@ void ScriptView::unload()
void ScriptView::edit() void ScriptView::edit()
{ {
if(!filename.isEmpty()) if(!filename.isEmpty())
QDesktopServices::openUrl(QUrl(QDir::fromNativeSeparators(filename))); if(!QDesktopServices::openUrl(QUrl(QDir::fromNativeSeparators(filename))))
SimpleWarningBox(this, tr("Error!"), tr("File open failed! Please open the file yourself..."));
} }
void ScriptView::run() void ScriptView::run()

View File

@ -110,7 +110,12 @@ void SystemBreakpointScriptDialog::on_openDebuggee_clicked()
{ {
// First open the script if that is available // First open the script if that is available
if(!ui->lineEditDebuggee->text().isEmpty()) if(!ui->lineEditDebuggee->text().isEmpty())
QDesktopServices::openUrl(QUrl(QDir::fromNativeSeparators(ui->lineEditDebuggee->text()))); {
if(!QDesktopServices::openUrl(QUrl(QDir::fromNativeSeparators(ui->lineEditDebuggee->text()))))
{
SimpleWarningBox(this, tr("Error!"), tr("File open failed! Please open the file yourself..."));
}
}
else else
{ {
// Ask the user to create a new script // Ask the user to create a new script
@ -129,7 +134,10 @@ void SystemBreakpointScriptDialog::on_openDebuggee_clicked()
ui->lineEditDebuggee->setText(defaultFileName); ui->lineEditDebuggee->setText(defaultFileName);
ui->openDebuggee->setText(tr("Open")); ui->openDebuggee->setText(tr("Open"));
// Open the file // Open the file
QDesktopServices::openUrl(QUrl(QDir::fromNativeSeparators(ui->lineEditDebuggee->text()))); if(!QDesktopServices::openUrl(QUrl(QDir::fromNativeSeparators(ui->lineEditDebuggee->text()))))
{
SimpleWarningBox(this, tr("Error!"), tr("File open failed! Please open the file yourself..."));
}
} }
} }
} }

View File

@ -248,6 +248,8 @@ Configuration::Configuration() : QObject(), noMoreMsgbox(false)
defaultColors.insert("SymbolLoadedTextColor", QColor("#008000")); defaultColors.insert("SymbolLoadedTextColor", QColor("#008000"));
defaultColors.insert("BackgroundFlickerColor", QColor("#ff6961")); defaultColors.insert("BackgroundFlickerColor", QColor("#ff6961"));
defaultColors.insert("LinkColor", QColor("#0000ff")); defaultColors.insert("LinkColor", QColor("#0000ff"));
defaultColors.insert("LogColor", QColor("#000000"));
defaultColors.insert("LogBackgroundColor", QColor("#FFF8F0"));
//bool settings //bool settings
QMap<QString, bool> disassemblyBool; QMap<QString, bool> disassemblyBool;