Commit 78f45dc8 authored by Bryant's avatar Bryant

Fixed line endings in MainWindow.cc

parent 5c33850d
...@@ -845,7 +845,7 @@ void MainWindow::showTool(bool show) ...@@ -845,7 +845,7 @@ void MainWindow::showTool(bool show)
}*/ }*/
void MainWindow::addCentralWidget(QWidget* widget, const QString& title) void MainWindow::addCentralWidget(QWidget* widget, const QString& title)
{ {
Q_UNUSED(title); Q_UNUSED(title);
// Check if this widget already has been added // Check if this widget already has been added
if (centerStack->indexOf(widget) == -1) if (centerStack->indexOf(widget) == -1)
{ {
...@@ -1266,49 +1266,50 @@ void MainWindow::loadStyle(QGC_MAINWINDOW_STYLE style) ...@@ -1266,49 +1266,50 @@ void MainWindow::loadStyle(QGC_MAINWINDOW_STYLE style)
void MainWindow::selectStylesheet() void MainWindow::selectStylesheet()
{ {
// Let user select style sheet // Let user select style sheet
styleFileName = QFileDialog::getOpenFileName(this, tr("Specify stylesheet"), styleFileName, tr("CSS Stylesheet (*.css);;")); QString newStyleFileName = QFileDialog::getOpenFileName(this, tr("Specify stylesheet"), styleFileName, tr("CSS Stylesheet (*.css);;"));
if (!styleFileName.endsWith(".css")) // Load the new style sheet if a valid one was selected.
if (!newStyleFileName.isNull())
{ {
QMessageBox msgBox; QFile styleSheet(newStyleFileName);
msgBox.setIcon(QMessageBox::Information); if (styleSheet.exists())
msgBox.setText(tr("QGroundControl did lot load a new style")); {
msgBox.setInformativeText(tr("No suitable .css file selected. Please select a valid .css file.")); styleFileName = newStyleFileName;
msgBox.setStandardButtons(QMessageBox::Ok); reloadStylesheet();
msgBox.setDefaultButton(QMessageBox::Ok); }
msgBox.exec();
return;
} }
// Load style sheet
reloadStylesheet();
} }
void MainWindow::reloadStylesheet() void MainWindow::reloadStylesheet()
{ {
// Load style sheet // Load style sheet
QFile* styleSheet = new QFile(styleFileName); QFile styleSheet(styleFileName);
if (!styleSheet->exists())
// Default to the indoor stylesheet if an invalid stylesheet was chosen.
if (!styleSheet.exists())
{ {
styleSheet = new QFile(":files/styles/style-indoor.css"); styleSheet.setFileName(":files/styles/style-indoor.css");
} }
if (styleSheet->open(QIODevice::ReadOnly | QIODevice::Text))
// Load the new stylesheet.
// We also replace an 'ICONDIR' token here with the proper application path.
if (styleSheet.open(QIODevice::ReadOnly | QIODevice::Text))
{ {
QString style = QString(styleSheet->readAll()); QString style = QString(styleSheet.readAll());
style.replace("ICONDIR", QCoreApplication::applicationDirPath()+ "files/styles/"); style.replace("ICONDIR", QCoreApplication::applicationDirPath()+ "files/styles/");
qApp->setStyleSheet(style); qApp->setStyleSheet(style);
} }
// Otherwise alert the user to the failure.
else else
{ {
QMessageBox msgBox; QMessageBox msgBox;
msgBox.setIcon(QMessageBox::Information); msgBox.setIcon(QMessageBox::Information);
msgBox.setText(tr("QGroundControl did lot load a new style")); msgBox.setText(tr("QGroundControl did not load a new style"));
msgBox.setInformativeText(tr("Stylesheet file %1 was not readable").arg(styleFileName)); msgBox.setInformativeText(tr("Stylesheet file %1 was not readable").arg(styleFileName));
msgBox.setStandardButtons(QMessageBox::Ok); msgBox.setStandardButtons(QMessageBox::Ok);
msgBox.setDefaultButton(QMessageBox::Ok); msgBox.setDefaultButton(QMessageBox::Ok);
msgBox.exec(); msgBox.exec();
} }
delete styleSheet;
} }
/** /**
...@@ -1611,7 +1612,7 @@ void MainWindow::addLink(LinkInterface *link) ...@@ -1611,7 +1612,7 @@ void MainWindow::addLink(LinkInterface *link)
void MainWindow::setActiveUAS(UASInterface* uas) void MainWindow::setActiveUAS(UASInterface* uas)
{ {
Q_UNUSED(uas); Q_UNUSED(uas);
// Enable and rename menu // Enable and rename menu
// ui.menuUnmanned_System->setTitle(uas->getUASName()); // ui.menuUnmanned_System->setTitle(uas->getUASName());
// if (!ui.menuUnmanned_System->isEnabled()) ui.menuUnmanned_System->setEnabled(true); // if (!ui.menuUnmanned_System->isEnabled()) ui.menuUnmanned_System->setEnabled(true);
...@@ -1872,7 +1873,7 @@ void MainWindow::UASCreated(UASInterface* uas) ...@@ -1872,7 +1873,7 @@ void MainWindow::UASCreated(UASInterface* uas)
void MainWindow::UASDeleted(UASInterface* uas) void MainWindow::UASDeleted(UASInterface* uas)
{ {
Q_UNUSED(uas); Q_UNUSED(uas);
if (UASManager::instance()->getUASList().count() == 0) if (UASManager::instance()->getUASList().count() == 0)
{ {
// Last system deleted // Last system deleted
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment