Просмотр исходного кода

Optimized css and shortcut flow

- Add dock shortcut
- Removed default desktop shorcut on new desktop creation
Toby Chui 11 часов назад
Родитель
Сommit
7a821124c7

+ 3 - 15
src/mod/desktop/service/files.go

@@ -4,12 +4,10 @@ import (
 	"encoding/json"
 	"errors"
 	"net/http"
-	"os"
 	"path/filepath"
 	"strconv"
 	"strings"
 
-	"imuslab.com/arozos/mod/filesystem/arozfs"
 	"imuslab.com/arozos/mod/filesystem/shortcut"
 	"imuslab.com/arozos/mod/info/logger"
 	"imuslab.com/arozos/mod/user"
@@ -45,7 +43,9 @@ type desktopObject struct {
 	IconY          int
 }
 
-// initUserFolderStructure creates the user's desktop, seeded from the template folder, on first use
+// initUserFolderStructure creates the user's (empty) desktop folder on first use.
+// File Manager, System Setting and the trash are reached from the launcher and
+// the dock, so a new desktop no longer gets shortcuts to them.
 func (s *Service) initUserFolderStructure(userinfo *user.User) {
 	userfsh, err := userinfo.GetHomeFileSystemHandler()
 	if err != nil {
@@ -59,19 +59,7 @@ func (s *Service) initUserFolderStructure(userinfo *user.User) {
 		return
 	}
 
-	//Desktop directory not exists. Create one and copy a template desktop
 	userFsa.MkdirAll(userDesktopPath, 0755)
-	if !utils.FileExists(s.opts.TemplateFolder) {
-		return
-	}
-	templateFiles, _ := filepath.Glob(filepath.Join(s.opts.TemplateFolder, "*"))
-	for _, tfile := range templateFiles {
-		input, err := os.ReadFile(tfile)
-		if err != nil {
-			continue
-		}
-		userFsa.WriteFile(arozfs.ToSlash(filepath.Join(userDesktopPath, filepath.Base(tfile))), input, 0755)
-	}
 }
 
 // isHiddenFile reports whether a desktop entry should be skipped

+ 3 - 8
src/mod/desktop/service/service.go

@@ -64,7 +64,6 @@ type Options struct {
 	TableName          string //Database table for desktop state, default "desktop"
 	WebRoot            string //Folder the web apps are served from, default "./web"
 	WallpaperRoot      string //Folder of the bundled wallpaper themes
-	TemplateFolder     string //Shortcuts copied onto a new user's desktop
 	Users              UserProvider
 	Shares             ShareChecker //Optional, nothing is shown as shared when nil
 	Modules            ModuleLookup //Optional, module shortcuts cannot be edited when nil
@@ -74,10 +73,9 @@ type Options struct {
 
 // Default values of Options
 const (
-	DefaultTableName      = "desktop"
-	DefaultWebRoot        = "./web"
-	DefaultWallpaperRoot  = "./web/img/desktop/bg"
-	DefaultTemplateFolder = "./system/desktop/template/"
+	DefaultTableName     = "desktop"
+	DefaultWebRoot       = "./web"
+	DefaultWallpaperRoot = "./web/img/desktop/bg"
 )
 
 // Service serves the desktop API
@@ -108,9 +106,6 @@ func New(opts Options) (*Service, error) {
 	if opts.WallpaperRoot == "" {
 		opts.WallpaperRoot = DefaultWallpaperRoot
 	}
-	if opts.TemplateFolder == "" {
-		opts.TemplateFolder = DefaultTemplateFolder
-	}
 
 	layoutManager, err := layout.NewManager(opts.Database, opts.TableName)
 	if err != nil {

+ 3 - 4
src/mod/desktop/service/service_test.go

@@ -128,10 +128,9 @@ func TestNewAppliesDefaults(t *testing.T) {
 		t.Fatalf("New returned unexpected error: %v", err)
 	}
 	checks := map[string][2]string{
-		"TableName":      {s.opts.TableName, DefaultTableName},
-		"WebRoot":        {s.opts.WebRoot, DefaultWebRoot},
-		"WallpaperRoot":  {s.opts.WallpaperRoot, DefaultWallpaperRoot},
-		"TemplateFolder": {s.opts.TemplateFolder, DefaultTemplateFolder},
+		"TableName":     {s.opts.TableName, DefaultTableName},
+		"WebRoot":       {s.opts.WebRoot, DefaultWebRoot},
+		"WallpaperRoot": {s.opts.WallpaperRoot, DefaultWallpaperRoot},
 	}
 	for field, got := range checks {
 		if got[0] != got[1] {

+ 0 - 4
src/system/desktop/template/File Manager.shortcut

@@ -1,4 +0,0 @@
-module
-File Manager
-File Manager
-SystemAO/file_system/img/desktop_icon.png

+ 0 - 4
src/system/desktop/template/System Setting.shortcut

@@ -1,4 +0,0 @@
-module
-System Setting
-System Setting
-SystemAO/system_setting/img/desktop_icon.png

+ 0 - 4
src/system/desktop/template/Trash Bin.shortcut

@@ -1,4 +0,0 @@
-module
-Trash Bin
-Trash Bin
-SystemAO/file_system/trashbin_img/desktop_icon.png

+ 42 - 0
src/system/locale/desktop.json

@@ -142,6 +142,13 @@
                 "launcher/noResults": "找不到相符的應用程式",
                 "launcher/noApps": "這個分類沒有應用程式",
                 "launcher/power": "電源",
+                "launcher/fileManager": "檔案管理員",
+                "launcher/settings": "系統設定",
+                "launcher/documents": "文件",
+                "launcher/downloads": "下載",
+                "launcher/music": "音樂",
+                "launcher/pictures": "圖片",
+                "launcher/videos": "影片",
                 "account/panel/stored": "此瀏覽器上的帳戶",
                 "tray/status": "系統狀態",
                 "tray/tasks": "背景任務",
@@ -293,6 +300,13 @@
                 "launcher/noResults": "找不到相符的應用程式",
                 "launcher/noApps": "這個分類沒有應用程式",
                 "launcher/power": "電源",
+                "launcher/fileManager": "檔案管理員",
+                "launcher/settings": "系統設定",
+                "launcher/documents": "文件",
+                "launcher/downloads": "下載",
+                "launcher/music": "音樂",
+                "launcher/pictures": "圖片",
+                "launcher/videos": "影片",
                 "account/panel/stored": "此瀏覽器上的帳戶",
                 "tray/status": "系統狀態",
                 "tray/tasks": "背景任務",
@@ -444,6 +458,13 @@
                 "launcher/noResults": "没有匹配的应用程序",
                 "launcher/noApps": "此类别中没有应用程序",
                 "launcher/power": "电源",
+                "launcher/fileManager": "文件管理器",
+                "launcher/settings": "系统设置",
+                "launcher/documents": "文档",
+                "launcher/downloads": "下载",
+                "launcher/music": "音乐",
+                "launcher/pictures": "图片",
+                "launcher/videos": "视频",
                 "account/panel/stored": "此浏览器上的账户",
                 "tray/status": "系统状态",
                 "tray/tasks": "后台任务",
@@ -596,6 +617,13 @@
                 "launcher/noResults": "No apps match your search",
                 "launcher/noApps": "No apps in this category",
                 "launcher/power": "Power",
+                "launcher/fileManager": "File Manager",
+                "launcher/settings": "Settings",
+                "launcher/documents": "Documents",
+                "launcher/downloads": "Downloads",
+                "launcher/music": "Music",
+                "launcher/pictures": "Pictures",
+                "launcher/videos": "Videos",
                 "account/panel/stored": "Accounts on this browser",
                 "tray/status": "System status",
                 "tray/tasks": "Background tasks",
@@ -748,6 +776,13 @@
                 "launcher/noResults": "一致するアプリはありません",
                 "launcher/noApps": "このカテゴリにはアプリがありません",
                 "launcher/power": "電源",
+                "launcher/fileManager": "ファイルマネージャー",
+                "launcher/settings": "システム設定",
+                "launcher/documents": "ドキュメント",
+                "launcher/downloads": "ダウンロード",
+                "launcher/music": "ミュージック",
+                "launcher/pictures": "ピクチャ",
+                "launcher/videos": "ビデオ",
                 "account/panel/stored": "このブラウザーのアカウント",
                 "tray/status": "システムの状態",
                 "tray/tasks": "バックグラウンドタスク",
@@ -900,6 +935,13 @@
                 "launcher/noResults": "일치하는 앱이 없습니다",
                 "launcher/noApps": "이 범주에 앱이 없습니다",
                 "launcher/power": "전원",
+                "launcher/fileManager": "파일 관리자",
+                "launcher/settings": "시스템 설정",
+                "launcher/documents": "문서",
+                "launcher/downloads": "다운로드",
+                "launcher/music": "음악",
+                "launcher/pictures": "사진",
+                "launcher/videos": "동영상",
                 "account/panel/stored": "이 브라우저의 계정",
                 "tray/status": "시스템 상태",
                 "tray/tasks": "백그라운드 작업",

+ 77 - 0
src/system/locale/system_settings/desktop.json

@@ -132,6 +132,17 @@
                 "sm/appiconsize/desc": "Dock 第一個按鈕開啟的應用程式選單中,應用程式圖示的大小。",
                 "sm/saved": "已儲存",
                 "sm/savefailed": "無法儲存",
+                "sm/shortcuts": "捷徑",
+                "sm/shortcuts/desc": "應用程式選單中電源按鈕旁的按鈕。",
+                "sm/sc/filemanager": "檔案管理員",
+                "sm/sc/settings": "系統設定",
+                "sm/sc/document": "文件",
+                "sm/sc/download": "下載",
+                "sm/sc/music": "音樂",
+                "sm/sc/photo": "圖片",
+                "sm/sc/video": "影片",
+                "sm/sc/opens": "在檔案管理員中開啟 {folder}",
+                "sm/sc/missing": "你的主資料夾中沒有 {folder} 資料夾",
                 "ast/savefailed": "無法儲存"
             },
             "titles": {},
@@ -267,6 +278,17 @@
                 "sm/appiconsize/desc": "Dock 第一個按鈕開啟的應用程式選單中,應用程式圖示的大小。",
                 "sm/saved": "已儲存",
                 "sm/savefailed": "無法儲存",
+                "sm/shortcuts": "捷徑",
+                "sm/shortcuts/desc": "應用程式選單中電源按鈕旁的按鈕。",
+                "sm/sc/filemanager": "檔案管理員",
+                "sm/sc/settings": "系統設定",
+                "sm/sc/document": "文件",
+                "sm/sc/download": "下載",
+                "sm/sc/music": "音樂",
+                "sm/sc/photo": "圖片",
+                "sm/sc/video": "影片",
+                "sm/sc/opens": "在檔案管理員中開啟 {folder}",
+                "sm/sc/missing": "你的主資料夾中沒有 {folder} 資料夾",
                 "ast/savefailed": "無法儲存"
             },
             "titles": {},
@@ -402,6 +424,17 @@
                 "sm/appiconsize/desc": "程序坞第一个按钮打开的应用程序菜单中,应用程序图标的大小。",
                 "sm/saved": "已保存",
                 "sm/savefailed": "无法保存",
+                "sm/shortcuts": "快捷方式",
+                "sm/shortcuts/desc": "应用程序菜单中电源按钮旁的按钮。",
+                "sm/sc/filemanager": "文件管理器",
+                "sm/sc/settings": "系统设置",
+                "sm/sc/document": "文档",
+                "sm/sc/download": "下载",
+                "sm/sc/music": "音乐",
+                "sm/sc/photo": "图片",
+                "sm/sc/video": "视频",
+                "sm/sc/opens": "在文件管理器中打开 {folder}",
+                "sm/sc/missing": "你的主文件夹中没有 {folder} 文件夹",
                 "ast/savefailed": "无法保存"
             },
             "titles": {},
@@ -537,6 +570,17 @@
                 "sm/appiconsize/desc": "Size of the app icons in the app menu the dock's first button opens.",
                 "sm/saved": "Saved",
                 "sm/savefailed": "Could not save",
+                "sm/shortcuts": "Shortcuts",
+                "sm/shortcuts/desc": "Buttons next to the power button of the app menu.",
+                "sm/sc/filemanager": "File Manager",
+                "sm/sc/settings": "System Settings",
+                "sm/sc/document": "Documents",
+                "sm/sc/download": "Downloads",
+                "sm/sc/music": "Music",
+                "sm/sc/photo": "Pictures",
+                "sm/sc/video": "Videos",
+                "sm/sc/opens": "Opens {folder} in the File Manager",
+                "sm/sc/missing": "There is no {folder} folder in your home folder",
                 "ast/savefailed": "Could not save"
             },
             "titles": {},
@@ -672,6 +716,17 @@
                 "sm/appiconsize/desc": "Size of the app icons in the app menu the dock's first button opens.",
                 "sm/saved": "Saved",
                 "sm/savefailed": "Could not save",
+                "sm/shortcuts": "Shortcuts",
+                "sm/shortcuts/desc": "Buttons next to the power button of the app menu.",
+                "sm/sc/filemanager": "File Manager",
+                "sm/sc/settings": "System Settings",
+                "sm/sc/document": "Documents",
+                "sm/sc/download": "Downloads",
+                "sm/sc/music": "Music",
+                "sm/sc/photo": "Pictures",
+                "sm/sc/video": "Videos",
+                "sm/sc/opens": "Opens {folder} in the File Manager",
+                "sm/sc/missing": "There is no {folder} folder in your home folder",
                 "ast/savefailed": "Could not save"
             },
             "titles": {},
@@ -807,6 +862,17 @@
                 "sm/appiconsize/desc": "Dock の最初のボタンで開くアプリメニューのアイコンのサイズです。",
                 "sm/saved": "保存しました",
                 "sm/savefailed": "保存できませんでした",
+                "sm/shortcuts": "ショートカット",
+                "sm/shortcuts/desc": "アプリメニューの電源ボタンの横に表示するボタンです。",
+                "sm/sc/filemanager": "ファイルマネージャー",
+                "sm/sc/settings": "システム設定",
+                "sm/sc/document": "ドキュメント",
+                "sm/sc/download": "ダウンロード",
+                "sm/sc/music": "ミュージック",
+                "sm/sc/photo": "ピクチャ",
+                "sm/sc/video": "ビデオ",
+                "sm/sc/opens": "ファイルマネージャーで {folder} を開きます",
+                "sm/sc/missing": "ホームフォルダーに {folder} フォルダーがありません",
                 "ast/savefailed": "保存できませんでした"
             },
             "titles": {},
@@ -942,6 +1008,17 @@
                 "sm/appiconsize/desc": "Dock의 첫 번째 버튼으로 여는 앱 메뉴의 앱 아이콘 크기입니다.",
                 "sm/saved": "저장됨",
                 "sm/savefailed": "저장할 수 없습니다",
+                "sm/shortcuts": "바로 가기",
+                "sm/shortcuts/desc": "앱 메뉴의 전원 버튼 옆에 표시되는 버튼입니다.",
+                "sm/sc/filemanager": "파일 관리자",
+                "sm/sc/settings": "시스템 설정",
+                "sm/sc/document": "문서",
+                "sm/sc/download": "다운로드",
+                "sm/sc/music": "음악",
+                "sm/sc/photo": "사진",
+                "sm/sc/video": "동영상",
+                "sm/sc/opens": "파일 관리자에서 {folder} 열기",
+                "sm/sc/missing": "홈 폴더에 {folder} 폴더가 없습니다",
                 "ast/savefailed": "저장할 수 없습니다"
             },
             "titles": {},

BIN
src/web/3D Modeler/img/desktop_icon.png


+ 148 - 0
src/web/SystemAO/desktop/settings/startmenu.html

@@ -98,6 +98,18 @@
     background: var(--ss-border);
 }
 
+#smRoot .sm-section-desc {
+    margin: -3px 0 8px 2px;
+    font-size: 11.5px;
+    line-height: 16px;
+    color: var(--ss-text-3);
+}
+#smRoot .sm-sc-icon {
+    width: 16px;
+    margin: 0;
+    color: var(--ss-text-2);
+}
+
 @media (max-width: 560px) {
     #smRoot .ss-row { flex-wrap: wrap; }
 }
@@ -174,6 +186,15 @@
             </div>
         </div>
     </div>
+
+    <div class="ss-section">
+        <div class="ss-section-title">
+            <svg viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M8 2.2v5"/><path d="M4.6 4.4a5 5 0 1 0 6.8 0"/></svg>
+            <span locale="sm/shortcuts">Shortcuts</span>
+        </div>
+        <div class="sm-section-desc" locale="sm/shortcuts/desc">Buttons next to the power button of the app menu.</div>
+        <div class="ss-card" id="smShortcuts"></div>
+    </div>
 </div>
 
 <script>
@@ -189,6 +210,12 @@
         script/desktop/dock.js). A desktop that is already open is told at
         once: through setStartMenuLayout when this page runs inside it, and
         through localStorage (desktop/startMenuChanged) for one in another tab.
+
+        Also the shortcuts next to the app menu's power button: the desktop
+        preference startmenu-shortcuts, a JSON list of the ids in SC_ITEMS,
+        removed when it holds the default (File Manager and System Settings).
+        script/desktop/launcher.js keeps the same ids and folder names, reads
+        it on start and is told through launcherSetShortcuts or localStorage.
     */
     var smLocale = (typeof NewAppLocale === "function") ? NewAppLocale() : {
         init: function (f, cb) { cb(); },
@@ -273,9 +300,130 @@
         });
     });
 
+    /*
+        Shortcuts. A folder can be chosen once the home folder holds one of
+        its names (any case); one that is chosen can always be switched off.
+    */
+    var SC_PREF = "startmenu-shortcuts";
+    var SC_DEFAULT = ["filemanager", "settings"];
+    var SC_ITEMS = [
+        { id: "filemanager", icon: "folder", label: ["sm/sc/filemanager", "File Manager"] },
+        { id: "settings", icon: "setting", label: ["sm/sc/settings", "System Settings"] },
+        { id: "document", icon: "file alternate", label: ["sm/sc/document", "Documents"], folders: ["Document", "Documents"] },
+        { id: "download", icon: "download", label: ["sm/sc/download", "Downloads"], folders: ["Download", "Downloads"] },
+        { id: "music", icon: "music", label: ["sm/sc/music", "Music"], folders: ["Music"] },
+        { id: "photo", icon: "image", label: ["sm/sc/photo", "Pictures"], folders: ["Photo", "Photos", "Picture", "Pictures"] },
+        { id: "video", icon: "film", label: ["sm/sc/video", "Videos"], folders: ["Video", "Videos"] }
+    ];
+    var scChosen = SC_DEFAULT.slice();
+    var scFolders = null; //lower case name -> folder name in user:/, null until listed
+
+    function scFolderOf(item) {
+        if (!item.folders || scFolders === null) return "";
+        for (var i = 0; i < item.folders.length; i++) {
+            var name = scFolders[item.folders[i].toLowerCase()];
+            if (name !== undefined) return name;
+        }
+        return "";
+    }
+
+    function scRender() {
+        var card = $("#smShortcuts").empty();
+        SC_ITEMS.forEach(function (item) {
+            var row = $('<div class="ss-row compact">' +
+                '<div class="ss-row-text"><div class="ss-row-label"><i class="icon sm-sc-icon"></i><span></span></div><div class="ss-row-desc"></div></div>' +
+                '<label class="ss-switch"><input type="checkbox"><span class="ss-track"></span></label>' +
+            '</div>');
+            var on = scChosen.indexOf(item.id) >= 0;
+            row.find("i").addClass(item.icon);
+            row.find(".ss-row-label span").text(smStr(item.label[0], item.label[1]));
+            var input = row.find("input").attr("data-id", item.id).prop("checked", on)
+                .attr("aria-label", smStr(item.label[0], item.label[1]));
+            var desc = row.find(".ss-row-desc");
+            if (item.folders && scFolders !== null) {
+                var folder = scFolderOf(item);
+                if (folder !== "") {
+                    desc.text(smStr("sm/sc/opens", "Opens {folder} in the File Manager").replace("{folder}", "user:/" + folder));
+                } else {
+                    desc.text(smStr("sm/sc/missing", "There is no {folder} folder in your home folder").replace("{folder}", item.folders[0]));
+                    input.prop("disabled", !on);
+                }
+            } else if (item.folders) {
+                //Not listed yet
+                input.prop("disabled", !on);
+            }
+            if (desc.text() === "") desc.remove();
+            card.append(row);
+        });
+    }
+
+    function scSameAsDefault(list) {
+        return list.length === SC_DEFAULT.length && SC_DEFAULT.every(function (id) { return list.indexOf(id) >= 0; });
+    }
+
+    function scTellDesktop(list) {
+        try {
+            if (typeof ao_module_virtualDesktop !== "undefined" && ao_module_virtualDesktop &&
+                typeof parent.launcherSetShortcuts === "function") {
+                parent.launcherSetShortcuts(list);
+            }
+        } catch (e) {}
+        try {
+            localStorage.setItem("desktop/startMenuChanged", JSON.stringify({ shortcuts: list, ts: Date.now() }));
+        } catch (e) {}
+    }
+
+    $("#smShortcuts").on("change", "input", function () {
+        var before = scChosen.slice();
+        var list = [];
+        $("#smShortcuts input").each(function () {
+            if ($(this).prop("checked")) list.push($(this).attr("data-id"));
+        });
+        scChosen = list;
+        var data = scSameAsDefault(list) ?
+            { preference: SC_PREF, remove: "true" } :
+            { preference: SC_PREF, value: JSON.stringify(list) };
+        $.ajax({ url: PREF_URL, method: "POST", data: data,
+            success: function (d) {
+                if (d != null && d.error !== undefined) return scFailed(before);
+                scRender();
+                scTellDesktop(list);
+                if (typeof msgbox === "function") msgbox(smStr("sm/saved", "Saved"), true, 1500);
+            },
+            error: function () { scFailed(before); } });
+    });
+
+    function scFailed(before) {
+        scChosen = before;
+        scRender();
+        if (typeof msgbox === "function") msgbox(smStr("sm/savefailed", "Could not save"), false);
+    }
+
+    function scLoad() {
+        smReadPref(SC_PREF, function (v) {
+            var list = null;
+            try { list = v ? JSON.parse(v) : null; } catch (e) { list = null; }
+            scChosen = Array.isArray(list) ? list.filter(function (id) {
+                return SC_ITEMS.some(function (item) { return item.id === id; });
+            }) : SC_DEFAULT.slice();
+            scRender();
+        });
+        $.ajax({ url: "../../system/file_system/listDir", method: "POST", data: { dir: "user:/" },
+            success: function (files) {
+                scFolders = {};
+                (Array.isArray(files) ? files : []).forEach(function (f) {
+                    if (f && f.IsDir && typeof f.Filename === "string") scFolders[f.Filename.toLowerCase()] = f.Filename;
+                });
+                scRender();
+            },
+            error: function () { scFolders = {}; scRender(); } });
+    }
+
     smLocale.init("../locale/system_settings/desktop.json", function () {
         smLocale.translate();
         smShow();
+        scRender();
+        scLoad();
         Object.keys(FIELDS).forEach(function (field) {
             smReadPref(FIELDS[field].key, function (v) {
                 smLayout[field] = FIELDS[field].values.indexOf(v) >= 0 ? v : FIELDS[field].fallback;

+ 4 - 1
src/web/desktop.html

@@ -165,7 +165,10 @@
                 <img class="usericon" src="img/desktop/system_icon/user.svg" draggable="false">
                 <span class="launcherUsername"></span>
             </div>
-            <div class="launcherPower" role="button"><i class="power off icon"></i></div>
+            <div class="launcherActions">
+                <div class="launcherShortcuts"></div>
+                <div class="launcherPower" role="button"><i class="power off icon"></i></div>
+            </div>
         </div>
     </div>
 

+ 4 - 2
src/web/script/desktop/README.md

@@ -37,7 +37,7 @@ Scripts (at the end of `<body>`, after the markup):
 | `dock.js` | dock and tray: clock, window groups (`dockAddWindow` / `dockRemoveWindow` / `dockUpdateFocus`), pins, trash (empty / full, *Empty Trash Bin*), window list, dock menus, tray server status (`setTrayServerStatus`), tray panel rules (`trayClosePanels`: one open at a time, closed by a press elsewhere, a click into a window or Escape), start menu layout (`setStartMenuLayout`: dock alignment, dock and app icon sizes from the Start Menu settings page), `getReservedBottom` |
 | `quickaccess.js` | quick access panel opened by the tray's server icon: server health (SMART, RAID; feeds the tray dot), network interfaces, dark mode / full screen / settings tiles, volume and brightness sliders, disk usage, all rendered from JSON endpoints |
 | `notifications.js` | notification centre (`toggleNotification`, `sendNotification`, relative times), calendar card (opens the Calendar app on a day), server notification polling, toasts |
-| `launcher.js` | the app launcher opened by the dock: live search, categories, grid, keyboard selection, tile and power menus, the account panel (switch / add / sign out accounts), drag to desktop / dock |
+| `launcher.js` | the app launcher opened by the dock: live search, categories, grid, keyboard selection, tile and power menus, the footer shortcuts next to the power button (preference `startmenu-shortcuts`: File Manager, System Setting and home folders such as Document or Music, picked in the Start Menu settings page), the account panel (switch / add / sign out accounts), drag to desktop / dock |
 | `launch.js` | `openModule`, `openFileWithModule`, opening icons, folders and shortcuts |
 | `windows.js` | float window manager: `newFloatWindow`, focus / z-order, min / max / close, setters |
 | `windowmove.js` | window drag, resize, docking, title bar event hooks |
@@ -66,6 +66,7 @@ Scripts (at the end of `<body>`, after the markup):
    | `launch.js` | `openModule`, `openFileWithModule`, `openContainerAppShortcut` |
    | `theme.js` | `initTheme`, `setThemeColor`, `toggleDesktopTheme`, `setAssistiveTitles` |
    | `dock.js` | `setStartMenuLayout` (System Settings > Desktop & Themes > Start Menu) |
+   | `launcher.js` | `launcherSetShortcuts` (the same settings page) |
    | `wallpaper.js` | `changeDesktopTheme`, `initBackgroundSwitchingAnimation` |
    | `backgroundtasks.js` | `startFileOperation`, `openFileOperationDialog` |
    | `launcher.js` / `icons.js` / `session.js` / `utils.js` / `boot.js` | `initModuleList` / `refresh` / `logout` / `bindObjectToIMEEvents` / `initDesktop` |
@@ -105,7 +106,8 @@ Scripts (at the end of `<body>`, after the markup):
    (`SystemAO/desktop/settings/theme.html`, `personalization.html`) preview a
    theme colour by painting `#navimenu, #dockTray` in the parent page.
    Pins are the desktop preference `dock-pinned`: a JSON list of module
-   names (File Manager and System Setting when unset) and of objects for
+   names (empty when unset: File Manager and System Setting are shortcuts in
+   the launcher footer, next to the power button) and of objects for
    folders, web links and container apps (`dockPinKey`); the trash icon asks
    `/system/file_system/trashState`, which stops at the first trashed item,
    and falls back to `listTrash` on servers without it. The dock is at least

+ 9 - 6
src/web/script/desktop/backgroundtasks.js

@@ -178,12 +178,15 @@ function renderBackgroundTasks(tasks){
 
     if (tasks.length == 0){
         backgroundTaskBusy = {};
-        if (list.children(".btEmpty").length == 0){
-            var empty = $('<div class="btEmpty"><i class="check circle outline icon"></i><span class="btEmptyText"></span><a class="btRefresh"></a></div>');
-            empty.find(".btEmptyText").text(applocale.getString("backgroundTasks/noTasks", "No running background tasks"));
-            empty.find(".btRefresh").text(applocale.getString("backgroundTasks/refresh", "Refresh"));
+        var empty = list.children(".btEmpty");
+        if (empty.length == 0){
+            empty = $('<div class="btEmpty"><i class="check circle outline icon"></i><span class="btEmptyText"></span><a class="btRefresh"></a></div>');
             list.empty().append(empty);
         }
+        //Set on every render: the first listing (boot.js) can arrive before
+        //the locale file, and the placeholder would otherwise stay in English
+        setBackgroundTaskText(empty.find(".btEmptyText"), applocale.getString("backgroundTasks/noTasks", "No running background tasks"));
+        setBackgroundTaskText(empty.find(".btRefresh"), applocale.getString("backgroundTasks/refresh", "Refresh"));
         return;
     }
 
@@ -225,7 +228,6 @@ function createBackgroundTaskRow(oprid){
         '</div>' +
     '</div>');
     row.attr("data-oprid", oprid);
-    row.find(".btCancel").attr("title", applocale.getString("backgroundTasks/cancel", "Cancel"));
     return row;
 }
 
@@ -275,7 +277,8 @@ function updateBackgroundTaskRow(row, task){
         applocale.getString("backgroundTasks/pause", "Pause"));
     pauseBtn.attr("data-paused", state == "paused" ? "true" : "false");
     pauseBtn.toggleClass("disabled", busy || state == "stopping");
-    row.find(".btCancel").toggleClass("disabled", busy || state == "stopping");
+    row.find(".btCancel").toggleClass("disabled", busy || state == "stopping")
+        .attr("title", applocale.getString("backgroundTasks/cancel", "Cancel"));
 }
 
 //Text that changes every second: only touch the DOM when it did

+ 3 - 0
src/web/script/desktop/boot.js

@@ -18,6 +18,8 @@ if (typeof(applocale) != "undefined"){
     applocale.init("./SystemAO/locale/desktop.json", function(){
         applocale.translate();
         initDesktop();
+        //The early listing below may have been drawn before the locale was in
+        updateBackgroundgTaskList();
     });
 }else{
     //Applocale not found. Is this a trim down version of ArozOS?
@@ -51,6 +53,7 @@ function initDesktop(){
     initStartMenuLayout();
     hookFloatWindowEvents();
     hookLaunchMenuEvents();
+    initLauncherShortcuts();
     initTheme();
     initStartupSounds();
     initUploadCuttoffValues();

+ 8 - 24
src/web/script/desktop/dock.css

@@ -28,7 +28,7 @@
     gap: 4px;
     padding: 0 var(--dt-dock-pad);
     border-radius: var(--dt-radius-l);
-    background-color: var(--dt-surface);
+    background-color: color-mix(in srgb, var(--dt-surface) 20%, transparent);
     -webkit-backdrop-filter: var(--dt-blur);
     backdrop-filter: var(--dt-blur);
     border: 1px solid var(--dt-border);
@@ -38,28 +38,6 @@
     transition: border-color .15s ease, box-shadow .15s ease;
 }
 
-/* macOS browsers (Safari, Firefox) do not render the backdrop blur here, so a near solid dock only hides the
-   wallpaper: make the background mostly see-through (the class is set in state.js) */
-html.isMacOS #navimenu,
-html.isMacOS #dockTray {
-    background-color: color-mix(in srgb, var(--dt-surface) 20%, transparent);
-}
-
-/* Over the see-through tray the wallpaper decides the contrast: use the dark theme text */
-html.isMacOS #dockTray {
-    --dt-text: #f2f2f4;
-    --dt-text-muted: rgba(255, 255, 255, 0.85);
-    --dt-hover: rgba(255, 255, 255, 0.10);
-    color: var(--dt-text);
-}
-
-/* A soft shadow keeps the light text readable over bright wallpapers */
-html.isMacOS #dockTray .clock,
-html.isMacOS #dockTray .trayItem i.icon {
-    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.45);
-}
-
-
 /* Too wide for the middle: dock.js places it left of the tray instead */
 #navimenu.offCentre {
     transform: none;
@@ -248,11 +226,15 @@ body.dockAlignLeft #navimenu {
     gap: 2px;
     padding: 0 6px;
     border-radius: var(--dt-radius-l);
-    background-color: var(--dt-surface);
+    background-color: color-mix(in srgb, var(--dt-surface) 20%, transparent);
     -webkit-backdrop-filter: var(--dt-blur);
     backdrop-filter: var(--dt-blur);
     border: 1px solid var(--dt-border);
     box-shadow: var(--dt-shadow);
+    /* force override color on docktray */
+    --dt-text: #f2f2f4;
+    --dt-text-muted: rgba(255, 255, 255, 0.85);
+    --dt-hover: rgba(255, 255, 255, 0.10);
     color: var(--dt-text);
     user-select: none;
     -webkit-user-select: none;
@@ -278,6 +260,7 @@ body.dockAlignLeft #navimenu {
     margin: 0;
     font-size: 16px;
     color: var(--dt-text);
+    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.45);
 }
 
 /* Server status: a dot on the icon only when the disks need attention */
@@ -310,6 +293,7 @@ body.dockAlignLeft #navimenu {
     letter-spacing: 0;
     font-variant-numeric: tabular-nums;
     white-space: nowrap;
+    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.45);
 }
 
 #dockTray .clock .time {

+ 9 - 2
src/web/script/desktop/dock.js

@@ -40,7 +40,7 @@
 */
 
 var DOCK_PINNED_PREF = "dock-pinned";
-var DOCK_DEFAULT_PINNED = ["File Manager", "System Setting"];
+var DOCK_DEFAULT_PINNED = []; //File Manager and System Setting sit in the launcher footer instead
 var DOCK_ICON_MAX = 36; //--dt-dock-icon of the chosen size, read back by setStartMenuLayout
 var DOCK_ICON_MIN = 30;
 var DOCK_TRASH_EMPTY = "img/desktop/dock/trash_empty.svg";
@@ -1260,7 +1260,14 @@ function initStartMenuLayout(){
             return;
         }
         try {
-            setStartMenuLayout(JSON.parse(e.newValue).layout);
+            var change = JSON.parse(e.newValue);
+            if (change.layout){
+                setStartMenuLayout(change.layout);
+            }
+            if (change.shortcuts !== undefined && typeof launcherSetShortcuts == "function"){
+                //The footer shortcuts of the launcher (launcher.js)
+                launcherSetShortcuts(change.shortcuts);
+            }
         } catch (err) {}
     });
 }

+ 11 - 0
src/web/script/desktop/launcher.css

@@ -233,6 +233,7 @@ body.appIconsLarge #listMenu .launcherTile img {
 }
 
 #listMenu .launcherUser:hover,
+#listMenu .launcherShortcut:hover,
 #listMenu .launcherPower:hover {
     background-color: var(--dt-hover);
 }
@@ -254,6 +255,15 @@ body.appIconsLarge #listMenu .launcherTile img {
     color: var(--dt-text);
 }
 
+#listMenu .launcherActions,
+#listMenu .launcherShortcuts {
+    flex-shrink: 0;
+    display: flex;
+    align-items: center;
+    gap: 2px;
+}
+
+#listMenu .launcherShortcut,
 #listMenu .launcherPower {
     width: 38px;
     height: 38px;
@@ -264,6 +274,7 @@ body.appIconsLarge #listMenu .launcherTile img {
     cursor: pointer;
 }
 
+#listMenu .launcherShortcut i.icon,
 #listMenu .launcherPower i.icon {
     margin: 0;
     height: auto;

+ 152 - 0
src/web/script/desktop/launcher.js

@@ -52,6 +52,7 @@ function initModuleList() {
         success: function(data) {
             moduleInstalled = data;
             launcherRender();
+            launcherRenderShortcuts();
             dockModulesLoaded();
             checkFileSystemAccess();
 
@@ -353,6 +354,152 @@ function openContainerAppFromMenu(object) {
     });
 }
 
+/*
+    Footer shortcuts next to the power button. The user picks them in System
+    Settings > Desktop & Themes > Start Menu (SystemAO/desktop/settings/
+    startmenu.html, which keeps its own copy of the ids and folder names):
+    the desktop preference "startmenu-shortcuts" is a JSON list of ids, unset
+    means File Manager and System Setting. An app shows only when the user
+    may open it, a folder only when the home folder holds one of its names
+    (any case). The home folder is only listed while a folder is chosen.
+*/
+var LAUNCHER_SHORTCUT_PREF = "startmenu-shortcuts";
+var LAUNCHER_SHORTCUT_DEFAULT = ["filemanager", "settings"];
+var LAUNCHER_SHORTCUTS = [
+    {id: "document", folders: ["Document", "Documents"], icon: "file alternate", label: ["launcher/documents", "Documents"]},
+    {id: "download", folders: ["Download", "Downloads"], icon: "download", label: ["launcher/downloads", "Downloads"]},
+    {id: "music", folders: ["Music"], icon: "music", label: ["launcher/music", "Music"]},
+    {id: "photo", folders: ["Photo", "Photos", "Picture", "Pictures"], icon: "image", label: ["launcher/pictures", "Pictures"]},
+    {id: "video", folders: ["Video", "Videos"], icon: "film", label: ["launcher/videos", "Videos"]},
+    {id: "filemanager", module: "File Manager", icon: "folder", label: ["launcher/fileManager", "File Manager"]},
+    {id: "settings", module: "System Setting", icon: "setting", label: ["launcher/settings", "Settings"]}
+];
+var launcherShortcutIds = LAUNCHER_SHORTCUT_DEFAULT.slice();
+var launcherHomeFolders = {}; //lower case name -> folder name in user:/, from the last listing
+
+function launcherShortcutByID(id){
+    return LAUNCHER_SHORTCUTS.find(function(sc){
+        return sc.id == id;
+    });
+}
+
+function initLauncherShortcuts(){
+    $.ajax({
+        url: "system/desktop/preference",
+        method: "POST",
+        data: {preference: LAUNCHER_SHORTCUT_PREF},
+        success: function(data){
+            var list = null;
+            if (typeof data == "string" && data != ""){
+                try {
+                    list = JSON.parse(data);
+                } catch (ex) {
+                    list = null;
+                }
+            }
+            launcherSetShortcuts(list);
+        },
+        error: function(){
+            launcherSetShortcuts(null);
+        }
+    });
+}
+
+//Show these shortcuts (a list of ids; anything else means the default).
+//Also called by the Start Menu settings page.
+function launcherSetShortcuts(ids){
+    if (!Array.isArray(ids)){
+        ids = LAUNCHER_SHORTCUT_DEFAULT;
+    }
+    launcherShortcutIds = ids.filter(function(id){
+        return launcherShortcutByID(id) != undefined;
+    });
+    launcherRenderShortcuts();
+    launcherRefreshHomeFolders();
+}
+
+//The folder of user:/ a folder shortcut opens, "" when there is none
+function launcherShortcutFolder(sc){
+    for (var i = 0; i < sc.folders.length; i++){
+        var name = launcherHomeFolders[sc.folders[i].toLowerCase()];
+        if (name != undefined){
+            return "user:/" + name;
+        }
+    }
+    return "";
+}
+
+function launcherRefreshHomeFolders(){
+    var wantsFolder = launcherShortcutIds.some(function(id){
+        return launcherShortcutByID(id).folders != undefined;
+    });
+    if (!wantsFolder){
+        return;
+    }
+    $.ajax({
+        url: "system/file_system/listDir",
+        method: "POST",
+        data: {dir: "user:/"},
+        success: function(data){
+            if (!Array.isArray(data)){
+                //An empty home folder (null) or an error
+                data = [];
+            }
+            var folders = {};
+            data.forEach(function(file){
+                if (file && file.IsDir && typeof file.Filename == "string"){
+                    folders[file.Filename.toLowerCase()] = file.Filename;
+                }
+            });
+            launcherHomeFolders = folders;
+            launcherRenderShortcuts();
+        }
+    });
+}
+
+function launcherRenderShortcuts(){
+    var box = $("#listMenu .launcherShortcuts");
+    box.empty();
+    LAUNCHER_SHORTCUTS.forEach(function(sc){
+        if (launcherShortcutIds.indexOf(sc.id) < 0){
+            return;
+        }
+        var path = "";
+        if (sc.module){
+            var mod = getModuleInfoFromName(sc.module);
+            if (!mod || !isLaunchableModule(mod)){
+                return;
+            }
+        }else{
+            path = launcherShortcutFolder(sc);
+            if (path == ""){
+                return;
+            }
+        }
+        var label = applocale.getString(sc.label[0], sc.label[1]);
+        var button = $('<div class="launcherShortcut" role="button"><i class="icon"></i></div>');
+        button.find("i").addClass(sc.icon);
+        button.attr({"data-id": sc.id, "title": label, "aria-label": label});
+        if (path != ""){
+            button.attr("data-path", path);
+        }
+        box.append(button);
+    });
+}
+
+function launcherOpenShortcut(button){
+    var sc = launcherShortcutByID($(button).attr("data-id"));
+    if (sc == undefined){
+        return;
+    }
+    hideListMenu();
+    if (sc.module){
+        openModule(sc.module);
+    }else{
+        openFolder($(button).attr("data-path"));
+    }
+}
+
 function openModuleFromMenu(object) {
     var moduleName = $(object).attr("module");
     openModule(moduleName);
@@ -412,6 +559,8 @@ function launcherOpen(){
     $(".launcherUsername").text(userInfo.Username || "");
     $("#listMenu").stop(true, true).fadeIn(120);
     launcherPlace();
+    //A chosen folder may have been made or removed since the last opening
+    launcherRefreshHomeFolders();
     $("#dockLauncherBtn").addClass("pressed");
     listMenuShown = true;
     setTimeout(function(){
@@ -652,6 +801,9 @@ function hookLaunchMenuEvents(){
             launcherHideAccountPanel();
         }
     });
+    $("#listMenu .launcherShortcuts").off(".launcher").on("click.launcher", ".launcherShortcut", function(){
+        launcherOpenShortcut(this);
+    });
     $("#listMenu .launcherPower").off(".launcher").on("click.launcher", function(event){
         event.stopPropagation();
         launcherShowPowerMenu(this);