MCPcopy Create free account
hub / github.com/baumgarr/nixnote2 / drawBackGround

Method drawBackGround

dialog/screencapture.cpp:96–137  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

94
95
96void ScreenCapture::drawBackGround()
97{
98 // create painter on pixelmap of desktop
99 QPainter painter(&desktopPixmapBkg);
100
101 // set painter brush on 85% transparency
102 painter.setBrush(QBrush(QColor(0, 0, 0, 85), Qt::SolidPattern));
103
104 // draw rect of desktop size in poainter
105 painter.drawRect(QApplication::desktop()->rect());
106
107 QRect txtRect = QApplication::desktop()->screenGeometry(QApplication::desktop()->primaryScreen());
108 QString txtTip = QApplication::tr("Use your mouse to draw a rectangle to screenshot or exit pressing\nany key or using the right or middle mouse buttons.");
109
110 txtRect.setHeight(qRound(txtRect.height() / 10.f)); // rounded val of text rect height
111
112 painter.setPen(QPen(Qt::red)); // ste message rect border color
113 painter.setBrush(QBrush(QColor(255, 255, 255, 180), Qt::SolidPattern));
114 QRect txtBgRect = painter.boundingRect(txtRect, Qt::AlignCenter, txtTip);
115
116 // set height & width of bkg rect
117 txtBgRect.setX(txtBgRect.x() - 6);
118 txtBgRect.setY(txtBgRect.y() - 4);
119 txtBgRect.setWidth(txtBgRect.width() + 12);
120 txtBgRect.setHeight(txtBgRect.height() + 8);
121
122 painter.drawRect(txtBgRect);
123
124 // Draw the text
125 painter.setPen(QPen(Qt::black)); // black color pen
126 painter.drawText(txtBgRect, Qt::AlignCenter, txtTip);
127
128 palBackground = (qApp->desktop()->numScreens() > 1);
129
130 // set bkg to pallette widget
131 if (palBackground)
132 {
133 QPalette newPalette = palette();
134 newPalette.setBrush(QPalette::Window, QBrush(desktopPixmapBkg));
135 setPalette(newPalette);
136 }
137}
138
139void ScreenCapture::drawRectSelection(QPainter &painter)
140{

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected