|
@@ -29,7 +29,7 @@ class KMBookmark: NSObject {
|
|
var children: [KMBookmark] = [] //子
|
|
var children: [KMBookmark] = [] //子
|
|
|
|
|
|
static func bookmark(url: URL, pageIndex: UInt, label: String) -> KMBookmark {
|
|
static func bookmark(url: URL, pageIndex: UInt, label: String) -> KMBookmark {
|
|
- var bookmark = KMBookmark()
|
|
|
|
|
|
+ let bookmark = KMBookmark()
|
|
bookmark.fileURL = url
|
|
bookmark.fileURL = url
|
|
bookmark.pageIndex = pageIndex
|
|
bookmark.pageIndex = pageIndex
|
|
bookmark.label = label
|
|
bookmark.label = label
|
|
@@ -41,7 +41,7 @@ class KMBookmark: NSObject {
|
|
return KMBookmark()
|
|
return KMBookmark()
|
|
}
|
|
}
|
|
|
|
|
|
- static func bookmark(properties: NSDictionary) -> KMBookmark {
|
|
|
|
|
|
+ static func bookmark(properties: [String: Any]) -> KMBookmark {
|
|
return KMBookmark()
|
|
return KMBookmark()
|
|
}
|
|
}
|
|
|
|
|
|
@@ -85,17 +85,22 @@ class KMFolderBookmark: KMBookmark {
|
|
return KMFolderBookmark()
|
|
return KMFolderBookmark()
|
|
}
|
|
}
|
|
|
|
|
|
- static func bookmarkRoot(childrenProperties: NSArray) -> KMFolderBookmark {
|
|
|
|
- var bookmark = KMFolderBookmark()
|
|
|
|
- var childs: [KMBookmark] = []
|
|
|
|
- for setup in childrenProperties {
|
|
|
|
- let bookmark = KMBookmark()
|
|
|
|
- bookmark.documentSetup = setup as! [String : String]
|
|
|
|
- childs.append(bookmark)
|
|
|
|
|
|
+ override var icon: NSImage {
|
|
|
|
+ get {
|
|
|
|
+ return NSImage(named: NSImage.folderName)!
|
|
|
|
+ }
|
|
|
|
+ set {
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ override var alternateIcon: NSImage {
|
|
|
|
+ get {
|
|
|
|
+ return NSImage(named: NSImage.multipleDocumentsName)!
|
|
|
|
+ }
|
|
|
|
+ set {
|
|
|
|
+
|
|
}
|
|
}
|
|
- bookmark.children = childs
|
|
|
|
- bookmark.label = NSLocalizedString("Bookmarks Menu", comment: "")
|
|
|
|
- return bookmark
|
|
|
|
}
|
|
}
|
|
|
|
|
|
// - (id)initRootWithChildrenProperties:(NSArray *)childrenProperties {
|
|
// - (id)initRootWithChildrenProperties:(NSArray *)childrenProperties {
|
|
@@ -111,6 +116,70 @@ class KMFolderBookmark: KMBookmark {
|
|
// }
|
|
// }
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+class KMRootBookmark: KMFolderBookmark {
|
|
|
|
+ static func bookmarkRoot(childrenProperties: NSArray) -> KMRootBookmark {
|
|
|
|
+ var bookmark = KMRootBookmark()
|
|
|
|
+ var childs: [KMBookmark] = []
|
|
|
|
+ for setup in childrenProperties {
|
|
|
|
+ let bookmark = KMBookmark()
|
|
|
|
+ bookmark.documentSetup = setup as! [String : String]
|
|
|
|
+ childs.append(bookmark)
|
|
|
|
+ }
|
|
|
|
+ bookmark.children = childs
|
|
|
|
+ bookmark.label = NSLocalizedString("Bookmarks Menu", comment: "")
|
|
|
|
+ return bookmark
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ override var icon: NSImage {
|
|
|
|
+ get {
|
|
|
|
+ var iconImage = NSImage()
|
|
|
|
+ let iconSize = NSSize(width: 16.0, height: 16.0)
|
|
|
|
+ let drawingHandler: (NSRect) -> Bool = { rect in
|
|
|
|
+ NSColor(calibratedWhite: 0.0, alpha: 0.2).set()
|
|
|
|
+ NSBezierPath(rect: NSRect(x: 1.0, y: 1.0, width: 14.0, height: 13.0)).fill()
|
|
|
|
+ NSGraphicsContext.saveGraphicsState()
|
|
|
|
+ let path = NSBezierPath()
|
|
|
|
+ path.move(to: NSPoint(x: 2.0, y: 2.0))
|
|
|
|
+ path.line(to: NSPoint(x: 2.0, y: 15.0))
|
|
|
|
+ path.line(to: NSPoint(x: 7.0, y: 15.0))
|
|
|
|
+ path.line(to: NSPoint(x: 7.0, y: 13.0))
|
|
|
|
+ path.line(to: NSPoint(x: 14.0, y: 13.0))
|
|
|
|
+ path.line(to: NSPoint(x: 14.0, y: 2.0))
|
|
|
|
+ path.close()
|
|
|
|
+ NSColor.white.set()
|
|
|
|
+ NSShadow.setShadowWith(NSColor(calibratedWhite: 0.0, alpha: 0.33333), blurRadius: 2.0, yOffset: -1.0)
|
|
|
|
+ path.fill()
|
|
|
|
+ NSGraphicsContext.restoreGraphicsState()
|
|
|
|
+ NSColor(calibratedRed: 0.162, green: 0.304, blue: 0.755, alpha: 1.0).set()
|
|
|
|
+ NSRect(x: 2.0, y: 13.0, width: 5.0, height: 2.0).fill()
|
|
|
|
+ NSColor(calibratedRed: 0.894, green: 0.396, blue: 0.202, alpha: 1.0).set()
|
|
|
|
+ NSRect(x: 3.0, y: 4.0, width: 1.0, height: 1.0).fill()
|
|
|
|
+ NSRect(x: 3.0, y: 7.0, width: 1.0, height: 1.0).fill()
|
|
|
|
+ NSRect(x: 3.0, y: 10.0, width: 1.0, height: 1.0).fill()
|
|
|
|
+ NSColor(calibratedWhite: 0.6, alpha: 1.0).set()
|
|
|
|
+ NSRect(x: 5.0, y: 4.0, width: 1.0, height: 1.0).fill()
|
|
|
|
+ NSRect(x: 5.0, y: 7.0, width: 1.0, height: 1.0).fill()
|
|
|
|
+ NSRect(x: 5.0, y: 10.0, width: 1.0, height: 1.0).fill()
|
|
|
|
+ for i in 0..<7 {
|
|
|
|
+ for j in 0..<3 {
|
|
|
|
+ NSColor(calibratedWhite: 0.45 + 0.1 * CGFloat(Float(arc4random()) / Float(UInt32.max)), alpha: 1.0).set()
|
|
|
|
+ NSRect(x: 6.0 + CGFloat(i), y: 4.0 + CGFloat(3 * j), width: 1.0, height: 1.0).fill()
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ let gradient = NSGradient(starting: NSColor(calibratedWhite: 0.0, alpha: 0.1), ending: NSColor(calibratedWhite: 0.0, alpha: 0.0))
|
|
|
|
+ gradient?.draw(in: NSRect(x: 2.0, y: 2.0, width: 12.0, height: 11.0), angle: 90.0)
|
|
|
|
+ return true
|
|
|
|
+ }
|
|
|
|
+ iconImage = NSImage(size: iconSize, flipped: false, drawingHandler: drawingHandler)
|
|
|
|
+
|
|
|
|
+ return iconImage
|
|
|
|
+ }
|
|
|
|
+ set {
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+}
|
|
|
|
+
|
|
//MARK: Session
|
|
//MARK: Session
|
|
class KMSessionBookmark: KMBookmark {
|
|
class KMSessionBookmark: KMBookmark {
|
|
override var bookmarkType: KMBookmarkType {
|
|
override var bookmarkType: KMBookmarkType {
|