1
mirror of https://invent.kde.org/network/falkon.git synced 2024-11-11 01:22:10 +01:00

SpeedDial: Add option to lock the dials position

BUG: 403684
FIXED-IN: 24.04.0

Signed-off-by: Juraj Oravec <jurajoravec@mailo.com>
This commit is contained in:
Juraj Oravec 2023-12-08 23:58:47 +01:00
parent e6bda46955
commit ea46326c2e
5 changed files with 29 additions and 1 deletions

View File

@ -527,7 +527,8 @@ input[type=checkbox] {
data-max-pages-row="%ROW-PAGES%" data-max-pages-row="%ROW-PAGES%"
data-dial-width="%SD-SIZE%" data-dial-width="%SD-SIZE%"
data-sd-center="%SD-CENTER%" data-sd-center="%SD-CENTER%"
data-initial-script='%INITIAL-SCRIPT%'> data-initial-script='%INITIAL-SCRIPT%'
data-lock-dials='%LOCK-DIALS%'>
</p> </p>
<noscript>%JAVASCRIPT-DISABLED%</noscript> <noscript>%JAVASCRIPT-DISABLED%</noscript>
@ -544,6 +545,10 @@ input[type=checkbox] {
<input type="checkbox" id="SdCntrToggle" name="sdcntrt"/> <input type="checkbox" id="SdCntrToggle" name="sdcntrt"/>
<label for="SdCntrToggle"></label>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;%TXT_CNTRDLS% <label for="SdCntrToggle"></label>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;%TXT_CNTRDLS%
</div> </div>
<div class="checkbox">
<input type="checkbox" id="SdLockDials"/>
<label for="SdLockDials"></label>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;%TXT_LOCKDIALS%
</div>
<div class="togop"> <div class="togop">
<p align="center"><label for="PgInRow">%TXT_NRROWS%</label></p> <p align="center"><label for="PgInRow">%TXT_NRROWS%</label></p>
</div> </div>

View File

@ -37,6 +37,7 @@ function configureSpeedDial()
$('#BgImgSelSiz').val(scriptData.bSize).attr('selected', 'selected'); $('#BgImgSelSiz').val(scriptData.bSize).attr('selected', 'selected');
$('#BgImgToggle').prop('checked', scriptData.imgBackground != ""); $('#BgImgToggle').prop('checked', scriptData.imgBackground != "");
$('#SdCntrToggle').prop('checked', scriptData.sdCenter == "true"); $('#SdCntrToggle').prop('checked', scriptData.sdCenter == "true");
$('#SdLockDials').prop('checked', scriptData.lockDials == "true");
$('#BgImgToggle').is(':checked') ? $('#BgImgSel').removeAttr('disabled') : $('#BgImgSel').attr('disabled', 'disabled'); $('#BgImgToggle').is(':checked') ? $('#BgImgSel').removeAttr('disabled') : $('#BgImgSel').attr('disabled', 'disabled');
$('#BgImgToggle').is(':checked') ? $('#BgImgSelSiz').removeAttr('disabled') : $('#BgImgSelSiz').attr('disabled', 'disabled'); $('#BgImgToggle').is(':checked') ? $('#BgImgSelSiz').removeAttr('disabled') : $('#BgImgSelSiz').attr('disabled', 'disabled');
$('#SdSizeToggle').is(':checked') ? $('#SdSize').removeAttr('disabled') : $('#SdSize').attr('disabled', 'disabled'); $('#SdSizeToggle').is(':checked') ? $('#SdSize').removeAttr('disabled') : $('#SdSize').attr('disabled', 'disabled');
@ -343,11 +344,13 @@ function saveSettings() {
scriptData.maxPagesRow = $('#PgInRow').val(); scriptData.maxPagesRow = $('#PgInRow').val();
scriptData.dialWidth = $('#SdSize').val(); scriptData.dialWidth = $('#SdSize').val();
scriptData.sdCenter = $('#SdCntrToggle').prop('checked'); scriptData.sdCenter = $('#SdCntrToggle').prop('checked');
scriptData.lockDials = $('#SdLockDials').prop('checked');
external.speedDial.setBackgroundImage($('#BgImgHoldUrl').val()); external.speedDial.setBackgroundImage($('#BgImgHoldUrl').val());
external.speedDial.setBackgroundImageSize($('#BgImgSelSiz').val()); external.speedDial.setBackgroundImageSize($('#BgImgSelSiz').val());
external.speedDial.setPagesInRow(scriptData.maxPagesRow); external.speedDial.setPagesInRow(scriptData.maxPagesRow);
external.speedDial.setSdSize(scriptData.dialWidth); external.speedDial.setSdSize(scriptData.dialWidth);
external.speedDial.setSdCentered(scriptData.sdCenter == "true"); external.speedDial.setSdCentered(scriptData.sdCenter == "true");
external.speedDial.setLockDials(scriptData.lockDials == "true");
alignPage(); alignPage();
} }
@ -479,6 +482,7 @@ function init() {
containment: 'document', containment: 'document',
opacity: 0.8, opacity: 0.8,
distance: 40, distance: 40,
disabled: scriptData.lockDials == "true",
start: function(event, ui) { start: function(event, ui) {
disableCentering(); disableCentering();
}, },

View File

@ -235,6 +235,7 @@ QString FalkonSchemeReply::speeddialPage()
dPage.replace(QLatin1String("%TXT_NRROWS%"), tr("Maximum pages in a row:")); dPage.replace(QLatin1String("%TXT_NRROWS%"), tr("Maximum pages in a row:"));
dPage.replace(QLatin1String("%TXT_SDSIZE%"), tr("Change size of pages:")); dPage.replace(QLatin1String("%TXT_SDSIZE%"), tr("Change size of pages:"));
dPage.replace(QLatin1String("%TXT_CNTRDLS%"), tr("Center speed dials")); dPage.replace(QLatin1String("%TXT_CNTRDLS%"), tr("Center speed dials"));
dPage.replace(QLatin1String("%TXT_LOCKDIALS%"), tr("Lock the position of SpeedDial entries."));
dPage = QzTools::applyDirectionToPage(dPage); dPage = QzTools::applyDirectionToPage(dPage);
} }
@ -248,6 +249,7 @@ QString FalkonSchemeReply::speeddialPage()
page.replace(QLatin1String("%ROW-PAGES%"), QString::number(dial->pagesInRow())); page.replace(QLatin1String("%ROW-PAGES%"), QString::number(dial->pagesInRow()));
page.replace(QLatin1String("%SD-SIZE%"), QString::number(dial->sdSize())); page.replace(QLatin1String("%SD-SIZE%"), QString::number(dial->sdSize()));
page.replace(QLatin1String("%SD-CENTER%"), dial->sdCenter() ? QSL("true") : QSL("false")); page.replace(QLatin1String("%SD-CENTER%"), dial->sdCenter() ? QSL("true") : QSL("false"));
page.replace(QLatin1String("%LOCK-DIALS%"), dial->lockDials() ? QSL("true") : QSL("false"));
return page; return page;
} }

View File

@ -60,6 +60,7 @@ void SpeedDial::loadSettings()
m_maxPagesInRow = settings.value(QSL("pagesrow"), 4).toInt(); m_maxPagesInRow = settings.value(QSL("pagesrow"), 4).toInt();
m_sizeOfSpeedDials = settings.value(QSL("sdsize"), 231).toInt(); m_sizeOfSpeedDials = settings.value(QSL("sdsize"), 231).toInt();
m_sdcentered = settings.value(QSL("sdcenter"), false).toBool(); m_sdcentered = settings.value(QSL("sdcenter"), false).toBool();
m_lockDials = settings.value(QSL("lock-dials"), false).toBool();
settings.endGroup(); settings.endGroup();
if (allPages.isEmpty()) { if (allPages.isEmpty()) {
@ -90,6 +91,7 @@ void SpeedDial::saveSettings()
settings.setValue(QSL("pagesrow"), m_maxPagesInRow); settings.setValue(QSL("pagesrow"), m_maxPagesInRow);
settings.setValue(QSL("sdsize"), m_sizeOfSpeedDials); settings.setValue(QSL("sdsize"), m_sizeOfSpeedDials);
settings.setValue(QSL("sdcenter"), m_sdcentered); settings.setValue(QSL("sdcenter"), m_sdcentered);
settings.setValue(QSL("lock-dials"), m_lockDials);
settings.endGroup(); settings.endGroup();
} }
@ -175,6 +177,13 @@ bool SpeedDial::sdCenter()
return m_sdcentered; return m_sdcentered;
} }
bool SpeedDial::lockDials()
{
ENSURE_LOADED;
return m_lockDials;
}
QString SpeedDial::backgroundImage() QString SpeedDial::backgroundImage()
{ {
ENSURE_LOADED; ENSURE_LOADED;
@ -324,6 +333,11 @@ void SpeedDial::setSdCentered(bool centered)
m_autoSaver->changeOccurred(); m_autoSaver->changeOccurred();
} }
void SpeedDial::setLockDials(bool lockDials)
{
m_lockDials = lockDials;
}
void SpeedDial::thumbnailCreated(const QPixmap &pixmap) void SpeedDial::thumbnailCreated(const QPixmap &pixmap)
{ {
auto* thumbnailer = qobject_cast<PageThumbnailer*>(sender()); auto* thumbnailer = qobject_cast<PageThumbnailer*>(sender());

View File

@ -62,6 +62,7 @@ public:
int pagesInRow(); int pagesInRow();
int sdSize(); int sdSize();
bool sdCenter(); bool sdCenter();
bool lockDials();
QString backgroundImage(); QString backgroundImage();
QString backgroundImageUrl(); QString backgroundImageUrl();
@ -86,6 +87,7 @@ public Q_SLOTS:
void setPagesInRow(int count); void setPagesInRow(int count);
void setSdSize(int count); void setSdSize(int count);
void setSdCentered(bool centered); void setSdCentered(bool centered);
void setLockDials(bool lockDials);
private Q_SLOTS: private Q_SLOTS:
void thumbnailCreated(const QPixmap &pixmap); void thumbnailCreated(const QPixmap &pixmap);
@ -105,6 +107,7 @@ private:
int m_maxPagesInRow; int m_maxPagesInRow;
int m_sizeOfSpeedDials; int m_sizeOfSpeedDials;
bool m_sdcentered; bool m_sdcentered;
bool m_lockDials;
QList<Page> m_pages; QList<Page> m_pages;
AutoSaver* m_autoSaver; AutoSaver* m_autoSaver;