mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-03-31 04:25:35 +08:00
Ref T286, added "copy caches/settings" component (using API)
This commit is contained in:
@@ -33,6 +33,7 @@ namespace BlackGui
|
||||
enum Pages
|
||||
{
|
||||
Legal,
|
||||
CopySettingsAndCaches,
|
||||
CopyModels,
|
||||
CopySettings,
|
||||
CopyCaches,
|
||||
|
||||
@@ -78,6 +78,31 @@
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<widget class="BlackGui::Components::CCopySettingsAndCachesWizardPage" name="wp_CopySettingsAndCaches">
|
||||
<property name="title">
|
||||
<string>Copy settings and caches</string>
|
||||
</property>
|
||||
<property name="subTitle">
|
||||
<string>Copy settings and caches from other swift versions</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="vl_CopySettingsAndCaches">
|
||||
<property name="leftMargin">
|
||||
<number>4</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>4</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>4</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>4</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="BlackGui::Components::CCopySettingsAndCachesComponent" name="comp_CopySettingsAndCachesComponen"/>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<widget class="BlackGui::Components::CCopyConfigurationWizardPage" name="wp_CopySettings">
|
||||
<property name="title">
|
||||
<string>Copy configuration from another installation</string>
|
||||
@@ -413,6 +438,18 @@
|
||||
<header>blackgui/components/legalinfocomponent.h</header>
|
||||
<container>1</container>
|
||||
</customwidget>
|
||||
<customwidget>
|
||||
<class>BlackGui::Components::CCopySettingsAndCachesComponent</class>
|
||||
<extends>QFrame</extends>
|
||||
<header>blackgui/components/copysettingsandcachescomponent.h</header>
|
||||
<container>1</container>
|
||||
</customwidget>
|
||||
<customwidget>
|
||||
<class>BlackGui::Components::CCopySettingsAndCachesWizardPage</class>
|
||||
<extends>QWizardPage</extends>
|
||||
<header>blackgui/components/copysettingsandcachescomponent.h</header>
|
||||
<container>1</container>
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
<resources/>
|
||||
<connections>
|
||||
|
||||
388
src/blackgui/components/copysettingsandcachescomponent.cpp
Normal file
388
src/blackgui/components/copysettingsandcachescomponent.cpp
Normal file
@@ -0,0 +1,388 @@
|
||||
/* Copyright (C) 2018
|
||||
* swift project Community / Contributors
|
||||
*
|
||||
* This file is part of swift Project. It is subject to the license terms in the LICENSE file found in the top-level
|
||||
* directory of this distribution and at http://www.swift-project.org/license.html. No part of swift project,
|
||||
* including this file, may be copied, modified, propagated, or distributed except according to the terms
|
||||
* contained in the LICENSE file.
|
||||
*/
|
||||
|
||||
#include "copysettingsandcachescomponent.h"
|
||||
#include "ui_copysettingsandcachescomponent.h"
|
||||
#include "blackgui/guiapplication.h"
|
||||
#include "blackgui/guiutility.h"
|
||||
#include "blackmisc/cachesettingsutils.h"
|
||||
#include "blackmisc/json.h"
|
||||
#include "blackmisc/fileutils.h"
|
||||
#include "blackmisc/icons.h"
|
||||
|
||||
#include <QRegularExpression>
|
||||
#include <QFileInfo>
|
||||
#include <QStringBuilder>
|
||||
|
||||
using namespace BlackMisc;
|
||||
using namespace BlackMisc::Audio;
|
||||
using namespace BlackMisc::Input;
|
||||
using namespace BlackMisc::Network;
|
||||
using namespace BlackMisc::Network::Data;
|
||||
using namespace BlackMisc::Network::Settings;
|
||||
using namespace BlackMisc::Simulation::Settings;
|
||||
using namespace BlackCore::Audio;
|
||||
using namespace BlackCore::Application;
|
||||
using namespace BlackCore::Data;
|
||||
using namespace BlackGui::Settings;
|
||||
|
||||
namespace BlackGui
|
||||
{
|
||||
namespace Components
|
||||
{
|
||||
CCopySettingsAndCachesComponent::CCopySettingsAndCachesComponent(QWidget *parent) :
|
||||
QFrame(parent),
|
||||
ui(new Ui::CCopySettingsAndCachesComponent)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
this->initAll();
|
||||
this->allCheckBoxesReadOnly();
|
||||
connect(ui->pb_SelectAll, &QPushButton::clicked, this, &CCopySettingsAndCachesComponent::selectAll);
|
||||
connect(ui->pb_DeselectAll, &QPushButton::clicked, this, &CCopySettingsAndCachesComponent::deselectAll);
|
||||
connect(ui->pb_Copy, &QPushButton::clicked, this, &CCopySettingsAndCachesComponent::copy);
|
||||
connect(ui->comp_OtherSwiftVersions, &COtherSwiftVersionsComponent::versionChanged, this, &CCopySettingsAndCachesComponent::onOtherVersionChanged);
|
||||
}
|
||||
|
||||
CCopySettingsAndCachesComponent::~CCopySettingsAndCachesComponent()
|
||||
{ }
|
||||
|
||||
void CCopySettingsAndCachesComponent::onOtherVersionChanged(const CApplicationInfo &info)
|
||||
{
|
||||
readOnlyCheckbox(ui->cb_SettingsAudio, !CCacheSettingsUtils::hasOtherVersionSettingsFile(info, m_settingsAudio.getFilename()));
|
||||
readOnlyCheckbox(ui->cb_SettingsAudioInputDevice, !CCacheSettingsUtils::hasOtherVersionSettingsFile(info, m_settingsAudio.getFilename()));
|
||||
readOnlyCheckbox(ui->cb_SettingsAudioOutputDevice, !CCacheSettingsUtils::hasOtherVersionSettingsFile(info, m_settingsAudioOutputDevice.getFilename()));
|
||||
|
||||
readOnlyCheckbox(ui->cb_SettingsNetworkTrafficServers, !CCacheSettingsUtils::hasOtherVersionSettingsFile(info, m_settingsTrafficNetworkServers.getFilename()));
|
||||
readOnlyCheckbox(ui->cb_CacheLastNetworkServer, !CCacheSettingsUtils::hasOtherVersionCacheFile(info, m_cacheLastNetworkServer.getFilename()));
|
||||
readOnlyCheckbox(ui->cb_CacheLastVatsimServer, !CCacheSettingsUtils::hasOtherVersionCacheFile(info, m_cacheLastVatsimServer.getFilename()));
|
||||
|
||||
readOnlyCheckbox(ui->cb_SettingsGuiGeneral, !CCacheSettingsUtils::hasOtherVersionSettingsFile(info, m_settingsGuiGeneral.getFilename()));
|
||||
readOnlyCheckbox(ui->cb_SettingsDockWidget, !CCacheSettingsUtils::hasOtherVersionSettingsFile(info, m_settingsDockWidget.getFilename()));
|
||||
readOnlyCheckbox(ui->cb_SettingsViewUpdate, !CCacheSettingsUtils::hasOtherVersionSettingsFile(info, m_settingsViewUpdate.getFilename()));
|
||||
|
||||
readOnlyCheckbox(ui->cb_SettingsEnabledSimulators, !CCacheSettingsUtils::hasOtherVersionSettingsFile(info, m_settingsEnabledSimulators.getFilename()));
|
||||
readOnlyCheckbox(ui->cb_SettingsSimulatorFSX, !CCacheSettingsUtils::hasOtherVersionSettingsFile(info, m_settingsSimulatorFsx.getFilename()));
|
||||
readOnlyCheckbox(ui->cb_SettingsSimulatorP3D, !CCacheSettingsUtils::hasOtherVersionSettingsFile(info, m_settingsSimulatorP3D.getFilename()));
|
||||
readOnlyCheckbox(ui->cb_SettingsSimulatorXPlane, !CCacheSettingsUtils::hasOtherVersionSettingsFile(info, m_settingsSimulatorXPlane.getFilename()));
|
||||
|
||||
readOnlyCheckbox(ui->cb_SettingsActionHotkeys, !CCacheSettingsUtils::hasOtherVersionSettingsFile(info, m_settingsActionHotkeys.getFilename()));
|
||||
readOnlyCheckbox(ui->cb_SettingsTextMessages, !CCacheSettingsUtils::hasOtherVersionSettingsFile(info, m_settingsTextMessage.getFilename()));
|
||||
readOnlyCheckbox(ui->cb_SettingsAtcStations, !CCacheSettingsUtils::hasOtherVersionSettingsFile(info, m_settingsAtcStations.getFilename()));
|
||||
|
||||
readOnlyCheckbox(ui->cb_SettingsConsolidation, !CCacheSettingsUtils::hasOtherVersionSettingsFile(info, m_settingsConsolidation.getFilename()));
|
||||
readOnlyCheckbox(ui->cb_SettingsModel, !CCacheSettingsUtils::hasOtherVersionSettingsFile(info, m_settingsModel.getFilename()));
|
||||
}
|
||||
|
||||
void CCopySettingsAndCachesComponent::initAll()
|
||||
{
|
||||
this->initAudio();
|
||||
this->initNetwork();
|
||||
this->initUi();
|
||||
this->initSimulator();
|
||||
this->initMisc();
|
||||
this->initModel();
|
||||
}
|
||||
|
||||
void CCopySettingsAndCachesComponent::initAudio()
|
||||
{
|
||||
ui->cb_SettingsAudio->setText(checkBoxText(TSettings::humanReadable(), true));
|
||||
ui->cb_SettingsAudioInputDevice->setText(checkBoxText(TInputDevice::humanReadable(), true));
|
||||
ui->cb_SettingsAudioOutputDevice->setText(checkBoxText(TOutputDevice::humanReadable(), true));
|
||||
}
|
||||
|
||||
void CCopySettingsAndCachesComponent::initNetwork()
|
||||
{
|
||||
ui->cb_SettingsNetworkTrafficServers->setText(checkBoxText(TTrafficServers::humanReadable(), true));
|
||||
ui->cb_CacheLastNetworkServer->setText(checkBoxText(TLastServer::humanReadable(), false));
|
||||
ui->cb_CacheLastVatsimServer->setText(checkBoxText(TVatsimLastServer::humanReadable(), false));
|
||||
}
|
||||
|
||||
void CCopySettingsAndCachesComponent::initUi()
|
||||
{
|
||||
ui->cb_SettingsGuiGeneral->setText(checkBoxText(TGeneralGui::humanReadable(), true));
|
||||
ui->cb_SettingsDockWidget->setText(checkBoxText(TDockWidget::humanReadable(), true));
|
||||
ui->cb_SettingsViewUpdate->setText(checkBoxText(TViewUpdateSettings::humanReadable(), true));
|
||||
}
|
||||
|
||||
void CCopySettingsAndCachesComponent::initSimulator()
|
||||
{
|
||||
ui->cb_SettingsEnabledSimulators->setText(checkBoxText(TEnabledSimulators::humanReadable(), true));
|
||||
ui->cb_SettingsSimulatorFSX->setText(checkBoxText(TSimulatorFsx::humanReadable(), true));
|
||||
ui->cb_SettingsSimulatorP3D->setText(checkBoxText(TSimulatorP3D::humanReadable(), true));
|
||||
ui->cb_SettingsSimulatorXPlane->setText(checkBoxText(TSimulatorXP::humanReadable(), true));
|
||||
}
|
||||
|
||||
void CCopySettingsAndCachesComponent::initMisc()
|
||||
{
|
||||
ui->cb_SettingsActionHotkeys->setText(checkBoxText(TActionHotkeys::humanReadable(), true));
|
||||
ui->cb_SettingsAtcStations->setText(checkBoxText(TAtcStationsSettings::humanReadable(), true));
|
||||
ui->cb_SettingsTextMessages->setText(checkBoxText(TextMessageSettings::humanReadable(), true));
|
||||
}
|
||||
|
||||
void CCopySettingsAndCachesComponent::initModel()
|
||||
{
|
||||
ui->cb_SettingsModel->setText(checkBoxText(TModel::humanReadable(), true));
|
||||
ui->cb_SettingsConsolidation->setText(checkBoxText(TBackgroundConsolidation::humanReadable(), true));
|
||||
}
|
||||
|
||||
void CCopySettingsAndCachesComponent::copy()
|
||||
{
|
||||
const CApplicationInfo otherVersionInfo = ui->comp_OtherSwiftVersions->selectedOtherVersion();
|
||||
if (otherVersionInfo.isNull()) { return; }
|
||||
|
||||
// ------- audio -------
|
||||
if (ui->cb_SettingsAudio->isChecked())
|
||||
{
|
||||
const QString joStr = CCacheSettingsUtils::otherVersionSettingsFileContent(otherVersionInfo, m_settingsAudio.getFilename());
|
||||
if (!joStr.isEmpty())
|
||||
{
|
||||
const Audio::CSettings audioSettings = Audio::CSettings::fromJson(joStr, true);
|
||||
this->displayStatusMessage(m_settingsAudio.setAndSave(audioSettings), audioSettings.toQString(true));
|
||||
}
|
||||
}
|
||||
|
||||
if (ui->cb_SettingsAudioInputDevice->isChecked())
|
||||
{
|
||||
const QString joStr = CCacheSettingsUtils::otherVersionSettingsFileContent(otherVersionInfo, m_settingsAudioInputDevice.getFilename());
|
||||
const QString audioInputSettings = Json::firstJsonValueAsString(joStr);
|
||||
if (!audioInputSettings.isEmpty())
|
||||
{
|
||||
this->displayStatusMessage(m_settingsAudioInputDevice.setAndSave(audioInputSettings), audioInputSettings);
|
||||
}
|
||||
}
|
||||
|
||||
if (ui->cb_SettingsAudioOutputDevice->isChecked())
|
||||
{
|
||||
const QString joStr = CCacheSettingsUtils::otherVersionSettingsFileContent(otherVersionInfo, m_settingsAudioOutputDevice.getFilename());
|
||||
const QString audioOutputSettings = Json::firstJsonValueAsString(joStr);
|
||||
if (!audioOutputSettings.isEmpty())
|
||||
{
|
||||
this->displayStatusMessage(m_settingsAudioOutputDevice.setAndSave(audioOutputSettings), audioOutputSettings);
|
||||
}
|
||||
}
|
||||
|
||||
// ------- network -------
|
||||
if (ui->cb_CacheLastNetworkServer->isChecked())
|
||||
{
|
||||
const QString joStr = CCacheSettingsUtils::otherVersionCacheFileContent(otherVersionInfo, m_cacheLastNetworkServer.getFilename());
|
||||
if (!joStr.isEmpty())
|
||||
{
|
||||
const CServer server = CServer::fromJson(joStr, true);
|
||||
this->displayStatusMessage(m_cacheLastNetworkServer.set(server), server.toQString(true));
|
||||
}
|
||||
}
|
||||
|
||||
if (ui->cb_CacheLastVatsimServer->isChecked())
|
||||
{
|
||||
const QString joStr = CCacheSettingsUtils::otherVersionCacheFileContent(otherVersionInfo, m_cacheLastVatsimServer.getFilename());
|
||||
if (!joStr.isEmpty())
|
||||
{
|
||||
const CServer server = CServer::fromJson(joStr, true);
|
||||
this->displayStatusMessage(m_cacheLastVatsimServer.set(server), server.toQString(true));
|
||||
}
|
||||
}
|
||||
|
||||
// ------- GUI -------
|
||||
if (ui->cb_SettingsGuiGeneral->isChecked())
|
||||
{
|
||||
const QString joStr = CCacheSettingsUtils::otherVersionSettingsFileContent(otherVersionInfo, m_settingsGuiGeneral.getFilename());
|
||||
if (!joStr.isEmpty())
|
||||
{
|
||||
const CGeneralGuiSettings guiGeneral = CGeneralGuiSettings::fromJson(joStr, true);
|
||||
this->displayStatusMessage(m_settingsGuiGeneral.setAndSave(guiGeneral), guiGeneral.toQString(true));
|
||||
}
|
||||
}
|
||||
|
||||
if (ui->cb_SettingsDockWidget->isChecked())
|
||||
{
|
||||
const QString joStr = CCacheSettingsUtils::otherVersionSettingsFileContent(otherVersionInfo, m_settingsDockWidget.getFilename());
|
||||
if (!joStr.isEmpty())
|
||||
{
|
||||
const CDockWidgetSettings dwSettings = CDockWidgetSettings::fromJson(joStr, true);
|
||||
this->displayStatusMessage(m_settingsDockWidget.setAndSave(dwSettings), dwSettings.toQString(true));
|
||||
}
|
||||
}
|
||||
|
||||
if (ui->cb_SettingsViewUpdate->isChecked())
|
||||
{
|
||||
const QString joStr = CCacheSettingsUtils::otherVersionSettingsFileContent(otherVersionInfo, m_settingsViewUpdate.getFilename());
|
||||
if (!joStr.isEmpty())
|
||||
{
|
||||
const CViewUpdateSettings viewUpdate = CViewUpdateSettings::fromJson(joStr, true);
|
||||
this->displayStatusMessage(m_settingsViewUpdate.setAndSave(viewUpdate), viewUpdate.toQString(true));
|
||||
}
|
||||
}
|
||||
|
||||
// ------- sims -------
|
||||
if (ui->cb_SettingsEnabledSimulators->isChecked())
|
||||
{
|
||||
const QString joStr = CCacheSettingsUtils::otherVersionSettingsFileContent(otherVersionInfo, m_settingsEnabledSimulators.getFilename());
|
||||
if (!joStr.isEmpty())
|
||||
{
|
||||
const QStringList enabledSims = Json::firstJsonValueAsStringList(joStr);
|
||||
if (!enabledSims.isEmpty())
|
||||
{
|
||||
this->displayStatusMessage(m_settingsEnabledSimulators.setAndSave(enabledSims), enabledSims.join(", "));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (ui->cb_SettingsSimulatorFSX->isChecked())
|
||||
{
|
||||
const QString joStr = CCacheSettingsUtils::otherVersionSettingsFileContent(otherVersionInfo, m_settingsSimulatorFsx.getFilename());
|
||||
if (!joStr.isEmpty())
|
||||
{
|
||||
const CSimulatorSettings settings = CSimulatorSettings::fromJson(joStr, true);
|
||||
this->displayStatusMessage(m_settingsSimulatorFsx.setAndSave(settings), settings.toQString(true));
|
||||
}
|
||||
}
|
||||
|
||||
if (ui->cb_SettingsSimulatorP3D->isChecked())
|
||||
{
|
||||
const QString joStr = CCacheSettingsUtils::otherVersionSettingsFileContent(otherVersionInfo, m_settingsSimulatorP3D.getFilename());
|
||||
if (!joStr.isEmpty())
|
||||
{
|
||||
const CSimulatorSettings settings = CSimulatorSettings::fromJson(joStr, true);
|
||||
this->displayStatusMessage(m_settingsSimulatorP3D.setAndSave(settings), settings.toQString(true));
|
||||
}
|
||||
}
|
||||
|
||||
if (ui->cb_SettingsSimulatorXPlane->isChecked())
|
||||
{
|
||||
const QString joStr = CCacheSettingsUtils::otherVersionSettingsFileContent(otherVersionInfo, m_settingsSimulatorXPlane.getFilename());
|
||||
if (!joStr.isEmpty())
|
||||
{
|
||||
const CSimulatorSettings settings = CSimulatorSettings::fromJson(joStr, true);
|
||||
this->displayStatusMessage(m_settingsSimulatorXPlane.setAndSave(settings), settings.toQString(true));
|
||||
}
|
||||
}
|
||||
|
||||
// ------ model ------
|
||||
if (ui->cb_SettingsModel->isChecked())
|
||||
{
|
||||
const QString joStr = CCacheSettingsUtils::otherVersionSettingsFileContent(otherVersionInfo, m_settingsModel.getFilename());
|
||||
if (!joStr.isEmpty())
|
||||
{
|
||||
const CModelSettings settings = CModelSettings::fromJson(joStr, true);
|
||||
this->displayStatusMessage(m_settingsModel.setAndSave(settings), settings.toQString(true));
|
||||
}
|
||||
}
|
||||
|
||||
if (ui->cb_SettingsConsolidation->isChecked())
|
||||
{
|
||||
const QString joStr = CCacheSettingsUtils::otherVersionSettingsFileContent(otherVersionInfo, m_settingsConsolidation.getFilename());
|
||||
if (!joStr.isEmpty())
|
||||
{
|
||||
bool ok = false;
|
||||
const int consolidation = Json::firstJsonValueAsInt(joStr, -1, &ok);
|
||||
if (ok)
|
||||
{
|
||||
this->displayStatusMessage(m_settingsConsolidation.setAndSave(consolidation), QString::number(consolidation));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// ------ misc -------
|
||||
if (ui->cb_SettingsActionHotkeys->isChecked())
|
||||
{
|
||||
const QString joStr = CCacheSettingsUtils::otherVersionSettingsFileContent(otherVersionInfo, m_settingsActionHotkeys.getFilename());
|
||||
if (!joStr.isEmpty())
|
||||
{
|
||||
const CActionHotkeyList hotkeys = CActionHotkeyList::fromJson(joStr, true);
|
||||
this->displayStatusMessage(m_settingsActionHotkeys.setAndSave(hotkeys), hotkeys.toQString(true));
|
||||
}
|
||||
}
|
||||
|
||||
if (ui->cb_SettingsAtcStations->isChecked())
|
||||
{
|
||||
const QString joStr = CCacheSettingsUtils::otherVersionSettingsFileContent(otherVersionInfo, m_settingsAtcStations.getFilename());
|
||||
if (!joStr.isEmpty())
|
||||
{
|
||||
const CAtcStationsSettings settings = CAtcStationsSettings::fromJson(joStr, true);
|
||||
this->displayStatusMessage(m_settingsAtcStations.setAndSave(settings), settings.toQString(true));
|
||||
}
|
||||
}
|
||||
|
||||
if (ui->cb_SettingsTextMessages->isChecked())
|
||||
{
|
||||
const QString joStr = CCacheSettingsUtils::otherVersionSettingsFileContent(otherVersionInfo, m_settingsTextMessage.getFilename());
|
||||
if (!joStr.isEmpty())
|
||||
{
|
||||
const CTextMessageSettings settings = CTextMessageSettings::fromJson(joStr, true);
|
||||
this->displayStatusMessage(m_settingsTextMessage.setAndSave(settings), settings.toQString(true));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void CCopySettingsAndCachesComponent::selectAll()
|
||||
{
|
||||
for (QCheckBox *cb : this->checkBoxes())
|
||||
{
|
||||
cb->setChecked(cb->isEnabled());
|
||||
}
|
||||
}
|
||||
|
||||
void CCopySettingsAndCachesComponent::deselectAll()
|
||||
{
|
||||
for (QCheckBox *cb : this->checkBoxes())
|
||||
{
|
||||
cb->setChecked(false);
|
||||
}
|
||||
}
|
||||
|
||||
QList<QCheckBox *> CCopySettingsAndCachesComponent::checkBoxes() const
|
||||
{
|
||||
return this->findChildren<QCheckBox *>();
|
||||
}
|
||||
|
||||
void CCopySettingsAndCachesComponent::displayStatusMessage(const CStatusMessage &msg, const QString &value)
|
||||
{
|
||||
if (msg.isEmpty()) { return; }
|
||||
if (value.isEmpty())
|
||||
{
|
||||
ui->le_Status->setText(msg.getMessage());
|
||||
}
|
||||
else
|
||||
{
|
||||
ui->le_Status->setText(msg.getMessage() % QStringLiteral(" ") % value);
|
||||
}
|
||||
if (sGui) { sGui->processEventsToRefreshGui(); }
|
||||
}
|
||||
|
||||
void CCopySettingsAndCachesComponent::allCheckBoxesReadOnly()
|
||||
{
|
||||
for (QCheckBox *cb : checkBoxes())
|
||||
{
|
||||
readOnlyCheckbox(cb, true);
|
||||
}
|
||||
}
|
||||
|
||||
void CCopySettingsAndCachesComponent::readOnlyCheckbox(QCheckBox *cb, bool readOnly)
|
||||
{
|
||||
Q_ASSERT_X(cb, Q_FUNC_INFO, "need checkbox");
|
||||
CGuiUtility::checkBoxReadOnly(cb, readOnly);
|
||||
if (readOnly) { cb->setChecked(false); }
|
||||
cb->setEnabled(!readOnly);
|
||||
cb->setIcon(readOnly ? CIcons::cross16() : CIcons::tick16());
|
||||
}
|
||||
|
||||
QString CCopySettingsAndCachesComponent::checkBoxText(const QString &text, bool setting)
|
||||
{
|
||||
static const QString s("%1 [setting]");
|
||||
static const QString c("%1 [cache]");
|
||||
return setting ? s.arg(text) : c.arg(text);
|
||||
}
|
||||
|
||||
bool CCopySettingsAndCachesWizardPage::validatePage()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
} // ns
|
||||
} // ns
|
||||
158
src/blackgui/components/copysettingsandcachescomponent.h
Normal file
158
src/blackgui/components/copysettingsandcachescomponent.h
Normal file
@@ -0,0 +1,158 @@
|
||||
/* Copyright (C) 2018
|
||||
* swift project Community / Contributors
|
||||
*
|
||||
* This file is part of swift Project. It is subject to the license terms in the LICENSE file found in the top-level
|
||||
* directory of this distribution and at http://www.swift-project.org/license.html. No part of swift project,
|
||||
* including this file, may be copied, modified, propagated, or distributed except according to the terms
|
||||
* contained in the LICENSE file.
|
||||
*/
|
||||
|
||||
//! \file
|
||||
|
||||
#ifndef BLACKGUI_COMPONENTS_COPYSETTINGSANDCACHESCOMPONENT_H
|
||||
#define BLACKGUI_COMPONENTS_COPYSETTINGSANDCACHESCOMPONENT_H
|
||||
|
||||
#include "blackgui/blackguiexport.h"
|
||||
#include "blackgui/settings/guisettings.h"
|
||||
#include "blackgui/settings/dockwidgetsettings.h"
|
||||
#include "blackgui/settings/viewupdatesettings.h"
|
||||
#include "blackgui/settings/textmessagesettings.h"
|
||||
#include "blackgui/settings/atcstationssettings.h"
|
||||
#include "blackcore/data/launchersetup.h"
|
||||
#include "blackcore/data/vatsimsetup.h"
|
||||
#include "blackcore/audio/audiosettings.h"
|
||||
#include "blackcore/application/applicationsettings.h"
|
||||
#include "blackcore/application/updatesettings.h"
|
||||
#include "blackmisc/simulation/data/modelcaches.h"
|
||||
#include "blackmisc/simulation/data/lastmodel.h"
|
||||
#include "blackmisc/simulation/settings/simulatorsettings.h"
|
||||
#include "blackmisc/simulation/settings/modelsettings.h"
|
||||
#include "blackmisc/network/data/lastserver.h"
|
||||
#include "blackmisc/network/settings/servers.h"
|
||||
#include "blackmisc/applicationinfo.h"
|
||||
|
||||
#include <QWizardPage>
|
||||
#include <QFrame>
|
||||
#include <QScopedPointer>
|
||||
#include <QCheckBox>
|
||||
#include <QList>
|
||||
|
||||
namespace Ui { class CCopySettingsAndCachesComponent; }
|
||||
namespace BlackGui
|
||||
{
|
||||
namespace Components
|
||||
{
|
||||
/**
|
||||
* Copy settings and caches
|
||||
*/
|
||||
class CCopySettingsAndCachesComponent : public QFrame
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
//! Ctor
|
||||
explicit CCopySettingsAndCachesComponent(QWidget *parent = nullptr);
|
||||
|
||||
//! Dtor
|
||||
virtual ~CCopySettingsAndCachesComponent();
|
||||
|
||||
private:
|
||||
//! Other version has been changed
|
||||
void onOtherVersionChanged(const BlackMisc::CApplicationInfo &info);
|
||||
|
||||
//! Init UI
|
||||
void initAll();
|
||||
|
||||
//! Audio init
|
||||
void initAudio();
|
||||
|
||||
//! Network init
|
||||
void initNetwork();
|
||||
|
||||
//! UI init
|
||||
void initUi();
|
||||
|
||||
//! Simulator init
|
||||
void initSimulator();
|
||||
|
||||
//! Misc. init
|
||||
void initMisc();
|
||||
|
||||
//! Model init
|
||||
void initModel();
|
||||
|
||||
//! Copy
|
||||
void copy();
|
||||
|
||||
//! Select all
|
||||
void selectAll();
|
||||
|
||||
//! Deselect all
|
||||
void deselectAll();
|
||||
|
||||
//! All checkboxes
|
||||
QList<QCheckBox *> checkBoxes() const;
|
||||
|
||||
//! Display status message
|
||||
void displayStatusMessage(const BlackMisc::CStatusMessage &msg, const QString &value);
|
||||
|
||||
//! All check boxes read only
|
||||
void allCheckBoxesReadOnly();
|
||||
|
||||
//! Enable checkbox
|
||||
static void readOnlyCheckbox(QCheckBox *cb, bool readOnly);
|
||||
|
||||
//! Checkbox text
|
||||
static QString checkBoxText(const QString &text, bool setting);
|
||||
|
||||
QScopedPointer<Ui::CCopySettingsAndCachesComponent> ui;
|
||||
|
||||
BlackMisc::CSetting<BlackCore::Audio::TSettings> m_settingsAudio { this };
|
||||
BlackMisc::CSetting<BlackCore::Audio::TInputDevice> m_settingsAudioInputDevice { this };
|
||||
BlackMisc::CSetting<BlackCore::Audio::TOutputDevice> m_settingsAudioOutputDevice { this };
|
||||
BlackMisc::CSetting<BlackMisc::Network::Settings::TTrafficServers> m_settingsTrafficNetworkServers { this };
|
||||
BlackMisc::CSetting<Settings::TGeneralGui> m_settingsGuiGeneral { this };
|
||||
BlackMisc::CSetting<Settings::TDockWidget> m_settingsDockWidget { this };
|
||||
BlackMisc::CSetting<Settings::TViewUpdateSettings> m_settingsViewUpdate { this };
|
||||
BlackMisc::CSetting<BlackCore::Application::TEnabledSimulators> m_settingsEnabledSimulators { this };
|
||||
BlackMisc::CSetting<BlackCore::Application::TActionHotkeys> m_settingsActionHotkeys { this };
|
||||
BlackMisc::CSetting<BlackMisc::Simulation::Settings::TSimulatorFsx> m_settingsSimulatorFsx { this }; //!< FSX settings
|
||||
BlackMisc::CSetting<BlackMisc::Simulation::Settings::TSimulatorFs9> m_settingsSimulatorFs9 { this }; //!< FS9 settings
|
||||
BlackMisc::CSetting<BlackMisc::Simulation::Settings::TSimulatorP3D> m_settingsSimulatorP3D { this }; //!< P3D settings
|
||||
BlackMisc::CSetting<BlackMisc::Simulation::Settings::TSimulatorXP> m_settingsSimulatorXPlane { this }; //!< XP settings
|
||||
BlackMisc::CSetting<Settings::TBackgroundConsolidation> m_settingsConsolidation { this }; //!< consolidation time
|
||||
BlackMisc::CSetting<BlackMisc::Simulation::Settings::TModel> m_settingsModel { this }; //!< model setting
|
||||
BlackMisc::CSetting<BlackGui::Settings::TAtcStationsSettings> m_settingsAtcStations { this };
|
||||
BlackMisc::CSetting<BlackGui::Settings::TextMessageSettings> m_settingsTextMessage { this };
|
||||
|
||||
BlackMisc::CData<BlackMisc::Network::Data::TLastServer> m_cacheLastNetworkServer { this }; //!< recently used server (VATSIM, other)
|
||||
BlackMisc::CData<BlackCore::Data::TVatsimLastServer> m_cacheLastVatsimServer { this }; //!< recently used VATSIM server
|
||||
BlackMisc::CData<BlackMisc::Simulation::Data::TSimulatorLastSelection> m_cacheModelSetCurrentSimulator { this };
|
||||
BlackMisc::CData<BlackMisc::Simulation::Data::TModelCacheLastSelection> m_cacheModelsCurrentSimulator { this };
|
||||
BlackMisc::CData<BlackMisc::Simulation::Data::TLastModel> m_cacheLastAircraftModel { this }; //!< recently used aircraft model
|
||||
BlackMisc::CData<BlackCore::Data::TLauncherSetup> m_cacheLauncherSetup { this };
|
||||
BlackMisc::CData<BlackCore::Data::TVatsimSetup> m_cacheVatsimSetup { this };
|
||||
};
|
||||
|
||||
/**
|
||||
* Wizard page for CCopySettingsAndCaches
|
||||
*/
|
||||
class CCopySettingsAndCachesWizardPage : public QWizardPage
|
||||
{
|
||||
public:
|
||||
//! Constructors
|
||||
using QWizardPage::QWizardPage;
|
||||
|
||||
//! Set config
|
||||
void setConfigComponent(CCopySettingsAndCachesComponent *config) { m_copyCachesAndSettings = config; }
|
||||
|
||||
//! \copydoc QWizardPage::validatePage
|
||||
virtual bool validatePage() override;
|
||||
|
||||
private:
|
||||
CCopySettingsAndCachesComponent *m_copyCachesAndSettings = nullptr;
|
||||
};
|
||||
} // ns
|
||||
} // ns
|
||||
|
||||
#endif // guard
|
||||
351
src/blackgui/components/copysettingsandcachescomponent.ui
Normal file
351
src/blackgui/components/copysettingsandcachescomponent.ui
Normal file
@@ -0,0 +1,351 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>CCopySettingsAndCachesComponent</class>
|
||||
<widget class="QFrame" name="CCopySettingsAndCachesComponent">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>379</width>
|
||||
<height>472</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Frame</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="vl_CopySettingsAndCache" stretch="0,1">
|
||||
<item>
|
||||
<widget class="QGroupBox" name="gb_OtherSwiftVersions">
|
||||
<property name="title">
|
||||
<string>Select the version to copy from</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="vl_OtherSwiftVersions">
|
||||
<item>
|
||||
<widget class="BlackGui::Components::COtherSwiftVersionsComponent" name="comp_OtherSwiftVersions">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>0</width>
|
||||
<height>125</height>
|
||||
</size>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QGroupBox" name="gb_WhatToCopy">
|
||||
<property name="title">
|
||||
<string>What to copy?</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gl_WhatToCopy">
|
||||
<item row="2" column="0" colspan="3">
|
||||
<widget class="QFrame" name="fr_Buttons">
|
||||
<property name="frameShape">
|
||||
<enum>QFrame::StyledPanel</enum>
|
||||
</property>
|
||||
<property name="frameShadow">
|
||||
<enum>QFrame::Raised</enum>
|
||||
</property>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<item>
|
||||
<widget class="QLineEdit" name="le_Status">
|
||||
<property name="readOnly">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="pb_DeselectAll">
|
||||
<property name="text">
|
||||
<string>deselect all</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="pb_SelectAll">
|
||||
<property name="text">
|
||||
<string>select all</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="pb_Copy">
|
||||
<property name="text">
|
||||
<string>copy</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="0">
|
||||
<widget class="QFrame" name="fr_Left">
|
||||
<layout class="QVBoxLayout" name="vl_left">
|
||||
<property name="leftMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QGroupBox" name="gb_Audio">
|
||||
<property name="title">
|
||||
<string>Audio</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="vl_Audio">
|
||||
<item>
|
||||
<widget class="QCheckBox" name="cb_SettingsAudio">
|
||||
<property name="text">
|
||||
<string>Audio1</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="cb_SettingsAudioInputDevice">
|
||||
<property name="text">
|
||||
<string>Audio2</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="cb_SettingsAudioOutputDevice">
|
||||
<property name="text">
|
||||
<string>Audio3</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QGroupBox" name="gb_Ui">
|
||||
<property name="title">
|
||||
<string>UI</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_4">
|
||||
<item>
|
||||
<widget class="QCheckBox" name="cb_SettingsGuiGeneral">
|
||||
<property name="text">
|
||||
<string>UI1</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="cb_SettingsDockWidget">
|
||||
<property name="text">
|
||||
<string>UI2</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="cb_SettingsViewUpdate">
|
||||
<property name="text">
|
||||
<string>UI3</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="2">
|
||||
<widget class="QFrame" name="fr_Right">
|
||||
<layout class="QVBoxLayout" name="vl_Right">
|
||||
<property name="leftMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QGroupBox" name="gb_Misc">
|
||||
<property name="title">
|
||||
<string>Misc.</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="vl_Misc">
|
||||
<item>
|
||||
<widget class="QCheckBox" name="cb_SettingsActionHotkeys">
|
||||
<property name="text">
|
||||
<string>Keys</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="cb_SettingsAtcStations">
|
||||
<property name="text">
|
||||
<string>ATC stations</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="cb_SettingsTextMessages">
|
||||
<property name="text">
|
||||
<string>Text Messages</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QGroupBox" name="gb_Model">
|
||||
<property name="title">
|
||||
<string>Models</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="vl_Models">
|
||||
<item>
|
||||
<widget class="QCheckBox" name="cb_SettingsModel">
|
||||
<property name="text">
|
||||
<string>Model</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="cb_SettingsConsolidation">
|
||||
<property name="text">
|
||||
<string>Consolidation</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QFrame" name="fr_Middle">
|
||||
<layout class="QVBoxLayout" name="vl_Middle">
|
||||
<property name="leftMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QGroupBox" name="gb_Network">
|
||||
<property name="title">
|
||||
<string>Network</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="vl_Network">
|
||||
<item>
|
||||
<widget class="QCheckBox" name="cb_SettingsNetworkTrafficServers">
|
||||
<property name="text">
|
||||
<string>Network1</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="cb_CacheLastNetworkServer">
|
||||
<property name="text">
|
||||
<string>Network2</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="cb_CacheLastVatsimServer">
|
||||
<property name="text">
|
||||
<string>Network3</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QGroupBox" name="gb_Simulator">
|
||||
<property name="title">
|
||||
<string>Simulator</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="vl_Simulator">
|
||||
<item>
|
||||
<widget class="QCheckBox" name="cb_SettingsEnabledSimulators">
|
||||
<property name="text">
|
||||
<string>Enabled sims</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="cb_SettingsSimulatorFSX">
|
||||
<property name="text">
|
||||
<string>FSX</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="cb_SettingsSimulatorP3D">
|
||||
<property name="text">
|
||||
<string>P3D</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="cb_SettingsSimulatorXPlane">
|
||||
<property name="text">
|
||||
<string>XPlane</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<customwidgets>
|
||||
<customwidget>
|
||||
<class>BlackGui::Components::COtherSwiftVersionsComponent</class>
|
||||
<extends>QFrame</extends>
|
||||
<header>blackgui/components/otherswiftversionscomponent.h</header>
|
||||
<container>1</container>
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
<tabstops>
|
||||
<tabstop>cb_SettingsAudio</tabstop>
|
||||
<tabstop>cb_SettingsAudioInputDevice</tabstop>
|
||||
<tabstop>cb_SettingsAudioOutputDevice</tabstop>
|
||||
<tabstop>cb_SettingsGuiGeneral</tabstop>
|
||||
<tabstop>cb_SettingsDockWidget</tabstop>
|
||||
<tabstop>cb_SettingsViewUpdate</tabstop>
|
||||
<tabstop>cb_SettingsNetworkTrafficServers</tabstop>
|
||||
<tabstop>cb_CacheLastNetworkServer</tabstop>
|
||||
<tabstop>cb_CacheLastVatsimServer</tabstop>
|
||||
<tabstop>cb_SettingsEnabledSimulators</tabstop>
|
||||
<tabstop>cb_SettingsSimulatorFSX</tabstop>
|
||||
<tabstop>cb_SettingsSimulatorP3D</tabstop>
|
||||
<tabstop>cb_SettingsSimulatorXPlane</tabstop>
|
||||
<tabstop>cb_SettingsActionHotkeys</tabstop>
|
||||
<tabstop>le_Status</tabstop>
|
||||
<tabstop>pb_DeselectAll</tabstop>
|
||||
<tabstop>pb_SelectAll</tabstop>
|
||||
<tabstop>pb_Copy</tabstop>
|
||||
</tabstops>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
||||
Reference in New Issue
Block a user