mirror of
https://github.com/HackPlan/quark-shell-mac.git
synced 2026-01-12 22:27:07 +08:00
[Close #44] Add quark.resizePopup()
This commit is contained in:
@@ -33,10 +33,11 @@ quark.appBundleVersion
|
||||
// Enable/disable Web Inspector
|
||||
quark.debug = true
|
||||
|
||||
// Open/close the popup window
|
||||
// Manipulate the popup window
|
||||
quark.openPopup()
|
||||
quark.closePopup()
|
||||
quark.togglePopup()
|
||||
quark.resizePopup({width: 326, height: 623})
|
||||
|
||||
// Quit application
|
||||
quark.quit()
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="6250" systemVersion="14B25" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES">
|
||||
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="8191" systemVersion="15A282b" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES">
|
||||
<dependencies>
|
||||
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="6250"/>
|
||||
<plugIn identifier="com.apple.WebKitIBPlugin" version="6250"/>
|
||||
<deployment identifier="macosx"/>
|
||||
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="8191"/>
|
||||
<plugIn identifier="com.apple.WebKitIBPlugin" version="8191"/>
|
||||
</dependencies>
|
||||
<objects>
|
||||
<customObject id="-2" userLabel="File's Owner" customClass="NSApplication">
|
||||
@@ -27,13 +28,21 @@
|
||||
<rect key="frame" x="0.0" y="0.0" width="320" height="280"/>
|
||||
<autoresizingMask key="autoresizingMask"/>
|
||||
<subviews>
|
||||
<webView fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="kp8-f9-tLw">
|
||||
<webView translatesAutoresizingMaskIntoConstraints="NO" id="kp8-f9-tLw">
|
||||
<rect key="frame" x="0.0" y="0.0" width="320" height="270"/>
|
||||
<animations/>
|
||||
<webPreferences key="preferences" defaultFontSize="12" defaultFixedFontSize="12">
|
||||
<nil key="identifier"/>
|
||||
</webPreferences>
|
||||
</webView>
|
||||
</subviews>
|
||||
<constraints>
|
||||
<constraint firstItem="kp8-f9-tLw" firstAttribute="top" secondItem="K10-CQ-J3N" secondAttribute="top" constant="10" id="8yw-um-fHS"/>
|
||||
<constraint firstAttribute="bottom" secondItem="kp8-f9-tLw" secondAttribute="bottom" id="TUI-1i-XAm"/>
|
||||
<constraint firstAttribute="trailing" secondItem="kp8-f9-tLw" secondAttribute="trailing" id="dww-IB-gOv"/>
|
||||
<constraint firstItem="kp8-f9-tLw" firstAttribute="leading" secondItem="K10-CQ-J3N" secondAttribute="leading" id="ouW-Xo-0qu"/>
|
||||
</constraints>
|
||||
<animations/>
|
||||
</view>
|
||||
</window>
|
||||
<menu title="Main Menu" systemMenu="main" id="tdM-1d-aZL">
|
||||
|
||||
@@ -19,5 +19,6 @@
|
||||
- (void)showWindow;
|
||||
- (void)hideWindow;
|
||||
- (void)toggleWindow;
|
||||
- (void)resizeWindow:(CGSize)size;
|
||||
|
||||
@end
|
||||
|
||||
@@ -117,6 +117,13 @@
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
- (void)resizeWindow:(CGSize)size
|
||||
{
|
||||
[self.window setFrame:CGRectMake(0, 0, size.width, size.height) display:NO];
|
||||
[self refreshStyle];
|
||||
}
|
||||
|
||||
- (void)statusItemClicked
|
||||
{
|
||||
const NSUInteger buttonMask = [NSEvent pressedMouseButtons];
|
||||
|
||||
@@ -67,6 +67,7 @@ static const NSInteger kPreferencesDefaultHeight = 192;
|
||||
if (selector == @selector(openPopup) ||
|
||||
selector == @selector(closePopup) ||
|
||||
selector == @selector(togglePopup) ||
|
||||
selector == @selector(resizePopup:) ||
|
||||
selector == @selector(quit) ||
|
||||
selector == @selector(openURL:) ||
|
||||
selector == @selector(changeIcon:) ||
|
||||
@@ -103,7 +104,10 @@ static const NSInteger kPreferencesDefaultHeight = 192;
|
||||
{
|
||||
id result = nil;
|
||||
|
||||
if (selector == @selector(notify:)) {
|
||||
if (selector == @selector(resizePopup:)) {
|
||||
result = @"resizePopup";
|
||||
}
|
||||
else if (selector == @selector(notify:)) {
|
||||
result = @"notify";
|
||||
}
|
||||
else if (selector == @selector(changeIcon:)) {
|
||||
@@ -183,6 +187,18 @@ static const NSInteger kPreferencesDefaultHeight = 192;
|
||||
[self.appDelegate toggleWindow];
|
||||
}
|
||||
|
||||
- (void)resizePopup:(WebScriptObject *)obj
|
||||
{
|
||||
QSHWebScriptObjectConverter *converter = [[QSHWebScriptObjectConverter alloc] initWithWebView:self.webView];
|
||||
NSDictionary *options = [converter dictionaryFromWebScriptObject:obj];
|
||||
CGFloat width = [options[@"width"] doubleValue];
|
||||
CGFloat height = [options[@"height"] doubleValue];
|
||||
|
||||
if (options[@"width"] && options[@"height"]) {
|
||||
[self.appDelegate resizeWindow:CGSizeMake(width, height)];
|
||||
}
|
||||
}
|
||||
|
||||
- (void)quit
|
||||
{
|
||||
[NSApp terminate:nil];
|
||||
|
||||
@@ -52,6 +52,7 @@
|
||||
}
|
||||
button:active {
|
||||
background-color: #e8e8e8;
|
||||
color: black;
|
||||
}
|
||||
canvas {
|
||||
display: none;
|
||||
@@ -90,6 +91,8 @@
|
||||
<button onclick="confirm('Quark Shell rocks!')">Confirm</button>
|
||||
</p>
|
||||
<p>
|
||||
<button onclick="quark.resizePopup({width: 400, height: 320})">Resize</button>
|
||||
<button style="visibility: hidden;"></button>
|
||||
<button onclick="quark.quit()">Quit</button>
|
||||
</p>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user