mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2025-12-12 15:49:28 -08:00
refactor: remove ReleaseChannel keeping track of its own indexes (#5366)
This commit is contained in:
@@ -21,11 +21,8 @@
|
||||
|
||||
#define GIT_SHORT_HASH_LEN 7
|
||||
|
||||
int ReleaseChannel::sharedIndex = 0;
|
||||
|
||||
ReleaseChannel::ReleaseChannel() : netMan(new QNetworkAccessManager(this)), response(nullptr), lastRelease(nullptr)
|
||||
{
|
||||
index = sharedIndex++;
|
||||
}
|
||||
|
||||
ReleaseChannel::~ReleaseChannel()
|
||||
|
||||
@@ -82,9 +82,6 @@ public:
|
||||
~ReleaseChannel() override;
|
||||
|
||||
protected:
|
||||
// shared by all instances
|
||||
static int sharedIndex;
|
||||
int index;
|
||||
QNetworkAccessManager *netMan;
|
||||
QNetworkReply *response;
|
||||
Release *lastRelease;
|
||||
@@ -94,10 +91,6 @@ protected:
|
||||
virtual QString getReleaseChannelUrl() const = 0;
|
||||
|
||||
public:
|
||||
int getIndex() const
|
||||
{
|
||||
return index;
|
||||
}
|
||||
Release *getLastRelease()
|
||||
{
|
||||
return lastRelease;
|
||||
|
||||
@@ -174,8 +174,9 @@ GeneralSettingsPage::GeneralSettingsPage()
|
||||
GeneralSettingsPage::retranslateUi();
|
||||
|
||||
// connect the ReleaseChannel combo box only after the entries are inserted in retranslateUi
|
||||
connect(&updateReleaseChannelBox, SIGNAL(currentIndexChanged(int)), &settings, SLOT(setUpdateReleaseChannel(int)));
|
||||
updateReleaseChannelBox.setCurrentIndex(settings.getUpdateReleaseChannel()->getIndex());
|
||||
connect(&updateReleaseChannelBox, SIGNAL(currentIndexChanged(int)), &settings,
|
||||
SLOT(setUpdateReleaseChannelIndex(int)));
|
||||
updateReleaseChannelBox.setCurrentIndex(settings.getUpdateReleaseChannelIndex());
|
||||
|
||||
setLayout(mainLayout);
|
||||
}
|
||||
@@ -309,7 +310,7 @@ void GeneralSettingsPage::retranslateUi()
|
||||
int oldIndex = updateReleaseChannelBox.currentIndex();
|
||||
updateReleaseChannelBox.clear();
|
||||
for (ReleaseChannel *chan : settings.getUpdateReleaseChannels()) {
|
||||
updateReleaseChannelBox.insertItem(chan->getIndex(), tr(chan->getName().toUtf8()));
|
||||
updateReleaseChannelBox.addItem(tr(chan->getName().toUtf8()));
|
||||
}
|
||||
updateReleaseChannelBox.setCurrentIndex(oldIndex);
|
||||
}
|
||||
|
||||
@@ -1139,9 +1139,9 @@ void SettingsCache::setDownloadSpoilerStatus(bool _spoilerStatus)
|
||||
emit downloadSpoilerStatusChanged();
|
||||
}
|
||||
|
||||
void SettingsCache::setUpdateReleaseChannel(int _updateReleaseChannel)
|
||||
void SettingsCache::setUpdateReleaseChannelIndex(int value)
|
||||
{
|
||||
updateReleaseChannel = _updateReleaseChannel;
|
||||
updateReleaseChannel = value;
|
||||
settings->setValue("personal/updatereleasechannel", updateReleaseChannel);
|
||||
}
|
||||
|
||||
|
||||
@@ -290,6 +290,10 @@ public:
|
||||
{
|
||||
return seenTips;
|
||||
}
|
||||
int getUpdateReleaseChannelIndex() const
|
||||
{
|
||||
return updateReleaseChannel;
|
||||
}
|
||||
ReleaseChannel *getUpdateReleaseChannel() const
|
||||
{
|
||||
return releaseChannels.at(qMax(0, updateReleaseChannel));
|
||||
@@ -712,7 +716,7 @@ public slots:
|
||||
void setCheckUpdatesOnStartup(QT_STATE_CHANGED_T value);
|
||||
void setNotifyAboutUpdate(QT_STATE_CHANGED_T _notifyaboutupdate);
|
||||
void setNotifyAboutNewVersion(QT_STATE_CHANGED_T _notifyaboutnewversion);
|
||||
void setUpdateReleaseChannel(int _updateReleaseChannel);
|
||||
void setUpdateReleaseChannelIndex(int value);
|
||||
void setMaxFontSize(int _max);
|
||||
};
|
||||
|
||||
|
||||
@@ -321,7 +321,7 @@ void SettingsCache::setNotifyAboutNewVersion(QT_STATE_CHANGED_T /* _notifyaboutn
|
||||
void SettingsCache::setDownloadSpoilerStatus(bool /* _spoilerStatus */)
|
||||
{
|
||||
}
|
||||
void SettingsCache::setUpdateReleaseChannel(int /* _updateReleaseChannel */)
|
||||
void SettingsCache::setUpdateReleaseChannelIndex(int /* value */)
|
||||
{
|
||||
}
|
||||
void SettingsCache::setMaxFontSize(int /* _max */)
|
||||
|
||||
@@ -325,7 +325,7 @@ void SettingsCache::setNotifyAboutNewVersion(QT_STATE_CHANGED_T /* _notifyaboutn
|
||||
void SettingsCache::setDownloadSpoilerStatus(bool /* _spoilerStatus */)
|
||||
{
|
||||
}
|
||||
void SettingsCache::setUpdateReleaseChannel(int /* _updateReleaseChannel */)
|
||||
void SettingsCache::setUpdateReleaseChannelIndex(int /* value */)
|
||||
{
|
||||
}
|
||||
void SettingsCache::setMaxFontSize(int /* _max */)
|
||||
|
||||
Reference in New Issue
Block a user