don't restore window pos invisible; clean up msgbox (#1632)
* don't restore window pos invisible; clean up msgbox * remembers more dialog position
This commit is contained in:
parent
e5a614432f
commit
a3a25e1695
|
@ -1,6 +1,7 @@
|
|||
#include "BrowseDialog.h"
|
||||
#include "ui_BrowseDialog.h"
|
||||
#include <QFileDialog>
|
||||
#include <Configuration.h>
|
||||
|
||||
BrowseDialog::BrowseDialog(QWidget* parent, const QString & title, const QString & text, const QString & filter, const QString & defaultPath, bool save) :
|
||||
QDialog(parent),
|
||||
|
@ -11,10 +12,12 @@ BrowseDialog::BrowseDialog(QWidget* parent, const QString & title, const QString
|
|||
setWindowTitle(title);
|
||||
ui->label->setText(text);
|
||||
ui->lineEdit->setText(QDir::toNativeSeparators(defaultPath));
|
||||
Config()->setupWindowPos(this);
|
||||
}
|
||||
|
||||
BrowseDialog::~BrowseDialog()
|
||||
{
|
||||
Config()->saveWindowPos(this);
|
||||
delete ui;
|
||||
}
|
||||
|
||||
|
|
|
@ -33,6 +33,7 @@ DataCopyDialog::DataCopyDialog(const QVector<byte_t>* data, QWidget* parent) : Q
|
|||
ui->comboType->setCurrentIndex(DataCByte);
|
||||
|
||||
printData((DataType)ui->comboType->currentIndex());
|
||||
Config()->setupWindowPos(this);
|
||||
}
|
||||
|
||||
QString DataCopyDialog::printEscapedString(bool & bPrevWasHex, int ch, const char* hexFormat)
|
||||
|
@ -319,6 +320,7 @@ void DataCopyDialog::printData(DataType type)
|
|||
|
||||
DataCopyDialog::~DataCopyDialog()
|
||||
{
|
||||
Config()->saveWindowPos(this);
|
||||
delete ui;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
#include "EntropyDialog.h"
|
||||
#include "ui_EntropyDialog.h"
|
||||
#include <Configuration.h>
|
||||
|
||||
EntropyDialog::EntropyDialog(QWidget* parent) :
|
||||
QDialog(parent),
|
||||
|
@ -11,10 +12,12 @@ EntropyDialog::EntropyDialog(QWidget* parent) :
|
|||
mBlockSize = 128;
|
||||
mPointCount = 300;
|
||||
mInitialized = false;
|
||||
Config()->setupWindowPos(this);
|
||||
}
|
||||
|
||||
EntropyDialog::~EntropyDialog()
|
||||
{
|
||||
Config()->saveWindowPos(this);
|
||||
delete ui;
|
||||
}
|
||||
|
||||
|
|
|
@ -67,6 +67,8 @@ FavouriteTools::FavouriteTools(QWidget* parent) :
|
|||
connect(ui->tabWidget, SIGNAL(currentChanged(int)), this, SLOT(tabChanged(int)));
|
||||
emit ui->listTools->itemSelectionChanged();
|
||||
updateToolsBtnEnabled();
|
||||
|
||||
Config()->setupWindowPos(this);
|
||||
}
|
||||
|
||||
void FavouriteTools::setupTools(QString name, QTableWidget* list)
|
||||
|
@ -484,6 +486,7 @@ void FavouriteTools::tabChanged(int i)
|
|||
|
||||
FavouriteTools::~FavouriteTools()
|
||||
{
|
||||
Config()->saveWindowPos(this);
|
||||
delete ui;
|
||||
}
|
||||
|
||||
|
|
|
@ -36,10 +36,12 @@ HexEditDialog::HexEditDialog(QWidget* parent) : QDialog(parent), ui(new Ui::HexE
|
|||
|
||||
updateStyle();
|
||||
updateCodepage();
|
||||
Config()->setupWindowPos(this);
|
||||
}
|
||||
|
||||
HexEditDialog::~HexEditDialog()
|
||||
{
|
||||
Config()->saveWindowPos(this);
|
||||
delete ui;
|
||||
}
|
||||
|
||||
|
|
|
@ -566,14 +566,9 @@ void MemoryMapView::memoryAllocateSlot()
|
|||
DbgCmdExecDirect(QString("alloc %1").arg(ToPtrString(memsize)).toUtf8().constData());
|
||||
duint addr = DbgValFromString("$result");
|
||||
if(addr != 0)
|
||||
{
|
||||
DbgCmdExec("dump $result");
|
||||
}
|
||||
else
|
||||
{
|
||||
SimpleErrorBox(this, tr("Error"), tr("Memory allocation failed!"));
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -630,10 +625,7 @@ void MemoryMapView::selectAddress(duint va)
|
|||
return;
|
||||
}
|
||||
}
|
||||
QMessageBox msg(QMessageBox::Critical, tr("Error"), tr("Address %0 not found in memory map...").arg(ToPtrString(va)));
|
||||
msg.setWindowIcon(DIcon("compile-error.png"));
|
||||
msg.exec();
|
||||
QMessageBox::warning(this, tr("Error"), QString());
|
||||
SimpleErrorBox(this, tr("Error"), tr("Address %0 not found in memory map...").arg(ToPtrString(va)));
|
||||
}
|
||||
|
||||
void MemoryMapView::gotoOriginSlot()
|
||||
|
|
|
@ -443,11 +443,7 @@ void PatchDialog::on_btnPatchFile_clicked()
|
|||
patchList.push_back(curPatchList.at(i).patch);
|
||||
if(!curPatchList.size() || !patchList.size())
|
||||
{
|
||||
QMessageBox msg(QMessageBox::Information, tr("Information"), tr("Nothing to patch!"));
|
||||
msg.setWindowIcon(DIcon("information.png"));
|
||||
msg.setParent(this, Qt::Dialog);
|
||||
msg.setWindowFlags(msg.windowFlags() & (~Qt::WindowContextHelpButtonHint));
|
||||
msg.exec();
|
||||
SimpleInfoBox(this, tr("Information"), tr("Nothing to patch!"));
|
||||
return;
|
||||
}
|
||||
char szModName[MAX_PATH] = "";
|
||||
|
@ -482,11 +478,7 @@ void PatchDialog::on_btnPatchFile_clicked()
|
|||
SimpleErrorBox(this, tr("Error!"), tr("Failed to save patched file (%1)").arg(error));
|
||||
return;
|
||||
}
|
||||
QMessageBox msg(QMessageBox::Information, tr("Information"), tr("%1/%2 patch(es) applied!").arg(patched).arg(patchList.size()));
|
||||
msg.setWindowIcon(DIcon("information.png"));
|
||||
msg.setParent(this, Qt::Dialog);
|
||||
msg.setWindowFlags(msg.windowFlags() & (~Qt::WindowContextHelpButtonHint));
|
||||
msg.exec();
|
||||
SimpleInfoBox(this, tr("Information"), tr("%1/%2 patch(es) applied!").arg(patched).arg(patchList.size()));
|
||||
}
|
||||
|
||||
void PatchDialog::on_btnImport_clicked()
|
||||
|
@ -567,11 +559,7 @@ void PatchDialog::on_btnImport_clicked()
|
|||
//Check if any patch exists
|
||||
if(!patchList.size())
|
||||
{
|
||||
QMessageBox msg(QMessageBox::Information, tr("Information"), tr("No patches to apply in the current process."));
|
||||
msg.setWindowIcon(DIcon("information.png"));
|
||||
msg.setParent(this, Qt::Dialog);
|
||||
msg.setWindowFlags(msg.windowFlags() & (~Qt::WindowContextHelpButtonHint));
|
||||
msg.exec();
|
||||
SimpleInfoBox(this, tr("Information"), tr("No patches to apply in the current process."));
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -619,11 +607,7 @@ void PatchDialog::on_btnImport_clicked()
|
|||
updatePatches();
|
||||
GuiUpdateAllViews();
|
||||
|
||||
QMessageBox msg(QMessageBox::Information, tr("Information"), tr("%1/%2 patch(es) applied!").arg(patched).arg(patchList.size()));
|
||||
msg.setWindowIcon(DIcon("information.png"));
|
||||
msg.setParent(this, Qt::Dialog);
|
||||
msg.setWindowFlags(msg.windowFlags() & (~Qt::WindowContextHelpButtonHint));
|
||||
msg.exec();
|
||||
SimpleInfoBox(this, tr("Information"), tr("%1/%2 patch(es) applied!").arg(patched).arg(patchList.size()));
|
||||
}
|
||||
|
||||
void PatchDialog::on_btnExport_clicked()
|
||||
|
@ -669,11 +653,7 @@ void PatchDialog::saveAs1337(const QString & filename)
|
|||
|
||||
if(!lines.size())
|
||||
{
|
||||
QMessageBox msg(QMessageBox::Information, tr("Information"), tr("No patches to export."));
|
||||
msg.setWindowIcon(DIcon("information.png"));
|
||||
msg.setParent(this, Qt::Dialog);
|
||||
msg.setWindowFlags(msg.windowFlags() & (~Qt::WindowContextHelpButtonHint));
|
||||
msg.exec();
|
||||
SimpleInfoBox(this, tr("Information"), tr("No patches to export."));
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -683,9 +663,5 @@ void PatchDialog::saveAs1337(const QString & filename)
|
|||
file.write(text.toUtf8().constData(), text.length());
|
||||
file.close();
|
||||
|
||||
QMessageBox msg(QMessageBox::Information, tr("Information"), tr("%1 patch(es) exported!").arg(patches));
|
||||
msg.setWindowIcon(DIcon("information.png"));
|
||||
msg.setParent(this, Qt::Dialog);
|
||||
msg.setWindowFlags(msg.windowFlags() & (~Qt::WindowContextHelpButtonHint));
|
||||
msg.exec();
|
||||
SimpleInfoBox(this, tr("Information"), tr("%1 patch(es) exported!").arg(patches));
|
||||
}
|
||||
|
|
|
@ -514,12 +514,7 @@ void SettingsDialog::on_chkSetJIT_stateChanged(int arg1)
|
|||
* Scenario 2: the JIT in Windows registry its NOT this debugger, if the database of the debugger
|
||||
* was removed and the user in MISC tab wants check and uncheck the JIT checkbox: he can (this block its NOT executed then).
|
||||
*/
|
||||
QMessageBox msg(QMessageBox::Warning, tr("ERROR NOT FOUND OLD JIT"), tr("NOT FOUND OLD JIT ENTRY STORED, USE SETJIT COMMAND"));
|
||||
msg.setWindowIcon(DIcon("compile-warning.png"));
|
||||
msg.setParent(this, Qt::Dialog);
|
||||
msg.setWindowFlags(msg.windowFlags() & (~Qt::WindowContextHelpButtonHint));
|
||||
msg.exec();
|
||||
|
||||
SimpleWarningBox(this, tr("ERROR NOT FOUND OLD JIT"), tr("NOT FOUND OLD JIT ENTRY STORED, USE SETJIT COMMAND"));
|
||||
settings.miscSetJIT = true;
|
||||
}
|
||||
else
|
||||
|
|
|
@ -55,32 +55,32 @@ void SimpleTraceDialog::on_btnOk_clicked()
|
|||
auto logCondition = ui->editLogCondition->addHistoryClear();
|
||||
if(!DbgCmdExecDirect(QString("TraceSetLog \"%1\", \"%2\"").arg(escapeText(logText), escapeText(logCondition)).toUtf8().constData()))
|
||||
{
|
||||
QMessageBox::warning(this, tr("Error"), tr("Failed to set log text/condition!"));
|
||||
SimpleWarningBox(this, tr("Error"), tr("Failed to set log text/condition!"));
|
||||
return;
|
||||
}
|
||||
auto commandText = ui->editCommandText->addHistoryClear();
|
||||
auto commandCondition = ui->editCommandCondition->addHistoryClear();
|
||||
if(!DbgCmdExecDirect(QString("TraceSetCommand \"%1\", \"%2\"").arg(escapeText(commandText), escapeText(commandCondition)).toUtf8().constData()))
|
||||
{
|
||||
QMessageBox::warning(this, tr("Error"), tr("Failed to set command text/condition!"));
|
||||
SimpleWarningBox(this, tr("Error"), tr("Failed to set command text/condition!"));
|
||||
return;
|
||||
}
|
||||
auto switchCondition = ui->editSwitchCondition->addHistoryClear();
|
||||
if(!DbgCmdExecDirect(QString("TraceSetSwitchCondition \"%1\"").arg(escapeText(switchCondition)).toUtf8().constData()))
|
||||
{
|
||||
QMessageBox::warning(this, tr("Error"), tr("Failed to set switch condition!"));
|
||||
SimpleWarningBox(this, tr("Error"), tr("Failed to set switch condition!"));
|
||||
return;
|
||||
}
|
||||
if(!DbgCmdExecDirect(QString("TraceSetLogFile \"%1\"").arg(escapeText(mLogFile)).toUtf8().constData()))
|
||||
{
|
||||
QMessageBox::warning(this, tr("Error"), tr("Failed to set log file!"));
|
||||
SimpleWarningBox(this, tr("Error"), tr("Failed to set log file!"));
|
||||
return;
|
||||
}
|
||||
auto breakCondition = ui->editBreakCondition->addHistoryClear();
|
||||
auto maxTraceCount = ui->spinMaxTraceCount->value();
|
||||
if(!DbgCmdExecDirect(QString("%1 \"%2\", .%3").arg(mTraceCommand, escapeText(breakCondition)).arg(maxTraceCount).toUtf8().constData()))
|
||||
{
|
||||
QMessageBox::warning(this, tr("Error"), tr("Failed to start trace!"));
|
||||
SimpleWarningBox(this, tr("Error"), tr("Failed to start trace!"));
|
||||
return;
|
||||
}
|
||||
accept();
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
#include "ui_WordEditDialog.h"
|
||||
#include "ValidateExpressionThread.h"
|
||||
#include "StringUtil.h"
|
||||
#include <Configuration.h>
|
||||
|
||||
WordEditDialog::WordEditDialog(QWidget* parent)
|
||||
: QDialog(parent),
|
||||
|
@ -24,6 +25,7 @@ WordEditDialog::WordEditDialog(QWidget* parent)
|
|||
connect(mValidateThread, SIGNAL(expressionChanged(bool, bool, dsint)), this, SLOT(expressionChanged(bool, bool, dsint)));
|
||||
connect(ui->expressionLineEdit, SIGNAL(textChanged(QString)), mValidateThread, SLOT(textChanged(QString)));
|
||||
mWord = 0;
|
||||
Config()->setupWindowPos(this);
|
||||
}
|
||||
|
||||
void WordEditDialog::validateExpression(QString expression)
|
||||
|
@ -36,6 +38,7 @@ void WordEditDialog::validateExpression(QString expression)
|
|||
|
||||
WordEditDialog::~WordEditDialog()
|
||||
{
|
||||
Config()->saveWindowPos(this);
|
||||
mValidateThread->stop();
|
||||
mValidateThread->wait();
|
||||
delete ui;
|
||||
|
|
|
@ -3,6 +3,8 @@
|
|||
#include <QFontInfo>
|
||||
#include <QMessageBox>
|
||||
#include <QIcon>
|
||||
#include <QScreen>
|
||||
#include <QGuiApplication>
|
||||
#include "AbstractTableView.h"
|
||||
|
||||
Configuration* Configuration::mPtr = nullptr;
|
||||
|
@ -308,6 +310,12 @@ Configuration::Configuration() : QObject(), noMoreMsgbox(false)
|
|||
addWindowPosConfig(guiUint, "AttachDialog");
|
||||
addWindowPosConfig(guiUint, "GotoDialog");
|
||||
addWindowPosConfig(guiUint, "EditBreakpointDialog");
|
||||
addWindowPosConfig(guiUint, "BrowseDialog");
|
||||
addWindowPosConfig(guiUint, "FavouriteTools");
|
||||
addWindowPosConfig(guiUint, "EntropyDialog");
|
||||
addWindowPosConfig(guiUint, "HexEditDialog");
|
||||
addWindowPosConfig(guiUint, "WordEditDialog");
|
||||
addWindowPosConfig(guiUint, "DataCopyDialog");
|
||||
defaultUints.insert("Gui", guiUint);
|
||||
|
||||
//uint settings
|
||||
|
@ -1111,17 +1119,28 @@ void Configuration::registerMainMenuStringList(QList<QAction*>* menu)
|
|||
NamedMenuBuilders.append(MenuMap(menu, menu->size() - 1));
|
||||
}
|
||||
|
||||
static bool IsPointVisible(QPoint pos)
|
||||
{
|
||||
for(const auto & i : QGuiApplication::screens())
|
||||
{
|
||||
QRect rt = i->geometry();
|
||||
if(rt.left() <= pos.x() && rt.right() >= pos.x() && rt.top() <= pos.y() && rt.bottom() >= pos.y())
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Configuration::setupWindowPos Moves the dialog to the saved position
|
||||
* @param window this
|
||||
*/
|
||||
void Configuration::setupWindowPos(QWidget* window)
|
||||
{
|
||||
duint X, Y;
|
||||
X = getUint("Gui", QString(window->metaObject()->className()) + "X");
|
||||
Y = getUint("Gui", QString(window->metaObject()->className()) + "Y");
|
||||
if(X != 0 && Y != 0)
|
||||
window->move(X, Y);
|
||||
QPoint pos;
|
||||
pos.setX(getUint("Gui", QString(window->metaObject()->className()) + "X"));
|
||||
pos.setY(getUint("Gui", QString(window->metaObject()->className()) + "Y"));
|
||||
if(pos.x() != 0 && pos.y() != 0 && IsPointVisible(pos))
|
||||
window->move(pos);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -58,6 +58,15 @@ void SimpleWarningBox(QWidget* parent, const QString & title, const QString & te
|
|||
msg.exec();
|
||||
}
|
||||
|
||||
void SimpleInfoBox(QWidget* parent, const QString & title, const QString & text)
|
||||
{
|
||||
QMessageBox msg(QMessageBox::Information, title, text, QMessageBox::NoButton, parent);
|
||||
msg.setWindowIcon(DIcon("information.png"));
|
||||
msg.setParent(parent, Qt::Dialog);
|
||||
msg.setWindowFlags(msg.windowFlags() & (~Qt::WindowContextHelpButtonHint));
|
||||
msg.exec();
|
||||
}
|
||||
|
||||
QString getSymbolicName(duint addr)
|
||||
{
|
||||
char labelText[MAX_LABEL_SIZE] = "";
|
||||
|
|
|
@ -12,6 +12,7 @@ QByteArray & ByteReverse(QByteArray & array);
|
|||
bool SimpleInputBox(QWidget* parent, const QString & title, QString defaultValue, QString & output, const QString & placeholderText, QIcon* icon = nullptr);
|
||||
void SimpleErrorBox(QWidget* parent, const QString & title, const QString & text);
|
||||
void SimpleWarningBox(QWidget* parent, const QString & title, const QString & text);
|
||||
void SimpleInfoBox(QWidget* parent, const QString & title, const QString & text);
|
||||
QString getSymbolicName(duint addr);
|
||||
bool isEaster();
|
||||
QString couldItBeSeasonal(QString icon);
|
||||
|
|
|
@ -49,9 +49,5 @@ void UpdateChecker::finishedSlot(QNetworkReply* reply)
|
|||
info = QString(tr("You have a development build (%1) of x64dbg!")).arg(ToDateString(build));
|
||||
else
|
||||
info = QString(tr("You have the latest build (%1) of x64dbg!")).arg(ToDateString(build));
|
||||
QMessageBox msg(QMessageBox::Information, tr("Information"), info);
|
||||
msg.setWindowIcon(DIcon("information.png"));
|
||||
msg.setParent(mParent, Qt::Dialog);
|
||||
msg.setWindowFlags(msg.windowFlags() & (~Qt::WindowContextHelpButtonHint));
|
||||
msg.exec();
|
||||
SimpleInfoBox(mParent, tr("Information"), info);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue