ariya.io About Talks Articles

Buzz, or Shake My Window

1 min read

Ctrl+G is a very well-known shortcut by Yahoo! Messenger users. It means buzz your contact. Essentially, the other side will get “Buzz!” message, along with sound effect (if enabled) and the shaking of the chat window. The last part is very interesting and obviously used to steal the attention. It is difficult to explain if you never have experienced it 🙂

To buzz-enabling your Qt application, here is the code snippet taken from what I have implemented for KYIM long time ago:

void Mainwin::buzz()
{
  int xp = x();
  int yp = y();
  QTime t;
 
  t.start();
  for ( int i = 32; i > ; )
  {
    QApplication::processEvents();
    if ( t.elapsed() >= 1 )
    {
      int delta = i >> 2;
      int dir = i & 3;
      int dx = ((dir==1)||(dir==2)) ? delta : -delta;
      int dy = (dir<2) ? delta : -delta;
      move( xp+dx, yp+dy );
      t.restart();
      i--;
    }
  }
  move( xp, yp );
}

Happy buzzing !

Related posts:

♡ this article? Explore more articles and follow me Twitter.

Share this on Twitter Facebook