Remove obsolete usb dialog
This commit is contained in:
parent
a87a3eef82
commit
5f0d26e64a
@ -80,7 +80,6 @@ signals:
|
||||
void cameraSave();
|
||||
void cameraRecord();
|
||||
void openConnectDialog();
|
||||
void openUSBDialog();
|
||||
void openWifiDialog();
|
||||
void showBrightnessSlider();
|
||||
void showVolumeSlider();
|
||||
|
@ -1,37 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include <QDialog>
|
||||
|
||||
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();
|
||||
};
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -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();
|
||||
|
@ -1,143 +0,0 @@
|
||||
#include <QMessageBox>
|
||||
#include <QFileInfo>
|
||||
#include <QTextStream>
|
||||
#include <f1x/openauto/autoapp/UI/USBDialog.hpp>
|
||||
#include <ui_usbdialog.h>
|
||||
#include <libusb.h>
|
||||
#include <blkid/blkid.h>
|
||||
#include <exception>
|
||||
|
||||
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);
|
||||
}
|
@ -1,285 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>USBDialog</class>
|
||||
<widget class="QDialog" name="USBDialog">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>500</width>
|
||||
<height>306</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>500</width>
|
||||
<height>300</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Connect to device</string>
|
||||
</property>
|
||||
<property name="styleSheet">
|
||||
<string notr="true">background-color: rgb(46, 52, 54);
|
||||
color: rgb(255, 255, 255);</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<widget class="QGroupBox" name="groupBoxUSB">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Minimum">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>0</width>
|
||||
<height>100</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="title">
|
||||
<string>USB Device List</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_3">
|
||||
<property name="topMargin">
|
||||
<number>9</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QListWidget" name="listWidgetUSB">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>0</width>
|
||||
<height>100</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="font">
|
||||
<font>
|
||||
<pointsize>14</pointsize>
|
||||
<weight>75</weight>
|
||||
<bold>true</bold>
|
||||
</font>
|
||||
</property>
|
||||
<property name="styleSheet">
|
||||
<string notr="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;
|
||||
}</string>
|
||||
</property>
|
||||
<property name="autoScrollMargin">
|
||||
<number>16</number>
|
||||
</property>
|
||||
<property name="editTriggers">
|
||||
<set>QAbstractItemView::NoEditTriggers</set>
|
||||
</property>
|
||||
<property name="gridSize">
|
||||
<size>
|
||||
<width>0</width>
|
||||
<height>40</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="batchSize">
|
||||
<number>100</number>
|
||||
</property>
|
||||
<property name="sortingEnabled">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QWidget" name="horizontalWidget" native="true">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<item>
|
||||
<widget class="QPushButton" name="pushButtonUpdate">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>0</width>
|
||||
<height>30</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>16777215</width>
|
||||
<height>30</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="font">
|
||||
<font>
|
||||
<weight>75</weight>
|
||||
<bold>true</bold>
|
||||
</font>
|
||||
</property>
|
||||
<property name="styleSheet">
|
||||
<string notr="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);</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Refresh</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="pushButtonMount">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>0</width>
|
||||
<height>30</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>16777215</width>
|
||||
<height>30</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="font">
|
||||
<font>
|
||||
<weight>75</weight>
|
||||
<bold>true</bold>
|
||||
</font>
|
||||
</property>
|
||||
<property name="styleSheet">
|
||||
<string notr="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);</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Mount</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="pushButtonRemove">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>0</width>
|
||||
<height>30</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>16777215</width>
|
||||
<height>30</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="baseSize">
|
||||
<size>
|
||||
<width>0</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="font">
|
||||
<font>
|
||||
<weight>75</weight>
|
||||
<bold>true</bold>
|
||||
</font>
|
||||
</property>
|
||||
<property name="styleSheet">
|
||||
<string notr="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);</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Unmount</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="pushButtonClose">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>0</width>
|
||||
<height>30</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>16777215</width>
|
||||
<height>30</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="font">
|
||||
<font>
|
||||
<weight>75</weight>
|
||||
<bold>true</bold>
|
||||
</font>
|
||||
</property>
|
||||
<property name="styleSheet">
|
||||
<string notr="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);</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Close</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
@ -34,7 +34,6 @@
|
||||
#include <f1x/openauto/autoapp/UI/MainWindow.hpp>
|
||||
#include <f1x/openauto/autoapp/UI/SettingsWindow.hpp>
|
||||
#include <f1x/openauto/autoapp/UI/ConnectDialog.hpp>
|
||||
#include <f1x/openauto/autoapp/UI/USBDialog.hpp>
|
||||
#include <f1x/openauto/autoapp/UI/WifiDialog.hpp>
|
||||
#include <f1x/openauto/Common/Log.hpp>
|
||||
|
||||
@ -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);
|
||||
|
Loading…
x
Reference in New Issue
Block a user