MCPcopy Create free account
hub / github.com/altairwei/WizNotePlus / adjustButtonPosition

Method adjustButtonPosition

src/gui/documentviewer/WizEditorToolBar.cpp:2630–2728  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2628}
2629
2630void WizEditorToolBar::adjustButtonPosition()
2631{
2632 int parentWidgetWidth = m_editor->width() - WizSmartScaleUI(28) - 1; //28 ???
2633 //
2634 int firstWidth = firstLineWidth();
2635 //
2636 bool changed = false;
2637 //
2638 if (firstWidth > parentWidgetWidth)
2639 {
2640 while (firstWidth > parentWidgetWidth)
2641 {
2642 auto items = buttonContainersInFirstLine();
2643 if (items.isEmpty())
2644 break;
2645 //
2646 QWidget* last = items.last();
2647 moveWidgetFromFristLineToSecondLine(last);
2648 changed = true;
2649 //
2650 firstWidth = firstLineWidth();
2651 }
2652 }
2653 else if (firstWidth < parentWidgetWidth)
2654 {
2655 while (firstWidth < parentWidgetWidth)
2656 {
2657 auto items = buttonContainersInSecondLine();
2658 if (items.isEmpty())
2659 break;
2660 //
2661 QWidget * widget = items.first();
2662 int width = widget->sizeHint().width();
2663 if (width + firstWidth > parentWidgetWidth)
2664 break;
2665 //
2666 moveWidgetFromSecondLineToFirstLine(widget);
2667 changed = true;
2668 //
2669 firstWidth = firstLineWidth();
2670 }
2671 }
2672 //
2673 if (!changed)
2674 return;
2675 //
2676 for (auto widget : buttonContainersInFirstLine())
2677 {
2678 widget->setVisible(true);
2679 }
2680 //
2681 auto items = buttonContainersInSecondLine();
2682 //
2683 int total = 0;
2684 //
2685 for (auto widget : items)
2686 {
2687 total += widget->sizeHint().width();

Callers 4

resizeEventMethod · 0.80
resizeEventMethod · 0.80
showEditorBarMethod · 0.80

Calls 7

WizSmartScaleUIFunction · 0.85
widthMethod · 0.80
isEmptyMethod · 0.80
sizeMethod · 0.80
sizeHintMethod · 0.45
hideMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected