How to check current language of awful.widget.keyboardlayout? - awesome-wm

On my awesomewm panel, I have added the keyboard layout object:
mykeyboardlayout = awful.widget.keyboardlayout()
It changes between two languages when I press Caps Lock:
localectl --no-convert set-x11-keymap gb,ara pc105 ,qwerty_digits grp:caps_toggle
How can I check in awesome which language is currently set ('ar' or 'gb') so that I can display a symbol instead of just text?

Related

Get the actual Qt window title, properly replacing the [*] placeholder

I need to get the visible title of a Qt top level window (or MDI subwindow), because I want to list window titles in different places just like they're visible for the user.
Consider a program that supports multiple top level editor windows (or an MDI area with similar purposes) that should list the titles of those windows, like a menu or an internal "window manager".
If I want to list those windows and also support the [*] placeholder for the windowModified property, their windowTitle() will return that annoying placeholder no matter of their state.
Unfortunately, the windowTitle feature is a bit abstract, for the following reasons:
due to the windowModified feature, it always returns the placeholder if it's set;
the [*] placeholder can be "escaped" with multiple, even occurrences, in order to actually display [*] in the window title: Title [*][*] will always be shown as Title [*] no matter the value of the windowModified property;
if the windowTitle property is an empty string (the default), it falls back to the windowFilePath property, which not only make it always include the [*] placeholder, but could also behave oddly in the rare case that property contains the [*] placeholder; while I realize that this is a very odd (and somehow irresponsible, assuming the system actually supports it) situation, I still want a reliable way to get the currently resulting window title, even in those rare (though "wrong") situations;
Is there a way to get the real title that Qt sets for the window, considering the above?
The best approach for top level windows (not MDI subwindows) is to use QWindow::title:
This property holds the window's title in the windowing system
The window title might appear in the title area of the window
decorations, depending on the windowing system and the window flags.
It might also be used by the windowing system to identify the window
in other contexts, such as in the task switcher.
How to obtain the QWindow?
If you already know the QWidget, you can use QWidget::windowHandle. Note that the QWindow object is only available for native widgets (f.ex. top level widgets, but not for MDI subwindow).
Another approach is to directly query for all the top level windows using QGuiApplication::topLevelWindows
MDI subwindow support?
As those MDI subwindows are not top level windows, the QWindow doesn't exists. So, this approach doesn't work in that case. Possible solutions are:
See #musicamente's answer, mimicking the Qt placeholder replacement procedure.
Create a Qt bug report to expose the resolved window title or alter the Qt source code yourself to do so and distribute it with your application.
There is no absolute and certain way to get the title that the OS will finally show in the title bar of a top level window.
As explained in the windowTitle documentation, some systems might support displaying the applicationDisplayName. Some highly customizable (Linux) OS might show an altered version of the provided title. There is almost no way to get the "final", displayed title, unless you want to dig into specific OS modules that interface with the Window Manager (and that might not be enough anyway, due to the high level of customization possible on *nix systems).
Considering that what's relevant for the OP is the "internal" window title (what Qt finally "relays" to the system), the solution is to implement what Qt actually does internally with qt_setWindowTitle_helperHelper().
Be aware that the Qt implementation is not perfect. There are some odd cases when specific combinations of the placeholder string are used. For instance:
using [*] [*] [*] as window title results in "[*]" being shown for an unmodified window and "* [*] *" otherwise;
with [*] [*][*] [*], the unmodified window title is " [*] [*]" (note the leading space) and the other is "* [*]* [*]"
While, as said above, the Qt implementation is far from perfect, what we're interested into is the actual window title relayed to the OS, so we must adhere to it, since the visual result is the important aspect, no matter whether it's "correct" or not.
Finally, remember that this implementation might become invalid in the future, in case Qt developers decide to change this behavior (and, I believe, they should).
The following code is a simple function that will return the actual window title relayed to the OS for a give widget, which can be used for any situation in which the visible title has to be displayed:
def realWindowTitle(widget):
title = widget.windowTitle()
placeHolder = '[*]'
if not placeHolder in title:
return title
phSize = len(placeHolder)
style = widget.style()
if (widget.isWindowModified()
and style.styleHint(
style.SH_TitleBar_ModifyNotification, None, widget)
# for PyQt6 or full Enum support use
# style.StyleHint.SH_TitleBar_ModifyNotification
):
replaceHolder = '*'
else:
replaceHolder = ''
index = title.find(placeHolder)
while index != -1:
index += phSize
count = 1
while title.find(placeHolder, index) == index:
count += 1
index += phSize
if count % 2: # odd number of [*] -> replace last one
lastIndex = title.rfind(placeHolder, 0, index)
title = (title[:lastIndex]
+ replaceHolder
+ title[lastIndex + phSize:])
index = title.find(placeHolder, index)
# return "escaped" sequences of the remaining double placeholders
return title.replace('[*][*]', placeHolder)

How to clear a text field using Robot Framework?

I'm using the Sikuli Library with Robot Framework to run tests for a local windows application. Most solutions online are selenium based but I believe that only to work for web applications.
Entering text has been fine for the empty fields when there isn't a default value concerned.
Currently, I'm dealing with a field that contains a default value of 5000 but I need to change it to 10.
Text Field:
So far I've tried things such as:
Double-clicking the field first to highlight then type over (Input Text single clicks and removes highlight anyway)
Single-Clicking as Input text single clicks itself (Does not happen fast enough to simulate a double click)
I will answer in Sikuli terms. You just execute Ctrl+a to select content of the cell and then type 10
type('a', KeyModifier.CTRL)
type('10)

what is the component typ or the domain of a button in abap

i searched the web for some hours but could not found anything to the topic,
neither in english "abap component typ of button" nor in german "abap komponententyp Drucktaste".
I want to create a structure in the dictonary which should contain some buttons,
which i add into a Dynpro via the "Dict/Programmfelder-Fenster F6" in the Screen Painter and have access in a report via "TABLES: structurename" resp. class that handle the process after input (pai) for me.
The idea is to have full controll of all events and fields in a controller like in the Design Pattern Model View Controll (MVC).
*&---------------------------------------------------------------------*
*& Module STATUS_2000 OUTPUT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
MODULE status_2000 OUTPUT. " PBO
SET PF-STATUS '2000'.
SET TITLEBAR '2000'.
caretaker->pbo( ).
ENDMODULE. " STATUS_2000 OUTPUT
*&---------------------------------------------------------------------*
*& Module USER_COMMAND_2000 INPUT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
MODULE user_command_2000 INPUT. " PAI
caretaker->pai( EXPORTING
iv_ok_code = ok_code ).
ENDMODULE. " USER_COMMAND_2000 INPUT
The handling for the default events like BACK, CANCEL and END which could be set in the PF-STATUS of the Dynpro and data components like e.g. UNAME (user name) and WERKS which can be easy added to a structure in the dictionary works fine that way.
Thanks in advance for any help.
Ok, here we go. I've got a solution.
I found the following help in german http://help.sap.com/saphelp_banking80/helpdata/de/d1/802352454211d189710000e8322d00/content.htm the same exist in english http://help.sap.com/saphelp_banking80/helpdata/en/d1/802352454211d189710000e8322d00/content.htm
If you add e.g. char1 or char7 into your dictionary structure and you add it in the screen painter to the dynpro you have the possibility to transform it into a button which have then the behaviour of a regular button.
To transform the char-input-field after adding it to the screen you need to double click it. A Popup window will appear (Screen Painter: Attribute).
At the bottom there is a section called Attribute with three tabs (Dict, Program, Display).
In tab program deselect "Inputfield".
In Screen Painter in menu bar: edit > convert > Pushbutton
(the field should now changed its look)
In Popup window "Screen Painter: Attribute" in tab program deselect outputfield
set the name/lable of the button above in the field text and the function code in the field FktCode
Now you have a button which is part of your structure and can be observed in your class.

Any keyboard shortcut to display Xcode's "Show Find Options"?

Xcode offers several key codes to open the Find (CMD-F) or Find and Replace (CMD-OPT-F) editor toolbar, but how can I get the Find Options to show without having to move my mouse over the magnifying glass and clicking (which takes forever, I misclick, and then have to select the menu item - ugh)?
I have not found a single key to do this, but just discovered that after using
CMD-F
or
CMD-OPT-F
that the Find search field has focus, and by tapping the
down arrow key
twice followed by a
Return key, that it opened (do again to close)!
I added a key code sequence to Butler so I can use a single key to do this, so use your favorite Macro program to do likewise.
EDIT: Just discovered this still works in Xcode 7, you just need to do 2 down-arrows followed by a return.

How do I set alternate keys for a given command?

Preferences is bound to command+, by default. Suppose I want to add an additional key binding so that F2 (for example) also binds to Preferences? It must be possible because a few of the standard commands have alternate keystrokes.
According to the docs this is possible, but only with text commands.
"To add a sequence to an existing one, click the Add (+) button and type the new sequence. This only works for text commands; you cannot assign more than one sequence to a menu command."
You can find that in "Xcode 4.2 Developer Lbrary / Tools & Languages / IDEs / Key Bindings Preferences Help / Customizing Keyboard Shortcuts"

Resources