Commit 6ff969e3 authored by Niklas Freund's avatar Niklas Freund
Browse files

Fixed window being too small after restoring from maximized state

parent 5ec2cc53
......@@ -2550,6 +2550,25 @@ void KCalculator::slotPaste()
core.setOnlyUpdateOperation(false);
}
//------------------------------------------------------------------------------
// Name: resizeEvent
// Desc: resize window and make sure it's large enough for its content
//------------------------------------------------------------------------------
void KCalculator::resizeEvent(QResizeEvent* event)
{
// Call the overridden resize event
KXmlGuiWindow::resizeEvent(event);
// If the content size is now larger than the window size, resize window to fit
QSize contentSize = firstVerticalLayout->contentsRect().size();
QMargins contentMargins = KCalculator::contentsMargins();
QSize windowSize = KCalculator::frameSize();
if (contentSize.width() + contentMargins.left() + contentMargins.right() > windowSize.width() || contentSize.height() + contentMargins.top() + contentMargins.bottom() > windowSize.height()) {
KCalculator::resize(0,0); // force window as small as possible for current layout
}
}
////////////////////////////////////////////////////////////////
// Include the meta-object code for classes in this file
//
......
......@@ -126,6 +126,8 @@ private:
void setAngle();
void setBase();
void resizeEvent(QResizeEvent* event) override;
void updateDisplay(UpdateFlags flags);
void updateHistoryWithFunction(CalcEngine::Operation);
KCalcStatusBar *statusBar();
......
......@@ -24,7 +24,7 @@
<enum>QLayout::SetMinimumSize</enum>
</property>
<item>
<layout class="QVBoxLayout">
<layout class="QVBoxLayout" name="firstVerticalLayout">
<item>
<widget class="KCalcDisplay" name="calc_display">
<property name="sizePolicy">
......
Markdown is supported
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