1
0
Fork 0

GUI: option for UTF16 log redirection

This commit is contained in:
mrexodia 2016-11-27 16:06:47 +01:00
parent e72cff052a
commit 0d27aeb160
No known key found for this signature in database
GPG Key ID: FC89E0AAA0C1AAD8
7 changed files with 44 additions and 14 deletions

View File

@ -27,6 +27,10 @@ LogView::LogView(QWidget* parent) : QTextBrowser(parent), logRedirection(NULL)
connect(Bridge::getBridge(), SIGNAL(setLogEnabled(bool)), this, SLOT(setLoggingEnabled(bool)));
connect(this, SIGNAL(anchorClicked(QUrl)), this, SLOT(onAnchorClicked(QUrl)));
duint setting;
if(BridgeSettingGetUint("Misc", "Utf16LogRedirect", &setting))
utf16Redirect = !!setting;
setupContextMenu();
}
@ -160,8 +164,11 @@ void LogView::addMsgToLogSlot(QString msg)
// redirect the log
if(logRedirection != NULL)
{
auto utf8 = msg.toUtf8();
if(!fwrite(utf8.constData(), utf8.size(), 1, logRedirection))
if(utf16Redirect)
msg.replace("\n", "\r\n");
msg.utf16();
auto data = utf16Redirect ? QByteArray((const char*)msg.utf16(), msg.size() * 2) : msg.toUtf8();
if(!fwrite(data.constData(), data.size(), 1, logRedirection))
{
fclose(logRedirection);
logRedirection = NULL;
@ -177,6 +184,8 @@ void LogView::addMsgToLogSlot(QString msg)
cursor.movePosition(QTextCursor::End);
if(autoScroll)
this->moveCursor(QTextCursor::End);
if(utf16Redirect)
msg.replace("\r\n", "\n");
msg.replace(QChar('&'), QString("&"));
msg.replace(QChar('<'), QString("&lt;"));
msg.replace(QChar('>'), QString("&gt;"));
@ -252,7 +261,14 @@ void LogView::redirectLogSlot()
if(logRedirection == NULL)
GuiAddLogMessage(tr("_wfopen() failed. Log will not be redirected to %1.\n").arg(browse.path).toUtf8().constData());
else
{
if(utf16Redirect && ftell(logRedirection) == 0)
{
unsigned short BOM = 0xfeff;
fwrite(&BOM, 2, 1, logRedirection);
}
GuiAddLogMessage(tr("Log will be redirected to %1.\n").arg(browse.path).toUtf8().constData());
}
}
}
}

View File

@ -32,6 +32,7 @@ public slots:
private:
bool loggingEnabled;
bool autoScroll;
bool utf16Redirect = false;
QAction* actionCopy;
QAction* actionPaste;

View File

@ -219,7 +219,7 @@ MainWindow::MainWindow(QWidget* parent)
mWidgetList.push_back(WidgetInfo(mHandlesView, "HandlesTab"));
// If LoadSaveTabOrder disabled, load tabs in default order
if(!ConfigBool("Miscellaneous", "LoadSaveTabOrder"))
if(!ConfigBool("Gui", "LoadSaveTabOrder"))
loadTabDefaultOrder();
else
loadTabSavedOrder();

View File

@ -201,12 +201,14 @@ void SettingsDialog::LoadSettings()
GetSettingBool("Gui", "PidInHex", &settings.guiPidInHex);
GetSettingBool("Gui", "SidebarWatchLabels", &settings.guiSidebarWatchLabels);
GetSettingBool("Gui", "NoForegroundWindow", &settings.guiNoForegroundWindow);
GetSettingBool("Gui", "LoadSaveTabOrder", &settings.guiLoadSaveTabOrder);
ui->chkFpuRegistersLittleEndian->setChecked(settings.guiFpuRegistersLittleEndian);
ui->chkSaveColumnOrder->setChecked(settings.guiSaveColumnOrder);
ui->chkNoCloseDialog->setChecked(settings.guiNoCloseDialog);
ui->chkPidInHex->setChecked(settings.guiPidInHex);
ui->chkSidebarWatchLabels->setChecked(settings.guiSidebarWatchLabels);
ui->chkNoForegroundWindow->setChecked(settings.guiNoForegroundWindow);
ui->chkSaveLoadTabOrder->setChecked(settings.guiLoadSaveTabOrder);
//Misc tab
if(DbgFunctions()->GetJit)
@ -268,8 +270,8 @@ void SettingsDialog::LoadSettings()
bJitOld = settings.miscSetJIT;
bJitAutoOld = settings.miscSetJITAuto;
GetSettingBool("Miscellaneous", "LoadSaveTabOrder", &settings.miscLoadSaveTabOrder);
ui->chkSaveLoadTabOrder->setChecked(settings.miscLoadSaveTabOrder);
GetSettingBool("Misc", "Utf16LogRedirect", &settings.miscUtf16LogRedirect);
ui->chkUtf16LogRedirect->setChecked(settings.miscUtf16LogRedirect);
}
void SettingsDialog::SaveSettings()
@ -327,6 +329,7 @@ void SettingsDialog::SaveSettings()
BridgeSettingSetUint("Gui", "PidInHex", settings.guiPidInHex);
BridgeSettingSetUint("Gui", "SidebarWatchLabels", settings.guiSidebarWatchLabels);
BridgeSettingSetUint("Gui", "NoForegroundWindow", settings.guiNoForegroundWindow);
BridgeSettingSetUint("Gui", "LoadSaveTabOrder", settings.guiLoadSaveTabOrder);
//Misc tab
if(DbgFunctions()->GetJit)
@ -352,8 +355,7 @@ void SettingsDialog::SaveSettings()
if(settings.miscSymbolCache)
BridgeSettingSet("Symbols", "CachePath", ui->editSymbolCache->text().toUtf8().constData());
BridgeSettingSet("Misc", "HelpOnSymbolicNameUrl", ui->editHelpOnSymbolicNameUrl->text().toUtf8().constData());
BridgeSettingSetUint("Miscellaneous", "LoadSaveTabOrder", settings.miscLoadSaveTabOrder);
BridgeSettingSetUint("Misc", "Utf16LogRedirect", settings.miscUtf16LogRedirect);
BridgeSettingFlush();
Config()->load();
@ -677,7 +679,7 @@ void SettingsDialog::on_editSymbolCache_textEdited(const QString & arg1)
void SettingsDialog::on_chkSaveLoadTabOrder_stateChanged(int arg1)
{
settings.miscLoadSaveTabOrder = arg1 != Qt::Unchecked;
settings.guiLoadSaveTabOrder = arg1 != Qt::Unchecked;
emit chkSaveLoadTabOrderStateChanged((bool)arg1);
}
@ -736,3 +738,8 @@ void SettingsDialog::on_chkNoHighlightOperands_toggled(bool checked)
bTokenizerConfigUpdated = true;
settings.disasmNoHighlightOperands = checked;
}
void SettingsDialog::on_chkUtf16LogRedirect_toggled(bool checked)
{
settings.miscUtf16LogRedirect = checked;
}

View File

@ -79,6 +79,7 @@ private slots:
void on_chkConfirmBeforeAtt_stateChanged(int arg1);
void on_editSymbolStore_textEdited(const QString & arg1);
void on_editSymbolCache_textEdited(const QString & arg1);
void on_chkUtf16LogRedirect_toggled(bool checked);
private:
//enums
@ -154,12 +155,13 @@ private:
bool guiPidInHex;
bool guiSidebarWatchLabels;
bool guiNoForegroundWindow;
bool guiLoadSaveTabOrder;
//Misc Tab
bool miscSetJIT;
bool miscSetJITAuto;
bool miscSymbolStore;
bool miscSymbolCache;
bool miscLoadSaveTabOrder;
bool miscUtf16LogRedirect;
};
//variables

View File

@ -685,6 +685,13 @@
</item>
</layout>
</item>
<item>
<widget class="QCheckBox" name="chkUtf16LogRedirect">
<property name="text">
<string>UTF-16 Log Redirect*</string>
</property>
</widget>
</item>
<item>
<spacer name="verticalSpacer_3">
<property name="orientation">

View File

@ -209,16 +209,13 @@ Configuration::Configuration() : QObject(), noMoreMsgbox(false)
engineBool.insert("ShowSuspectedCallStack", false);
defaultBools.insert("Engine", engineBool);
QMap<QString, bool> miscellaneousBool;
miscellaneousBool.insert("LoadSaveTabOrder", false);
defaultBools.insert("Miscellaneous", miscellaneousBool);
QMap<QString, bool> guiBool;
guiBool.insert("FpuRegistersLittleEndian", false);
guiBool.insert("SaveColumnOrder", true);
guiBool.insert("NoCloseDialog", false);
guiBool.insert("PidInHex", true);
guiBool.insert("SidebarWatchLabels", true);
guiBool.insert("LoadSaveTabOrder", false);
//Named menu settings
insertMenuBuilderBools(&guiBool, "CPUDisassembly", 50); //CPUDisassembly
insertMenuBuilderBools(&guiBool, "CPUDump", 50); //CPUDump
@ -625,7 +622,7 @@ void Configuration::readUints()
void Configuration::writeUints()
{
duint setting;
bool bSaveLoadTabOrder = ConfigBool("Miscellaneous", "LoadSaveTabOrder");
bool bSaveLoadTabOrder = ConfigBool("Gui", "LoadSaveTabOrder");
//write config
for(int i = 0; i < Uints.size(); i++)