Fix ‘add-default-catalog’ flow from aircraft list
This commit is contained in:
parent
42936f4f22
commit
0da17d895c
5 changed files with 56 additions and 40 deletions
|
@ -180,8 +180,7 @@ void AddOnsController::officialCatalogAction(QString s)
|
|||
QSettings settings;
|
||||
settings.setValue("hide-official-catalog-message", true);
|
||||
} else if (s == "add-official") {
|
||||
// TEMPROARY, FIXME
|
||||
// AddOnsPage::addDefaultCatalog(nullptr, false /* not silent */);
|
||||
m_catalogs->installDefaultCatalog();
|
||||
}
|
||||
|
||||
emit showNoOfficialHangarChanged();
|
||||
|
|
|
@ -64,7 +64,7 @@ protected:
|
|||
} else if ((aReason == STATUS_REFRESHED) || (aReason == STATUS_SUCCESS)) {
|
||||
m_model->refreshPackages();
|
||||
} else {
|
||||
qWarning() << "failed refresh of "
|
||||
qWarning() << "failed refresh of"
|
||||
<< QString::fromStdString(aCatalog->url()) << ":" << aReason << endl;
|
||||
}
|
||||
|
||||
|
|
|
@ -40,6 +40,7 @@ public:
|
|||
if (length > 0) {
|
||||
// warn if we had valid bytes but couldn't load it, i.e corrupted data or similar
|
||||
qWarning() << "failed to load image data for URL:" << QString::fromStdString(aThumbnailUrl);
|
||||
owner->clearImage();
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
@ -125,7 +126,11 @@ void ThumbnailImageItem::setAircraftUri(QString uri)
|
|||
int variant = package->indexOfVariant(packageId);
|
||||
const auto thumbnail = package->thumbnailForVariant(variant);
|
||||
m_imageUrl = QUrl(QString::fromStdString(thumbnail.url));
|
||||
globals->packageRoot()->requestThumbnailData(m_imageUrl.toString().toStdString());
|
||||
if (m_imageUrl.isValid()) {
|
||||
globals->packageRoot()->requestThumbnailData(m_imageUrl.toString().toStdString());
|
||||
} else {
|
||||
clearImage();
|
||||
}
|
||||
}
|
||||
} else {
|
||||
QFileInfo aircraftSetPath(QUrl(uri).toLocalFile());
|
||||
|
@ -138,6 +143,7 @@ void ThumbnailImageItem::setAircraftUri(QString uri)
|
|||
setImage(img);
|
||||
} else {
|
||||
qWarning() << Q_FUNC_INFO << "failed to load thumbnail from:" << thumbnailPath;
|
||||
clearImage();
|
||||
}
|
||||
}
|
||||
} // of local aircraft case
|
||||
|
@ -168,3 +174,12 @@ void ThumbnailImageItem::setImage(QImage image)
|
|||
emit sourceSizeChanged();
|
||||
update();
|
||||
}
|
||||
|
||||
void ThumbnailImageItem::clearImage()
|
||||
{
|
||||
m_image = QImage{};
|
||||
m_imageDirty = true;
|
||||
setImplicitSize(m_maximumSize.width(), m_maximumSize.height());
|
||||
emit sourceSizeChanged();
|
||||
update();
|
||||
}
|
||||
|
|
|
@ -49,6 +49,7 @@ private:
|
|||
friend class ThumbnailPackageDelegate;
|
||||
|
||||
void setImage(QImage image);
|
||||
void clearImage();
|
||||
|
||||
QString m_aircraftUri;
|
||||
QUrl m_imageUrl;
|
||||
|
|
|
@ -1,49 +1,50 @@
|
|||
import QtQuick 2.2
|
||||
import FlightGear.Launcher 1.0 as FG
|
||||
|
||||
Rectangle {
|
||||
Item {
|
||||
id: root
|
||||
|
||||
height: noDefaultCatalogRow.childrenRect.height + (Style.margin * 2);
|
||||
height: frameRect.height + (Style.margin * 2);
|
||||
z: 100
|
||||
color: "white"
|
||||
border.width: 1
|
||||
border.color: Style.minorFrameColor
|
||||
|
||||
Row {
|
||||
Rectangle {
|
||||
id: frameRect
|
||||
y: Style.margin
|
||||
id: noDefaultCatalogRow
|
||||
spacing: Style.margin
|
||||
height: noDefaultCatalogRow.childrenRect.height + (Style.margin * 2);
|
||||
width: parent.width
|
||||
color: "white"
|
||||
border.width: 1
|
||||
border.color: Style.minorFrameColor
|
||||
|
||||
Text {
|
||||
text: "The official FlightGear aircraft hangar is not added, so many standard "
|
||||
+ "aircraft will not be available. You can add the hangar now, or hide "
|
||||
+ "this message. The offical hangar can always be restored from the 'Add-Ons' page."
|
||||
wrapMode: Text.WordWrap
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
width: root.width - (addDefaultButton.width + hideButton.width + Style.margin * 3)
|
||||
}
|
||||
Row {
|
||||
y: Style.margin
|
||||
id: noDefaultCatalogRow
|
||||
spacing: Style.margin
|
||||
|
||||
Button {
|
||||
id: addDefaultButton
|
||||
text: qsTr("Add default hangar")
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
|
||||
onClicked: {
|
||||
console.warn("Implement me")
|
||||
|
||||
// _launcher.officialCatalogAction("add-official");
|
||||
Text {
|
||||
text: qsTr("The official FlightGear aircraft hangar is not added, so many standard "
|
||||
+ "aircraft will not be available. You can add the hangar now, or hide "
|
||||
+ "this message. The offical hangar can always be restored from the 'Add-Ons' page.")
|
||||
wrapMode: Text.WordWrap
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
width: root.width - (addDefaultButton.width + hideButton.width + Style.margin * 3)
|
||||
}
|
||||
}
|
||||
|
||||
Button {
|
||||
id: hideButton
|
||||
text: qsTr("Hide")
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
|
||||
onClicked: {
|
||||
_addOns.officialCatalogAction("hide");
|
||||
Button {
|
||||
id: addDefaultButton
|
||||
text: _addOns.catalogs.isAddingCatalog ? qsTr("Adding hangar")
|
||||
: qsTr("Add default hangar")
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
onClicked: _addOns.officialCatalogAction("add-official");
|
||||
enabled: !_addOns.catalogs.isAddingCatalog
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Button {
|
||||
id: hideButton
|
||||
text: qsTr("Hide")
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
onClicked: _addOns.officialCatalogAction("hide");
|
||||
}
|
||||
} // content row
|
||||
} // visible frame
|
||||
} // root item
|
||||
|
|
Loading…
Add table
Reference in a new issue