Skip to content

Commit

Permalink
Fix welcome screen preference setting and optimize dot removal logic …
Browse files Browse the repository at this point in the history
…in gradient generator
  • Loading branch information
mauro-balades committed Feb 21, 2025
1 parent 81fed8a commit bb7c400
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 6 deletions.
2 changes: 1 addition & 1 deletion l10n
2 changes: 1 addition & 1 deletion src/browser/base/content/ZenStartup.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@

_checkForWelcomePage() {
if (!Services.prefs.getBoolPref('zen.welcome-screen.seen', false)) {
//Services.prefs.setBoolPref('zen.welcome-screen.seen', true);
Services.prefs.setBoolPref('zen.welcome-screen.seen', true);
Services.scriptloader.loadSubScript('chrome://browser/content/zen-components/ZenWelcome.mjs', window);
}
},
Expand Down
1 change: 1 addition & 0 deletions src/browser/base/content/ZenUIManager.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -678,6 +678,7 @@ var gZenVerticalTabsManager = {
if (newName) {
gBrowser._setTabLabel(this._tabEdited, newName);
this._tabEdited.setAttribute('zen-has-static-label', 'true');
gZenUIManager.showToast('zen-tabs-renamed');
} else {
gBrowser.setTabTitle(this._tabEdited);
}
Expand Down
2 changes: 1 addition & 1 deletion src/browser/base/content/zen-popupset.inc.xhtml
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@
<box data-algo="float" data-num-dots="1" data-position="116,167" style="background: #be9ac9;"></box>
<box data-algo="float" data-num-dots="1" data-position="122,110" style="background: #cdcea1;"></box>
<box data-algo="float" data-num-dots="1" data-position="181,83" style="background: #6ac593;"></box>
<box data-algo="complementary" data-num-dots="3" data-position="82,112" style="background: linear-gradient(135deg, #1e90ff, #cfb179);"></box>
<box data-algo="complementary" data-num-dots="2" data-position="82,112" style="background: linear-gradient(135deg, #1e90ff, #cfb179);"></box>
</hbox>
</hbox>
<hbox class="zen-theme-picker-gradient">
Expand Down
15 changes: 12 additions & 3 deletions src/browser/base/zen-components/ZenGradientGenerator.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,11 @@
dot.element.remove();
}
this.dots = [];
} else if (numDots < this.dots.length) {
for (let i = numDots; i < this.dots.length; i++) {
this.dots[i].element.remove();
}
this.dots = this.dots.slice(0, numDots);
}
// Generate new gradient from the single color given
const [x, y] = rawPosition.split(',').map((pos) => parseInt(pos));
Expand Down Expand Up @@ -449,11 +454,10 @@
const centerPosition = { x: rect.width / 2, y: rect.height / 2 };

const harmonyAngles = getColorHarmonyType(dots.length + (action === 'add' ? 1 : action === 'remove' ? -1 : 0), this.dots);
if (!harmonyAngles || harmonyAngles.angles.length === 0) return dots;

this.useAlgo = harmonyAngles.type;

if (!harmonyAngles || harmonyAngles.angles.length === 0) return dots;

let primaryDot = dots.find((dot) => dot.ID === 0);
if (!primaryDot) return [];

Expand Down Expand Up @@ -916,7 +920,11 @@
this.isDarkMode ? 0.2 : -0.5,
`rgb(${dominantColor[0]}, ${dominantColor[1]}, ${dominantColor[2]})`
);
return result?.match(/\d+/g).map(Number);
const color = result?.match(/\d+/g).map(Number);
if (!color || color.length !== 3) {
return this.getNativeAccentColor();
}
return color;
}

async onWorkspaceChange(workspace, skipUpdate = false, theme = null) {
Expand Down Expand Up @@ -1043,6 +1051,7 @@
if (dominantColor) {
browser.document.documentElement.style.setProperty(
'--zen-primary-color',
typeof dominantColor === 'string' ? dominantColor :
`rgb(${dominantColor[0]}, ${dominantColor[1]}, ${dominantColor[2]})`
);
}
Expand Down
1 change: 1 addition & 0 deletions src/browser/base/zen-components/ZenPinnedTabManager.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -399,6 +399,7 @@
await ZenPinnedTabsStorage.savePin(pin);
this.resetPinChangedUrl(tab);
await this._refreshPinnedTabs();
gZenUIManager.showToast('zen-pinned-tab-replaced');
}

async _setPinnedAttributes(tab) {
Expand Down

0 comments on commit bb7c400

Please sign in to comment.