Merge pull request #72 from chrik5/quicktag
first version of a quicktag modul
This commit is contained in:
84
contrib/de_DE/LC_MESSAGES/quicktag.po
Normal file
84
contrib/de_DE/LC_MESSAGES/quicktag.po
Normal file
@@ -0,0 +1,84 @@
|
||||
# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
|
||||
# This file is distributed under the same license as the PACKAGE package.
|
||||
#
|
||||
# Christian Kanzian <christian.kanzian@gmx.at>, 2017.
|
||||
msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: \n"
|
||||
"Report-Msgid-Bugs-To: \n"
|
||||
"POT-Creation-Date: 2017-02-20 17:38+0100\n"
|
||||
"PO-Revision-Date: 2017-02-20 17:50+0100\n"
|
||||
"Last-Translator: Christian Kanzian <christian.kanzian@gmx.at>\n"
|
||||
"Language-Team: German <kde-i18n-de@kde.org>\n"
|
||||
"Language: de\n"
|
||||
"MIME-Version: 1.0\n"
|
||||
"Content-Type: text/plain; charset=UTF-8\n"
|
||||
"Content-Transfer-Encoding: 8bit\n"
|
||||
"Plural-Forms: nplurals=2; plural=(n != 1);\n"
|
||||
"X-Generator: Lokalize 1.5\n"
|
||||
|
||||
#: quicktag.lua:64
|
||||
msgid "max. length of button labels"
|
||||
msgstr "Max. Länge der Schaltflächen-Beschriftung"
|
||||
|
||||
#: quicktag.lua:65
|
||||
msgid "may range from 15 to 60 - needs a restart"
|
||||
msgstr "Bereich von 15 bis 60 möglich - Neustart erforderlich"
|
||||
|
||||
#: quicktag.lua:78
|
||||
msgid "number of quicktag fields"
|
||||
msgstr "Anzahl von quicktag Feldern"
|
||||
|
||||
#: quicktag.lua:79
|
||||
msgid "may range from 2 to 20 - needs a restart"
|
||||
msgstr "Bereich von 2 bis 20 möglich - Neustart erforderlich"
|
||||
|
||||
#: quicktag.lua:119
|
||||
#, lua-format
|
||||
msgid "quicktag %i is empty, please set a tag"
|
||||
msgstr "quicktag %i ist leer - bitte Tag eingeben"
|
||||
|
||||
#: quicktag.lua:134
|
||||
msgid "no images selected"
|
||||
msgstr "keine Bilder ausgewählt"
|
||||
|
||||
#: quicktag.lua:144
|
||||
#, lua-format
|
||||
msgid "tag \"%s\" attached to %i image(s)"
|
||||
msgstr "Tag \"%s\" an %i Bild(er) angehängt"
|
||||
|
||||
#: quicktag.lua:165
|
||||
msgid "old quicktag"
|
||||
msgstr "Alter quicktag"
|
||||
|
||||
#: quicktag.lua:166
|
||||
msgid "select the quicktag to replace"
|
||||
msgstr "Wähle den quicktag der ersetzt werden soll"
|
||||
|
||||
#: quicktag.lua:182 quicktag.lua:206
|
||||
msgid "new quicktag"
|
||||
msgstr "Neuer quicktag"
|
||||
|
||||
#: quicktag.lua:185
|
||||
msgid "enter your tag here"
|
||||
msgstr "Bitte Tag hier eingeben"
|
||||
|
||||
#: quicktag.lua:189
|
||||
msgid "set quicktag"
|
||||
msgstr "Setze Tag"
|
||||
|
||||
#: quicktag.lua:193
|
||||
msgid "new quicktag is empty!"
|
||||
msgstr "Neuer Tag ist leer!"
|
||||
|
||||
#: quicktag.lua:197
|
||||
#, lua-format
|
||||
msgid "quicktag \"%s\" replaced by \"%s\""
|
||||
msgstr "quicktag \"%s\" ersetzt durch \"%s\" "
|
||||
|
||||
#: quicktag.lua:246
|
||||
#, lua-format
|
||||
msgid "quicktag %i"
|
||||
msgstr "quicktag %i"
|
||||
|
||||
|
||||
251
contrib/quicktag.lua
Normal file
251
contrib/quicktag.lua
Normal file
@@ -0,0 +1,251 @@
|
||||
--[[
|
||||
This file is part of darktable,
|
||||
Copyright (C) 2017 by Christian Kanzian
|
||||
|
||||
Thanks to
|
||||
Copyright (C) 2016 Bill Ferguson
|
||||
Copyright (C) 2017 Tobias Jakobs
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
]]
|
||||
|
||||
--[[
|
||||
QUICKTAG
|
||||
For faster attaching your favorite tags, the script adds shortcuts and
|
||||
the module "quicktag" in lighttable mode with a changeable number of buttons.
|
||||
To each button a tag can be assigned. If the tags do not exist in your database,
|
||||
they are added to the database once they get the first time attached to an image.
|
||||
|
||||
The number of buttons/shortcuts can be changed in the lua preferences.
|
||||
Changes in the number require a restart of darktable.
|
||||
|
||||
INSTALATION
|
||||
* copy this file in $CONFIGDIR/lua/ where CONFIGDIR is your darktable configuration directory
|
||||
* add the following line in the file $CONFIGDIR/luarc require "quicktag"
|
||||
|
||||
USAGE
|
||||
* set the number of quicktags between 2 and 10 in the preferences dialog and restart darktable
|
||||
* if wanted set the shortcuts in the preferences dialog
|
||||
* to add or change a quicktag, first select the old tag with the combobox "old quicktag",
|
||||
enter a new tag in the "new quicktag" filed and press "set quicktag"
|
||||
* use a shortcut or button to attach the tag to selected images
|
||||
]]
|
||||
|
||||
|
||||
local dt = require "darktable"
|
||||
local debug = require "darktable.debug"
|
||||
|
||||
|
||||
local gettext = dt.gettext
|
||||
|
||||
dt.configuration.check_version(...,{3,0,0},{4,0,0},{5,0,0})
|
||||
|
||||
-- Tell gettext where to find the .mo file translating messages for a particular domain
|
||||
gettext.bindtextdomain("quicktag",dt.configuration.config_dir.."/lua/")
|
||||
|
||||
local function _(msgid)
|
||||
return gettext.dgettext("quicktag", msgid)
|
||||
end
|
||||
|
||||
-- maximum length of button labels
|
||||
dt.preferences.register("quickTag",
|
||||
"labellength",
|
||||
"integer", -- type
|
||||
_("max. length of button labels"), -- label
|
||||
_("may range from 15 to 60 - needs a restart"), -- tooltip
|
||||
25, -- default
|
||||
15, -- min
|
||||
60)
|
||||
|
||||
|
||||
|
||||
local max_label_length = dt.preferences.read("quickTag", "labellength", "integer")
|
||||
|
||||
-- register number of quicktags
|
||||
dt.preferences.register("quickTag",
|
||||
"quickTagnumber",
|
||||
"integer", -- type
|
||||
_("number of quicktag fields"), -- label
|
||||
_("may range from 2 to 20 - needs a restart"), -- tooltip
|
||||
5, -- default
|
||||
2, -- min
|
||||
20)
|
||||
|
||||
local qnr = dt.preferences.read("quickTag", "quickTagnumber", "integer")
|
||||
|
||||
|
||||
|
||||
-- get quicktags from the preferences
|
||||
local quicktag_table = {}
|
||||
|
||||
|
||||
local function read_pref_tags()
|
||||
for j=1,qnr do
|
||||
quicktag_table[j] = dt.preferences.read("quickTag", "quicktag"..j, "string")
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
local quicktag_label = {}
|
||||
|
||||
|
||||
local function abbrevate_tags(t)
|
||||
for i=1,qnr do
|
||||
local taglength = string.len(t[i])
|
||||
if taglength > max_label_length then
|
||||
local max_2 = math.floor(max_label_length/2)
|
||||
quicktag_label[i] = string.sub(t[i],0,max_2).."..."..string.sub(t[i],taglength - max_2)
|
||||
else
|
||||
quicktag_label[i] = t[i]
|
||||
end
|
||||
-- print(quicktag_label[i])
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
-- quicktag function to attach tags
|
||||
local function tagattach(tag,qtagnr)
|
||||
if tag == "" then
|
||||
dt.print(string.format(_("quicktag %i is empty, please set a tag"), qtagnr))
|
||||
return true
|
||||
end
|
||||
|
||||
local tagnr = dt.tags.find(tag)
|
||||
|
||||
--create tag if it does not exist
|
||||
if tagnr == nil then
|
||||
dt.tags.create(tag)
|
||||
tagnr = dt.tags.find(tag)
|
||||
end
|
||||
|
||||
local sel_images = dt.gui.action_images
|
||||
|
||||
if next(sel_images) == nil then
|
||||
dt.print(_("no images selected"))
|
||||
return true
|
||||
end
|
||||
|
||||
local counter = 0
|
||||
|
||||
for _,image in ipairs(sel_images) do
|
||||
dt.tags.attach(tagnr,image)
|
||||
counter = counter+1
|
||||
end
|
||||
dt.print(string.format(_("tag \"%s\" attached to %i image(s)"), tag, counter))
|
||||
end
|
||||
|
||||
|
||||
-- create quicktag module elements
|
||||
-- read tags from preferences for initialization
|
||||
read_pref_tags()
|
||||
abbrevate_tags(quicktag_table)
|
||||
|
||||
|
||||
local button = {}
|
||||
|
||||
-- function to create buttons with tags as labels
|
||||
for j=1,qnr do
|
||||
button[#button+1] = dt.new_widget("button") {
|
||||
label = j..": "..quicktag_table[j],
|
||||
clicked_callback = function() tagattach(tostring(quicktag_table[j]),j) end}
|
||||
end
|
||||
|
||||
|
||||
local old_quicktag = dt.new_widget("combobox"){
|
||||
label = _("old quicktag"),
|
||||
tooltip = _("select the quicktag to replace")
|
||||
}
|
||||
|
||||
local function update_quicktag_list()
|
||||
-- abrevate long tags for the labels
|
||||
abbrevate_tags(quicktag_table)
|
||||
for j=1,qnr do
|
||||
button[j].label = j..": "..quicktag_label[j]
|
||||
old_quicktag[j] = j..": "..quicktag_table[j]
|
||||
end
|
||||
end
|
||||
|
||||
update_quicktag_list()
|
||||
|
||||
local new_quicktag = dt.new_widget("entry"){
|
||||
text = "",
|
||||
placeholder = _("new quicktag"),
|
||||
is_password = true,
|
||||
editable = true,
|
||||
tooltip = _("enter your tag here")
|
||||
}
|
||||
|
||||
local set_quicktag_button = dt.new_widget("button") {
|
||||
label = _("set quicktag"),
|
||||
clicked_callback = function()
|
||||
local old_tag = quicktag_table[old_quicktag.selected]
|
||||
if new_quicktag.text == "" then
|
||||
dt.print(_("new quicktag is empty!"))
|
||||
else
|
||||
quicktag_table[old_quicktag.selected] = new_quicktag.text
|
||||
dt.preferences.write("quickTag", "quicktag"..old_quicktag.selected, "string", new_quicktag.text)
|
||||
dt.print(string.format(_("quicktag \"%s\" replaced by \"%s\""), old_tag, new_quicktag.text))
|
||||
update_quicktag_list()
|
||||
new_quicktag.text = ""
|
||||
end
|
||||
end,
|
||||
}
|
||||
|
||||
local new_qt_widget = dt.new_widget ("box") {
|
||||
orientation = "horizontal",
|
||||
dt.new_widget("label") { label = _("new quicktag") },
|
||||
new_quicktag,
|
||||
set_quicktag_button
|
||||
}
|
||||
|
||||
|
||||
-- back UI elements in a table
|
||||
-- thanks to wpferguson for the hint
|
||||
local widget_table = {}
|
||||
|
||||
for i=1,qnr do
|
||||
widget_table[#widget_table + 1] = button[i]
|
||||
end
|
||||
|
||||
widget_table[#widget_table + 1] = dt.new_widget("separator"){}
|
||||
widget_table[#widget_table + 1] = old_quicktag
|
||||
widget_table[#widget_table + 1] = new_qt_widget
|
||||
|
||||
|
||||
--create module
|
||||
dt.register_lib(
|
||||
"quicktag", -- Module name
|
||||
"quicktag", -- name
|
||||
true, -- expandable
|
||||
false, -- resetable
|
||||
{[dt.gui.views.lighttable] = {"DT_UI_CONTAINER_PANEL_RIGHT_CENTER", 490}},
|
||||
|
||||
dt.new_widget("box"){
|
||||
orientation = "vertical",
|
||||
table.unpack(widget_table),
|
||||
|
||||
},
|
||||
nil,-- view_enter
|
||||
nil -- view_leave
|
||||
)
|
||||
|
||||
-- create shortcuts
|
||||
for i=1,qnr do
|
||||
dt.register_event("shortcut",
|
||||
function(event, shortcut) tagattach(tostring(quicktag_table[i])) end,
|
||||
string.format(_("quicktag %i"),i))
|
||||
end
|
||||
|
||||
-- vim: shiftwidth=2 expandtab tabstop=2 cindent syntax=lua
|
||||
-- kate: tab-indents: off; indent-width 2; replace-tabs on; remove-trailing-space on;
|
||||
Reference in New Issue
Block a user