From 78f45dc85283348168dc5c347104d4a5c79e632d Mon Sep 17 00:00:00 2001 From: Bryant Date: Sun, 19 May 2013 00:59:15 -0700 Subject: [PATCH] Fixed line endings in MainWindow.cc --- src/ui/MainWindow.cc | 47 ++++++++++++++++++++++---------------------- 1 file changed, 24 insertions(+), 23 deletions(-) diff --git a/src/ui/MainWindow.cc b/src/ui/MainWindow.cc index 6e2ef31c0..e8bd78e53 100644 --- a/src/ui/MainWindow.cc +++ b/src/ui/MainWindow.cc @@ -845,7 +845,7 @@ void MainWindow::showTool(bool show) }*/ void MainWindow::addCentralWidget(QWidget* widget, const QString& title) { - Q_UNUSED(title); + Q_UNUSED(title); // Check if this widget already has been added if (centerStack->indexOf(widget) == -1) { @@ -1266,49 +1266,50 @@ void MainWindow::loadStyle(QGC_MAINWINDOW_STYLE style) void MainWindow::selectStylesheet() { // 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; - msgBox.setIcon(QMessageBox::Information); - msgBox.setText(tr("QGroundControl did lot load a new style")); - msgBox.setInformativeText(tr("No suitable .css file selected. Please select a valid .css file.")); - msgBox.setStandardButtons(QMessageBox::Ok); - msgBox.setDefaultButton(QMessageBox::Ok); - msgBox.exec(); - return; + QFile styleSheet(newStyleFileName); + if (styleSheet.exists()) + { + styleFileName = newStyleFileName; + reloadStylesheet(); + } } - - // Load style sheet - reloadStylesheet(); } void MainWindow::reloadStylesheet() { // Load style sheet - QFile* styleSheet = new QFile(styleFileName); - if (!styleSheet->exists()) + QFile styleSheet(styleFileName); + + // 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/"); qApp->setStyleSheet(style); } + // Otherwise alert the user to the failure. else { QMessageBox msgBox; 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.setStandardButtons(QMessageBox::Ok); msgBox.setDefaultButton(QMessageBox::Ok); msgBox.exec(); } - delete styleSheet; } /** @@ -1611,7 +1612,7 @@ void MainWindow::addLink(LinkInterface *link) void MainWindow::setActiveUAS(UASInterface* uas) { - Q_UNUSED(uas); + Q_UNUSED(uas); // Enable and rename menu // ui.menuUnmanned_System->setTitle(uas->getUASName()); // if (!ui.menuUnmanned_System->isEnabled()) ui.menuUnmanned_System->setEnabled(true); @@ -1872,7 +1873,7 @@ void MainWindow::UASCreated(UASInterface* uas) void MainWindow::UASDeleted(UASInterface* uas) { - Q_UNUSED(uas); + Q_UNUSED(uas); if (UASManager::instance()->getUASList().count() == 0) { // Last system deleted -- 2.22.0