Skip to content

Commit

Permalink
Fixed menubar item width issue.
Browse files Browse the repository at this point in the history
  • Loading branch information
venj committed Dec 19, 2016
1 parent 0fb5219 commit 5b334ad
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 5 deletions.
8 changes: 6 additions & 2 deletions Battery Time/AppDelegate.m
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
#import <notify.h>
#import <ServiceManagement/ServiceManagement.h>

#define STATUS_ITEM_GAP 6.0

@interface AppDelegate ()
@property (nonatomic, strong) NSMenu *statusMenu;
@property (nonatomic, strong) NSMenuItem *batteryMenu;
Expand Down Expand Up @@ -62,7 +64,7 @@ - (void)createStatusItem {
self.statusItem = [[NSStatusBar systemStatusBar] statusItemWithLength:NSVariableStatusItemLength];
NSAttributedString *title = [self menuTitle];
self.statusItem.attributedTitle = title;
self.statusItem.length = [title size].width + 6.0;
self.statusItem.length = [title size].width + STATUS_ITEM_GAP;
self.statusMenu = [[NSMenu alloc] init];
self.statusMenu.delegate = self;
self.statusItem.menu = self.statusMenu;
Expand Down Expand Up @@ -96,7 +98,9 @@ - (NSString *)currentBatteryRemainTime {
}

- (void)updateBatteryTimeInfo {
self.statusItem.attributedTitle = [self menuTitle];
NSAttributedString *title = [self menuTitle];
self.statusItem.attributedTitle = title;
self.statusItem.length = [title size].width + STATUS_ITEM_GAP;
self.batteryMenu.title = [self currentBatteryRemainTime];
}

Expand Down
4 changes: 2 additions & 2 deletions Battery Time/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>1.2</string>
<string>1.2.1</string>
<key>CFBundleVersion</key>
<string>6</string>
<string>7</string>
<key>LSApplicationCategoryType</key>
<string>public.app-category.utilities</string>
<key>LSMinimumSystemVersion</key>
Expand Down
2 changes: 1 addition & 1 deletion Readme.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

### 下载

访问 [Releases](https://github.com/venj/Battery-Time/releases/) 页面,或 [点此下载](https://github.com/venj/Battery-Time/releases/download/1.2/BatteryTime.zip)
访问 [Releases](https://github.com/venj/Battery-Time/releases/) 页面,或 [点此下载](https://github.com/venj/Battery-Time/releases/download/1.2.1/BatteryTime.zip)

### 关闭登录时启动

Expand Down

0 comments on commit 5b334ad

Please sign in to comment.