parent
a416d03614
commit
92fbbd4812
11 changed files with 15 additions and 53 deletions
|
@ -290,9 +290,6 @@ void AmneziaApplication::initModels()
|
||||||
m_engine->rootContext()->setContextProperty("ServersModel", m_serversModel.get());
|
m_engine->rootContext()->setContextProperty("ServersModel", m_serversModel.get());
|
||||||
connect(m_serversModel.get(), &ServersModel::containersUpdated, m_containersModel.get(),
|
connect(m_serversModel.get(), &ServersModel::containersUpdated, m_containersModel.get(),
|
||||||
&ContainersModel::updateModel);
|
&ContainersModel::updateModel);
|
||||||
connect(m_serversModel.get(), &ServersModel::defaultContainerChanged, m_containersModel.get(),
|
|
||||||
&ContainersModel::setDefaultContainer);
|
|
||||||
m_containersModel->setDefaultContainer(m_serversModel->getDefaultContainer()); // make better?
|
|
||||||
|
|
||||||
m_languageModel.reset(new LanguageModel(m_settings, this));
|
m_languageModel.reset(new LanguageModel(m_settings, this));
|
||||||
m_engine->rootContext()->setContextProperty("LanguageModel", m_languageModel.get());
|
m_engine->rootContext()->setContextProperty("LanguageModel", m_languageModel.get());
|
||||||
|
|
|
@ -33,7 +33,7 @@ void ConnectionController::openConnection()
|
||||||
int serverIndex = m_serversModel->getDefaultServerIndex();
|
int serverIndex = m_serversModel->getDefaultServerIndex();
|
||||||
ServerCredentials credentials = m_serversModel->getServerCredentials(serverIndex);
|
ServerCredentials credentials = m_serversModel->getServerCredentials(serverIndex);
|
||||||
|
|
||||||
DockerContainer container = m_containersModel->getDefaultContainer();
|
DockerContainer container = m_serversModel->getDefaultContainer(serverIndex);
|
||||||
const QJsonObject &containerConfig = m_containersModel->getContainerConfig(container);
|
const QJsonObject &containerConfig = m_containersModel->getContainerConfig(container);
|
||||||
|
|
||||||
if (container == DockerContainer::None) {
|
if (container == DockerContainer::None) {
|
||||||
|
|
|
@ -284,7 +284,7 @@ void InstallController::updateContainer(QJsonObject config)
|
||||||
m_protocolModel->updateModel(config);
|
m_protocolModel->updateModel(config);
|
||||||
|
|
||||||
if ((serverIndex == m_serversModel->getDefaultServerIndex())
|
if ((serverIndex == m_serversModel->getDefaultServerIndex())
|
||||||
&& (container == m_containersModel->getDefaultContainer())) {
|
&& (container == m_serversModel->getDefaultContainer(serverIndex))) {
|
||||||
emit currentContainerUpdated();
|
emit currentContainerUpdated();
|
||||||
} else {
|
} else {
|
||||||
emit updateContainerFinished(tr("Settings updated successfully"));
|
emit updateContainerFinished(tr("Settings updated successfully"));
|
||||||
|
|
|
@ -39,7 +39,6 @@ QVariant ContainersModel::data(const QModelIndex &index, int role) const
|
||||||
case EasySetupOrderRole: return ContainerProps::easySetupOrder(container);
|
case EasySetupOrderRole: return ContainerProps::easySetupOrder(container);
|
||||||
case IsInstalledRole: return m_containers.contains(container);
|
case IsInstalledRole: return m_containers.contains(container);
|
||||||
case IsCurrentlyProcessedRole: return container == static_cast<DockerContainer>(m_currentlyProcessedContainerIndex);
|
case IsCurrentlyProcessedRole: return container == static_cast<DockerContainer>(m_currentlyProcessedContainerIndex);
|
||||||
case IsDefaultRole: return container == m_defaultContainerIndex;
|
|
||||||
case IsSupportedRole: return ContainerProps::isSupportedByCurrentPlatform(container);
|
case IsSupportedRole: return ContainerProps::isSupportedByCurrentPlatform(container);
|
||||||
case IsShareableRole: return ContainerProps::isShareable(container);
|
case IsShareableRole: return ContainerProps::isShareable(container);
|
||||||
}
|
}
|
||||||
|
@ -64,18 +63,6 @@ void ContainersModel::updateModel(const QJsonArray &containers)
|
||||||
endResetModel();
|
endResetModel();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ContainersModel::setDefaultContainer(const int containerIndex)
|
|
||||||
{
|
|
||||||
m_defaultContainerIndex = static_cast<DockerContainer>(containerIndex);
|
|
||||||
emit dataChanged(index(containerIndex, 0), index(containerIndex, 0));
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
DockerContainer ContainersModel::getDefaultContainer()
|
|
||||||
{
|
|
||||||
return m_defaultContainerIndex;
|
|
||||||
}
|
|
||||||
|
|
||||||
void ContainersModel::setCurrentlyProcessedContainerIndex(int index)
|
void ContainersModel::setCurrentlyProcessedContainerIndex(int index)
|
||||||
{
|
{
|
||||||
m_currentlyProcessedContainerIndex = index;
|
m_currentlyProcessedContainerIndex = index;
|
||||||
|
@ -127,7 +114,6 @@ QHash<int, QByteArray> ContainersModel::roleNames() const
|
||||||
|
|
||||||
roles[IsInstalledRole] = "isInstalled";
|
roles[IsInstalledRole] = "isInstalled";
|
||||||
roles[IsCurrentlyProcessedRole] = "isCurrentlyProcessed";
|
roles[IsCurrentlyProcessedRole] = "isCurrentlyProcessed";
|
||||||
roles[IsDefaultRole] = "isDefault";
|
|
||||||
roles[IsSupportedRole] = "isSupported";
|
roles[IsSupportedRole] = "isSupported";
|
||||||
roles[IsShareableRole] = "isShareable";
|
roles[IsShareableRole] = "isShareable";
|
||||||
return roles;
|
return roles;
|
||||||
|
|
|
@ -42,9 +42,6 @@ public:
|
||||||
public slots:
|
public slots:
|
||||||
void updateModel(const QJsonArray &containers);
|
void updateModel(const QJsonArray &containers);
|
||||||
|
|
||||||
DockerContainer getDefaultContainer();
|
|
||||||
void setDefaultContainer(const int containerIndex);
|
|
||||||
|
|
||||||
void setCurrentlyProcessedContainerIndex(int containerIndex);
|
void setCurrentlyProcessedContainerIndex(int containerIndex);
|
||||||
int getCurrentlyProcessedContainerIndex();
|
int getCurrentlyProcessedContainerIndex();
|
||||||
|
|
||||||
|
@ -58,14 +55,12 @@ protected:
|
||||||
QHash<int, QByteArray> roleNames() const override;
|
QHash<int, QByteArray> roleNames() const override;
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void defaultContainerChanged();
|
|
||||||
void containersModelUpdated();
|
void containersModelUpdated();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QMap<DockerContainer, QJsonObject> m_containers;
|
QMap<DockerContainer, QJsonObject> m_containers;
|
||||||
|
|
||||||
int m_currentlyProcessedContainerIndex;
|
int m_currentlyProcessedContainerIndex;
|
||||||
DockerContainer m_defaultContainerIndex;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // CONTAINERS_MODEL_H
|
#endif // CONTAINERS_MODEL_H
|
||||||
|
|
|
@ -403,23 +403,23 @@ void ServersModel::addContainerConfig(const int containerIndex, const QJsonObjec
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ServersModel::setDefaultContainer(const int containerIndex)
|
void ServersModel::setDefaultContainer(const int serverIndex, const int containerIndex)
|
||||||
{
|
{
|
||||||
auto container = static_cast<DockerContainer>(containerIndex);
|
auto container = static_cast<DockerContainer>(containerIndex);
|
||||||
QJsonObject s = m_servers.at(m_currentlyProcessedServerIndex).toObject();
|
QJsonObject s = m_servers.at(serverIndex).toObject();
|
||||||
s.insert(config_key::defaultContainer, ContainerProps::containerToString(container));
|
s.insert(config_key::defaultContainer, ContainerProps::containerToString(container));
|
||||||
editServer(s); //check
|
editServer(s); //check
|
||||||
emit defaultContainerChanged(container);
|
emit defaultContainerChanged(container);
|
||||||
}
|
}
|
||||||
|
|
||||||
DockerContainer ServersModel::getDefaultContainer()
|
DockerContainer ServersModel::getDefaultContainer(const int serverIndex)
|
||||||
{
|
{
|
||||||
return qvariant_cast<DockerContainer>(data(m_currentlyProcessedServerIndex, DefaultContainerRole));
|
return qvariant_cast<DockerContainer>(data(serverIndex, DefaultContainerRole));
|
||||||
}
|
}
|
||||||
|
|
||||||
const QString ServersModel::getDefaultContainerName()
|
const QString ServersModel::getDefaultContainerName()
|
||||||
{
|
{
|
||||||
auto defaultContainer = getDefaultContainer();
|
auto defaultContainer = getDefaultContainer(m_defaultServerIndex);
|
||||||
return ContainerProps::containerHumanNames().value(defaultContainer);
|
return ContainerProps::containerHumanNames().value(defaultContainer);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -91,8 +91,8 @@ public slots:
|
||||||
ErrorCode removeAllContainers();
|
ErrorCode removeAllContainers();
|
||||||
ErrorCode rebootServer();
|
ErrorCode rebootServer();
|
||||||
|
|
||||||
void setDefaultContainer(const int containerIndex);
|
void setDefaultContainer(const int serverIndex, const int containerIndex);
|
||||||
DockerContainer getDefaultContainer();
|
DockerContainer getDefaultContainer(const int serverIndex);
|
||||||
const QString getDefaultContainerName();
|
const QString getDefaultContainerName();
|
||||||
|
|
||||||
QStringList getAllInstalledServicesName(const int serverIndex);
|
QStringList getAllInstalledServicesName(const int serverIndex);
|
||||||
|
|
|
@ -139,6 +139,7 @@ Button {
|
||||||
|
|
||||||
onClicked: {
|
onClicked: {
|
||||||
if (!ConnectionController.isConnectionInProgress) {
|
if (!ConnectionController.isConnectionInProgress) {
|
||||||
|
ServersModel.setCurrentlyProcessedServerIndex(ServersModel.defaultIndex)
|
||||||
ApiController.updateServerConfigFromApi()
|
ApiController.updateServerConfigFromApi()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,24 +26,6 @@ ListView {
|
||||||
id: containersRadioButtonGroup
|
id: containersRadioButtonGroup
|
||||||
}
|
}
|
||||||
|
|
||||||
Connections {
|
|
||||||
target: ServersModel
|
|
||||||
|
|
||||||
function onCurrentlyProcessedServerIndexChanged() {
|
|
||||||
if (ContainersModel.getDefaultContainer()) {
|
|
||||||
menuContent.checkCurrentItem()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function checkCurrentItem() {
|
|
||||||
var item = menuContent.itemAtIndex(currentIndex)
|
|
||||||
if (item !== null) {
|
|
||||||
var radioButton = item.children[0].children[0]
|
|
||||||
radioButton.checked = true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
delegate: Item {
|
delegate: Item {
|
||||||
implicitWidth: rootWidth
|
implicitWidth: rootWidth
|
||||||
implicitHeight: content.implicitHeight
|
implicitHeight: content.implicitHeight
|
||||||
|
@ -69,7 +51,7 @@ ListView {
|
||||||
showImage: !isInstalled
|
showImage: !isInstalled
|
||||||
|
|
||||||
checkable: isInstalled && !ConnectionController.isConnected && isSupported
|
checkable: isInstalled && !ConnectionController.isConnected && isSupported
|
||||||
checked: isDefault
|
checked: proxyContainersModel.mapToSource(index) === ServersModel.getDefaultContainer(ServersModel.defaultIndex)
|
||||||
|
|
||||||
onClicked: {
|
onClicked: {
|
||||||
if (ConnectionController.isConnected && isInstalled) {
|
if (ConnectionController.isConnected && isInstalled) {
|
||||||
|
@ -79,7 +61,7 @@ ListView {
|
||||||
|
|
||||||
if (checked) {
|
if (checked) {
|
||||||
containersDropDown.menuVisible = false
|
containersDropDown.menuVisible = false
|
||||||
ServersModel.setDefaultContainer(proxyContainersModel.mapToSource(index))
|
ServersModel.setDefaultContainer(ServersModel.defaultIndex, proxyContainersModel.mapToSource(index))
|
||||||
} else {
|
} else {
|
||||||
if (!isSupported && isInstalled) {
|
if (!isSupported && isInstalled) {
|
||||||
PageController.showErrorMessage(qsTr("The selected protocol is not supported on the current platform"))
|
PageController.showErrorMessage(qsTr("The selected protocol is not supported on the current platform"))
|
||||||
|
|
|
@ -26,7 +26,7 @@ PageType {
|
||||||
|
|
||||||
function onInstallContainerFinished(finishedMessage, isServiceInstall) {
|
function onInstallContainerFinished(finishedMessage, isServiceInstall) {
|
||||||
if (!ConnectionController.isConnected && !isServiceInstall) {
|
if (!ConnectionController.isConnected && !isServiceInstall) {
|
||||||
ServersModel.setDefaultContainer(ContainersModel.getCurrentlyProcessedContainerIndex())
|
ServersModel.setDefaultContainer(ServersModel.currentlyProcessedIndex, ContainersModel.getCurrentlyProcessedContainerIndex())
|
||||||
}
|
}
|
||||||
|
|
||||||
PageController.closePage() // close installing page
|
PageController.closePage() // close installing page
|
||||||
|
|
|
@ -365,7 +365,8 @@ PageType {
|
||||||
target: serverSelector
|
target: serverSelector
|
||||||
|
|
||||||
function onSeverSelectorIndexChanged() {
|
function onSeverSelectorIndexChanged() {
|
||||||
protocolSelectorListView.currentIndex = proxyContainersModel.mapFromSource(ServersModel.getDefaultContainer())
|
var defaultContainer = proxyContainersModel.mapFromSource(ServersModel.getDefaultContainer(ServersModel.currentlyProcessedIndex))
|
||||||
|
protocolSelectorListView.currentIndex = defaultContainer
|
||||||
protocolSelectorListView.triggerCurrentItem()
|
protocolSelectorListView.triggerCurrentItem()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue