Commit 8f1a3f1f authored by Ingo Klöcker's avatar Ingo Klöcker
Browse files

Allow getting the parentWId of a command

This enables us to pass the parentWId to a command started from another
command.

GnuPG-bug-id: 5832
parent b1529a3a
......@@ -157,7 +157,7 @@ void Command::setParentWidget(QWidget *widget)
void Command::setParentWId(WId wid)
{
d->parentWId = wid;
d->parentWId_ = wid;
}
void Command::setView(QAbstractItemView *view)
......@@ -229,8 +229,8 @@ void Command::addTemporaryView(const QString &title, AbstractKeyListSortFilterPr
void Command::applyWindowID(QWidget *w) const
{
if (w) {
if (d->parentWId) {
if (QWidget *pw = QWidget::find(d->parentWId)) {
if (d->parentWId()) {
if (QWidget *pw = QWidget::find(d->parentWId())) {
// remember the current focus widget; re-parenting resets it
QWidget *focusWidget = w->focusWidget();
w->setParent(pw, w->windowFlags());
......@@ -239,7 +239,7 @@ void Command::applyWindowID(QWidget *w) const
}
} else {
w->setAttribute(Qt::WA_NativeWindow, true);
KWindowSystem::setMainWindow(w->windowHandle(), d->parentWId);
KWindowSystem::setMainWindow(w->windowHandle(), d->parentWId());
}
} else {
// remember the current focus widget; re-parenting resets it
......
......@@ -50,6 +50,10 @@ public:
return view_;
}
}
WId parentWId() const
{
return parentWId_;
}
KeyListModelInterface *model() const
{
return view_ ? dynamic_cast<KeyListModelInterface *>(view_->model()) : nullptr;
......@@ -89,8 +93,8 @@ public:
void error(const QString &text, const QString &caption = QString(), KMessageBox::Options options = KMessageBox::Notify) const
{
if (parentWId) {
KMessageBox::errorWId(parentWId, text, caption, options);
if (parentWId_) {
KMessageBox::errorWId(parentWId_, text, caption, options);
} else {
KMessageBox::error(parentWidgetOrView(), text, caption, options);
}
......@@ -99,16 +103,16 @@ public:
{
static const QString noDontShowAgainName{};
const QString title = caption.isEmpty() ? i18nc("@title:window", "Success") : caption;
if (parentWId) {
KMessageBox::informationWId(parentWId, text, title, noDontShowAgainName, options);
if (parentWId_) {
KMessageBox::informationWId(parentWId_, text, title, noDontShowAgainName, options);
} else {
KMessageBox::information(parentWidgetOrView(), text, title, noDontShowAgainName, options);
}
}
void information(const QString &text, const QString &caption = QString(), const QString &dontShowAgainName = QString(), KMessageBox::Options options = KMessageBox::Notify) const
{
if (parentWId) {
KMessageBox::informationWId(parentWId, text, caption, dontShowAgainName, options);
if (parentWId_) {
KMessageBox::informationWId(parentWId_, text, caption, dontShowAgainName, options);
} else {
KMessageBox::information(parentWidgetOrView(), text, caption, dontShowAgainName, options);
}
......@@ -126,7 +130,7 @@ private:
QList<QPersistentModelIndex> indexes_;
QPointer<QAbstractItemView> view_;
QPointer<QWidget> parentWidget_;
WId parentWId = 0;
WId parentWId_ = 0;
QPointer<KeyListController> controller_;
};
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment