How can I set the title of non-main-windows in an NSDocument application? - nswindow

I am working on a document-based OSX application, with master-detail style windows. I understand how to open additional windows, to display additional information, by using -makeWindowControllers and adding extra window controllers, but I can't set the title of the new windows. I have tried using -setTitle and -windowTitleForDocumentDisplayName in both Document.m and in my sub-classed window controller class, but I can't get the window title to change.
How do I change the title of non-main-windows, which have a sub-classed window controller, in an NSDocument based application?
EDIT: I know there are some suggestions on SO about using an IBOutlet to the window to do this, but surely the window controller has a reference to its window anyway, right?

Related

How to control size of FileChooser dialog in JavaFX

I want to set FileChooser dialog preferred size. For now, it cannot be set and just appears with fixed size always (occupied with almost full screen). I can't find resizing method in FileChooser intance and even control dialog after it appears.
I don't think that this is possible. The documentation of FileChooser states
Provides support for standard platform file dialogs. (...) The configuration of the displayed dialog is controlled by the values of the FileChooser properties set before the corresponding show*Dialog method is called. This configuration includes the dialog's title, the initial directory displayed in the dialog and the extension filter(s) for the listed files.
The popup dialog is provided by your operating system, so it cannot be customized directly. Your only option is using the bit of API that the FileChooser class itself provides. Since JavaFX is a cross platform UI framework, the customization options probably have been limited to the ones that are supported natively by all major platforms.
If you absolutely must customize the file chooser, you can try to embed a Swing JFileChooser in your JavaFX app.
As noted here, the JavaFX FileChooser is provided by the host platform. In particular, "For configuration properties which values haven't been set explicitly, the displayed dialog uses their platform default values." Presumably, this includes size.
On macOS, Java/FX 17 LTS, if you resize the dialog, the new dialog size is saved as a preference; when invoked again, the last used dialog size is restored.
Please feel free to add your user experience on other platforms. This FileChooserDemo can be used for testing.

How to make the top QWidget modal?

I'm developing an application in PyQT5 which has a QWidget object on the top. This application needs to be able to run in 'kiosk' mode, so my aim is to make that top QWidget modal and prevent any other running application of being focused.
The skeleton of the main class is below. Note that I'm calling the setWindowModality() method which in theory sets the behavior of the window to the chosen one:
class MyApp(QWidget):
def __init__(self):
QWidget.__init__(self)
self.setWindowModality(3)
My main method is the following:
app = QApplication(sys.argv)
MyApp()
sys.exit(app.exec_())
As per the setWindowModality() method documentation:
Qt.NonModal 0 The window is not modal and does not block input to other windows.
Qt.WindowModal 1 The window is modal to a single window
hierarchy and blocks input to its parent window, all grandparent
windows, and all siblings of its parent and grandparent windows.
Qt.ApplicationModal 2 The window is modal to the application and
blocks input to all windows.
The problem is that the window is not modal at all, I can switch to a different application (say a Web browser), which is exactly what I want to prevent. I've also tried 1, 2, 3 as values and they produce the same behavior.
I'm afraid this could be a design restriction in order to avoid apps block other apps, but I'm not sure of it and I'm unable to confirm it.
Am I missing something obvious here? In case the problem is the design restriction, is there a way to still simulate a modal window?
Modality is only with respect to current application. If application has only one open top level window, then there's no difference between application and window modal. This modality has no effect on other applications, so you are not able to achieve what you want with it, there's no simple "desktop modal" flag.
You can use Qt to make the window full screen, but you have to use other means to prevent user from accessing the desktop, or closing the app (often bound to ALT-F4 keyboard shortcut). If your platform is Windows, then I don't know how to do that, but I'm sure there's a way. Under X11 (used on Linux usually), the most straightforward way to do that is not have a desktop at all, simply by just running the app without desktop. Look up nodm package for an easy way to do this.

Application viewer setfullscreen function not hiding ubuntu sidebar

I'm building the UI for an application using Qt and QML for Ubuntu Linux. I have a viewer window with a canvas element which is supposed to be fullscreen by default. On opening the application this works fine (i.e. Ubuntu sidebar and top taskbar are hidden). However, once I minimize my application and then maximize it again by using viewer->setFullScreen();, the Ubuntu sidebar and top taskbar are still visible and there is an offset while writing on the canvas due to the same.
Any help would be appreciated.
According to this topic on askubuntu, your problem do really looks like Unity bug (or feature). But, according to somehow related bug on Launchpad, it seems that you can get desired behavior by:
Turn "Always On Top" on via right-clicking the titlebar of your window, before making it go fullscreen.
This will prevent the Unity panel from rendering on top of this fullscreen-window, when using the other screen.
In Qt you can set Qt::WindowStaysOnTopHint to your window/widget via QWidget::windowFlags.
Pay additional attention to notes in official documentation:
This function calls setParent() when changing the flags for a window, causing the widget to be hidden. You must call show() to make the widget visible again.
About Qt::WindowStaysOnTopHint -- Informs the window system that the window should stay on top of all other windows. Note that on some window managers on X11 you also have to pass Qt::X11BypassWindowManagerHint for this flag to work correctly.
Hope this helps.

how to get a "lightbox" like behaviour in Qt

I have a Qt project where I'm using QGraphicsView framework, also I have popup windows on the scenes. (QDialogs)
When someone clicks on a certain button a popup window appears, and I'm invoking it with the .exec() method instead of .show() to make it the active one. Also I want to give it a visual effect like lightbox provides for html pages, so it would be obvious for the user too, that the background window won't communicate. Do you know any simple solution to make it work? or is it hard to implement in Qt?
EDIT: I don't know if it's obvious of not, but it's a desktop application, not a web application.
Just create QFrame over necessary area with customized background and transparency. For animation effect you may use QPropertyAnimation + QGraphicEffects and other stuff from qt animation framework.
Now I found another way to accomplish what I wanted. Like this:
QWidget* mytranswidget = new QWidget(mybgwidget);
mytranswidget->setStyleSheet( "background:transparent; background-color:rgba(0,0,0‌​,95)");
mytranswidget->setWindowFlag(Qt::FramelessWindowHint);
mytranswidget->setGeometry(mybgwidget->rect());
mytranswidget->show();
I'm doing it at the beginning of my popup widget's constructor so it's being drawn before draw my popup, so it will be shown in the right order.

Air application created with Flex - How do I create a fly-out window to the left/right

I have an Air application with a main window. I would like to have a new window fly out from the side of the main window when the user clicks on a button in the main window. The window that appears needs to display information based on value passed from the main form. How can I achieve this with Flex Builder 3?
Target platform: any version of Flash/Flex/Air.
You'll probably want to use view states. Check out the Flex in one Week video tutorial on "Creating View States":
http://www.adobe.com/devnet/flex/videotraining/
What you want to do is what tweenMax was made for. it's a .swc that you add into your project. It will allow you to use the tweenLite (or tweenMax) command.
import com.greensock.*;
TweenLite.to(mc, 1, {x:65, y:117});
So you would say if your stage was 500 px wide and you want the box to come in from the right. Add the child at maybe 505, and then tween.to whatever x value you want. Yep. it's that easy. And the other parameters are for duration and easing and even alpha so you have control over that too. They even have a swf in the website so you an play with it and practice. http://www.greensock.com/tweenmax/

Resources