~mateo-salta/nitroshare/nitroshare

« back to all changes in this revision

Viewing changes to src/sharebox/CShareBox.cpp

  • Committer: Nathan Osman
  • Date: 2012-06-27 21:56:40 UTC
  • Revision ID: admin@quickmediasolutions.com-20120627215640-c6mspvllk1br9vx2
Implemented basic progress bar for uploads (which seems to be broken at the moment) and corrected a bug with the way unique IDs were generated for each machine.

Show diffs side-by-side

added added

removed removed

Lines of Context:
28
28
#include <QPen>
29
29
#include <QUrl>
30
30
 
 
31
#include <file/CFileSender.h>
31
32
#include <sharebox/CShareBox.h>
32
33
#include <util/settings.h>
33
34
 
37
38
 
38
39
CShareBox::CShareBox()
39
40
    : QWidget(QApplication::desktop()), m_draw_scale(140.0f / 256.0f),
40
 
      m_highlight(false), m_dragging(false), m_progress(ProgressNone)
 
41
      m_highlight(false), m_dragging(false), m_progress(CFileSender::ProgressNone)
41
42
{
42
43
    /* The share box should (ideally) be frameless, transparent, and stick
43
44
       to the desktop as a widget. This isn't as easy as it sounds, however and
116
117
{
117
118
    /* We only accept URLs being dragged on to the box and only if
118
119
       we are not already involved in transferring a file. */
119
 
    if(event->mimeData()->hasUrls() && m_progress == ProgressNone)
 
120
    if(event->mimeData()->hasUrls() && m_progress == CFileSender::ProgressNone)
120
121
    {
121
122
        SetHighlight(true);
122
123
        event->accept();
214
215
    painter.setPen(m_highlight?m_text_highlight:m_text_normal);
215
216
    painter.drawText(0, 156, 256, 30, Qt::AlignHCenter | Qt::AlignVCenter, text);
216
217
 
217
 
    /* If we have a current progress value, then draw the progress
218
 
       bar - otherwise draw three circles to look nice :) */
219
 
    if(m_progress < ProgressNone)
 
218
    /* Draw the progress bar if there is a transfer in progress, otherwise draw either
 
219
       a checkmark, 'x', or three circles (if nothing is happening). */
 
220
    if(m_progress < CFileSender::ProgressNone)
220
221
    {
221
222
        painter.setBrush(QBrush(QColor(63, 63, 63)));
222
223
        painter.drawRoundedRect(26, 200, 204, 18, 8.0f, 8.0f);
225
226
        painter.setBrush(QBrush(m_text_normal));
226
227
        painter.drawRoundedRect(28, 202, 200 * (m_progress / 100.0f), 14, 6.0f, 6.0f);
227
228
    }
228
 
    else if(m_progress > ProgressNone)
229
 
    {
230
 
        painter.drawPixmap(112, 200, 32, 32, (m_progress == ProgressComplete)?m_success:m_error);
231
 
    }
 
229
    else if(m_progress > CFileSender::ProgressNone)
 
230
        painter.drawPixmap(112, 200, 32, 32, (m_progress == CFileSender::ProgressComplete)?m_success:m_error);
232
231
    else
233
232
    {
234
233
        painter.drawEllipse(90,  210, 16, 16);