~mateo-salta/nitroshare/nitroshare

« back to all changes in this revision

Viewing changes to src/widgets/CBroadcastDiscoveryWidget.cpp

  • Committer: Nathan Osman
  • Date: 2012-07-03 18:54:45 UTC
  • Revision ID: admin@quickmediasolutions.com-20120703185445-39gkajlpzikj764i
Adjusted the wizard to make certain steps mandatory and added a nice animation to the broadcast discovery page.

Show diffs side-by-side

added added

removed removed

Lines of Context:
22
22
#include "ui_CBroadcastDiscoveryWidget.h"
23
23
 
24
24
CBroadcastDiscoveryWidget::CBroadcastDiscoveryWidget(QWidget * parent)
25
 
    : QWidget(parent), ui(new Ui::CBroadcastDiscoveryWidget), m_listener(NULL)
 
25
    : QWidget(parent), ui(new Ui::CBroadcastDiscoveryWidget), m_listener(NULL),
 
26
      m_animation_frame(false)
26
27
{
27
28
    ui->setupUi(this);
 
29
 
 
30
    connect(&m_animation_timer, SIGNAL(timeout()), SLOT(OnTimer()));
28
31
}
29
32
 
30
33
CBroadcastDiscoveryWidget::~CBroadcastDiscoveryWidget()
59
62
 
60
63
        m_broadcasters.append(broadcaster);
61
64
    }
 
65
 
 
66
    m_animation_timer.start(500);
62
67
}
63
68
 
64
69
void CBroadcastDiscoveryWidget::StopBroadcasting()
74
79
        delete m_listener;
75
80
        m_listener = NULL;
76
81
    }
 
82
 
 
83
    m_animation_timer.stop();
77
84
}
78
85
 
79
86
void CBroadcastDiscoveryWidget::OnPing(QHostAddress address)
87
94
            ui->DiscoveryLabel->setText(tr("Network discovery complete!"));
88
95
 
89
96
            m_interface = broadcaster->GetName();
 
97
 
 
98
            emit FoundInterface();
 
99
 
 
100
            /* We could have called StopBroadcasting() here but then the
 
101
               other machines would stop receiving broadcast packets. */
 
102
            m_animation_timer.stop();
90
103
        }
91
104
}
 
105
 
 
106
void CBroadcastDiscoveryWidget::OnTimer()
 
107
{
 
108
    ui->DiscoveryImage->setPixmap(QPixmap(QString(":/images/discovery%1.png").arg(m_animation_frame?1:2)));
 
109
    m_animation_frame = !m_animation_frame;
 
110
}