Adeed a new spin box in the gui to track the variable which stores the maximum size limit allowed for autodownload in channels.

This spin box was linked to the variable from the p3gxschannel.h file. This spin box has 8GB as it's default value.
This commit is contained in:
Tushar Garg 2023-04-09 18:10:16 +05:30
parent 4f1bdbca70
commit 7dabc1ff9b
3 changed files with 76 additions and 25 deletions

View File

@ -22,6 +22,8 @@
#include "rsharesettings.h"
#include "util/misc.h"
#include "gui/notifyqt.h"
#include "../../libretroshare/src/retroshare/rsgxschannels.h"
#include "../../libretroshare/src/services/p3gxschannels.h"
ChannelPage::ChannelPage(QWidget * parent, Qt::WindowFlags flags)
: ConfigPage(parent, flags)
@ -33,7 +35,10 @@ ChannelPage::ChannelPage(QWidget * parent, Qt::WindowFlags flags)
ui.groupFrameSettingsWidget->setOpenAllInNewTabText(tr("Open each channel in a new tab"));
ui.groupFrameSettingsWidget->setType(GroupFrameSettings::Channel) ;
connect(ui.emoteicon_checkBox,SIGNAL(toggled(bool)),this,SLOT(updateEmotes())) ;
connect(ui.emoteicon_checkBox,SIGNAL(toggled(bool)),this,SLOT(updateEmotes())) ;
// Connecting the spin box with the maximum auto download size in channels
connect(ui.autoDownloadSpinBox, SIGNAL(valueChanged(int)), this, SLOT(updateMaxAutoDownloadSizeLimit(int)));
}
@ -49,6 +54,13 @@ void ChannelPage::load()
Settings->beginGroup(QString("ChannelPostsWidget"));
whileBlocking(ui.emoteicon_checkBox)->setChecked(Settings->value("Emoteicons_ChannelDecription", true).toBool());
Settings->endGroup();
// Getting the maximum auto download size from the configuration
uint64_t maxAutoDownloadSize;
rsGxsChannels->getMaxAutoDownloadSizeLimit(maxAutoDownloadSize);
int temp=(maxAutoDownloadSize/(Size_Of_1_GB));
whileBlocking(ui.autoDownloadSpinBox)->setValue(temp);
}
void ChannelPage::updateEmotes()
@ -57,3 +69,11 @@ void ChannelPage::updateEmotes()
Settings->setValue("Emoteicons_ChannelDecription", ui.emoteicon_checkBox->isChecked());
Settings->endGroup();
}
// Function to update the maximum size allowed for auto download in channels
void ChannelPage::updateMaxAutoDownloadSizeLimit(int value)
{
uint64_t temp=(static_cast<uint64_t>(value)*Size_Of_1_GB);
rsGxsChannels->setMaxAutoDownloadSizeLimit(temp);
}

View File

@ -25,6 +25,8 @@
#include "ui_ChannelPage.h"
#include "gui/common/FilesDefs.h"
#define Size_Of_1_GB (1024 * 1024 * 1024) // It is the size of 1 GB in bytes.
class ChannelPage : public ConfigPage
{
Q_OBJECT
@ -34,7 +36,7 @@ public:
~ChannelPage();
/** Loads the settings for this page */
virtual void load();
virtual void load();
virtual QPixmap iconPixmap() const { return FilesDefs::getPixmapFromQtResourcePath(":/icons/settings/channels.svg") ; }
virtual QString pageName() const { return tr("Channels") ; }
@ -42,7 +44,10 @@ public:
private slots:
void updateEmotes();
// Function to update the maximum size allowed for auto download in channels
void updateMaxAutoDownloadSizeLimit(int value);
private:
Ui::ChannelPage ui;
};

View File

@ -6,22 +6,23 @@
<rect>
<x>0</x>
<y>0</y>
<width>423</width>
<width>526</width>
<height>334</height>
</rect>
</property>
<layout class="QGridLayout" name="gridLayout_3">
<item row="1" column="0">
<widget class="QGroupBox" name="tabsGroupBox">
<property name="title">
<string>Tabs</string>
<layout class="QGridLayout" name="gridLayout">
<item row="3" column="0">
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="GroupFrameSettingsWidget" name="groupFrameSettingsWidget" native="true"/>
</item>
</layout>
</widget>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>5</height>
</size>
</property>
</spacer>
</item>
<item row="0" column="0">
<widget class="QGroupBox" name="generalGroupBox">
@ -39,18 +40,43 @@
</layout>
</widget>
</item>
<item row="1" column="0">
<widget class="QGroupBox" name="tabsGroupBox">
<property name="title">
<string>Tabs</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="GroupFrameSettingsWidget" name="groupFrameSettingsWidget" native="true"/>
</item>
</layout>
</widget>
</item>
<item row="2" column="0">
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
<widget class="QGroupBox" name="downloadsGroupBox">
<property name="title">
<string>Downloads</string>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
<layout class="QFormLayout" name="formLayout">
<item row="0" column="0">
<widget class="QSpinBox" name="autoDownloadSpinBox">
<property name="minimum">
<number>1</number>
</property>
<property name="maximum">
<number>200</number>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QLabel" name="label">
<property name="text">
<string>Maximum Auto Download Size (in GBs)</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
</layout>
</widget>