diff --git a/include/f1x/openauto/autoapp/UI/MainWindow.hpp b/include/f1x/openauto/autoapp/UI/MainWindow.hpp index cbadd18..d874a4e 100644 --- a/include/f1x/openauto/autoapp/UI/MainWindow.hpp +++ b/include/f1x/openauto/autoapp/UI/MainWindow.hpp @@ -80,7 +80,6 @@ signals: void cameraSave(); void cameraRecord(); void openConnectDialog(); - void openUSBDialog(); void openWifiDialog(); void showBrightnessSlider(); void showVolumeSlider(); diff --git a/include/f1x/openauto/autoapp/UI/USBDialog.hpp b/include/f1x/openauto/autoapp/UI/USBDialog.hpp deleted file mode 100644 index 0688dbb..0000000 --- a/include/f1x/openauto/autoapp/UI/USBDialog.hpp +++ /dev/null @@ -1,37 +0,0 @@ -#pragma once - -#include - -namespace Ui { -class USBDialog; -} - -namespace f1x -{ -namespace openauto -{ -namespace autoapp -{ -namespace ui -{ - -class USBDialog : public QDialog -{ - Q_OBJECT - -public: - explicit USBDialog(QWidget *parent = nullptr); - ~USBDialog() override; - - Ui::USBDialog *ui_; - -private slots: - void scanDrives(); - void on_pushButtonMount_clicked(); - void on_pushButtonRemove_clicked(); -}; - -} -} -} -} diff --git a/src/autoapp/UI/MainWindow.cpp b/src/autoapp/UI/MainWindow.cpp index a8ad0e8..c8a8f3a 100644 --- a/src/autoapp/UI/MainWindow.cpp +++ b/src/autoapp/UI/MainWindow.cpp @@ -166,7 +166,6 @@ MainWindow::MainWindow(configuration::IConfiguration::Pointer configuration, QWi connect(ui_->pushButtonMusic2, &QPushButton::clicked, this, &MainWindow::playerShow); connect(ui_->pushButtonBack, &QPushButton::clicked, this, &MainWindow::playerHide); connect(ui_->pushButtonPlayerBack, &QPushButton::clicked, this, &MainWindow::playerHide); - //connect(ui_->pushButtonUSB, &QPushButton::clicked, this, &MainWindow::openUSBDialog); // by default hide bluetooth button on init ui_->pushButtonBluetooth->hide(); diff --git a/src/autoapp/UI/USBDialog.cpp b/src/autoapp/UI/USBDialog.cpp deleted file mode 100644 index 4f6797f..0000000 --- a/src/autoapp/UI/USBDialog.cpp +++ /dev/null @@ -1,143 +0,0 @@ -#include -#include -#include -#include -#include -#include -#include -#include - -namespace f1x -{ -namespace openauto -{ -namespace autoapp -{ -namespace ui -{ - -USBDialog::USBDialog(QWidget *parent) - : QDialog(parent) - , ui_(new Ui::USBDialog) -{ - ui_->setupUi(this); - connect(ui_->pushButtonClose, &QPushButton::clicked, this, &USBDialog::close); - connect(ui_->pushButtonUpdate, &QPushButton::clicked, this, &USBDialog::scanDrives); - scanDrives(); - ui_->listWidgetUSB->setCurrentRow(0); -} - -USBDialog::~USBDialog() -{ - delete ui_; -} - -} -} -} -} - -void f1x::openauto::autoapp::ui::USBDialog::scanDrives() -{ - int currentdevice = 0; - int cleaner = ui_->listWidgetUSB->count(); - while (cleaner > -1) { - ui_->listWidgetUSB->takeItem(cleaner); - cleaner--; - } - ui_->listWidgetUSB->clear(); - - QFile partitionsFile(QString("/proc/partitions")); - partitionsFile.open(QIODevice::ReadOnly); - QTextStream data_return(&partitionsFile); - QStringList localpartitions; - localpartitions = data_return.readAll().split("\n"); - partitionsFile.close(); - - while (currentdevice < localpartitions.count()-1) { - QString line = localpartitions[currentdevice].simplified(); - QString device = line.split(" ")[3]; - - // filter partition list for drives - not nice but working - if (!device.startsWith("ram") && !device.startsWith("name") && !device.startsWith("mmc") && device != "") { - if (!device.endsWith("0") && !device.endsWith("1") && !device.endsWith("2") && !device.endsWith("3") && !device.endsWith("4") && !device.endsWith("5") && !device.endsWith("6") && !device.endsWith("7") && !device.endsWith("8") && !device.endsWith("9")) { - device = "/dev/" + device; - const char *dev_base_name = QString(device).toStdString().c_str(); - blkid_probe pr = blkid_new_probe_from_filename(dev_base_name); - blkid_partlist ls; - int nparts, i=1; - ls = blkid_probe_get_partitions(pr); - nparts = blkid_partlist_numof_partitions(ls); - - const char *label; - const char *type; - const char *mounted; - - while (i <= nparts) { - QString partitionpath = QString(device) + QString::number(i); - const char *dev_name = QString(partitionpath).toStdString().c_str(); - pr = blkid_new_probe_from_filename(dev_name); - blkid_do_probe(pr); - blkid_probe_lookup_value(pr, "LABEL", &label, nullptr); - blkid_probe_lookup_value(pr, "TYPE", &type, nullptr); - // exclude CSSTORAGE cause mounted another way by system service - if (QString::fromStdString(label) != "CSSTORAGE") { - // check mount state - if (system(qPrintable("mount | grep " + partitionpath + " >/dev/null")) != 0) { - mounted = "unmounted"; - } else { - mounted = "mounted"; - } - ui_->listWidgetUSB->addItem(QString::fromStdString(dev_name) + " (" + QString::fromStdString(label) + " / " + QString::fromStdString(type) + " | " + QString::fromStdString(mounted) + ")"); - ui_->listWidgetUSB->update(); - } - i++; - } - blkid_free_probe(pr); - } - } - currentdevice++; - } - system("/usr/local/bin/autoapp_helper cleansymlinks &"); - ui_->listWidgetUSB->setCurrentRow(0); -} - -void f1x::openauto::autoapp::ui::USBDialog::on_pushButtonMount_clicked() -{ - QString selected = ui_->listWidgetUSB->item(ui_->listWidgetUSB->currentRow())->text(); - if (ui_->listWidgetUSB->count() > 0 && selected.contains("/dev/")) { - QString mountfulldevicepath = selected.split(" ")[0]; - QString mountdevice = mountfulldevicepath.split("/")[2]; - - system(qPrintable("sudo umount -f " + mountfulldevicepath + " >/dev/null")); - system(qPrintable("sudo fuser -km /media/USBDRIVES/" + mountdevice + " >/dev/null")); - system(qPrintable("sudo mkdir -p /media/USBDRIVES/" + mountdevice + " >/dev/null")); - system(qPrintable("sudo chmod 777 /media/USBDRIVES/" + mountdevice + " >/dev/null")); - system(qPrintable("sudo mount " + mountfulldevicepath + " /media/USBDRIVES/" + mountdevice + " >/dev/null")); - system(qPrintable("ln -s /media/USBDRIVES/" + mountdevice + "/Music/* /media/MYMEDIA >/dev/null")); - scanDrives(); - } else { - QMessageBox errorMessage(QMessageBox::Critical, "Select error", "Nothing selected!", QMessageBox::Ok); - errorMessage.setWindowFlags(Qt::WindowStaysOnTopHint); - errorMessage.exec(); - } - ui_->listWidgetUSB->setCurrentRow(0); -} - -void f1x::openauto::autoapp::ui::USBDialog::on_pushButtonRemove_clicked() -{ - QString selected = ui_->listWidgetUSB->item(ui_->listWidgetUSB->currentRow())->text(); - if (ui_->listWidgetUSB->count() > 0 && selected.contains("/dev/")) { - QString mountfulldevicepath = selected.split(" ")[0]; - QString mountdevice = mountfulldevicepath.split("/")[2]; - - system(qPrintable("sudo umount -f " + mountfulldevicepath + " >/dev/null" + " && sudo rmdir /media/USBDRIVES/" + mountdevice + " >/dev/null")); - system(qPrintable("sudo fuser -km /media/USBDRIVES/" + mountdevice + " >/dev/null" + " && sudo rmdir /media/USBDRIVES/" + mountdevice + " >/dev/null")); - scanDrives(); - } else { - QMessageBox errorMessage(QMessageBox::Critical, "Select error", "Nothing selected!", QMessageBox::Ok); - errorMessage.setWindowFlags(Qt::WindowStaysOnTopHint); - errorMessage.exec(); - } - ui_->listWidgetUSB->setCurrentRow(0); -} diff --git a/src/autoapp/UI/usbdialog.ui b/src/autoapp/UI/usbdialog.ui deleted file mode 100644 index fe60527..0000000 --- a/src/autoapp/UI/usbdialog.ui +++ /dev/null @@ -1,285 +0,0 @@ - - - USBDialog - - - - 0 - 0 - 500 - 306 - - - - - 0 - 0 - - - - - 500 - 300 - - - - Connect to device - - - background-color: rgb(46, 52, 54); -color: rgb(255, 255, 255); - - - - - - - 0 - 0 - - - - - 0 - 100 - - - - USB Device List - - - - 9 - - - - - - 0 - 0 - - - - - 0 - 100 - - - - - 14 - 75 - true - - - - QScrollBar { - width: 40px; - background-color: rgba(85, 87, 83, 0.7); -} - -QWidget { -background-color: rgba(85, 87, 83, 0.7); -color: rgb(255, 255, 255); -border: 2px solid rgba(255,255,255,0.5); -outline: none; -} - -QListView { - height: 40px; -} - - - 16 - - - QAbstractItemView::NoEditTriggers - - - - 0 - 40 - - - - 100 - - - true - - - - - - - - - - - 0 - 0 - - - - - - - - 0 - 0 - - - - - 0 - 30 - - - - - 16777215 - 30 - - - - - 75 - true - - - - background-color: rgba(186, 189, 182, 0.5); -border-radius: 4px; -border: 2px solid rgba(255,255,255,0.5); -color: rgb(255, 255, 255); - - - Refresh - - - - - - - - 0 - 0 - - - - - 0 - 30 - - - - - 16777215 - 30 - - - - - 75 - true - - - - background-color: rgba(138, 226, 52, 0.5); -border-radius: 4px; -border: 2px solid rgba(255,255,255,0.5); -color: rgb(255, 255, 255); - - - Mount - - - - - - - - 0 - 0 - - - - - 0 - 30 - - - - - 16777215 - 30 - - - - - 0 - 0 - - - - - 75 - true - - - - background-color: rgba(164, 0, 0, 0.5); -border-radius: 4px; -border: 2px solid rgba(255,255,255,0.5); -color: rgb(255, 255, 255); - - - Unmount - - - - - - - - 0 - 0 - - - - - 0 - 30 - - - - - 16777215 - 30 - - - - - 75 - true - - - - background-color: rgba(186, 189, 182, 0.5); -border-radius: 4px; -border: 2px solid rgba(255,255,255,0.5); -color: rgb(255, 255, 255); - - - Close - - - - - - - - - - - diff --git a/src/autoapp/autoapp.cpp b/src/autoapp/autoapp.cpp index 4d38cbf..f159855 100644 --- a/src/autoapp/autoapp.cpp +++ b/src/autoapp/autoapp.cpp @@ -34,7 +34,6 @@ #include #include #include -#include #include #include @@ -106,11 +105,6 @@ int main(int argc, char* argv[]) autoapp::configuration::RecentAddressesList recentAddressesList(7); recentAddressesList.read(); - autoapp::ui::USBDialog usbDialog; - usbDialog.setWindowFlags(Qt::WindowStaysOnTopHint); - // center dialog - usbDialog.move((width - 500)/2,(height-306)/2); - autoapp::ui::WifiDialog wifiDialog; wifiDialog.setWindowFlags(Qt::WindowStaysOnTopHint); // center dialog @@ -127,7 +121,6 @@ int main(int argc, char* argv[]) QObject::connect(&mainWindow, &autoapp::ui::MainWindow::openSettings, &settingsWindow, &autoapp::ui::SettingsWindow::showFullScreen); QObject::connect(&mainWindow, &autoapp::ui::MainWindow::openSettings, &settingsWindow, &autoapp::ui::SettingsWindow::loadSystemValues); QObject::connect(&mainWindow, &autoapp::ui::MainWindow::openConnectDialog, &connectDialog, &autoapp::ui::ConnectDialog::exec); - QObject::connect(&mainWindow, &autoapp::ui::MainWindow::openUSBDialog, &usbDialog, &autoapp::ui::USBDialog::exec); QObject::connect(&mainWindow, &autoapp::ui::MainWindow::openWifiDialog, &wifiDialog, &autoapp::ui::WifiDialog::exec); qApplication.setOverrideCursor(Qt::BlankCursor);