src/gui/widgets/qmenu.cpp
changeset 25 e24348a560a6
parent 23 89e065397ea6
child 29 b72c6db6890b
equal deleted inserted replaced
23:89e065397ea6 25:e24348a560a6
   259     const int hmargin = style->pixelMetric(QStyle::PM_MenuHMargin, &opt, q),
   259     const int hmargin = style->pixelMetric(QStyle::PM_MenuHMargin, &opt, q),
   260               vmargin = style->pixelMetric(QStyle::PM_MenuVMargin, &opt, q),
   260               vmargin = style->pixelMetric(QStyle::PM_MenuVMargin, &opt, q),
   261               icone = style->pixelMetric(QStyle::PM_SmallIconSize, &opt, q);
   261               icone = style->pixelMetric(QStyle::PM_SmallIconSize, &opt, q);
   262     const int fw = style->pixelMetric(QStyle::PM_MenuPanelWidth, &opt, q);
   262     const int fw = style->pixelMetric(QStyle::PM_MenuPanelWidth, &opt, q);
   263     const int deskFw = style->pixelMetric(QStyle::PM_MenuDesktopFrameWidth, &opt, q);
   263     const int deskFw = style->pixelMetric(QStyle::PM_MenuDesktopFrameWidth, &opt, q);
   264 
       
   265     const int sfcMargin = style->sizeFromContents(QStyle::CT_Menu, &opt, QApplication::globalStrut(), q).width() - QApplication::globalStrut().width();
       
   266     const int min_column_width = q->minimumWidth() - (sfcMargin + leftmargin + rightmargin + 2 * (fw + hmargin));
       
   267     const int tearoffHeight = tearoff ? style->pixelMetric(QStyle::PM_MenuTearoffHeight, &opt, q) : 0;
   264     const int tearoffHeight = tearoff ? style->pixelMetric(QStyle::PM_MenuTearoffHeight, &opt, q) : 0;
   268 
   265 
   269     //for compatability now - will have to refactor this away..
   266     //for compatability now - will have to refactor this away..
   270     tabWidth = 0;
   267     tabWidth = 0;
   271     maxIconWidth = 0;
   268     maxIconWidth = 0;
   335             sz = style->sizeFromContents(QStyle::CT_MenuItem, &opt, sz, q);
   332             sz = style->sizeFromContents(QStyle::CT_MenuItem, &opt, sz, q);
   336         }
   333         }
   337 
   334 
   338 
   335 
   339         if (!sz.isEmpty()) {
   336         if (!sz.isEmpty()) {
   340             max_column_width = qMax(min_column_width, qMax(max_column_width, sz.width()));
   337             max_column_width = qMax(max_column_width, sz.width());
   341             //wrapping
   338             //wrapping
   342             if (!scroll &&
   339             if (!scroll &&
   343                y+sz.height()+vmargin > dh - (deskFw * 2)) {
   340                y+sz.height()+vmargin > dh - (deskFw * 2)) {
   344                 ncols++;
   341                 ncols++;
   345                 y = vmargin;
   342                 y = vmargin;
   349             actionRects[i] = QRect(0, 0, sz.width(), sz.height());
   346             actionRects[i] = QRect(0, 0, sz.width(), sz.height());
   350         }
   347         }
   351     }
   348     }
   352 
   349 
   353     max_column_width += tabWidth; //finally add in the tab width
   350     max_column_width += tabWidth; //finally add in the tab width
       
   351     const int sfcMargin = style->sizeFromContents(QStyle::CT_Menu, &opt, QApplication::globalStrut(), q).width() - QApplication::globalStrut().width();
       
   352     const int min_column_width = q->minimumWidth() - (sfcMargin + leftmargin + rightmargin + 2 * (fw + hmargin));
       
   353     max_column_width = qMax(min_column_width, max_column_width);
       
   354 
   354 
   355 
   355     //calculate position
   356     //calculate position
   356     const int base_y = vmargin + fw + topmargin +
   357     const int base_y = vmargin + fw + topmargin +
   357         (scroll ? scroll->scrollOffset : 0) +
   358         (scroll ? scroll->scrollOffset : 0) +
   358         tearoffHeight;
   359         tearoffHeight;