PDA

View Full Version : How to use Combobox to show a Ballon?



Bong.Da.City
19th August 2010, 12:21
What i want to do is to make a simple thing...
A combobox which have option ( off, 5 minutes, 10 minutes, 30 minutes, 1 hour ) and if is for example choosed to 1 hour every hour ( 17:00, 18:00 and all of that ) show a ballon that the time now is ( current_time ).

So i have some ideas but i do not know hot to put it..


QTimer *timer = new QTimer(this);
this->updateTimeLabel();
timer->start(1000);


void roloi::updateTimeLabel()
{
//this basicaly takes the first 5 characters of the time string, starting from right to left
QString clockSharp = QTime::currentTime().toString().right(5);
//set a new pallete to color our label
QColor fg;
fg.setNamedColor("black");
QPalette pal = ui->timeLabel->palette();

if (reminder.left(1) != "C" && reminder.left(1) != "0")
{
switch (reminder.toInt()) {
case 1:
if (clockSharp=="00:00" || clockSharp=="05:00" || clockSharp=="10:00" || clockSharp=="15:00" || clockSharp=="20:00" || clockSharp=="25:00" || clockSharp=="30:00" || clockSharp=="35:00" || clockSharp=="40:00" || clockSharp=="45:00" || clockSharp=="50:00" || clockSharp=="55:00") {
fg = sharpColor;
if (showPop) showBaloon();
}
break;
case 2:
if (clockSharp=="00:00" || clockSharp=="10:00" || clockSharp=="20:00" || clockSharp=="30:00" || clockSharp=="40:00" || clockSharp=="50:00" ) {
fg = sharpColor;
if (showPop) showBaloon();
}
break;
case 3:
if (clockSharp=="00:00" || clockSharp=="15:00" || clockSharp=="30:00" || clockSharp=="45:00" ) {
fg = sharpColor;
if (showPop) showBaloon();
}
break;
case 4:
if (clockSharp=="00:00" || clockSharp=="30:00" ) {
fg = sharpColor;
if (showPop) showBaloon();
}
break;
case 5:
if (clockSharp=="00:00" ) {
fg = sharpColor;
if (showPop) showBaloon();
}
break;
}
}
pal.setColor(QPalette::Foreground,fg);
ui->timeLabel->setPalette(pal);
ui->timeLabel->setText(QTime::currentTime().toString());
trayIcon->setToolTip("Clock | " + ui->timeLabel->text() + "\n\nDouble click to show the window.\nMiddle click to exit the application.");
this->setWindowTitle("Clock | " + ui->timeLabel->text());

if (reminder.left(1)=="C" && reminder.length() > 1 && !cstTimer->isActive() && QTime::currentTime().toString().right(2) == "00")
{
cstTimer = new QTimer(this);
connect(cstTimer, SIGNAL(timeout()), this, SLOT(customReminder()));
cstTimer->start(60000 * reminder.right(reminder.length()-1).toInt());
} else if (reminder.left(1)!="C" && cstTimer->isActive()){
cstTimer->stop();
}
}


void roloi::showBaloon()
{
trayIcon->showMessage("Clock alert", "It's " + QTime::currentTime().toString().left(5) + ".",
QSystemTrayIcon::Information, 5000);

}