Browse Source

Merge branch 'pr/5767'

Eugene Pankov 4 years ago
parent
commit
9e0808fca3

+ 1 - 0
tabby-core/src/api/tabRecovery.ts

@@ -4,6 +4,7 @@ import { NewTabParameters } from '../services/tabs.service'
 export interface RecoveryToken {
     [_: string]: any
     type: string
+    tabIcon?: string|null
     tabColor?: string|null
 }
 

+ 7 - 0
tabby-core/src/components/baseTab.component.ts

@@ -51,6 +51,13 @@ export abstract class BaseTabComponent extends BaseComponent {
     set color (value: string|null) { this._color = value }
     private _color: string|null = null
 
+    /**
+     * icon override for the tab's header
+     */
+    get icon (): string|null { return this._icon }
+    set icon (value: string|null) { this._icon = value }
+    private _icon: string|null = null
+
     hasFocus = false
 
     /**

+ 10 - 0
tabby-core/src/components/splitTab.component.ts

@@ -624,6 +624,16 @@ export class SplitTabComponent extends BaseTabComponent implements AfterViewInit
         super.clearActivity()
     }
 
+    get icon (): string|null {
+        return this.getFocusedTab()?.icon ?? null
+    }
+
+    set icon (icon: string|null) {
+        for (const t of this.getAllTabs()) {
+            t.icon = icon
+        }
+    }
+
     get color (): string|null {
         return this.getFocusedTab()?.color ?? null
     }

+ 6 - 0
tabby-core/src/components/tabHeader.component.pug

@@ -5,6 +5,12 @@
 .index(*ngIf='!config.store.terminal.hideTabIndex && hostApp.platform === Platform.macOS', cdkDragHandle) {{index + 1}}
 .index(*ngIf='!config.store.terminal.hideTabIndex && hostApp.platform !== Platform.macOS') {{index + 1}}
 
+.icon(
+    *ngIf='config.store.terminal.showTabProfileIcon && tab.icon',
+    [ngClass]='tab.icon',
+    [style.color]='tab.color'
+)
+
 .name(
     [title]='tab.customTitle || tab.title',
     [class.no-hover]='config.store.terminal.hideCloseButton'

+ 7 - 1
tabby-core/src/components/tabHeader.component.scss

@@ -26,7 +26,8 @@ $tabs-height: 38px;
       height: $tabs-height;
     }
 
-    .index {
+    .index,
+    .icon {
         flex: none;
         font-weight: bold;
         -webkit-app-region: no-drag;
@@ -40,6 +41,11 @@ $tabs-height: 38px;
         margin-top: 1px;
     }
 
+    .icon {
+        font-size: 13px;
+        margin: 1px 4px 0 0;
+    }
+
     .name {
         flex: auto;
         margin-top: 1px;

+ 3 - 0
tabby-core/src/services/profiles.service.ts

@@ -54,6 +54,9 @@ export class ProfilesService {
             if (fullProfile.color) {
                 params.inputs['color'] = fullProfile.color
             }
+            if (fullProfile.icon) {
+                params.inputs['icon'] = fullProfile.icon
+            }
         }
         return params
     }

+ 4 - 0
tabby-core/src/services/tabRecovery.service.ts

@@ -35,6 +35,9 @@ export class TabRecoveryService {
         if (token) {
             token.tabTitle = tab.title
             token.tabCustomTitle = tab.customTitle
+            if (tab.icon) {
+                token.tabIcon = tab.icon
+            }
             if (tab.color) {
                 token.tabColor = tab.color
             }
@@ -51,6 +54,7 @@ export class TabRecoveryService {
                 }
                 const tab = await provider.recover(token)
                 tab.inputs = tab.inputs ?? {}
+                tab.inputs.icon = token.tabIcon ?? null
                 tab.inputs.color = token.tabColor ?? null
                 tab.inputs.title = token.tabTitle || ''
                 tab.inputs.customTitle = token.tabCustomTitle || ''

+ 4 - 0
tabby-core/src/theme.scss

@@ -62,6 +62,10 @@ app-root  {
                         color: rgba(255, 255, 255, 0.4);
                     }
 
+                    .icon {
+                        opacity: .75;
+                    }
+
                     button {
                         color: $body-color;
                         border: none;

+ 9 - 0
tabby-settings/src/components/windowSettingsTab.component.pug

@@ -286,6 +286,15 @@ h3.mt-4(translate) Tabs
         (ngModelChange)='config.save();',
     )
 
+.form-line
+    .header
+        .title(translate) Show profile icon on tab
+
+    toggle(
+        [(ngModel)]='config.store.terminal.showTabProfileIcon',
+        (ngModelChange)='config.save();',
+    )
+
 .form-line
     .header
         .title(translate) Hide tab close button

+ 1 - 0
tabby-terminal/src/config.ts

@@ -19,6 +19,7 @@ export class TerminalConfigProvider extends ConfigProvider {
             cursor: 'block',
             cursorBlink: true,
             hideTabIndex: false,
+            showTabProfileIcon: false,
             hideCloseButton: false,
             rightClick: 'menu',
             pasteOnMiddleClick: true,