update latest dev

This commit is contained in:
hawkeyexp 2019-01-20 11:00:44 +01:00
parent c63494334b
commit 4ebdcd935f
2 changed files with 97 additions and 89 deletions

View File

@ -157,12 +157,8 @@ MainWindow::MainWindow(configuration::IConfiguration::Pointer configuration, QWi
ui_->labelLockDummy->hide(); ui_->labelLockDummy->hide();
} }
if (check_file_exist("/etc/crankshaft.branch")) { if (std::ifstream("/etc/crankshaft.branch")) {
QFile branchFile(QString("/etc/crankshaft.branch")); QString branch = configuration_->readFileContent("/etc/crankshaft.branch");
branchFile.open(QIODevice::ReadOnly);
QTextStream data_branch(&branchFile);
QString branch = data_branch.readAll().split("\n")[0];
branchFile.close();
if (branch != "crankshaft-ng") { if (branch != "crankshaft-ng") {
if (branch == "csng-dev") { if (branch == "csng-dev") {
ui_->Header_Label->setText("<html><head/><body><p><span style=' font-style:normal; color:#ffffff;'>crank</span><span style=' font-style:normal; color:#5ce739;'>shaft </span><span style=' font-style:normal; color:#40bfbf;'>NG </span><span style=' font-style:normal; color:#888a85;'>- </span><span style=' font-style:normal; color:#cc0000;'>Dev-Build</span></p></body></html>"); ui_->Header_Label->setText("<html><head/><body><p><span style=' font-style:normal; color:#ffffff;'>crank</span><span style=' font-style:normal; color:#5ce739;'>shaft </span><span style=' font-style:normal; color:#40bfbf;'>NG </span><span style=' font-style:normal; color:#888a85;'>- </span><span style=' font-style:normal; color:#cc0000;'>Dev-Build</span></p></body></html>");
@ -206,8 +202,22 @@ MainWindow::MainWindow(configuration::IConfiguration::Pointer configuration, QWi
ui_->pushButtonLock->hide(); ui_->pushButtonLock->hide();
ui_->pushButtonLock2->hide(); ui_->pushButtonLock2->hide();
ui_->btDevice->hide(); ui_->btDevice->hide();
// check if a device is connected via bluetooth
if (std::ifstream("/tmp/btdevice")) {
if (ui_->btDevice->isVisible() == false || ui_->btDevice->text().simplified() == "") {
QString btdevicename = configuration_->readFileContent("/tmp/btdevice");
ui_->btDevice->setText(btdevicename);
ui_->btDevice->show();
}
} else {
if (ui_->btDevice->isVisible() == true) {
ui_->btDevice->hide();
}
}
// hide brightness slider of control file is not existing // hide brightness slider of control file is not existing
QFileInfo brightnessFile(brightnessFilename); QFileInfo brightnessFile(brightnessFilename);
if (!brightnessFile.exists() && !this->brightnessButtonForce) { if (!brightnessFile.exists() && !this->brightnessButtonForce) {
@ -402,13 +412,8 @@ MainWindow::MainWindow(configuration::IConfiguration::Pointer configuration, QWi
// read param file // read param file
if (std::ifstream("/boot/crankshaft/volume")) { if (std::ifstream("/boot/crankshaft/volume")) {
QFile audioparamFile(QString("/boot/crankshaft/volume"));
audioparamFile.open(QIODevice::ReadOnly);
QTextStream data_param(&audioparamFile);
QString getparams = data_param.readAll();
audioparamFile.close();
// init volume // init volume
QString vol=QString::number(getparams.toInt()); QString vol=QString::number(configuration_->readFileContent("/boot/crankshaft/volume").toInt());
ui_->volumeValueLabel->setText(vol+"%"); ui_->volumeValueLabel->setText(vol+"%");
ui_->horizontalSliderVolume->setValue(vol.toInt()); ui_->horizontalSliderVolume->setValue(vol.toInt());
} }
@ -795,9 +800,9 @@ void f1x::openauto::autoapp::ui::MainWindow::updateAlpha()
ui_->pushButtonDummy3->setStyleSheet( "background-color: rgba(186, 189, 182, " + alp + " ); border-radius: 4px; border: 2px solid rgba(255,255,255,0.5);"); ui_->pushButtonDummy3->setStyleSheet( "background-color: rgba(186, 189, 182, " + alp + " ); border-radius: 4px; border: 2px solid rgba(255,255,255,0.5);");
ui_->pushButtonDebug->setStyleSheet( "background-color: rgba(85, 87, 83, " + alp + " ); border-radius: 4px; border: 2px solid rgba(255,255,255,0.5);"); ui_->pushButtonDebug->setStyleSheet( "background-color: rgba(85, 87, 83, " + alp + " ); border-radius: 4px; border: 2px solid rgba(255,255,255,0.5);");
ui_->pushButtonMusic->setStyleSheet( "background-color: rgba(78, 154, 6, " + alp + " ); border-radius: 4px; border: 2px solid rgba(255,255,255,0.5); color: rgb(255,255,255);"); ui_->pushButtonMusic->setStyleSheet( "background-color: rgba(78, 154, 6, " + alp + " ); border-radius: 4px; border: 2px solid rgba(255,255,255,0.5); color: rgb(255,255,255);");
ui_->pushButtonAndroidAuto->setStyleSheet( "background-color: rgba(48, 140, 198, " + alp + " ); border-radius: 4px; border: 2px solid rgba(255,255,255,0.5); color: rgb(255,255,255); border-bottom: 0px; border-top: 0px;"); ui_->pushButtonAndroidAuto->setStyleSheet( "background-color: rgba(48, 140, 198, " + alp + " ); border: 2px solid rgba(255,255,255,0.5); color: rgb(255,255,255); border-bottom: 0px; border-top: 0px;");
ui_->labelAndroidAutoBottom->setStyleSheet( "background-color: rgba(48, 140, 198, " + alp + " ); border-radius: 4px; border: 2px solid rgba(255,255,255,0.5); color: rgb(255,255,255); border-top: 0px;"); ui_->labelAndroidAutoBottom->setStyleSheet( "background-color: rgba(48, 140, 198, " + alp + " ); border-bottom-left-radius: 4px; border-bottom-right-radius: 4px; border: 2px solid rgba(255,255,255,0.5); color: rgb(255,255,255); border-top: 0px;");
ui_->labelAndroidAutoTop->setStyleSheet( "background-color: rgba(48, 140, 198, " + alp + " ); border-radius: 4px; border: 2px solid rgba(255,255,255,0.5); color: rgb(255,255,255); border-bottom: 0px;"); ui_->labelAndroidAutoTop->setStyleSheet( "background-color: rgba(48, 140, 198, " + alp + " ); border-top-left-radius: 4px; border-top-right-radius: 4px; border: 2px solid rgba(255,255,255,0.5); color: rgb(255,255,255); border-bottom: 0px;");
ui_->pushButtonNoDevice->setStyleSheet( "background-color: rgba(48, 140, 198, " + alp + " ); border-radius: 4px; border: 2px solid rgba(255,255,255,0.5); color: rgb(255,255,255);"); ui_->pushButtonNoDevice->setStyleSheet( "background-color: rgba(48, 140, 198, " + alp + " ); border-radius: 4px; border: 2px solid rgba(255,255,255,0.5); color: rgb(255,255,255);");
ui_->pushButtonNoWiFiDevice->setStyleSheet( "background-color: rgba(252, 175, 62, " + alp + " ); border-radius: 4px; border: 2px solid rgba(255,255,255,0.5); color: rgb(255,255,255);"); ui_->pushButtonNoWiFiDevice->setStyleSheet( "background-color: rgba(252, 175, 62, " + alp + " ); border-radius: 4px; border: 2px solid rgba(255,255,255,0.5); color: rgb(255,255,255);");
// old style // old style
@ -1064,8 +1069,33 @@ void f1x::openauto::autoapp::ui::MainWindow::showTime()
MainWindow::updateBG(); MainWindow::updateBG();
} }
} }
}
// check connected devices
if (localDevice->isValid()) {
QString localDeviceName = localDevice->name();
QString localDeviceAddress = localDevice->address().toString();
QList<QBluetoothAddress> btdevices;
btdevices = localDevice->connectedDevices();
int count = btdevices.count();
if (count > 0) {
//QBluetoothAddress btdevice = btdevices[0];
//QString btmac = btdevice.toString();
//ui_->btDeviceCount->setText(QString::number(count));
if (ui_->btDevice->isVisible() == false) {
ui_->btDevice->show();
}
if (std::ifstream("/tmp/btdevice")) {
ui_->btDevice->setText(configuration_->readFileContent("/tmp/btdevice"));
}
} else {
if (ui_->btDevice->isVisible() == true) {
ui_->btDevice->hide();
ui_->btDevice->setText("BT-Device");
}
}
}
}
void f1x::openauto::autoapp::ui::MainWindow::on_horizontalSliderProgressPlayer_sliderMoved(int position) void f1x::openauto::autoapp::ui::MainWindow::on_horizontalSliderProgressPlayer_sliderMoved(int position)
{ {
@ -1171,17 +1201,28 @@ void f1x::openauto::autoapp::ui::MainWindow::on_mp3List_itemClicked(QListWidgetI
void f1x::openauto::autoapp::ui::MainWindow::metaDataChanged() void f1x::openauto::autoapp::ui::MainWindow::metaDataChanged()
{ {
QString fullpathplaying = player->currentMedia().canonicalUrl().toString();
QString filename = QFileInfo(fullpathplaying).fileName();
QImage img = player->metaData(QMediaMetaData::CoverArtImage).value<QImage>(); QImage img = player->metaData(QMediaMetaData::CoverArtImage).value<QImage>();
QImage imgscaled = img.scaled(270,270,Qt::IgnoreAspectRatio); QImage imgscaled = img.scaled(270,270,Qt::IgnoreAspectRatio);
if (!imgscaled.isNull()) { if (!imgscaled.isNull()) {
ui_->pushButtonBack->setIcon(QPixmap::fromImage(imgscaled)); ui_->pushButtonBack->setIcon(QPixmap::fromImage(imgscaled));
} else { } else {
ui_->pushButtonBack->setIcon(QPixmap("://coverlogo.png")); if (playlist->currentIndex() != -1 && fullpathplaying != "") {
QString filename = ui_->mp3List->item(playlist->currentIndex())->text();
QString cover = this->musicfolder + "/" + this->albumfolder + "/" + filename + ".png";
if (check_file_exist(cover.toStdString().c_str())) {
QPixmap img = cover;
ui_->pushButtonBack->setIcon(img.scaled(270,270,Qt::KeepAspectRatio));
} else {
ui_->pushButtonBack->setIcon(QPixmap("://coverlogo.png"));
}
} else {
ui_->pushButtonBack->setIcon(QPixmap("://coverlogo.png"));
}
} }
QString fullpathplaying = player->currentMedia().canonicalUrl().toString();
QString filename = QFileInfo(fullpathplaying).fileName();
try { try {
// use metadata from mp3list widget (prescanned id3 by taglib) // use metadata from mp3list widget (prescanned id3 by taglib)
if (playlist->currentIndex() != -1 && fullpathplaying != "") { if (playlist->currentIndex() != -1 && fullpathplaying != "") {
@ -1310,29 +1351,36 @@ void f1x::openauto::autoapp::ui::MainWindow::scanFiles()
QList<QMediaContent> content; QList<QMediaContent> content;
QDir directory(this->musicfolder + "/" + this->albumfolder); QDir directory(this->musicfolder + "/" + this->albumfolder);
QStringList mp3s = directory.entryList(QStringList() << "*.mp3" << "*.flac" << "*.aac" << "*.ogg" << "*.mp4" << "*.mp4a" << "*.wma",QDir::Files, QDir::Name); QStringList mp3s = directory.entryList(QStringList() << "*.mp3" << "*.flac" << "*.aac" << "*.ogg" << "*.mp4" << "*.mp4a" << "*.wma" << "*.strm",QDir::Files, QDir::Name);
foreach (QString filename, mp3s) { foreach (QString filename, mp3s) {
// add to mediacontent // add to mediacontent
content.push_back(QMediaContent(QUrl::fromLocalFile(this->musicfolder + "/" + this->albumfolder + "/" + filename))); if (filename.endsWith(".strm")) {
// add items to gui QString url=configuration_->readFileContent(this->musicfolder + "/" + this->albumfolder + "/" + filename);
// read metadata using taglib content.push_back(QMediaContent(QUrl(url)));
try { ui_->mp3List->addItem(filename.replace(".strm",""));
TagLib::FileRef file((this->musicfolder + "/" + this->albumfolder + "/" + filename).toUtf8(),true); //ui_->mp3List->addItem(url);
TagLib::String artist_string = file.tag()->artist(); } else {
TagLib::String title_string = file.tag()->title(); content.push_back(QMediaContent(QUrl::fromLocalFile(this->musicfolder + "/" + this->albumfolder + "/" + filename)));
TagLib::uint track_string = file.tag()->track(); // add items to gui
QString artistid3 = QString::fromStdWString(artist_string.toCWString()); // read metadata using taglib
QString titleid3 = QString::fromStdWString(title_string.toCWString()); try {
QString trackid3 = QString::number(track_string); TagLib::FileRef file((this->musicfolder + "/" + this->albumfolder + "/" + filename).toUtf8(),true);
int tracklength = trackid3.length(); TagLib::String artist_string = file.tag()->artist();
if (tracklength < 2) { TagLib::String title_string = file.tag()->title();
trackid3 = "0" + trackid3; TagLib::uint track_string = file.tag()->track();
QString artistid3 = QString::fromStdWString(artist_string.toCWString());
QString titleid3 = QString::fromStdWString(title_string.toCWString());
QString trackid3 = QString::number(track_string);
int tracklength = trackid3.length();
if (tracklength < 2) {
trackid3 = "0" + trackid3;
}
QString ID3Entry = trackid3 + ": " + artistid3 + " - " + titleid3;
ui_->mp3List->addItem(ID3Entry);
} catch (...) {
// old way only adding filename to list
ui_->mp3List->addItem(filename);
} }
QString ID3Entry = trackid3 + ": " + artistid3 + " - " + titleid3;
ui_->mp3List->addItem(ID3Entry);
} catch (...) {
// old way only adding filename to list
ui_->mp3List->addItem(filename);
} }
} }
// set playlist // set playlist
@ -1479,7 +1527,6 @@ void f1x::openauto::autoapp::ui::MainWindow::tmpChanged()
try { try {
if (std::ifstream("/tmp/entityexit")) { if (std::ifstream("/tmp/entityexit")) {
MainWindow::TriggerAppStop(); MainWindow::TriggerAppStop();
usleep(1000000);
std::remove("/tmp/entityexit"); std::remove("/tmp/entityexit");
} }
} catch (...) { } catch (...) {
@ -1617,23 +1664,6 @@ void f1x::openauto::autoapp::ui::MainWindow::tmpChanged()
} }
} }
// check if a device is connected via bluetooth
if (std::ifstream("/tmp/btdevice")) {
if (ui_->btDevice->isVisible() == false || ui_->btDevice->text().simplified() == "") {
QFile phoneBTData(QString("/tmp/btdevice"));
phoneBTData.open(QIODevice::ReadOnly);
QTextStream data_date(&phoneBTData);
QString linedate = data_date.readAll();
phoneBTData.close();
ui_->btDevice->setText(linedate.simplified());
ui_->btDevice->show();
}
} else {
if (ui_->btDevice->isVisible() == true) {
ui_->btDevice->hide();
}
}
if (std::ifstream("/tmp/config_in_progress") || std::ifstream("/tmp/debug_in_progress") || std::ifstream("/tmp/enable_pairing")) { if (std::ifstream("/tmp/config_in_progress") || std::ifstream("/tmp/debug_in_progress") || std::ifstream("/tmp/enable_pairing")) {
if (ui_->SysinfoTopLeft2->isVisible() == false) { if (ui_->SysinfoTopLeft2->isVisible() == false) {
if (std::ifstream("/tmp/config_in_progress")) { if (std::ifstream("/tmp/config_in_progress")) {
@ -1891,16 +1921,11 @@ void f1x::openauto::autoapp::ui::MainWindow::tmpChanged()
// read value from tsl2561 // read value from tsl2561
if (std::ifstream("/tmp/tsl2561") && this->configuration_->showLux()) { if (std::ifstream("/tmp/tsl2561") && this->configuration_->showLux()) {
QFile paramFile("/tmp/tsl2561");
paramFile.open(QIODevice::ReadOnly);
QTextStream data(&paramFile);
QStringList value = data.readAll().split("\n");
paramFile.close();
if (ui_->label_left->isVisible() == false) { if (ui_->label_left->isVisible() == false) {
ui_->label_left->show(); ui_->label_left->show();
ui_->label_right->show(); ui_->label_right->show();
} }
ui_->label_left->setText("Lux: " + value[0]); ui_->label_left->setText("Lux: " + configuration_->readFileContent("/tmp/tsl2561"));
} else { } else {
if (ui_->label_left->isVisible() == true) { if (ui_->label_left->isVisible() == true) {
ui_->label_left->hide(); ui_->label_left->hide();
@ -1952,23 +1977,4 @@ void f1x::openauto::autoapp::ui::MainWindow::tmpChanged()
} }
} }
updateNetworkInfo(); updateNetworkInfo();
//QString localDeviceName;
//QString localDeviceAddress;
//if (localDevice->isValid()) {
// localDeviceName = localDevice->name();
// localDeviceAddress = localDevice->address().toString();
// QList<QBluetoothAddress> btdevices;
// btdevices = localDevice->connectedDevices();
// int count = btdevices.count();
// if (count > 0) {
// QBluetoothAddress btdevice = btdevices[0];
// QString btmac = btdevice.toString();
// ui_->btDevice->setText("BT: " + QString::number(count));
// } else {
// ui_->btDevice->setText("BT: " + QString::number(count));
// }
//}
} }

View File

@ -7,7 +7,7 @@
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>1010</width> <width>1010</width>
<height>1657</height> <height>1646</height>
</rect> </rect>
</property> </property>
<property name="sizePolicy"> <property name="sizePolicy">
@ -777,7 +777,8 @@ border-radius: 4px;
<string notr="true">background-color: rgb(32, 74, 135); <string notr="true">background-color: rgb(32, 74, 135);
color: rgb(255, 255, 255); color: rgb(255, 255, 255);
outline: none; outline: none;
border-radius: 4px;</string> border-radius: 4px;
</string>
</property> </property>
<property name="text"> <property name="text">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;&lt;span style=&quot; color:#29ffff;&quot;&gt;Pairable&lt;/span&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string> <string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;&lt;span style=&quot; color:#29ffff;&quot;&gt;Pairable&lt;/span&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
@ -1482,7 +1483,8 @@ border: no-border;</string>
<property name="styleSheet"> <property name="styleSheet">
<string notr="true">background-color: rgba(48, 140, 198, 0.5); <string notr="true">background-color: rgba(48, 140, 198, 0.5);
color: rgb(255, 255, 255); color: rgb(255, 255, 255);
border-radius: 4px; border-top-left-radius: 4px;
border-top-right-radius: 4px;
border: 2px solid rgba(255,255,255,0.5); border: 2px solid rgba(255,255,255,0.5);
outline: none; outline: none;
border-bottom: 0px;</string> border-bottom: 0px;</string>
@ -1509,7 +1511,6 @@ border-bottom: 0px;</string>
<property name="styleSheet"> <property name="styleSheet">
<string notr="true">background-color: rgba(48, 140, 198, 0.5); <string notr="true">background-color: rgba(48, 140, 198, 0.5);
color: rgb(255, 255, 255); color: rgb(255, 255, 255);
border-radius: 4px;
border: 2px solid rgba(255,255,255,0.5); border: 2px solid rgba(255,255,255,0.5);
outline: none; outline: none;
border-top: 0px; border-top: 0px;
@ -1552,7 +1553,8 @@ border-bottom: 0px;
<property name="styleSheet"> <property name="styleSheet">
<string notr="true">background-color: rgba(48, 140, 198, 0.5); <string notr="true">background-color: rgba(48, 140, 198, 0.5);
color: rgb(255, 255, 255); color: rgb(255, 255, 255);
border-radius: 4px; border-bottom-left-radius: 4px;
border-bottom-right-radius: 4px;
border: 2px solid rgba(255,255,255,0.5); border: 2px solid rgba(255,255,255,0.5);
outline: none; outline: none;
border-top: 0px;</string> border-top: 0px;</string>