From 328ff6d979c028ecba9c57d12c1e75637be20396 Mon Sep 17 00:00:00 2001 From: Dominik Riebeling Date: Sat, 8 Sep 2012 20:34:36 +0200 Subject: 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 --- rbutil/rbutilqt/rbutilqt.cpp | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'rbutil/rbutilqt/rbutilqt.cpp') diff --git a/rbutil/rbutilqt/rbutilqt.cpp b/rbutil/rbutilqt/rbutilqt.cpp index 62a4f583f7..aa0c365303 100644 --- a/rbutil/rbutilqt/rbutilqt.cpp +++ b/rbutil/rbutilqt/rbutilqt.cpp @@ -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.")); + } +} + -- cgit v1.2.3