[PC-BSD Commits] r15139 - pcbsd/current/src-qt4/pc-bluetoothmanager
svn at pcbsd.org
svn at pcbsd.org
Thu Feb 2 10:28:10 PST 2012
Author: kenmoore
Date: 2012-02-02 18:28:09 +0000 (Thu, 02 Feb 2012)
New Revision: 15139
Modified:
pcbsd/current/src-qt4/pc-bluetoothmanager/btmaingui.cpp
pcbsd/current/src-qt4/pc-bluetoothmanager/btmaingui.h
pcbsd/current/src-qt4/pc-bluetoothmanager/btmaingui.ui
Log:
Large number of changes to the bluetooth GUI - fixed bugs, cleaned up interface, make sure all buttons work properly, actively enable/disable buttons, etc...
Modified: pcbsd/current/src-qt4/pc-bluetoothmanager/btmaingui.cpp
===================================================================
--- pcbsd/current/src-qt4/pc-bluetoothmanager/btmaingui.cpp 2012-02-02 17:09:31 UTC (rev 15138)
+++ pcbsd/current/src-qt4/pc-bluetoothmanager/btmaingui.cpp 2012-02-02 18:28:09 UTC (rev 15139)
@@ -8,7 +8,7 @@
/* UI handles
* Comp settings Tab: pushChangeCompName pushDisconnectDevice pushRestart lineCompName listConnectedDevices
* New Device Tab: pushAddDevice pushScanNew listNewDevice newDeviceInfo
- * Old Device Tab: pushConfigureOld pushRemoveOld listOldDevice oldDeviceInfo
+ * Old Device Tab: pushConfigureOld pushRemoveOld listOldDevice oldDeviceInfo pushConnectDevice
*/
QStringList oldSaveBdaddrList, oldSaveKeyList, oldSavePinList, oldSaveNameList, newSaveBdaddrList, currentSaveDeviceList;
@@ -32,32 +32,73 @@
connect(ui->tabWidget,SIGNAL(currentChanged(int)),this,SLOT(tabChanged(int)));
connect(ui->pushRemoveOld,SIGNAL(clicked()),this,SLOT(removeOldDevice()));
connect(ui->listOldDevice,SIGNAL(currentRowChanged(int)),this,SLOT(updateOldDeviceInfo(int)));
+ connect(ui->listNewDevice,SIGNAL(currentRowChanged(int)),this,SLOT(refreshGUIslot(int)));
+ connect(ui->listConnectedDevices,SIGNAL(currentRowChanged(int)),this,SLOT(refreshGUIslot(int)));
connect(ui->pushAddDevice,SIGNAL(clicked()),this,SLOT(addNewDevice()));
connect(ui->pushConfigureOld,SIGNAL(clicked()),this,SLOT(configureOldDevice()));
connect(ui->pushDisconnectDevice,SIGNAL(clicked()),this,SLOT(disconnectDevice()));
+ connect(ui->pushConnectDevice,SIGNAL(clicked()),this,SLOT(connectDevice()));
+ connect(ui->pushRestart,SIGNAL(clicked()),this,SLOT(restartBluetooth()));
+ connect(ui->pushChangeCompName,SIGNAL(clicked()),this,SLOT(changeCompName()));
//Setup GUI enables/disables
//Start on the system settings tab
ui->tabWidget->setCurrentIndex(0);
//Load the information for each Tab as needed
updateCompInfo(); //Load info for computer settings tab
- scanForDevices(); //Do an initial Scan for available devices
refreshOldDeviceList(); //Load info for the saved devices tab (fill needed arrays)
+ refreshGUI();
}
void btmaingui::tabChanged(int newTab){
+
if(newTab==0){ //Computer Settings
updateCompInfo();
}else if(newTab==1){ //New Device Tab
- //Do nothing
+ if(newSaveBdaddrList.isEmpty() ){ refreshGUI(); scanForDevices(); }
}else if(newTab==2){ //Old Device Tab
refreshOldDeviceList();
}else{
qDebug() << "BlueToothManager: TabChanged Error: Tab #"<< newTab << " does not exist";
}
+ refreshGUI();
}
+void btmaingui::refreshGUI(){
+ //Get the current Tab
+ int tab = ui->tabWidget->currentIndex();
+ refreshGUIslot(tab);
+}
+
+void btmaingui::refreshGUIslot(int tab){
+ //Setup the dynamic enables/disables for each tab
+ if(tab==0){ //Computer Setting Tab
+ if(ui->listConnectedDevices->currentRow() == -1){ui->pushDisconnectDevice->setEnabled(FALSE);}
+ else{ui->pushDisconnectDevice->setEnabled(TRUE);}
+ ui->pushRestart->setEnabled(TRUE);
+ }else if(tab==1){
+ if(ui->listNewDevice->currentRow() == -1){ui->pushAddDevice->setEnabled(FALSE);}
+ else{ui->pushAddDevice->setEnabled(TRUE);}
+ ui->pushScanNew->setEnabled(TRUE);
+ }else if(tab==2){
+ if(ui->listOldDevice->currentRow() == -1){
+ ui->pushConfigureOld->setEnabled(FALSE);
+ ui->pushRemoveOld->setEnabled(FALSE);
+ ui->pushConnectDevice->setEnabled(FALSE);
+ }else{
+ ui->pushConfigureOld->setEnabled(TRUE);
+ ui->pushRemoveOld->setEnabled(TRUE);
+ ui->pushConnectDevice->setEnabled(TRUE);
+ }
+
+ }else{
+ qDebug() << "Attempted to refresh an unknown tab number:" << tab;
+ }
+}
+
void btmaingui::scanForDevices(){
+ ui->pushScanNew->setEnabled(FALSE);
+ ui->pushAddDevice->setEnabled(FALSE);
//Clear the GUI for new results
ui->newDeviceInfo->clear();
ui->newDeviceInfo->append(tr("Searching for discoverable Bluetooth devices"));
@@ -68,8 +109,7 @@
QStringList connectionList = Utils::runShellCommand("hccontrol read_connection_list");
for(int i=0; i<bdaddrList.length(); i++){
if( !connectionList.contains(bdaddrList[i]) && !oldSaveBdaddrList.contains(bdaddrList[i]) ){ //Check if it is a new device (not connected or saved)
- QString name = Hardware::getBTRemoteName(bdaddrList[i]);
- if( name.isEmpty() ){name = Hardware::getBTRemoteName(bdaddrList[i]);} //try one more time - have noticed occasional inconsistancy
+ QString name = Hardware::getBTRemoteName(bdaddrList[i],TRUE);
newSaveBdaddrList << bdaddrList[i];
ui->listNewDevice->addItem(name+" ("+bdaddrList[i]+")"); //Add it to the new device list
}
@@ -79,6 +119,8 @@
if(ui->listNewDevice->count()==0){ //No Devices found
ui->newDeviceInfo->append(tr("No new Bluetooth devices discovered! Please put your device into \"discovery\" mode and rescan."));
}
+ ui->pushScanNew->setEnabled(TRUE);
+ refreshGUI();
}
void btmaingui::refreshOldDeviceList(){
@@ -169,11 +211,13 @@
}
if(pin == "none"){ pin=""; }
+ ui->pushAddDevice->setEnabled(FALSE);
//Add the entry to hcsecd.conf
Hardware::addBTdevice(bdaddr,"",key,pin);
//Move to the Saved devices tab
ui->tabWidget->setCurrentIndex(2);
refreshOldDeviceList();
+ refreshGUI();
//Initiate pairing of device
QString result = Hardware::pairBTDevice(bdaddr);
@@ -196,7 +240,7 @@
for(int i=1; i<connectionList.length(); i++){ //skip the first line (labels)
QString bdaddr = connectionList[i].section(" ",0,0,QString::SectionSkipEmpty).simplified();
currentSaveDeviceList << bdaddr;
- QString name = Hardware::getBTRemoteName(bdaddr);
+ QString name = Hardware::getBTRemoteName(bdaddr,TRUE);
ui->listConnectedDevices->addItem(name+" ("+bdaddr+")");
}
}
@@ -216,6 +260,7 @@
ui->oldDeviceInfo->append("Key: "+oldSaveKeyList[row]);
ui->oldDeviceInfo->append("PIN: "+oldSavePinList[row]);
}
+ refreshGUI();
}
bool btmaingui::rootPermissions(){
@@ -226,7 +271,7 @@
void btmaingui::configureOldDevice(){
//Get the selected device information
- int row = ui->listOldDevice->currentRow();
+ int row = ui->listOldDevice->currentRow();
if(row == -1){
//No device selected
QMessageBox::warning(this,tr("Warning"),tr("No device has been selected. Please choose a device first."));
@@ -271,3 +316,67 @@
//Refresh the Box
updateCompInfo();
}
+
+void btmaingui::connectDevice(){
+ //Get the selected device
+ int row = ui->listOldDevice->currentRow();
+ if(row == -1){
+ //No device selected
+ QMessageBox::warning(this,tr("Warning"),tr("No device has been selected. Please choose a device first."));
+ return;
+ }
+ QString bdaddr = oldSaveBdaddrList[row];
+
+ //Initiate connection (pairing)
+ QString result = Hardware::pairBTDevice(bdaddr);
+
+ //Determine if the connection was successful
+ if(!result.isEmpty()){
+ //Error making the connection
+ QMessageBox::warning(this,tr("Pairing Error"),tr("Could not pair to this device. Please verify your device configuration before trying again."));
+ qDebug() << "Bluetooth Connection: " + result; //display the full error on the command line
+ return;
+ }
+
+ //Connection successful - cleanup GUI
+ ui->tabWidget->setCurrentIndex(0); //move to the Computer settings tab
+ updateCompInfo();
+ refreshGUI();
+
+}
+
+void btmaingui::restartBluetooth(){
+ ui->pushRestart->setEnabled(FALSE);
+ Hardware::restartBT();
+ //refresh the GUI
+ updateCompInfo();
+ refreshGUI();
+
+}
+
+void btmaingui::changeCompName(){
+ //Get the desired computer name
+ QStringList requests;
+ requests << tr("New Bluetooth Computer name");
+ QStringList outputs = Utils::quickUserInputBox(tr("New Bluetooth Name"),requests);
+ //Check for invalid names
+ if( outputs.join(" ").simplified().isEmpty() ){
+ //Error/cancelled operation - do nothing
+ qDebug() << "Change Computer Name: Cancelled";
+ return;
+ }else if(outputs.join(" ").contains("(") || outputs.join(" ").contains(")") || outputs.join(" ").contains(":") ){
+ QMessageBox::warning(this,tr("Invalid Name"),tr("Device name must not contain symbols"));
+ return;
+ }
+ QString newName = outputs[0];
+
+ //Retrieve the current device names
+ QStringList oNames = Hardware::getBTdevNames();
+
+ //Change the current computer name
+ Hardware::setBTdevName(newName,oNames[1]);
+
+ //Refresh the GUI
+ updateCompInfo();
+
+}
Modified: pcbsd/current/src-qt4/pc-bluetoothmanager/btmaingui.h
===================================================================
--- pcbsd/current/src-qt4/pc-bluetoothmanager/btmaingui.h 2012-02-02 17:09:31 UTC (rev 15138)
+++ pcbsd/current/src-qt4/pc-bluetoothmanager/btmaingui.h 2012-02-02 18:28:09 UTC (rev 15139)
@@ -21,10 +21,12 @@
Ui::btmaingui *ui;
void firstRun();
bool rootPermissions();
+ void refreshGUI();
private slots:
void scanForDevices();
void tabChanged(int);
+ void refreshGUIslot(int);
void refreshOldDeviceList();
void removeOldDevice();
void addNewDevice();
@@ -33,6 +35,9 @@
void updateOldDeviceInfo(int);
void configureOldDevice();
void disconnectDevice();
+ void connectDevice();
+ void restartBluetooth();
+ void changeCompName();
};
#endif // BTMAINGUI_H
Modified: pcbsd/current/src-qt4/pc-bluetoothmanager/btmaingui.ui
===================================================================
(Binary files differ)
More information about the Commits
mailing list