GithubHelp home page GithubHelp logo

Comments (40)

alphaonex86 avatar alphaonex86 commented on July 27, 2024

I can be do, at compil time or runtime?

Then how monitor a file... How detect a valid keybinding for Gtk?
If it can be done into a plugin it's better.
I can release it for the Ultracopier version 1.2, at the same time of Qt 5.4 requirements

Ideally it's have an API like Windows file explorer to catch the copy/move request and send it to external program. We could imagine the dbus plugins for ultracopier, what I have do before, but not maintained. I prefer clearly this way, Ultracopier is responsive only of the transfer.
Note: nobody is according with interface to provide, it's why ability to replace is so important.

from ultracopier.

 avatar commented on July 27, 2024

No, sorry for my english. I explain what i do in the script... Ofcourse you don't need to use Gtk.accelerator_valid, this is done in the script, i only tell you, that if you don't want allow user to select some types of key binding, you need to filter the user decisions.

You can use a Dbus iface, but in my opinion it's not needed only for send a keybindings and the list of files...

The problem it's that the extentions script don't have a GUI, so user can not change the keybindings in a graphical mode. You can see in the images what i request you. This component allow user to select the correct keybindings in fact.... See the documentation:
http://qt-project.org/doc/qt-4.8/qshortcut.html

The Qt and Gtk keybinding format aparently are not the same, so if can be easy for you, will be better send the keybindings in the gtk format. Any way, I can try convert the format if it's difficult in Qt. Or maybe Qt also understand Gtk and the inverse case...

About the monitor:
http://qt-project.org/doc/qt-4.8/qfilesystemwatcher.html

captura de pantalla de 2014-11-13 18 06 06

from ultracopier.

 avatar commented on July 27, 2024

In resume, the only thing that it's needed it's a graphical way to configure the key bindings and a way to know the keybinding selected by the user, to be apply.

from ultracopier.

alphaonex86 avatar alphaonex86 commented on July 27, 2024

Ok, now I understand. I'm not a native english speaker too.
All the plugins mecanism is ready to add cleanly this options.
But like you have say: The Qt and Gtk keybinding format aparently are not the same -> how do cleanly the bridge?

from ultracopier.

 avatar commented on July 27, 2024

Ultracopier it's not released with a keybinding, for now it's more easy to user used the standar Gtk way to write a keybinding directly in my file... I propose forget that my current file exist and generate a new one or pass the data using dbus, or using dConfig or gConfig (like you want)...

In my opinion there are not an standar way to share the keybinding, but there are a native way... I propose you using the keycodes(I guess that need to be the same keycode in gtk and in Qt).

http://stackoverflow.com/questions/14034209/convert-string-representation-of-keycode-to-qtkey-or-any-int-and-back

We can have a list of keys where the last one will be the key, and the others the modifiers (but the key code, NOT the key name)... So, key code can be translate in to a keyname easy, and sure will be the same for gtk and qt. You can use as a separator, the current separator of QKeySequences, or what you want.

from ultracopier.

 avatar commented on July 27, 2024

If you use Dbus or a file, or any other, you need to have a mechanism to be recover for an error (example: valid QT keybinding, are not allowed in Gtk). This is why i recommended you monitor the file, because in the case of an error in gtk, i will rewrite the file with the old keybindings, and ultracopier need to know what happend to refresh this value again, or the user will be lost.

from ultracopier.

 avatar commented on July 27, 2024

I recommended the file, because can be write on home folder, and in multiuser environment have a global config will create problems...

from ultracopier.

 avatar commented on July 27, 2024

This is the information that we need:
Edit:
http://qt-project.org/doc/qt-4.8/qkeysequence.html#StandardKey-enum

from ultracopier.

 avatar commented on July 27, 2024

I can confirm you that key name are not the same in gtk and in qt...

Example:

Qt shortcut: Ctrl+V
Gtk shortcut: <Control>V

We need to use the key code (The numeric value in this table) http://qt-project.org/doc/qt-4.8/qkeysequence.html#StandardKey-enum

from ultracopier.

alphaonex86 avatar alphaonex86 commented on July 27, 2024

http://files.first-world.info/temp/keybindig.tar.xz simple example, with single key bind, it's application, but I can transform into plugin later.

from ultracopier.

 avatar commented on July 27, 2024

I you try to do:
Qt::Key key = Qt::ControlModifier;

You will recive an error:

MainWindow.cpp:60: error: cannot convert 'Qt::KeyboardModifier' to 'Qt::Key' in initialization
Qt::Key key = Qt::ControlModifier;
^
We don't have any problem with normal keys, they have the same format...The problem will be the modifier... I try to pass the modifier values without any good result. Apparently we need to understand better how we can do an interpretation of hardware codes, and how qt and gtk will use the hardware code...

from ultracopier.

 avatar commented on July 27, 2024

I think we're wasting time here. Qt only has this list of keyboard modifiers:
http://qt-project.org/doc/qt-4.8/qt.html#KeyboardModifier-enum

And gtk only have this as modifier:
http://www.pygtk.org/pygtk2reference/gdk-constants.html#gdk-modifier-constants

When we remove the modifier for the mouse buttons it's more less the same list and it's really short.

Aditional to this fact, if i want to translate the keyboard state in Gtk i need to have the state(The modifier), I can not have acces to the keyboard state of a qt application in the script. Will be more easy parse the Qt keyboard format in a gtk application than the keycodes...

Please use the normal hotkey in Qt format (Ctrl+V) and i will translate this to gtk format... Also i see that is the same <Ctrl>V and <Control>V in Gtk, so it' also more easy...

from ultracopier.

 avatar commented on July 27, 2024

The only thing will be, not allowed user to select multiple keybinds at the same time for the same action.... They are separated by "," in QT.
captura de pantalla de 2014-11-16 02 30 35

from ultracopier.

 avatar commented on July 27, 2024

A gtk reader for ultracopier in qt format:

#! /usr/bin/python
#  -*- coding: utf-8 -*-

# UltraCopier-key-reader
#==========================
#
# An utility to read key code from ultracopier.
#
# Author: Lester Carballo Pérez([email protected])

from gi.repository import Gtk, Gdk, GObject, Gio
import os

KEY_ACCEL = "Ctrl+U"
FILE_KEY = ".config/ultracopier-keybind.conf"

class KeyCodeReader:
    def __init__(self):
        self.window = Gtk.Window()
        self.window.connect("destroy", self.on_destroy)
        self.label = Gtk.Label("None")
        self.window.add(self.label)
        self.window.show()
        self.label.show()
        self.call_timeout = 0
        path = os.path.join(os.path.expanduser("~"), FILE_KEY)
        if os.path.isfile(path):
            self.key_file = Gio.File.new_for_path(path)
            self.monitor = self.key_file.monitor_file(Gio.FileMonitorFlags.NONE, None)
            self.monitor_id = self.monitor.connect("changed", self.on_monitor_change_file)
            self.try_to_show()
        else:
            self.restore_accel(KEY_ACCEL)

    def try_to_show(self):
        key_code_string = self.read_key_from_file()
        if key_code_string != "":
            key, mods = Gtk.accelerator_parse(key_code_string)
            if Gtk.accelerator_valid(key, mods):
                self.label.set_text(key_code_string)
            else:
                self.restore_accel(KEY_ACCEL)
        else:
            self.restore_accel(KEY_ACCEL)

    def on_monitor_change_file(self, monitor, file, o, event):
        if self.call_timeout == 0:
            self.call_timeout = GObject.timeout_add(100, self.on_change_key)

    def on_change_key(self):
        if self.call_timeout > 0:
            GObject.source_remove(self.call_timeout)
            self.call_timeout = 0
        self.try_to_show()

    def read_key_from_file(self):
        path = self.key_file.get_path()
        if os.path.isfile(path):
            file = open(path, "r")
            key_name = file.readline().rstrip()
            file.close()
        key_name_gtk = self.translate_format_to_gtk(key_name)
        return key_name_gtk

    def restore_accel(self, accel):
        '''Called when the user select a wrong keybindings'''
        accel = self.translate_format_to_qt(accel)
        if self.monitor_id > 0:
            self.monitor.disconnect(self.monitor_id)
        path = self.key_file.get_path()
        if os.path.isfile(path):
            file = open(path, "w")
            file.seek(0)
            file.write("%s" %(accel))
            file.truncate()
            file.close()
        else:
            file = open(path, "w")
            file.write("%s" %(accel))
            file.close()
        dialog = Gtk.MessageDialog(None, Gtk.DialogFlags.MODAL, Gtk.MessageType.INFO, Gtk.ButtonsType.OK)
        accel = accel.replace("<", "&lt;").replace(">", "&gt;")
        msg = "The current shortcut key is not valid, we return to use '%s' as a shortcut key."%(accel)
        dialog.set_markup("<b>%s</b>" % msg)
        dialog.run()
        dialog.destroy()
        self.monitor_id = self.monitor.connect("changed", self.on_monitor_change_file)

    def translate_format_to_gtk(self, key_name):
        translate_accel = ""
        list_accel = key_name.split(",")
        if (len(list_accel) > 0):
            list_keys = list_accel[0].split("+")
            number_keys = len(list_keys)
            for pos, val in enumerate(list_keys):
               if(pos != number_keys - 1):
                   translate_accel += "<" + val + ">"
               else:
                   translate_accel += val
        return translate_accel

    def translate_format_to_qt(self, key_name):
        translate_accel = ""
        list_accel = key_name.split(">")
        number_keys = len(list_accel)
        if (number_keys > 0):
            for pos, val in enumerate(list_accel):
               if val[0] == "<":
                   val = val[1:]
               if val == "Control":
                   val = "Ctrl"
               if pos != number_keys - 1:
                   translate_accel += val + "+"
               else:
                   translate_accel += val
        return translate_accel

    def on_destroy(self, *arg):
        if self.call_timeout > 0:
            GObject.source_remove(self.call_timeout)
            self.call_timeout = 0
        Gtk.main_quit()

if __name__ == "__main__":
    KeyCodeReader()
    Gtk.main()

from ultracopier.

 avatar commented on July 27, 2024

Meta (Super), don't work well, need to be added also Qt::Key_Super_R and Qt::Key_Super_L:

 QList<int> modifier = QList<int>() << Qt::Key_Control << Qt::Key_Shift << Qt::Key_Meta  << Qt::Key_Super_R << Qt::Key_Super_L << Qt::Key_Alt << Qt::Key_AltGr;

from ultracopier.

alphaonex86 avatar alphaonex86 commented on July 27, 2024

Hello, the program is done into Qt5 only (no KDE widget, like Ultracopier). Tested with version Qt 5.2.
Sorry but I don't understand the python?

from ultracopier.

 avatar commented on July 27, 2024

I sent you a python script to test the integration... Because clear i can not test any thing without the missing .pro Some time ago I was try to reconstruct all your .pro from ultracopier, but I got tired trying.

I don't understand what do you say... I can test the integration when you release your new version or if you provide me a test version (binary) for ubuntu or if you made a separate application that also work equal to the same of how will work ultracopier...

You received the email that i sent you?

from ultracopier.

alphaonex86 avatar alphaonex86 commented on July 27, 2024

http://files.first-world.info/temp/keybindig.tar.xz -> you have the need here. Do it here no more. When it work here I will integrate into Ultracopier.

No I don't have receive you mail, maybe I have missing it.

from ultracopier.

 avatar commented on July 27, 2024

Test what happen with this seccuense:
Ctrl+Shift+U
Ctrl+Shift+T
Ctrl+Shift+Y

from ultracopier.

 avatar commented on July 27, 2024

This not occurs always, but sometime i get this:
captura de pantalla de 2014-11-17 06 53 44

from ultracopier.

alphaonex86 avatar alphaonex86 commented on July 27, 2024

Strange, as you have see I use custom widget, I was display numeric code, because maybe a mask is here.

user@amber ~ $ python2.7 py.py
Traceback (most recent call last):
File "py.py", line 11, in
from gi.repository import Gtk, Gdk, GObject, Gio
ImportError: No module named gi.repository
user@amber ~ $ python3.3 py.py
Traceback (most recent call last):
File "py.py", line 11, in
from gi.repository import Gtk, Gdk, GObject, Gio
ImportError: No module named 'gi'

from ultracopier.

 avatar commented on July 27, 2024

python3-gi
python-gi

from ultracopier.

 avatar commented on July 27, 2024

Ok the modification that i send you by email and the tools on Gtk that do the same of the qt app (also in using QT format):
https://github.com/lestcape/ultracopier-keybinding

from ultracopier.

 avatar commented on July 27, 2024

if you write the file of hotkey in qt format, I can use the key binding, and it's working... Just we need that the qt tool can work... I try to do that, but i get the error that you can see in the last image...
I also have a tool:
https://github.com/lestcape/ultracopier-keybinding/blob/master/ultracopier_accel_changer.py

That can be merged with the extension as well, but i don't have a place to call this tools, yet.. Create another item in nautilus or nemo, it's not a good solution(but if the qt tool not work, will be).

from ultracopier.

alphaonex86 avatar alphaonex86 commented on July 27, 2024

https://github.com/lestcape/ultracopier-keybinding -> I never have this error :(

A Qt plugin can do the same as a normal application. All the plugin system is ready.
Like you can see, I'm not experienced into hotkey.
Actually your code is int Qt format. I can directly transform your code in plugins, it's not a problem for me. Then when you repositiry is ready, I will transform it into plugin. And I can execute command when the plugin is loaded, just need be put into the contructor.

from ultracopier.

 avatar commented on July 27, 2024

Ok, I add Super_L and Super_R to the list and move the list to .h... Just first test the code on valgrind memory analyzer and construct the plugins then, could be a problem of my Qt version... I hope.

I update this: https://github.com/lestcape/ultracopier-keybinding

from ultracopier.

 avatar commented on July 27, 2024

I will update the extension to work with this code, if you modify some thing, please let me know...

from ultracopier.

alphaonex86 avatar alphaonex86 commented on July 27, 2024

Repository updated:
https://github.com/alphaonex86/Ultracopier/tree/master/plugins-alternative/PluginLoader/ultracopier-keybinding

from ultracopier.

 avatar commented on July 27, 2024

I see you large update... please see that i update the qt aplication first: https://github.com/lestcape/ultracopier-keybinding/commit/c667e53beb80c858be07aff630257b8ed7047979

1- Construct an static list in the newKey method it's not correctly, i move this to the constructor, to be done one time only...
2- The current list don't include Super_L and Super_R so, keybindings with this modifier will fail...
3- The script https://github.com/alphaonex86/Ultracopier/blob/master/plugins-alternative/PluginLoader/ultracopier-keybinding/ultracopier_accel_changer.py it's not necessary, it's the same thing (an equivalent of the qt implementation that do the same, but in gtk).
4- The pluging that you are made, can not work without the nautilus/nemo extentions, and this is not include, and can not be include, because the extentions need to be provided in a separate package, because have several dependencies to other packages that need to be satisfied (this is why you can not run the script directly).
5- You need to be sure that the extentions is installed on the system, to enable the plugins then, or you will to change a file for nothing, if there are not an extention listening... but this is difficult, because there are more than one extentions, there are currently two. One for Nemo and another for Nautilus. Also could be implemented another extention for Caja (is another fork of Nautilus for the Mate Desktop).

from ultracopier.

 avatar commented on July 27, 2024

See also that nautilus and nemo can be installed on different linux distros, and i only provide a debian packages structure (compatible with launchpad), so if you want to be included in arch linux or fedora (for example), some one need to create the package for this distro... Do not think on an extension as some thing that you can include in your project, it's totally dependent on the browser and browser packages, so can not be universal for all forks of nautilus, and can not be include inside another app as a plugin, because it's currently a plugin of the browser.

from ultracopier.

 avatar commented on July 27, 2024

https://plus.google.com/104272811378318660742/posts/V4C5UgntgZh

from ultracopier.

 avatar commented on July 27, 2024

The only way that you have currently to enable the plugins or not it's check for the existence of the file ultracopier-keybind.conf when ultracopier is starting...

from ultracopier.

alphaonex86 avatar alphaonex86 commented on July 27, 2024

Done. The plugin is do by the internal application, then it's few bit external to packages management of linux, but if one distro wish include it, it will do the package.
I never do linux packages (I don't known how do work open build service), it's always the distro what contact me to do the packages when it need more informations.
PS: sorry, very busy on my professionnal work

from ultracopier.

 avatar commented on July 27, 2024

Thats ok... I only make packages for ubuntu(because it's the distro that i use). Please let me know when you release the new version of ultracopier, to test what happen...

Remember that you can delete the python file without a problem.

Many successes ...

from ultracopier.

alphaonex86 avatar alphaonex86 commented on July 27, 2024

No change into the pugin API, then this plugins can directly be compiled for the actual version 1.0.1.13.
I will release the new version after Qt 5.4, because it's a new requirements. Then not before 2 month...

Noted.

Thanks;

from ultracopier.

 avatar commented on July 27, 2024

Thanks to you... Nothing will can have sense without all your big and hard work and your decision to register ultracopier as GPL... It's a shame the position the people that currently are development the browsers for linux in general, in this case... Like on windows, will be better a transparent and native support (can not be). I also wrote to the nautilus email list without answer and i was created an issue report in nemo extensions without answer. Maybe some day...

from ultracopier.

alphaonex86 avatar alphaonex86 commented on July 27, 2024

Same for KDE, haiku OS, reactOS... here...

from ultracopier.

 avatar commented on July 27, 2024

If you want to arrive at ubuntu. Do not go directly, because it's a long way that involve also money... Go first to debian, on ubuntu then will be used the debian release... Is what currently happen.

from ultracopier.

alphaonex86 avatar alphaonex86 commented on July 27, 2024

The version 1.2 is oriented to that's ;). The problem with most distro is usage of Qt system lib, for the version 1.2, I will use Qt 5.4 only, that's will greatly help into the linux integration.

from ultracopier.

 avatar commented on July 27, 2024

Yes.... On arch linux is not worked...

from ultracopier.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.