diff --git a/src/apps/seelenweg/i18n/translations/en.yml b/src/apps/seelenweg/i18n/translations/en.yml index 188829c1..49cf42fc 100644 --- a/src/apps/seelenweg/i18n/translations/en.yml +++ b/src/apps/seelenweg/i18n/translations/en.yml @@ -11,6 +11,9 @@ app_menu: pin_to_right: Pin to Right run_as: Run as Administrator unpin: Unpin +context_menu: + reorder_disable: Lock taskbar + reorder_enable: Unlock taskbar media: not_playing: Nothing is playing media_menu: diff --git a/src/apps/seelenweg/modules/bar/index.tsx b/src/apps/seelenweg/modules/bar/index.tsx index e282e276..7febcb51 100644 --- a/src/apps/seelenweg/modules/bar/index.tsx +++ b/src/apps/seelenweg/modules/bar/index.tsx @@ -64,6 +64,7 @@ export function SeelenWeg() { const settings = useSelector(Selectors.settings); const isOverlaped = useSelector(Selectors.isOverlaped); + let isReorderDisabled: boolean = useSelector(Selectors.reorderDisabled); const pinnedOnLeft = useSelector(Selectors.itemsOnLeft); const pinnedOnCenter = useSelector(Selectors.itemsOnCenter); const pinnedOnRight = useSelector(Selectors.itemsOnRight); @@ -162,10 +163,10 @@ export function SeelenWeg() { setAssociatedViewCounter((current) => calculateAssociatedViewCounter(current, isOpen)); }, []); - const projectSwItem = (item: SwItem) => ItemByType(item, shit); + const projectSwItem = (item: SwItem) => ItemByType(item, !isReorderDisabled, shit); return ( - + void) { +function ItemByType(item: SwItem, drag: boolean, callback: (isOpen: boolean) => void) { if (item.type === WegItemType.Pinned) { if ( item.path.toLowerCase().endsWith('.exe') || item.relaunchCommand.toLowerCase().includes('.exe') ) { - return ; + return ; } return ; } if (item.type === WegItemType.Temporal) { - return ; + return ; } if (item.type === WegItemType.Media) { - return ; + return ; } if (item.type === WegItemType.StartMenu) { - return ; + return ; } return null; diff --git a/src/apps/seelenweg/modules/bar/menu.tsx b/src/apps/seelenweg/modules/bar/menu.tsx index 0de5efe8..f937c707 100644 --- a/src/apps/seelenweg/modules/bar/menu.tsx +++ b/src/apps/seelenweg/modules/bar/menu.tsx @@ -10,7 +10,7 @@ import { RootActions } from '../shared/store/app'; import { Icon } from '../../../shared/components/Icon'; -export function getSeelenWegMenu(t: TFunction, restrictedBar?: boolean): ItemType[] { +export function getSeelenWegMenu(t: TFunction, restrictedBar?: boolean, isReorderDisabled?: boolean): ItemType[] { if (!!restrictedBar) { return [ { @@ -86,6 +86,14 @@ export function getSeelenWegMenu(t: TFunction, restrictedBar?: boolean): ItemTyp { type: 'divider', }, + { + key: 'reoder', + icon: , + label: t(!isReorderDisabled ? 'context_menu.reorder_disable' : 'context_menu.reorder_enable' ), + onClick() { + store.dispatch(RootActions.setWegReorderDisabled(!isReorderDisabled)); + }, + }, { key: 'task_manager', label: t('taskbar_menu.task_manager'), diff --git a/src/apps/seelenweg/modules/item/infra/DraggableItem.tsx b/src/apps/seelenweg/modules/item/infra/DraggableItem.tsx index e4337976..8e9ce77b 100644 --- a/src/apps/seelenweg/modules/item/infra/DraggableItem.tsx +++ b/src/apps/seelenweg/modules/item/infra/DraggableItem.tsx @@ -8,9 +8,10 @@ import { cx } from '../../../../shared/styles'; interface Props extends PropsWithChildren { item: SwItem; className?: String; + drag?: boolean; } -export function DraggableItem({ children, item, className }: Props) { +export function DraggableItem({ children, item, className, drag }: Props) { const ref = useRef(null); return ( @@ -18,7 +19,7 @@ export function DraggableItem({ children, item, className }: Props) { as="div" ref={ref} value={item} - drag + drag={drag} className={cx('weg-item-drag-container', className)} onDragStart={() => { ref.current?.classList.add('dragging'); diff --git a/src/apps/seelenweg/modules/item/infra/MediaSession.tsx b/src/apps/seelenweg/modules/item/infra/MediaSession.tsx index fcc25489..2c260b47 100644 --- a/src/apps/seelenweg/modules/item/infra/MediaSession.tsx +++ b/src/apps/seelenweg/modules/item/infra/MediaSession.tsx @@ -26,7 +26,7 @@ const MAX_LUMINANCE = 210; const MIN_LUMINANCE = 40; const BRIGHTNESS_MULTIPLIER = 1.5; // used in css -export function MediaSession({ item }: { item: MediaWegItem }) { +export function MediaSession({ item, drag }: { item: MediaWegItem; drag: boolean }) { const [luminance, setLuminance] = useState(0); const dockPosition = useSelector(Selectors.settings.position); @@ -65,7 +65,7 @@ export function MediaSession({ item }: { item: MediaWegItem }) { const isHorizontal = dockPosition === SeelenWegSide.Bottom || dockPosition === SeelenWegSide.Top; return ( - +
{ +export const StartMenu = memo(({ item, drag }: Props) => { const focused = useSelector(Selectors.focusedApp); const { t } = useTranslation(); @@ -28,7 +29,7 @@ export const StartMenu = memo(({ item }: Props) => { const isStartMenuOpen = startMenuExes.some((program) => (focused?.exe || '').endsWith(program)); return ( - +
void; } -export const UserApplication = memo(({ item, onAssociatedViewOpenChanged }: Props) => { +export const UserApplication = memo(({ item, drag, onAssociatedViewOpenChanged }: Props) => { const [openPreview, setOpenPreview] = useState(false); const [openContextMenu, setOpenContextMenu] = useState(false); const [blockUntil, setBlockUntil] = useState(moment(new Date())); @@ -88,6 +89,7 @@ export const UserApplication = memo(({ item, onAssociatedViewOpenChanged }: Prop return ( ) { + state.reorderDisabled = isDisabled.payload; + savePinnedItems(current(state)); + }, }, }); diff --git a/src/apps/seelenweg/modules/shared/store/domain.ts b/src/apps/seelenweg/modules/shared/store/domain.ts index 9884a0e4..e4cfddf0 100644 --- a/src/apps/seelenweg/modules/shared/store/domain.ts +++ b/src/apps/seelenweg/modules/shared/store/domain.ts @@ -33,6 +33,7 @@ export interface RootState extends IRootState { itemsOnLeft: SwItem[]; itemsOnCenter: SwItem[]; itemsOnRight: SwItem[]; + reorderDisabled: boolean; // ---------------------- focusedApp: FocusedApp | null; isOverlaped: boolean; diff --git a/src/apps/seelenweg/modules/shared/store/infra.ts b/src/apps/seelenweg/modules/shared/store/infra.ts index 60638814..ddb38c45 100644 --- a/src/apps/seelenweg/modules/shared/store/infra.ts +++ b/src/apps/seelenweg/modules/shared/store/infra.ts @@ -112,6 +112,7 @@ function loadSettingsToStore(settings: Settings) { } function loadWegItemsToStore(items: WegItems) { + store.dispatch(RootActions.setReorderDisabled(items.inner.isReorderDisabled)); store.dispatch(RootActions.setItemsOnLeft(items.inner.left)); store.dispatch(RootActions.setItemsOnCenter(items.inner.center)); store.dispatch(RootActions.setItemsOnRight(items.inner.right)); diff --git a/src/apps/seelenweg/modules/shared/store/storeApi.ts b/src/apps/seelenweg/modules/shared/store/storeApi.ts index 4328349f..0f544b78 100644 --- a/src/apps/seelenweg/modules/shared/store/storeApi.ts +++ b/src/apps/seelenweg/modules/shared/store/storeApi.ts @@ -16,7 +16,7 @@ export const savePinnedItems = debounce( }; const data = new WegItems({ - isReorderDisabled: false, + isReorderDisabled: state.reorderDisabled, left: state.itemsOnLeft.filter(cb), center: state.itemsOnCenter.filter(cb), right: state.itemsOnRight.filter(cb), diff --git a/src/apps/toolbar/i18n/translations/en.yml b/src/apps/toolbar/i18n/translations/en.yml index 1146d519..beb4e1bf 100644 --- a/src/apps/toolbar/i18n/translations/en.yml +++ b/src/apps/toolbar/i18n/translations/en.yml @@ -2,6 +2,8 @@ context_menu: add_module: Add Module remove: Remove Module settings: Settings + reorder_disable: Lock toolbar + reorder_enable: Unlock toolbar task_manager: Task Manager media: device: diff --git a/src/apps/toolbar/modules/item/infra/Inner.tsx b/src/apps/toolbar/modules/item/infra/Inner.tsx index 215a7c48..f911b259 100644 --- a/src/apps/toolbar/modules/item/infra/Inner.tsx +++ b/src/apps/toolbar/modules/item/infra/Inner.tsx @@ -59,6 +59,8 @@ export function InnerItem(props: InnerItemProps) { } = props; const { template, tooltip, onClickV2, style, id, badge } = module; + const structure = useSelector(Selectors.items); + const [mounted, setMounted] = React.useState(false); const env = useSelector(Selectors.env); @@ -112,6 +114,7 @@ export function InnerItem(props: InnerItemProps) { , + label: t(!items.isReorderDisabled ? 'context_menu.reorder_disable' : 'context_menu.reorder_enable' ), + onClick() { + dispatch(RootActions.setToolbarReorderDisabled(!items.isReorderDisabled)); + SaveToolbarItems(); + }, + }, { key: 'task_manager', icon: , diff --git a/src/apps/toolbar/modules/shared/store/app.ts b/src/apps/toolbar/modules/shared/store/app.ts index faf1d323..af7bee11 100644 --- a/src/apps/toolbar/modules/shared/store/app.ts +++ b/src/apps/toolbar/modules/shared/store/app.ts @@ -107,6 +107,12 @@ export const RootSlice = createSlice({ state.items.right = state.items.right.filter(filter); } }, + setToolbarReorderDisabled(state, action: PayloadAction) { + let enabled = action.payload; + if (state.items) { + state.items.isReorderDisabled = enabled; + } + }, }, }); diff --git a/src/background/state/application/toolbar_items.rs b/src/background/state/application/toolbar_items.rs index a15f2c99..4a8253f4 100644 --- a/src/background/state/application/toolbar_items.rs +++ b/src/background/state/application/toolbar_items.rs @@ -13,6 +13,7 @@ use super::FullState; impl FullState { fn initial_toolbar_items() -> Placeholder { Placeholder { + is_reorder_disabled: false, left: vec![ ToolbarItem2::Plugin("@default/user-folder".into()), ToolbarItem2::Inline(ToolbarItem::Text(TextToolbarItem {