refs #750, allow to reset window position of dock widget

This commit is contained in:
Klaus Basan
2016-08-29 18:33:00 +02:00
parent bfd94ea6a8
commit d2aa2e9c1c
4 changed files with 73 additions and 10 deletions

View File

@@ -31,6 +31,8 @@
#include <QWidget>
#include <Qt>
#include <QtGlobal>
#include <QApplication>
#include <QDesktopWidget>
using namespace BlackMisc;
using namespace BlackGui::Components;
@@ -339,10 +341,12 @@ namespace BlackGui
contextMenu->addAction(BlackMisc::CIcons::floatOne16(), "Float", this, &CDockWidget::toggleFloating);
}
// Margin actions
// State actions (windows state)
contextMenu->addAction(BlackMisc::CIcons::load16(), "Restore", this, &CDockWidget::restoreFromSettings);
contextMenu->addAction(BlackMisc::CIcons::save16(), "Save state", this, &CDockWidget::saveToSettings);
contextMenu->addAction(BlackMisc::CIcons::save16(), "Reset to defaults", this, &CDockWidget::resetSettings);
contextMenu->addAction(BlackMisc::CIcons::refresh16(), "Reset to defaults", this, &CDockWidget::resetSettings);
contextMenu->addAction(BlackMisc::CIcons::refresh16(), "Reset position", this, &CDockWidget::resetPosition);
this->m_input->setMargins(this->contentsMargins());
contextMenu->addAction(BlackMisc::CIcons::tableSheet16(), "Margins", this, &CDockWidget::ps_dummy);
contextMenu->addAction(this->m_marginMenuAction);
@@ -587,4 +591,11 @@ namespace BlackGui
this->setSettings(s);
this->restoreFromSettings();
}
void CDockWidget::resetPosition()
{
// center on screen when floating
if (!this->isFloating()) { return; }
this->move(QApplication::desktop()->screen()->rect().center() - this->rect().center());
}
} // namespace