I'd like my dock icon to be hidden and the app to be represented as a menu bearing icon on the menu bar (right hand side).
This will hide the icon:
http://www.macosxtips.co.uk/index_files/disable-the-dock-icon-for-any-application.html
Summarizing the URL, in the dict xml element inside Info.plist in the app, add the lines:
<key>LSUIElement</key>
<string>1</string>
You need to use the appropriate OS APIs to add the menu.
The alternative answer is by using TransformProcessType() to show/hide dock icon dynamically in code.
#import <Foundation/Foundation.h>
void toggleDockIcon(bool show) {
ProcessSerialNumber psn = {0, kCurrentProcess};
if (show) {
TransformProcessType(&psn, kProcessTransformToForegroundApplication);
} else {
TransformProcessType(&psn, kProcessTransformToUIElementApplication);
}
}
Related
I am having QToolBar with various tool buttons on it. I want to customize those buttons with some simple effects like, it should be seen that button is pressed, after pressing it should change its icon color or background color etc.
I tried but I could not succeed.
_toolbar = new QToolBar;
_toolbar->setIconSize(QSize(35,35));
_toolbar->setToolButtonStyle(Qt::ToolButtonTextUnderIcon);
void createIcons()
{
_zoomInIcon = QIcon::fromTheme("zoom-in");
_zoomIn = new QAction(_zoomInIcon, "Zoom in", this);
// code for other icons
_toolbar->addAction(_zoomIn);
}
void myClass::ZoomIn()
{
_zoomIn->setCheckable(true);
//QToolButton:_zoomInIcon {background-color: red; }
//setStyleSheet('background-color: red;');
// other logic
}
Moreover I am using Qt's default icons from this default-icons
But some of the icons are not looking good specially save in and save in as.
So does any one knows more default icons apart from above link in Qt ?
Can anyone help me ?
Try something like below (not tested)
//Get the tool button using the action
QToolButton* zoomInButton = mytoolbar->widgetForAction(_zoomIn);
//Set the style you want.
zoomInButton->setStyleSheet("QToolButton:pressed"
"{"
"background-color : red;"
"}"
);
And you can use all QPushButton styles, if your tool button don't have a menu.
https://doc.qt.io/qt-5/stylesheet-examples.html#customizing-qtoolbutton
The QToolButton has no menu. In this case, the QToolButton is styled
exactly like QPushButton.
I have been working on this for hours(today)/months. I just want my BG to stay permanent in all view controllers as well as the same buttons with the same commands for all of them.
It is only the foreground element that is transitioning around in the center of the viewfinder, from side to side.
I tried using a subclass, it did not effect my view controller at all. When it came to trying to get my buttons to stay, i tried to cheat and use a tab bar, but the tab bar controller is locked at the bottom and I can't move it up the y axis.
Is there an easier way? Is there a way to make a view controller have the main components and every other view controller has sub components that transitions, one from another using the main components controller.
When attempting to make a subclass, I made a touch class file and put..
import UIKit
class WallpaperWindow: UIWindow {
var wallpaper: UIImage? = UIImage(named: "BG.png") {
didSet {
// refresh if the image changed
setNeedsDisplay()
}
}
init() {
super.init(frame: UIScreen.main.bounds)
//clear the background color of all table views, so we can see the background
UITableView.appearance().backgroundColor = UIColor.clear
}
required init?(coder aDecoder: NSCoder) {
super.init(coder: aDecoder)
}
override func draw(_ rect: CGRect) {
// draw the wallper if set, otherwise default behaviour
if let wallpaper = wallpaper {
wallpaper.draw(in: self.bounds);
} else {
super.draw(rect)
}
}
and then put
var window: UIWindow? = WallpaperWindow()
into my AppDelegate...
the code was working find, just my background did not change at all...
Related in making the tab bar move up the y axis I had no luck, it was locked....counting even tough the UIcoding..
I wanted to have a collapsible widget. I used this code: How to make an expandable/collapsable section widget in QT.
I wanted the title of the QToolButton to be on the far left and the triangle icon to be on the right. I deleted the title, and moved the icon. Then I created a QPushButton and made it look like a QLabel and positioned it where I wanted the title to be. Now, I would like the title to be clickable - to have the same effect as clicking on the toggle icon would have. How do I connect these two signals?
Code for the QToolButton:
QObject::connect(toggleButton, &QToolButton::clicked, [this](const bool checked)
{
toggleButton->setArrowType(checked ? Qt::ArrowType::DownArrow : Qt::ArrowType::UpArrow);
toggleAnimation->setDirection(checked ? QAbstractAnimation::Forward : QAbstractAnimation::Backward);
toggleAnimation->start();
});
You can also write it like this:
QObject::connect(titleLabel, &QPushButten::clicked, toggleButton, &QToolButton::clicked);
I found that this works:
QObject::connect(titleLabel, &QPushButton::clicked, [this]
{
toggleButton->click();
});
Disclaimer: I have no idea if that is the correct way to do this.
I've got an app that uses a Toolbar in a NSWindow. I don't want users to be able to customize this toolbar for aesthetic reasons. In Sierra there's a new Menu option that gets inserted into "Menu > View" called Show Tab Bar. How do I disable this? Enabling it only seems to increase the tool bar's height as I don't have extra labels showing under the icons.
You can also do this on IB, on the Window’s attributes inspector
On 10.12, you need to now set the following when the window is created as Tab Bar is now available by default:
[NSWindow setAllowsAutomaticWindowTabbing: NO];
The answer is the same in Swift and SwiftUI
func applicationWillFinishLaunching(_ notification: Notification) {
NSWindow.allowsAutomaticWindowTabbing = false
}
Note that the call is made on the class NSWindow not on an instance of NSWindow
To disable tabbing on individual windows call setTabbingMode:
if([window respondsToSelector:#selector(setTabbingMode:)]) {
// this particular window doesn't support tabbing in Sierra.
[window setTabbingMode:NSWindowTabbingModeDisallowed];
}
If you don't want to compile against the latest frameworks, you can use the following code in your NSWindowsController sub classes:
Swift:
override func awakeFromNib() {
if NSAppKitVersionNumber > 1500 {
self.window?.setValue(2, forKey: "tabbingMode")
}
}
Objective-C:
- (void)awakeFromNib {
if (NSAppKitVersionNumber > 1500) {
[self.window setValue:[NSNumber numberWithInt:2] forKey:#"tabbingMode"];
}
}
Swift solution:
override func awakeFromNib() {
super.awakeFromNib()
if #available(OSX 10.12, *) {
tabbingMode = .disallowed
}
}
Swift 5
In your NSWindowController:
self.window?.tabbingMode = .disallowed
I embed SVG graphics in my Flex application using
package MyUI
{
public class Assets
{
[Embed(source="/assets/pic.svg"]
[Bindable]
public static var svgPic:Class;
}
}
and then extending the Tree class with some of my own code, setting the icon upon adding a node to the data provider:
public class MyTree extends Tree
{
public function MyTree()
{
// ...
this.iconField = "svgIcon";
// ...
this.dataProvider = new ArrayCollection;
this.dataProvider.addItem({ /* ... */ svgIcon: MyUI.Assets.svgPic /* ... */ });
// ...
}
}
Now I have two things I want to do:
use the SVG graphics in multiple places in the app, scaling them to the appropriate size for each appearance, i. e. scale them to a proper icon size when using them in the tree
change the size of the icon at runtime, e. g. display a slightly larger icon for selected items or let an icon "pulse" as a response to some event
I read the Flex documentation on the 9-slice scaling properties in the Embed tag, but I think that's not what I want.
Edit:
I unsuccessfully checked the "similar questions" suggested by SO, among others this one:
Flex: Modify an embedded icon and use it in a button?
Subclass mx.controls.treeClasses.TreeItemRenderer and make it resize the icon to your desired dimensions, or create your own item renderer implementation by using the same interfaces as TreeItemRenderer. Set a custom item renderer with the itemRenderer property:
exampleTree.itemRenderer = new ClassFactory( ExampleCustomItemRendererClass );
The answer to this question might point you in the right direction, without knowing more about the trouble you're having:
Flex: Modify an embedded icon and use it in a button?
Hope it helps!