forked from qt-creator/qt-creator
LoadCoreDialog: focus changes on invalid input
- if, in that order, the following input is invalid or is missing, focus the widget which sets that information: kit; local or remote corefile; local executable filename Change-Id: I0255a0550656e2974fda755f3681c7a2d64a37de Reviewed-by: Orgad Shaneh <orgads@gmail.com> Reviewed-by: hjk <hjk121@nokiamail.com>
This commit is contained in:
@@ -218,6 +218,36 @@ public:
|
|||||||
PathChooser *overrideStartScriptFileName;
|
PathChooser *overrideStartScriptFileName;
|
||||||
|
|
||||||
QDialogButtonBox *buttonBox;
|
QDialogButtonBox *buttonBox;
|
||||||
|
|
||||||
|
struct State
|
||||||
|
{
|
||||||
|
bool isValid() const
|
||||||
|
{
|
||||||
|
return validKit && validLocalExecFilename && validCoreFilename;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool validKit;
|
||||||
|
bool validLocalExecFilename;
|
||||||
|
bool validCoreFilename;
|
||||||
|
bool localCoreFile;
|
||||||
|
bool localKit;
|
||||||
|
};
|
||||||
|
|
||||||
|
State getDialogState(const AttachCoreDialog &p) const
|
||||||
|
{
|
||||||
|
State st;
|
||||||
|
st.localCoreFile = p.useLocalCoreFile();
|
||||||
|
st.validKit = (kitChooser->currentKit() != 0);
|
||||||
|
st.validLocalExecFilename = localExecFileName->isValid();
|
||||||
|
|
||||||
|
if (st.localCoreFile)
|
||||||
|
st.validCoreFilename = localCoreFileName->isValid();
|
||||||
|
else
|
||||||
|
st.validCoreFilename = !p.remoteCoreFile().isEmpty();
|
||||||
|
|
||||||
|
st.localKit = p.isLocalKit();
|
||||||
|
return st;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
AttachCoreDialog::AttachCoreDialog(QWidget *parent)
|
AttachCoreDialog::AttachCoreDialog(QWidget *parent)
|
||||||
@@ -302,6 +332,18 @@ int AttachCoreDialog::exec()
|
|||||||
connect(d->buttonBox, SIGNAL(accepted()), SLOT(accept()));
|
connect(d->buttonBox, SIGNAL(accepted()), SLOT(accept()));
|
||||||
changed();
|
changed();
|
||||||
|
|
||||||
|
AttachCoreDialogPrivate::State st = d->getDialogState(*this);
|
||||||
|
if (!st.validKit) {
|
||||||
|
d->kitChooser->setFocus();
|
||||||
|
} else if (!st.validCoreFilename) {
|
||||||
|
if (st.localCoreFile)
|
||||||
|
d->localCoreFileName->setFocus();
|
||||||
|
else
|
||||||
|
d->remoteCoreFileName->setFocus();
|
||||||
|
} else if (!st.validLocalExecFilename) {
|
||||||
|
d->localExecFileName->setFocus();
|
||||||
|
}
|
||||||
|
|
||||||
return QDialog::exec();
|
return QDialog::exec();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -335,24 +377,21 @@ void AttachCoreDialog::coreFileChanged(const QString &core)
|
|||||||
|
|
||||||
void AttachCoreDialog::changed()
|
void AttachCoreDialog::changed()
|
||||||
{
|
{
|
||||||
bool isValid = d->kitChooser->currentKit() && d->localExecFileName->isValid();
|
AttachCoreDialogPrivate::State st = d->getDialogState(*this);
|
||||||
bool isKitLocal = isLocalKit();
|
|
||||||
|
|
||||||
d->forceLocalLabel->setVisible(!isKitLocal);
|
d->forceLocalLabel->setVisible(!st.localKit);
|
||||||
d->forceLocalCheckBox->setVisible(!isKitLocal);
|
d->forceLocalCheckBox->setVisible(!st.localKit);
|
||||||
if (useLocalCoreFile()) {
|
if (st.localCoreFile) {
|
||||||
d->localCoreFileName->setVisible(true);
|
d->localCoreFileName->setVisible(true);
|
||||||
d->remoteCoreFileName->setVisible(false);
|
d->remoteCoreFileName->setVisible(false);
|
||||||
d->selectRemoteCoreButton->setVisible(false);
|
d->selectRemoteCoreButton->setVisible(false);
|
||||||
isValid = isValid && d->localCoreFileName->isValid();
|
|
||||||
} else {
|
} else {
|
||||||
d->localCoreFileName->setVisible(false);
|
d->localCoreFileName->setVisible(false);
|
||||||
d->remoteCoreFileName->setVisible(true);
|
d->remoteCoreFileName->setVisible(true);
|
||||||
d->selectRemoteCoreButton->setVisible(true);
|
d->selectRemoteCoreButton->setVisible(true);
|
||||||
isValid = isValid && !remoteCoreFile().isEmpty();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
d->buttonBox->button(QDialogButtonBox::Ok)->setEnabled(isValid);
|
d->buttonBox->button(QDialogButtonBox::Ok)->setEnabled(st.isValid());
|
||||||
}
|
}
|
||||||
|
|
||||||
void AttachCoreDialog::selectRemoteCoreFile()
|
void AttachCoreDialog::selectRemoteCoreFile()
|
||||||
|
Reference in New Issue
Block a user