Skip to content

Commit

Permalink
Update about layout
Browse files Browse the repository at this point in the history
  • Loading branch information
qwreey committed Jan 22, 2025
1 parent f13f26e commit 724eedd
Show file tree
Hide file tree
Showing 2 changed files with 97 additions and 28 deletions.
61 changes: 47 additions & 14 deletions src/libs/prefComponents.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,18 @@ function setLinkCursor(target: any) {
export function Dialog({
window,
title,
minHeight,
childrenRequest,
}: Dialog.Options): Adw.PreferencesDialog {
const dialog = new Dialog.PrefDialog(title, childrenRequest)
if (minHeight) dialog.height_request = minHeight
dialog.present(window)
return dialog
}
export namespace Dialog {
export interface Options {
title?: string
minHeight?: number
childrenRequest: (page: Adw.PreferencesPage)=>any
window: Adw.PreferencesWindow
}
Expand Down Expand Up @@ -228,15 +231,21 @@ export namespace Row {
export function DialogRow(options: DialogRow.Options): Adw.ActionRow {
return Row({
...options,
action: () => Dialog({
...options,
title: options.dialogTitle,
})
action: () => {
const dialog = Dialog({
...options,
title: options.dialogTitle,
})
if (options.onDialogCreated) {
options.onDialogCreated(dialog)
}
}
})
}
export namespace DialogRow {
export interface Options extends Dialog.Options, Row.Options {
dialogTitle?: string
onDialogCreated?: (dialog: Adw.PreferencesDialog)=>void
}
}
// #endregion DialogRow
Expand Down Expand Up @@ -962,7 +971,7 @@ export function LicenseRow(item: LicenseRow.License): Adw.ExpanderRow {
action: (expanded)=>{
if (!expanded) return
if (loaded) return
item.content().then(
if (item.content) item.content().then(
subtitle => contentRow.subtitle = subtitle
).catch(
error => contentRow.subtitle = `ERROR: ${error}`
Expand Down Expand Up @@ -1001,7 +1010,7 @@ export namespace LicenseRow {

// #region LogoBox
export function LogoBox({
icon, name, version,
icon, name, version, versionAction,
}: LogoBox.Options): Gtk.Box {
const logoBox = new Gtk.Box({
baseline_position: Gtk.BaselinePosition.CENTER,
Expand Down Expand Up @@ -1032,6 +1041,10 @@ export function LogoBox({
halign: Gtk.Align.CENTER,
})
logoBox.append(logoVersion)
if (versionAction) {
logoVersion.connect("clicked", ()=>versionAction())
setLinkCursor(logoVersion)
}

return logoBox
}
Expand All @@ -1040,6 +1053,7 @@ export namespace LogoBox {
name: string
version: string
icon: string
versionAction?: ()=>void
}
}
// #endregion LogoBox
Expand All @@ -1063,20 +1077,35 @@ export namespace LogoGroup {
export function ChangelogDialog({
content,
window,
currentBuildNumber,
defaultPageBuildNumber,
title,
subtitle,
}: ChangelogDialog.Options): Adw.PreferencesDialog {
const dialog = Dialog({
window,
title: _("Changelog"),
title: title ?? _("Changelog"),
childrenRequest: ()=>[Group({
title: title ?? "",
description: subtitle ?? "",
onCreated: (group: Adw.PreferencesGroup) => {
content()
.then(ChangelogDialog.getReleases)
.then(releases => releases.map(release => Row({
title: release.version,
subtitle: release.Date ?? "",
action: ()=>ChangelogDialog.ChangelogPage(dialog, release),
})))
.then(rows => rows.forEach(row => group.add(row)))
.then(ChangelogDialog.getReleases)
.then(releases => releases.map(release => Row({
title: release.version,
subtitle: release.Date ?? "",
action: ()=>ChangelogDialog.ChangelogPage(dialog, release),
onCreated: (row)=>{
if (release.BuildNumber == currentBuildNumber) {
row.add_css_class("success")
row.title += " " + _("(Current)")
}
if (release.BuildNumber == defaultPageBuildNumber) {
ChangelogDialog.ChangelogPage(dialog, release)
}
group.add(row)
}
})))
},
})]
})
Expand All @@ -1086,7 +1115,11 @@ export function ChangelogDialog({
export namespace ChangelogDialog {
export interface Options {
window: Adw.PreferencesWindow
currentBuildNumber: number
content: ()=>Promise<string>
defaultPageBuildNumber?: number
title?: string
subtitle?: string
}
const LITEM = (t: string,lv: number)=>`${"  ".repeat(lv)}<span alpha="70%"> • </span>${t}`
const TITLE = (t: string,lv: number)=>`<span size="${100+((8-lv)*2.5)}%"><span alpha="50%">${'#'.repeat(lv)} </span><span weight="bold">${t}</span></span>`
Expand Down
64 changes: 50 additions & 14 deletions src/prefPages/about.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import {
ContributorsRow,
LicenseRow,
LogoGroup,
DialogRow,
ChangelogDialog,
} from "../libs/prefComponents.js"

Expand All @@ -29,19 +30,54 @@ export const AboutPage = GObject.registerClass({
name: prefs.metadata.name,
icon: "qst-project-icon",
version: prefs.getVersionString(),
versionAction: () => ChangelogDialog({
window,
content: async () => prefs.getChangelog(),
currentBuildNumber: Config.buildNumber,
defaultPageBuildNumber: Config.buildNumber,
})
})

// Links
// About
Group({
parent: this,
// title: _('Links'),
title: _("About"),
description: _("Common extension informations"),
},[
Row({
title: _("Changelog"),
subtitle: _("Support development!"),
action: ()=>ChangelogDialog({ window, content: async () => prefs.getChangelog() }),
icon: "qst-patreon-logo-symbolic",
title: _("Changelogs"),
subtitle: _("View the change history for this extension"),
action: ()=>ChangelogDialog({
window,
title: _("Changelogs"),
subtitle: _("View the change history for this extension"),
content: async () => prefs.getChangelog(),
currentBuildNumber: Config.buildNumber,
}),
icon: "object-rotate-right-symbolic",
}),
DialogRow({
window,
title: _('License'),
subtitle: _('License of codes'),
dialogTitle: _("License"),
minHeight: 520,
icon: "emblem-documents-symbolic",
childrenRequest: _page=>[
Group({
title: _('License'),
description: _('License of codes')
}, prefs.getLicenses().map(LicenseRow)),
],
}),
])

// Links
Group({
parent: this,
title: _("Link"),
description: _("External links about this extension")
},[
Row({
uri: "https://patreon.com/user?u=44216831",
title: _("Donate via patreon"),
Expand Down Expand Up @@ -73,13 +109,13 @@ export const AboutPage = GObject.registerClass({
parent: this,
title: _('Contributor'),
description: _("The creators of this extension"),
}, prefs.getContributorRows().map(ContributorsRow))

// third party LICENSE
Group({
parent: this,
title: _('License'),
description: _('License of codes')
}, prefs.getLicenses().map(LicenseRow))
}, [
...prefs.getContributorRows().map(ContributorsRow),
Row({
title: _("More contributors"),
subtitle: _("See more contributors on github"),
uri: "https://github.com/qwreey/quick-settings-tweaks/graphs/contributors"
}),
])
}
})

0 comments on commit 724eedd

Please sign in to comment.