Permalink
Browse files

Fix "VIDEO" tab button not bold when entering quicksetting by toolbar

Refactor bold transition related code & l10n clean up.
  • Loading branch information...
alejx committed Feb 7, 2019
1 parent e92a3ee commit 83a2f8cc167d5963a157802b14c5e5ac4875a23a
@@ -16,10 +16,6 @@
"general.username" = "Username";
"general.password" = "Password";

// PlaylistViewController.swift
"playlist.playlist_cap" = "PLAYLIST";
"playlist.chapter_cap" = "CHAPTERS";

// MainWindowController.swift
"main.buffering_indicator" = "Buffering… %d%%";
"main.opening_stream" = "Opening stream…";
@@ -94,7 +94,7 @@
<rect key="frame" x="0.0" y="823" width="120" height="48"/>
<buttonCell key="cell" type="square" title="VIDEO" bezelStyle="shadowlessSquare" alignment="center" imageScaling="proportionallyDown" inset="2" id="lQt-I0-jHO">
<behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
<font key="font" metaFont="system"/>
<font key="font" metaFont="systemBold"/>
</buttonCell>
<connections>
<action selector="tabBtnAction:" target="-2" id="T17-c3-4hp"/>
@@ -1417,7 +1417,7 @@
<rect key="frame" x="0.0" y="0.0" width="360" height="823"/>
<clipView key="contentView" drawsBackground="NO" copiesOnScroll="NO" id="epy-wp-Ja5">
<rect key="frame" x="0.0" y="0.0" width="360" height="823"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<autoresizingMask key="autoresizingMask"/>
<subviews>
<customView translatesAutoresizingMaskIntoConstraints="NO" id="pm4-x9-WJ5" customClass="FlippedView" customModule="IINA" customModuleProvider="target">
<rect key="frame" x="0.0" y="-8" width="360" height="831"/>
@@ -1429,7 +1429,7 @@
<rect key="frame" x="0.0" y="304" width="360" height="72"/>
<clipView key="contentView" drawsBackground="NO" copiesOnScroll="NO" id="dJV-R0-O3M">
<rect key="frame" x="0.0" y="0.0" width="360" height="72"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<autoresizingMask key="autoresizingMask"/>
<subviews>
<tableView focusRingType="none" verticalHuggingPriority="750" allowsExpansionToolTips="YES" columnAutoresizingStyle="lastColumnOnly" columnResizing="NO" multipleSelection="NO" autosaveColumns="NO" rowSizeStyle="automatic" viewBased="YES" id="2vU-hm-gGB">
<rect key="frame" x="0.0" y="0.0" width="360" height="72"/>
@@ -1567,7 +1567,7 @@
<rect key="frame" x="0.0" y="187" width="360" height="72"/>
<clipView key="contentView" drawsBackground="NO" copiesOnScroll="NO" id="EKn-MX-Fao">
<rect key="frame" x="0.0" y="0.0" width="360" height="72"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<autoresizingMask key="autoresizingMask"/>
<subviews>
<tableView focusRingType="none" verticalHuggingPriority="750" allowsExpansionToolTips="YES" columnAutoresizingStyle="lastColumnOnly" columnResizing="NO" multipleSelection="NO" autosaveColumns="NO" rowSizeStyle="automatic" viewBased="YES" id="Jve-qX-Agy">
<rect key="frame" x="0.0" y="0.0" width="360" height="72"/>
@@ -205,18 +205,15 @@ class PlaylistViewController: NSViewController, NSTableViewDataSource, NSTableVi

/** Switch tab (for internal call) */
private func switchToTab(_ tab: TabViewType) {
let playlistStr = NSLocalizedString("playlist.playlist_cap", comment: "PLAYLIST")
let chapterStr = NSLocalizedString("playlist.chapter_cap", comment: "CHAPTERS")

switch tab {
case .playlist:
tabView.selectTabViewItem(at: 0)
playlistBtn.attributedTitle = NSAttributedString(string: playlistStr, attributes: Utility.tabTitleActiveFontAttributes)
chaptersBtn.attributedTitle = NSAttributedString(string: chapterStr, attributes: Utility.tabTitleFontAttributes)
Utility.setActive(playlistBtn, true)
Utility.setActive(chaptersBtn, false)
case .chapters:
tabView.selectTabViewItem(at: 1)
chaptersBtn.attributedTitle = NSAttributedString(string: chapterStr, attributes: Utility.tabTitleActiveFontAttributes)
playlistBtn.attributedTitle = NSAttributedString(string: playlistStr, attributes: Utility.tabTitleFontAttributes)
Utility.setActive(chaptersBtn, true)
Utility.setActive(playlistBtn, false)
}

currentTab = tab
@@ -282,33 +282,17 @@ class QuickSettingViewController: NSViewController, NSTableViewDataSource, NSTab
/** Switch tab (for internal call) */
private func switchToTab(_ tab: TabViewType) {
let button: NSButton
let tabIndex: Int
switch tab {
case .video:
button = videoTabBtn
tabIndex = 0
case .audio:
button = audioTabBtn
tabIndex = 1
case .sub:
button = subTabBtn
tabIndex = 2
default:
return
}
tabView.selectTabViewItem(at: tabIndex)
// cancel current active button
for btn in [videoTabBtn, audioTabBtn, subTabBtn] {
if let btn = btn {
let title = btn.title
btn.attributedTitle = NSAttributedString(string: title, attributes: Utility.tabTitleFontAttributes)
}
}
// the active one
let title = button.title
button.attributedTitle = NSAttributedString(string: title, attributes: Utility.tabTitleActiveFontAttributes)

currentTab = tab
tabBtnAction(button)
}

// MARK: - NSTableView delegate
@@ -391,16 +375,8 @@ class QuickSettingViewController: NSViewController, NSTableViewDataSource, NSTab
@IBAction func tabBtnAction(_ sender: NSButton) {
tabView.selectTabViewItem(at: sender.tag)
// cancel current active button
[videoTabBtn, audioTabBtn, subTabBtn].forEach { btn in
if let btn = btn {
let title = btn.title
btn.attributedTitle = NSAttributedString(string: title, attributes: Utility.tabTitleFontAttributes)
}
}
// the active one
let title = sender.title
sender.attributedTitle = NSAttributedString(string: title, attributes: Utility.tabTitleActiveFontAttributes)
[videoTabBtn, audioTabBtn, subTabBtn].forEach { Utility.setActive($0, false) }
Utility.setActive(sender, true)
reload()
}

@@ -10,9 +10,6 @@ import Cocoa

class Utility {

static let tabTitleFontAttributes = FontAttributes(font: .system, size: .system, align: .center).value
static let tabTitleActiveFontAttributes = FontAttributes(font: .systemBold, size: .system, align: .center).value

static let supportedFileExt: [MPVTrack.TrackType: [String]] = [
.video: ["mkv", "mp4", "avi", "m4v", "mov", "3gp", "ts", "mts", "m2ts", "wmv", "flv", "f4v", "asf", "webm", "rm", "rmvb", "qt", "dv", "mpg", "mpeg", "mxf", "vob", "gif"],
.audio: ["mp3", "aac", "mka", "dts", "flac", "ogg", "oga", "mogg", "m4a", "ac3", "opus", "wav", "wv", "aiff", "ape", "tta", "tak"],
@@ -387,6 +384,11 @@ class Utility {

// MARK: - Util functions
static func setActive(_ button: NSButton, _ active: Bool) {
button.attributedTitle = NSAttributedString(string: button.title,
attributes: FontAttributes(font: active ? .systemBold : .system, size: .system, align: .center).value)
}

static func toRealSubScale(fromDisplaySubScale scale: Double) -> Double {
return scale > 0 ? scale : -1 / scale
}
@@ -177,8 +177,6 @@
"pl_menu.reveal_in_finder" = "Im Finder anzeigen";
"pl_menu.title_multi" = "%d Dateien";
"pl_menu.wrong_sub" = "Falscher Untertitel!";
"playlist.chapter_cap" = "KAPITEL";
"playlist.playlist_cap" = "WIEDERGABELISTE";
"playlist.total_length" = "%@ insgesamt";
"playlist.total_length_with_selected" = "%@ von %@ ausgewählt";
"preference.advanced" = "Erweitert";
@@ -177,8 +177,6 @@
"pl_menu.reveal_in_finder" = "Mostrar en el Finder";
"pl_menu.title_multi" = "%d Elementos";
"pl_menu.wrong_sub" = "¡Subtítulo incorrecto!";
"playlist.chapter_cap" = "CAPÍTULOS";
"playlist.playlist_cap" = "LISTA DE REPRODUCCIÓN";
"playlist.total_length" = "%@ en total";
"playlist.total_length_with_selected" = "%@ de %@ seleccionados";
"preference.advanced" = "Avanzado";
@@ -177,8 +177,6 @@
"pl_menu.reveal_in_finder" = "Afficher dans le Finder";
"pl_menu.title_multi" = "%d éléments";
"pl_menu.wrong_sub" = "Mauvais sous-titre !";
"playlist.chapter_cap" = "CHAPITRES";
"playlist.playlist_cap" = "PLAYLIST";
"playlist.total_length" = "%@ au total";
"playlist.total_length_with_selected" = "%@ sur %@ sélectionnés";
"preference.advanced" = "Avancé";
@@ -16,10 +16,6 @@
"general.username" = "उपयोगकर्ता नाम";
"general.password" = "पारण शब्द";

// PlaylistViewController.swift
"playlist.playlist_cap" = "प्लेलिस्ट";
"playlist.chapter_cap" = "अध्याय";

// MainWindowController.swift
"main.buffering_indicator" = "बफरिंग… %d%%";
"main.opening_stream" = "खुलने की धारा…";
@@ -177,8 +177,6 @@
"pl_menu.reveal_in_finder" = "Mostra nel Finder";
"pl_menu.title_multi" = "%d Elementi";
"pl_menu.wrong_sub" = "Sotttotioli errati!";
"playlist.chapter_cap" = "CAPITOLI";
"playlist.playlist_cap" = "PLAYLIST";
"playlist.total_length" = "%@ sul totale";
"playlist.total_length_with_selected" = "%@ di %@ selezionato";
"preference.advanced" = "Avanzate";
@@ -177,8 +177,6 @@
"pl_menu.reveal_in_finder" = "Finderで表示";
"pl_menu.title_multi" = "%d個のアイテム";
"pl_menu.wrong_sub" = "誤った字幕です!";
"playlist.chapter_cap" = "チャプタ";
"playlist.playlist_cap" = "プレイリスト";
"playlist.total_length" = "合計 %@";
"playlist.total_length_with_selected" = "%@ / %@を選択中";
"preference.advanced" = "拡張";
@@ -177,8 +177,6 @@
"pl_menu.reveal_in_finder" = "파인더에서 보기";
"pl_menu.title_multi" = "%d개의 항목";
"pl_menu.wrong_sub" = "잘못된 자막!";
"playlist.chapter_cap" = "챕터";
"playlist.playlist_cap" = "재생목록";
"playlist.total_length" = "전체 %@";
"playlist.total_length_with_selected" = "%@ 선택됨 / 전체 %@";
"preference.advanced" = "고급설정";
@@ -177,8 +177,6 @@
"pl_menu.reveal_in_finder" = "Toon in Finder";
"pl_menu.title_multi" = "%d bestanden";
"pl_menu.wrong_sub" = "Verkeerde ondertiteling!";
"playlist.chapter_cap" = "HOOFDSTUKKEN";
"playlist.playlist_cap" = "AFSPEELLIJST";
"playlist.total_length" = "%@ in totaal";
"playlist.total_length_with_selected" = "%@ van %@ geselecteerd";
"preference.advanced" = "Geavanceerd";
@@ -177,8 +177,6 @@
"pl_menu.reveal_in_finder" = "Mostrar no Finder";
"pl_menu.title_multi" = "%d Itens";
"pl_menu.wrong_sub" = "Legenda Errada!";
"playlist.chapter_cap" = "CAPITULOS";
"playlist.playlist_cap" = "PLAYLIST";
"playlist.total_length" = "%@ do total";
"playlist.total_length_with_selected" = "%@ de %@ selecionado";
"preference.advanced" = "Avançado";
@@ -177,8 +177,6 @@
"pl_menu.reveal_in_finder" = "Arată în Finder";
"pl_menu.title_multi" = "%d elemente";
"pl_menu.wrong_sub" = "Subtitrare greșită!";
"playlist.chapter_cap" = "CAPITOLE";
"playlist.playlist_cap" = "LISTĂ DE REDARE";
"playlist.total_length" = "%@ în total";
"playlist.total_length_with_selected" = "%@ din %@ selectat";
"preference.advanced" = "Avansat";
@@ -177,8 +177,6 @@
"pl_menu.reveal_in_finder" = "Показать в Finder";
"pl_menu.title_multi" = "%d элементов";
"pl_menu.wrong_sub" = "Неверные субтитры!";
"playlist.chapter_cap" = "ГЛАВЫ";
"playlist.playlist_cap" = "ПЛЕЙЛИСТ";
"playlist.total_length" = "%@ в общей сложности";
"playlist.total_length_with_selected" = "%@ из %@ выбрано";
"preference.advanced" = "Дополнительно";
@@ -177,8 +177,6 @@
"pl_menu.reveal_in_finder" = "Zobraziť vo Finderi";
"pl_menu.title_multi" = "%d Položky";
"pl_menu.wrong_sub" = "Nesprávne Titulky!";
"playlist.chapter_cap" = "KAPITOLY";
"playlist.playlist_cap" = "PLAYLIST";
"playlist.total_length" = "%@ celkovo";
"playlist.total_length_with_selected" = "%@ z %@ označených";
"preference.advanced" = "Pokročilé";
@@ -177,8 +177,6 @@
"pl_menu.reveal_in_finder" = "Visa i Finder";
"pl_menu.title_multi" = "%d objekt";
"pl_menu.wrong_sub" = "Fel undertext!";
"playlist.chapter_cap" = "KAPITEL";
"playlist.playlist_cap" = "SPELLISTA";
"playlist.total_length" = "Totalt %@";
"playlist.total_length_with_selected" = "%@ av %@ markerade";
"preference.advanced" = "Avancerat";
@@ -177,8 +177,6 @@
"pl_menu.reveal_in_finder" = "Показати у Finder";
"pl_menu.title_multi" = "Елементів: %d";
"pl_menu.wrong_sub" = "Субтитри неправильні!";
"playlist.chapter_cap" = "РОЗДІЛИ";
"playlist.playlist_cap" = "ПІДБІРКА";
"playlist.total_length" = "%@ загалом";
"playlist.total_length_with_selected" = "%@ з %@ вибрано";
"preference.advanced" = "Експертні";
@@ -180,8 +180,6 @@
"pl_menu.browser" = "在浏览器中打开";
"pl_menu.copy_url" = "复制链接";
"pl_menu.copy_url_multi" = "复制链接";
"playlist.chapter_cap" = "章节";
"playlist.playlist_cap" = "播放列表";
"playlist.total_length" = "总计 %@";
"playlist.total_length_with_selected" = "选中 %@ / %@";
"preference.advanced" = "高级";
@@ -180,8 +180,6 @@
"pl_menu.browser" = "在瀏覽器中打開";
"pl_menu.copy_url" = "複製鏈接";
"pl_menu.copy_url_multi" = "複製鏈接";
"playlist.chapter_cap" = "章節";
"playlist.playlist_cap" = "播放列表";
"playlist.total_length" = "總計 %@";
"playlist.total_length_with_selected" = "選中 %@ / %@";
"preference.advanced" = "進階";

0 comments on commit 83a2f8c

Please sign in to comment.