~mateo-salta/nitroshare/nitroshare

« back to all changes in this revision

Viewing changes to src/sharebox/CShareBox.cpp

  • Committer: Nathan Osman
  • Date: 2012-06-24 04:25:19 UTC
  • Revision ID: admin@quickmediasolutions.com-20120624042519-resp0zd4ykkrhoxf
Added some style to the sharebox and an icon (and experimental progress bar).

Show diffs side-by-side

added added

removed removed

Lines of Context:
37
37
    // Set the constant attributes for the window
38
38
    setAttribute(Qt::WA_TranslucentBackground);
39
39
    setWindowFlags(Qt::FramelessWindowHint | Qt::WindowStaysOnBottomHint);
40
 
    setWindowOpacity(0.6f);
 
40
    setWindowOpacity(0.7f);
41
41
 
42
42
    Init();
43
43
 
50
50
 
51
51
void CShareBox::Init()
52
52
{
53
 
    m_bg_brush.setStyle(Qt::SolidPattern);
54
 
    m_bg_brush.setColor(Qt::black);
55
 
 
56
 
    m_highlight_pen.setColor(QColor(63, 63, 255));
57
 
    m_highlight_pen.setWidth(2);
58
 
 
59
 
    m_text_font.setPixelSize(20);
 
53
    /* Load the background image for the share box and the icon. */
 
54
    m_bg.load(":/images/sharebox.png");
 
55
    m_icon.load(":/images/network.png");
 
56
 
 
57
    /* Set the colors and fonts. */
 
58
    m_text_font.setPixelSize(18);
 
59
    m_text_normal.setRgb(215, 215, 215);
 
60
    m_text_highlight.setRgb(127, 127, 255);
 
61
    m_border_highlight.setRgb(127, 127, 215);
60
62
}
61
63
 
62
64
void CShareBox::Position()
70
72
    m_highlight = highlight;
71
73
    update();
72
74
 
73
 
    setWindowOpacity(highlight?1.0f:0.6f);
 
75
    setWindowOpacity(highlight?1.0f:0.7f);
74
76
}
75
77
 
76
78
void CShareBox::dragEnterEvent(QDragEnterEvent * event)
141
143
{
142
144
    QPainter painter(this);
143
145
    painter.setRenderHint(QPainter::Antialiasing, true);
144
 
    painter.setBrush(m_bg_brush);
145
 
 
146
 
    /* First draw the rectangle without any pen. */
147
 
    painter.setPen(Qt::NoPen);
148
 
    painter.drawRoundedRect(0, 0, 139, 139, 24.0f, 24.0f);
149
 
 
150
 
    /* If we are drawing the highlight, then set the appropriate
151
 
       color and draw the border inside the frame. */
 
146
 
 
147
    /* First draw the background. */
 
148
    painter.drawPixmap(0, 0, 139, 139, m_bg);
 
149
 
 
150
    /* Then draw the blue border if applicable. */
152
151
    if(m_highlight)
153
152
    {
154
 
        painter.setPen(m_highlight_pen);
155
 
        painter.drawRoundedRect(3, 3, 133, 133, 22.0f, 22.0f);
 
153
        painter.setPen(m_border_highlight);
 
154
        painter.drawRoundedRect(6, 6, 127, 127, 4.0f, 4.0f);
156
155
    }
157
 
    else
158
 
        painter.setPen(QColor(95, 95, 95));
159
156
 
160
 
    /* Draw the caption centered in the text box. */
161
157
    painter.setFont(m_text_font);
162
 
    painter.drawText(QRect(0, 0, 139, 139), Qt::AlignHCenter | Qt::AlignVCenter, "Share Box");
 
158
 
 
159
    /* Draw the shadow for the text. */
 
160
    painter.setPen(Qt::black);
 
161
    painter.drawText(QRect(1, 21, 139, 139), Qt::AlignHCenter | Qt::AlignVCenter, "Share Box");
 
162
 
 
163
    /* Draw the actual text. */
 
164
    painter.setPen(m_highlight?m_text_highlight:m_text_normal);
 
165
    painter.drawText(QRect(0, 20, 139, 139), Qt::AlignHCenter | Qt::AlignVCenter, "Share Box");
 
166
 
 
167
    /* Draw the progress bar. */
 
168
    painter.setBrush(QBrush(QColor(63, 63, 63)));
 
169
    painter.drawRoundedRect(14, 110, 114, 10, 5.0f, 5.0f);
 
170
 
 
171
    painter.setPen(Qt::NoPen);
 
172
    painter.setBrush(QBrush(m_text_normal));
 
173
    painter.drawRoundedRect(15, 111, 43, 8, 4.0f, 4.0f);
 
174
 
 
175
    painter.drawPixmap(46, 10, 48, 48, m_icon);
163
176
}