Changeset View
Changeset View
Standalone View
Standalone View
kstyle/breezehelper.cpp
Show First 20 Lines • Show All 455 Lines • ▼ Show 20 Line(s) | 453 | { | |||
---|---|---|---|---|---|
456 | painter->drawRect( rect ); | 456 | painter->drawRect( rect ); | ||
457 | 457 | | |||
458 | } else { | 458 | } else { | ||
459 | 459 | | |||
460 | painter->setClipRect( rect ); | 460 | painter->setClipRect( rect ); | ||
461 | 461 | | |||
462 | QRectF copy( strokedRect( rect ) ); | 462 | QRectF copy( strokedRect( rect ) ); | ||
463 | 463 | | |||
464 | const qreal radius( frameRadius( -1.0 ) ); | 464 | const qreal radius( frameRadius( PenWidth::Frame, -1 ) ); | ||
465 | if( !(sides&SideTop) ) copy.adjust( 0, -radius, 0, 0 ); | 465 | if( !(sides&SideTop) ) copy.adjust( 0, -radius, 0, 0 ); | ||
466 | if( !(sides&SideBottom) ) copy.adjust( 0, 0, 0, radius ); | 466 | if( !(sides&SideBottom) ) copy.adjust( 0, 0, 0, radius ); | ||
467 | if( !(sides&SideLeft) ) copy.adjust( -radius, 0, 0, 0 ); | 467 | if( !(sides&SideLeft) ) copy.adjust( -radius, 0, 0, 0 ); | ||
468 | if( !(sides&SideRight) ) copy.adjust( 0, 0, radius, 0 ); | 468 | if( !(sides&SideRight) ) copy.adjust( 0, 0, radius, 0 ); | ||
469 | 469 | | |||
470 | painter->setPen( outline ); | 470 | painter->setPen( outline ); | ||
471 | // painter->setBrush( Qt::NoBrush ); | 471 | // painter->setBrush( Qt::NoBrush ); | ||
472 | painter->drawRoundedRect( copy, radius, radius ); | 472 | painter->drawRoundedRect( copy, radius, radius ); | ||
Show All 22 Lines | 477 | } | |||
495 | void Helper::renderFrame( | 495 | void Helper::renderFrame( | ||
496 | QPainter* painter, const QRect& rect, | 496 | QPainter* painter, const QRect& rect, | ||
497 | const QColor& color, const QColor& outline ) const | 497 | const QColor& color, const QColor& outline ) const | ||
498 | { | 498 | { | ||
499 | 499 | | |||
500 | painter->setRenderHint( QPainter::Antialiasing ); | 500 | painter->setRenderHint( QPainter::Antialiasing ); | ||
501 | 501 | | |||
502 | QRectF frameRect( rect.adjusted( 1, 1, -1, -1 ) ); | 502 | QRectF frameRect( rect.adjusted( 1, 1, -1, -1 ) ); | ||
503 | qreal radius( frameRadius() ); | 503 | qreal radius( frameRadius( PenWidth::NoPen, -1 ) ); | ||
504 | 504 | | |||
505 | // set pen | 505 | // set pen | ||
506 | if( outline.isValid() ) | 506 | if( outline.isValid() ) | ||
507 | { | 507 | { | ||
508 | 508 | | |||
509 | painter->setPen( outline ); | 509 | painter->setPen( outline ); | ||
510 | frameRect = strokedRect( frameRect ); | 510 | frameRect = strokedRect( frameRect ); | ||
511 | radius = qMax( radius - 1, qreal( 0.0 ) ); | 511 | radius = newFrameRadius( radius, PenWidth::Frame ); | ||
512 | 512 | | |||
513 | } else { | 513 | } else { | ||
514 | 514 | | |||
515 | painter->setPen( Qt::NoPen ); | 515 | painter->setPen( Qt::NoPen ); | ||
516 | 516 | | |||
517 | } | 517 | } | ||
518 | 518 | | |||
519 | // set brush | 519 | // set brush | ||
Show All 36 Lines | 544 | { | |||
556 | break; | 556 | break; | ||
557 | 557 | | |||
558 | case SideBottom: | 558 | case SideBottom: | ||
559 | painter->drawLine( frameRect.bottomLeft(), frameRect.bottomRight() ); | 559 | painter->drawLine( frameRect.bottomLeft(), frameRect.bottomRight() ); | ||
560 | break; | 560 | break; | ||
561 | 561 | | |||
562 | case AllSides: | 562 | case AllSides: | ||
563 | { | 563 | { | ||
564 | const qreal radius( frameRadius( -1.0 ) ); | 564 | const qreal radius( frameRadius( PenWidth::Frame, -1 ) ); | ||
565 | painter->drawRoundedRect( frameRect, radius, radius ); | 565 | painter->drawRoundedRect( frameRect, radius, radius ); | ||
566 | break; | 566 | break; | ||
567 | } | 567 | } | ||
568 | 568 | | |||
569 | } | 569 | } | ||
570 | 570 | | |||
571 | } | 571 | } | ||
572 | 572 | | |||
573 | //______________________________________________________________________________ | 573 | //______________________________________________________________________________ | ||
574 | void Helper::renderMenuFrame( | 574 | void Helper::renderMenuFrame( | ||
575 | QPainter* painter, const QRect& rect, | 575 | QPainter* painter, const QRect& rect, | ||
576 | const QColor& color, const QColor& outline, bool roundCorners ) const | 576 | const QColor& color, const QColor& outline, bool roundCorners ) const | ||
577 | { | 577 | { | ||
578 | 578 | | |||
579 | 579 | | |||
580 | // set brush | 580 | // set brush | ||
581 | if( color.isValid() ) painter->setBrush( color ); | 581 | if( color.isValid() ) painter->setBrush( color ); | ||
582 | else painter->setBrush( Qt::NoBrush ); | 582 | else painter->setBrush( Qt::NoBrush ); | ||
583 | 583 | | |||
584 | if( roundCorners ) | 584 | if( roundCorners ) | ||
585 | { | 585 | { | ||
586 | 586 | | |||
587 | painter->setRenderHint( QPainter::Antialiasing ); | 587 | painter->setRenderHint( QPainter::Antialiasing ); | ||
588 | QRectF frameRect( rect ); | 588 | QRectF frameRect( rect ); | ||
589 | qreal radius( frameRadius() ); | 589 | qreal radius( frameRadius( PenWidth::NoPen, -1 ) ); | ||
590 | 590 | | |||
591 | // set pen | 591 | // set pen | ||
592 | if( outline.isValid() ) | 592 | if( outline.isValid() ) | ||
593 | { | 593 | { | ||
594 | 594 | | |||
595 | painter->setPen( outline ); | 595 | painter->setPen( outline ); | ||
596 | frameRect = strokedRect( frameRect ); | 596 | frameRect = strokedRect( frameRect ); | ||
597 | radius = qMax( radius - 1, qreal( 0.0 ) ); | 597 | radius = newFrameRadius( radius, PenWidth::Frame ); | ||
598 | 598 | | |||
599 | } else painter->setPen( Qt::NoPen ); | 599 | } else painter->setPen( Qt::NoPen ); | ||
600 | 600 | | |||
601 | // render | 601 | // render | ||
602 | painter->drawRoundedRect( frameRect, radius, radius ); | 602 | painter->drawRoundedRect( frameRect, radius, radius ); | ||
603 | 603 | | |||
604 | } else { | 604 | } else { | ||
605 | 605 | | |||
Show All 21 Lines | |||||
627 | { | 627 | { | ||
628 | 628 | | |||
629 | // setup painter | 629 | // setup painter | ||
630 | painter->setRenderHint( QPainter::Antialiasing, true ); | 630 | painter->setRenderHint( QPainter::Antialiasing, true ); | ||
631 | 631 | | |||
632 | // copy rect | 632 | // copy rect | ||
633 | QRectF frameRect( rect ); | 633 | QRectF frameRect( rect ); | ||
634 | frameRect.adjust( 1, 1, -1, -1 ); | 634 | frameRect.adjust( 1, 1, -1, -1 ); | ||
635 | qreal radius( frameRadius() ); | 635 | qreal radius( frameRadius( PenWidth::NoPen, -1 ) ); | ||
636 | 636 | | |||
637 | // shadow | 637 | // shadow | ||
638 | if( sunken ) { | 638 | if( sunken ) { | ||
639 | 639 | | |||
640 | frameRect.translate( 1, 1 ); | 640 | frameRect.translate( 1, 1 ); | ||
641 | 641 | | |||
642 | } else { | 642 | } else { | ||
643 | 643 | | |||
644 | renderRoundedRectShadow( painter, frameRect, shadow, radius ); | 644 | renderRoundedRectShadow( painter, frameRect, shadow, radius ); | ||
645 | 645 | | |||
646 | } | 646 | } | ||
647 | 647 | | |||
648 | if( outline.isValid() ) | 648 | if( outline.isValid() ) | ||
649 | { | 649 | { | ||
650 | 650 | | |||
651 | QLinearGradient gradient( frameRect.topLeft(), frameRect.bottomLeft() ); | 651 | QLinearGradient gradient( frameRect.topLeft(), frameRect.bottomLeft() ); | ||
652 | gradient.setColorAt( 0, outline.lighter( hasFocus ? 103:101 ) ); | 652 | gradient.setColorAt( 0, outline.lighter( hasFocus ? 103:101 ) ); | ||
653 | gradient.setColorAt( 1, outline.darker( hasFocus ? 110:103 ) ); | 653 | gradient.setColorAt( 1, outline.darker( hasFocus ? 110:103 ) ); | ||
654 | painter->setPen( QPen( QBrush( gradient ), 1.0 ) ); | 654 | painter->setPen( QPen( QBrush( gradient ), 1.0 ) ); | ||
655 | 655 | | |||
656 | frameRect = strokedRect( frameRect ); | 656 | frameRect = strokedRect( frameRect ); | ||
657 | radius = qMax( radius - 1, qreal( 0.0 ) ); | 657 | radius = newFrameRadius( radius, PenWidth::Frame ); | ||
658 | 658 | | |||
659 | } else painter->setPen( Qt::NoPen ); | 659 | } else painter->setPen( Qt::NoPen ); | ||
660 | 660 | | |||
661 | // content | 661 | // content | ||
662 | if( color.isValid() ) | 662 | if( color.isValid() ) | ||
663 | { | 663 | { | ||
664 | 664 | | |||
665 | QLinearGradient gradient( frameRect.topLeft(), frameRect.bottomLeft() ); | 665 | QLinearGradient gradient( frameRect.topLeft(), frameRect.bottomLeft() ); | ||
Show All 20 Lines | 681 | { | |||
686 | // setup painter | 686 | // setup painter | ||
687 | painter->setRenderHints( QPainter::Antialiasing ); | 687 | painter->setRenderHints( QPainter::Antialiasing ); | ||
688 | 688 | | |||
689 | const QRectF baseRect( rect.adjusted( 1, 1, -1, -1 ) ); | 689 | const QRectF baseRect( rect.adjusted( 1, 1, -1, -1 ) ); | ||
690 | 690 | | |||
691 | if( sunken ) | 691 | if( sunken ) | ||
692 | { | 692 | { | ||
693 | 693 | | |||
694 | const qreal radius( frameRadius() ); | 694 | const qreal radius( frameRadius( PenWidth::NoPen ) ); | ||
695 | 695 | | |||
696 | painter->setPen( Qt::NoPen ); | 696 | painter->setPen( Qt::NoPen ); | ||
697 | painter->setBrush( color ); | 697 | painter->setBrush( color ); | ||
698 | 698 | | |||
699 | painter->drawRoundedRect( baseRect, radius, radius ); | 699 | painter->drawRoundedRect( baseRect, radius, radius ); | ||
700 | 700 | | |||
701 | } else { | 701 | } else { | ||
702 | 702 | | |||
703 | const qreal radius( frameRadius(-0.5) ); | 703 | const qreal radius( frameRadius( PenWidth::Frame ) ); | ||
704 | 704 | | |||
705 | painter->setPen( color ); | 705 | painter->setPen( color ); | ||
706 | painter->setBrush( Qt::NoBrush ); | 706 | painter->setBrush( Qt::NoBrush ); | ||
707 | const QRectF outlineRect( strokedRect( baseRect ) ); | 707 | const QRectF outlineRect( strokedRect( baseRect ) ); | ||
708 | painter->drawRoundedRect( outlineRect, radius, radius ); | 708 | painter->drawRoundedRect( outlineRect, radius, radius ); | ||
709 | 709 | | |||
710 | } | 710 | } | ||
711 | 711 | | |||
712 | } | 712 | } | ||
713 | 713 | | |||
714 | //______________________________________________________________________________ | 714 | //______________________________________________________________________________ | ||
715 | void Helper::renderToolBoxFrame( | 715 | void Helper::renderToolBoxFrame( | ||
716 | QPainter* painter, const QRect& rect, int tabWidth, | 716 | QPainter* painter, const QRect& rect, int tabWidth, | ||
717 | const QColor& outline ) const | 717 | const QColor& outline ) const | ||
718 | { | 718 | { | ||
719 | 719 | | |||
720 | if( !outline.isValid() ) return; | 720 | if( !outline.isValid() ) return; | ||
721 | 721 | | |||
722 | // round radius | 722 | // round radius | ||
723 | const qreal radius( frameRadius() ); | 723 | const qreal radius( frameRadius( PenWidth::Frame ) ); | ||
724 | const QSizeF cornerSize( 2*radius, 2*radius ); | 724 | const QSizeF cornerSize( 2*radius, 2*radius ); | ||
725 | 725 | | |||
726 | // if rect - tabwidth is even, need to increase tabWidth by 1 unit | 726 | // if rect - tabwidth is even, need to increase tabWidth by 1 unit | ||
727 | // for anti aliasing | 727 | // for anti aliasing | ||
728 | if( !((rect.width() - tabWidth)%2) ) ++tabWidth; | 728 | if( !((rect.width() - tabWidth)%2) ) ++tabWidth; | ||
729 | 729 | | |||
730 | // adjust rect for antialiasing | 730 | // adjust rect for antialiasing | ||
731 | QRectF baseRect( strokedRect( rect ) ); | 731 | QRectF baseRect( strokedRect( rect ) ); | ||
Show All 24 Lines | |||||
756 | void Helper::renderTabWidgetFrame( | 756 | void Helper::renderTabWidgetFrame( | ||
757 | QPainter* painter, const QRect& rect, | 757 | QPainter* painter, const QRect& rect, | ||
758 | const QColor& color, const QColor& outline, Corners corners ) const | 758 | const QColor& color, const QColor& outline, Corners corners ) const | ||
759 | { | 759 | { | ||
760 | 760 | | |||
761 | painter->setRenderHint( QPainter::Antialiasing ); | 761 | painter->setRenderHint( QPainter::Antialiasing ); | ||
762 | 762 | | |||
763 | QRectF frameRect( rect.adjusted( 1, 1, -1, -1 ) ); | 763 | QRectF frameRect( rect.adjusted( 1, 1, -1, -1 ) ); | ||
764 | qreal radius( frameRadius() ); | 764 | qreal radius( frameRadius( PenWidth::NoPen, -1 ) ); | ||
765 | 765 | | |||
766 | // set pen | 766 | // set pen | ||
767 | if( outline.isValid() ) | 767 | if( outline.isValid() ) | ||
768 | { | 768 | { | ||
769 | 769 | | |||
770 | painter->setPen( outline ); | 770 | painter->setPen( outline ); | ||
771 | frameRect = strokedRect( frameRect ); | 771 | frameRect = strokedRect( frameRect ); | ||
772 | radius = qMax( radius-1, qreal( 0.0 ) ); | 772 | radius = newFrameRadius( radius, PenWidth::Frame ); | ||
773 | 773 | | |||
774 | } else painter->setPen( Qt::NoPen ); | 774 | } else painter->setPen( Qt::NoPen ); | ||
775 | 775 | | |||
776 | // set brush | 776 | // set brush | ||
777 | if( color.isValid() ) painter->setBrush( color ); | 777 | if( color.isValid() ) painter->setBrush( color ); | ||
778 | else painter->setBrush( Qt::NoBrush ); | 778 | else painter->setBrush( Qt::NoBrush ); | ||
779 | 779 | | |||
780 | // render | 780 | // render | ||
▲ Show 20 Lines • Show All 72 Lines • ▼ Show 20 Line(s) | |||||
853 | { | 853 | { | ||
854 | 854 | | |||
855 | // setup painter | 855 | // setup painter | ||
856 | painter->setRenderHint( QPainter::Antialiasing, true ); | 856 | painter->setRenderHint( QPainter::Antialiasing, true ); | ||
857 | 857 | | |||
858 | // copy rect and radius | 858 | // copy rect and radius | ||
859 | QRectF frameRect( rect ); | 859 | QRectF frameRect( rect ); | ||
860 | frameRect.adjust( 2, 2, -2, -2 ); | 860 | frameRect.adjust( 2, 2, -2, -2 ); | ||
861 | qreal radius( frameRadius() ); | 861 | qreal radius( frameRadius( PenWidth::NoPen, -1 ) ); | ||
862 | 862 | | |||
863 | // shadow | 863 | // shadow | ||
864 | if( sunken ) | 864 | if( sunken ) | ||
865 | { | 865 | { | ||
866 | 866 | | |||
867 | frameRect.translate(1, 1); | 867 | frameRect.translate(1, 1); | ||
868 | 868 | | |||
869 | } else { | 869 | } else { | ||
870 | 870 | | |||
871 | renderRoundedRectShadow( painter, frameRect, shadow, radius ); | 871 | renderRoundedRectShadow( painter, frameRect, shadow, radius ); | ||
872 | 872 | | |||
873 | } | 873 | } | ||
874 | 874 | | |||
875 | // content | 875 | // content | ||
876 | { | 876 | { | ||
877 | 877 | | |||
878 | painter->setPen( QPen( color, PenWidth::Frame ) ); | 878 | painter->setPen( QPen( color, PenWidth::Frame ) ); | ||
879 | painter->setBrush( Qt::NoBrush ); | 879 | painter->setBrush( Qt::NoBrush ); | ||
880 | 880 | | |||
881 | radius = qMax( radius-1, qreal( 0.0 ) ); | 881 | radius = newFrameRadius( radius, PenWidth::Frame ); | ||
882 | const QRectF contentRect( strokedRect( frameRect ) ); | 882 | const QRectF contentRect( strokedRect( frameRect ) ); | ||
883 | painter->drawRoundedRect( contentRect, radius, radius ); | 883 | painter->drawRoundedRect( contentRect, radius, radius ); | ||
884 | 884 | | |||
885 | } | 885 | } | ||
886 | 886 | | |||
887 | // mark | 887 | // mark | ||
888 | if( state == CheckOn ) | 888 | if( state == CheckOn ) | ||
889 | { | 889 | { | ||
▲ Show 20 Lines • Show All 368 Lines • ▼ Show 20 Line(s) | |||||
1258 | //______________________________________________________________________________ | 1258 | //______________________________________________________________________________ | ||
1259 | void Helper::renderTabBarTab( QPainter* painter, const QRect& rect, const QColor& color, const QColor& outline, Corners corners ) const | 1259 | void Helper::renderTabBarTab( QPainter* painter, const QRect& rect, const QColor& color, const QColor& outline, Corners corners ) const | ||
1260 | { | 1260 | { | ||
1261 | 1261 | | |||
1262 | // setup painter | 1262 | // setup painter | ||
1263 | painter->setRenderHint( QPainter::Antialiasing, true ); | 1263 | painter->setRenderHint( QPainter::Antialiasing, true ); | ||
1264 | 1264 | | |||
1265 | QRectF frameRect( rect ); | 1265 | QRectF frameRect( rect ); | ||
1266 | qreal radius( frameRadius() ); | 1266 | qreal radius( frameRadius( PenWidth::NoPen, -1 ) ); | ||
1267 | 1267 | | |||
1268 | // pen | 1268 | // pen | ||
1269 | if( outline.isValid() ) | 1269 | if( outline.isValid() ) | ||
1270 | { | 1270 | { | ||
1271 | 1271 | | |||
1272 | painter->setPen( outline ); | 1272 | painter->setPen( outline ); | ||
1273 | frameRect = strokedRect( frameRect ); | 1273 | frameRect = strokedRect( frameRect ); | ||
1274 | radius = qMax( radius-1, qreal( 0.0 ) ); | 1274 | radius = newFrameRadius( radius, PenWidth::Frame ); | ||
1275 | 1275 | | |||
1276 | } else painter->setPen( Qt::NoPen ); | 1276 | } else painter->setPen( Qt::NoPen ); | ||
1277 | 1277 | | |||
1278 | 1278 | | |||
1279 | // brush | 1279 | // brush | ||
1280 | if( color.isValid() ) painter->setBrush( color ); | 1280 | if( color.isValid() ) painter->setBrush( color ); | ||
1281 | else painter->setBrush( Qt::NoBrush ); | 1281 | else painter->setBrush( Qt::NoBrush ); | ||
1282 | 1282 | | |||
▲ Show 20 Lines • Show All 391 Lines • Show Last 20 Lines |