Monday, December 6, 2010

Qt4 TV-Like Sleep Application for Windows PC

Hello, i've made a application in Qt4 that provides a easy interface to sleep your computer, a lot like TV sleep function.
The application itself is cross-platform, but the commands to temporize the shutdown/restart are windows-specific.
Its really, really simple, here i share the source code, and a binary version : )
Download:
SleepTime Binaries
SleepTime Source
Relevant Functions ( Dialog.cpp)
void Dialog::on_pushButton_clicked()
{
//shutdown
QString time = QString::number(ui->lineEdit->text().toInt()*60);
QString command = "shutdown -s -t " + time;
system(command.toStdString().c_str());
}
void Dialog::on_pushButton_2_clicked()
{
//restart
QString time = QString::number(ui->lineEdit->text().toInt()*60);
QString command = "shutdown -r -t " + time;
system(command.toStdString().c_str());
}
void Dialog::on_pushButton_3_clicked()
{
//cancel
system("shutdown -a");
}

No comments:

Post a Comment