1
0
Fork 0
forked from len0rd/rockbox

Add "Eject" button to main window.

Since especially Windows puts the eject functionality behind an icon in the
systray which is usually hidden and doesn't complain if a USB drive is
unplugged without ejecting it first ejecting such a device might not be
obvious to everyone. Add a button to the main window allowing to eject the
selected player.

Currently only implemented for Windows.

Change-Id: I785ac1482cda03a1379cf6d0fd0d9a0ff8130092
This commit is contained in:
Dominik Riebeling 2012-09-08 20:34:36 +02:00
parent 4f99dd4264
commit 328ff6d979
7 changed files with 137 additions and 29 deletions

View file

@ -110,6 +110,11 @@ RbUtilQt::RbUtilQt(QWidget *parent) : QMainWindow(parent)
RegCloseKey(hk);
}
#endif
#if !defined(Q_OS_WIN32)
/* eject funtionality is only implemented on W32 right now. */
ui.buttonEject->setEnabled(false);
#endif
updateDevice();
downloadInfo();
@ -142,6 +147,7 @@ RbUtilQt::RbUtilQt(QWidget *parent) : QMainWindow(parent)
connect(ui.action_Configure, SIGNAL(triggered()), this, SLOT(configDialog()));
connect(ui.actionE_xit, SIGNAL(triggered()), this, SLOT(shutdown()));
connect(ui.buttonChangeDevice, SIGNAL(clicked()), this, SLOT(configDialog()));
connect(ui.buttonEject, SIGNAL(clicked()), this, SLOT(eject()));
connect(ui.buttonTalk, SIGNAL(clicked()), this, SLOT(createTalkFiles()));
connect(ui.buttonCreateVoice, SIGNAL(clicked()), this, SLOT(createVoiceFile()));
connect(ui.buttonVoice, SIGNAL(clicked()), this, SLOT(installVoice()));
@ -733,3 +739,19 @@ void RbUtilQt::changeEvent(QEvent *e)
}
}
void RbUtilQt::eject(void)
{
QString mountpoint = RbSettings::value(RbSettings::Mountpoint).toString();
if(Utils::ejectDevice(mountpoint)) {
QMessageBox::information(this, tr("Device ejected"),
tr("Device successfully ejected. "
"You may now disconnect the player from the PC."));
}
else {
QMessageBox::critical(this, tr("Ejecting failed"),
tr("Ejecting the device failed. Please make sure no programs "
"are accessing files on the device. If ejecting still "
"fails please use your computers eject funtionality."));
}
}