|
|
@ -13,7 +13,8 @@ |
|
|
|
|
|
|
|
|
|
|
|
QGCSettingsWidget::QGCSettingsWidget(QWidget *parent, Qt::WindowFlags flags) : |
|
|
|
QGCSettingsWidget::QGCSettingsWidget(QWidget *parent, Qt::WindowFlags flags) : |
|
|
|
QDialog(parent, flags), |
|
|
|
QDialog(parent, flags), |
|
|
|
ui(new Ui::QGCSettingsWidget) |
|
|
|
ui(new Ui::QGCSettingsWidget), |
|
|
|
|
|
|
|
mainWindow((MainWindow*)parent) |
|
|
|
{ |
|
|
|
{ |
|
|
|
ui->setupUi(this); |
|
|
|
ui->setupUi(this); |
|
|
|
|
|
|
|
|
|
|
@ -35,23 +36,34 @@ QGCSettingsWidget::QGCSettingsWidget(QWidget *parent, Qt::WindowFlags flags) : |
|
|
|
connect(GAudioOutput::instance(), SIGNAL(mutedChanged(bool)), ui->audioMuteCheckBox, SLOT(setChecked(bool))); |
|
|
|
connect(GAudioOutput::instance(), SIGNAL(mutedChanged(bool)), ui->audioMuteCheckBox, SLOT(setChecked(bool))); |
|
|
|
|
|
|
|
|
|
|
|
// Reconnect
|
|
|
|
// Reconnect
|
|
|
|
ui->reconnectCheckBox->setChecked(MainWindow::instance()->autoReconnectEnabled()); |
|
|
|
ui->reconnectCheckBox->setChecked(mainWindow->autoReconnectEnabled()); |
|
|
|
connect(ui->reconnectCheckBox, SIGNAL(clicked(bool)), MainWindow::instance(), SLOT(enableAutoReconnect(bool))); |
|
|
|
connect(ui->reconnectCheckBox, SIGNAL(clicked(bool)), mainWindow, SLOT(enableAutoReconnect(bool))); |
|
|
|
|
|
|
|
|
|
|
|
// Low power mode
|
|
|
|
// Low power mode
|
|
|
|
ui->lowPowerCheckBox->setChecked(MainWindow::instance()->lowPowerModeEnabled()); |
|
|
|
ui->lowPowerCheckBox->setChecked(mainWindow->lowPowerModeEnabled()); |
|
|
|
connect(ui->lowPowerCheckBox, SIGNAL(clicked(bool)), MainWindow::instance(), SLOT(enableLowPowerMode(bool))); |
|
|
|
connect(ui->lowPowerCheckBox, SIGNAL(clicked(bool)), mainWindow, SLOT(enableLowPowerMode(bool))); |
|
|
|
|
|
|
|
|
|
|
|
//Dock widget title bars
|
|
|
|
//Dock widget title bars
|
|
|
|
ui->titleBarCheckBox->setChecked(MainWindow::instance()->dockWidgetTitleBarsEnabled()); |
|
|
|
ui->titleBarCheckBox->setChecked(mainWindow->dockWidgetTitleBarsEnabled()); |
|
|
|
connect(ui->titleBarCheckBox,SIGNAL(clicked(bool)),MainWindow::instance(),SLOT(enableDockWidgetTitleBars(bool))); |
|
|
|
connect(ui->titleBarCheckBox,SIGNAL(clicked(bool)),mainWindow,SLOT(enableDockWidgetTitleBars(bool))); |
|
|
|
|
|
|
|
|
|
|
|
// Style
|
|
|
|
// Intialize the style UI to the proper values obtained from the MainWindow.
|
|
|
|
MainWindow::QGC_MAINWINDOW_STYLE style = MainWindow::instance()->getStyle(); |
|
|
|
MainWindow::QGC_MAINWINDOW_STYLE style = mainWindow->getStyle(); |
|
|
|
ui->styleChooser->setCurrentIndex(style); |
|
|
|
ui->styleChooser->setCurrentIndex(style); |
|
|
|
|
|
|
|
if (style == MainWindow::QGC_MAINWINDOW_STYLE_DARK) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
ui->styleSheetFile->setText(mainWindow->getDarkStyleSheet()); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
else |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
ui->styleSheetFile->setText(mainWindow->getLightStyleSheet()); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// And then connect all the signals for the UI for changing styles.
|
|
|
|
connect(ui->styleChooser, SIGNAL(currentIndexChanged(int)), this, SLOT(styleChanged(int))); |
|
|
|
connect(ui->styleChooser, SIGNAL(currentIndexChanged(int)), this, SLOT(styleChanged(int))); |
|
|
|
connect(ui->styleCustomButton, SIGNAL(clicked()), this, SLOT(selectStylesheet())); |
|
|
|
connect(ui->styleCustomButton, SIGNAL(clicked()), this, SLOT(selectStylesheet())); |
|
|
|
connect(ui->styleDefaultButton, SIGNAL(clicked()), this, SLOT(setDefaultStyle())); |
|
|
|
connect(ui->styleDefaultButton, SIGNAL(clicked()), this, SLOT(setDefaultStyle())); |
|
|
|
|
|
|
|
connect(ui->styleSheetFile, SIGNAL(editingFinished()), this, SLOT(lineEditFinished())); |
|
|
|
|
|
|
|
|
|
|
|
// Close / destroy
|
|
|
|
// Close / destroy
|
|
|
|
connect(ui->buttonBox, SIGNAL(accepted()), this, SLOT(deleteLater())); |
|
|
|
connect(ui->buttonBox, SIGNAL(accepted()), this, SLOT(deleteLater())); |
|
|
@ -100,17 +112,7 @@ void QGCSettingsWidget::selectStylesheet() |
|
|
|
// And update the UI as needed.
|
|
|
|
// And update the UI as needed.
|
|
|
|
else |
|
|
|
else |
|
|
|
{ |
|
|
|
{ |
|
|
|
switch (ui->styleChooser->currentIndex()) |
|
|
|
ui->styleSheetFile->setText(newStyleFileName); |
|
|
|
{ |
|
|
|
|
|
|
|
case 0: |
|
|
|
|
|
|
|
darkStyleSheet = newStyleFileName; |
|
|
|
|
|
|
|
ui->styleSheetFile->setText(darkStyleSheet); |
|
|
|
|
|
|
|
MainWindow::instance()->loadStyle(MainWindow::QGC_MAINWINDOW_STYLE_DARK, darkStyleSheet); |
|
|
|
|
|
|
|
case 1: |
|
|
|
|
|
|
|
lightStyleSheet = newStyleFileName; |
|
|
|
|
|
|
|
ui->styleSheetFile->setText(lightStyleSheet); |
|
|
|
|
|
|
|
MainWindow::instance()->loadStyle(MainWindow::QGC_MAINWINDOW_STYLE_LIGHT, lightStyleSheet); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -119,27 +121,41 @@ bool QGCSettingsWidget::updateStyle(QString style) |
|
|
|
switch (ui->styleChooser->currentIndex()) |
|
|
|
switch (ui->styleChooser->currentIndex()) |
|
|
|
{ |
|
|
|
{ |
|
|
|
case 0: |
|
|
|
case 0: |
|
|
|
darkStyleSheet = style; |
|
|
|
return mainWindow->loadStyle(MainWindow::QGC_MAINWINDOW_STYLE_DARK, style); |
|
|
|
return MainWindow::instance()->loadStyle(MainWindow::QGC_MAINWINDOW_STYLE_DARK, darkStyleSheet); |
|
|
|
|
|
|
|
case 1: |
|
|
|
case 1: |
|
|
|
lightStyleSheet = style; |
|
|
|
return mainWindow->loadStyle(MainWindow::QGC_MAINWINDOW_STYLE_LIGHT, style); |
|
|
|
return MainWindow::instance()->loadStyle(MainWindow::QGC_MAINWINDOW_STYLE_LIGHT, lightStyleSheet); |
|
|
|
|
|
|
|
default: |
|
|
|
default: |
|
|
|
return false; |
|
|
|
return false; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void QGCSettingsWidget::lineEditFinished() |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
QString newStyleFileName(ui->styleSheetFile->text()); |
|
|
|
|
|
|
|
QFile newStyleFile(newStyleFileName); |
|
|
|
|
|
|
|
if (!newStyleFile.exists() || !updateStyle(newStyleFileName)) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
QMessageBox msgBox; |
|
|
|
|
|
|
|
msgBox.setIcon(QMessageBox::Information); |
|
|
|
|
|
|
|
msgBox.setText(tr("QGroundControl did not load a new style")); |
|
|
|
|
|
|
|
msgBox.setInformativeText(tr("Stylesheet file %1 was not readable").arg(newStyleFileName)); |
|
|
|
|
|
|
|
msgBox.setStandardButtons(QMessageBox::Ok); |
|
|
|
|
|
|
|
msgBox.setDefaultButton(QMessageBox::Ok); |
|
|
|
|
|
|
|
msgBox.exec(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void QGCSettingsWidget::styleChanged(int index) |
|
|
|
void QGCSettingsWidget::styleChanged(int index) |
|
|
|
{ |
|
|
|
{ |
|
|
|
if (index == 1) |
|
|
|
if (index == 1) |
|
|
|
{ |
|
|
|
{ |
|
|
|
ui->styleSheetFile->setText(lightStyleSheet); |
|
|
|
ui->styleSheetFile->setText(mainWindow->getLightStyleSheet()); |
|
|
|
updateStyle(lightStyleSheet); |
|
|
|
mainWindow->loadStyle(MainWindow::QGC_MAINWINDOW_STYLE_LIGHT, mainWindow->getLightStyleSheet()); |
|
|
|
} |
|
|
|
} |
|
|
|
else |
|
|
|
else |
|
|
|
{ |
|
|
|
{ |
|
|
|
ui->styleSheetFile->setText(darkStyleSheet); |
|
|
|
ui->styleSheetFile->setText(mainWindow->getDarkStyleSheet()); |
|
|
|
updateStyle(darkStyleSheet); |
|
|
|
mainWindow->loadStyle(MainWindow::QGC_MAINWINDOW_STYLE_DARK, mainWindow->getDarkStyleSheet()); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -147,14 +163,12 @@ void QGCSettingsWidget::setDefaultStyle() |
|
|
|
{ |
|
|
|
{ |
|
|
|
if (ui->styleChooser->currentIndex() == 1) |
|
|
|
if (ui->styleChooser->currentIndex() == 1) |
|
|
|
{ |
|
|
|
{ |
|
|
|
lightStyleSheet = MainWindow::defaultLightStyle; |
|
|
|
ui->styleSheetFile->setText(MainWindow::defaultLightStyle); |
|
|
|
ui->styleSheetFile->setText(lightStyleSheet); |
|
|
|
mainWindow->loadStyle(MainWindow::QGC_MAINWINDOW_STYLE_LIGHT, MainWindow::defaultLightStyle); |
|
|
|
updateStyle(lightStyleSheet); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
else |
|
|
|
else |
|
|
|
{ |
|
|
|
{ |
|
|
|
darkStyleSheet = MainWindow::defaultDarkStyle; |
|
|
|
ui->styleSheetFile->setText(MainWindow::defaultDarkStyle); |
|
|
|
ui->styleSheetFile->setText(darkStyleSheet); |
|
|
|
mainWindow->loadStyle(MainWindow::QGC_MAINWINDOW_STYLE_DARK, MainWindow::defaultDarkStyle); |
|
|
|
updateStyle(darkStyleSheet); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|