Merge 0.4 branch to trunk
git-svn-id: https://svn.code.sf.net/p/keepassx/code/trunk@319 b624d157-de02-0410-bad0-e51aec6abb33
This commit is contained in:
@@ -34,13 +34,22 @@ void initAutoType(KeepassMainWindow* mainWin) {
|
||||
AutoTypeGlobalX11::AutoTypeGlobalX11(KeepassMainWindow* mainWin) : AutoTypeX11(mainWin) {
|
||||
wm_state = XInternAtom(dpy, "WM_STATE", true);
|
||||
windowRoot = XRootWindow(dpy, mainWin->x11Info().screen());
|
||||
shortcut.key = 0;
|
||||
focusedWindow = 0;
|
||||
oldCode = 0;
|
||||
oldMod = 0;
|
||||
//windowBlacklist << "kicker" << "KDE Desktop";
|
||||
classBlacklist << "desktop_window" << "gnome-panel"; // Gnome
|
||||
classBlacklist << "kdesktop" << "kicker"; // KDE 3
|
||||
classBlacklist << "Plasma"; // KDE 4
|
||||
classBlacklist << "xfdesktop" << "xfce4-panel"; // Xfce 4
|
||||
}
|
||||
|
||||
void AutoTypeGlobalX11::updateKeymap() {
|
||||
AutoTypeX11::updateKeymap();
|
||||
registerGlobalShortcut(shortcut);
|
||||
}
|
||||
|
||||
void AutoTypeGlobalX11::perform(IEntryHandle* entry, bool hideWindow, int nr, bool wasLocked){
|
||||
if (focusedWindow && (!hideWindow || wasLocked)) { // detect if global auto-type
|
||||
XSetInputFocus(dpy, focusedWindow, RevertToPointerRoot, CurrentTime);
|
||||
@@ -216,12 +225,15 @@ void AutoTypeGlobalX11::performGlobal(){
|
||||
}
|
||||
|
||||
bool AutoTypeGlobalX11::registerGlobalShortcut(const Shortcut& s){
|
||||
if (s.key==shortcut.key && s.ctrl==shortcut.ctrl && s.shift==shortcut.shift && s.alt==shortcut.alt && s.altgr==shortcut.altgr && s.win==shortcut.win)
|
||||
return true;
|
||||
if (s.key == 0)
|
||||
return false;
|
||||
|
||||
int code=XKeysymToKeycode(dpy, HelperX11::getKeysym(s.key));
|
||||
uint mod=HelperX11::getShortcutModifierMask(s);
|
||||
|
||||
if (s.key==shortcut.key && s.ctrl==shortcut.ctrl && s.shift==shortcut.shift && s.alt==shortcut.alt && s.altgr==shortcut.altgr && s.win==shortcut.win && code==oldCode && mod==oldMod)
|
||||
return true;
|
||||
|
||||
HelperX11::startCatchErrors();
|
||||
XGrabKey(dpy, code, mod, windowRoot, true, GrabModeAsync, GrabModeAsync);
|
||||
XGrabKey(dpy, code, mod | Mod2Mask, windowRoot, true, GrabModeAsync, GrabModeAsync);
|
||||
@@ -239,6 +251,8 @@ bool AutoTypeGlobalX11::registerGlobalShortcut(const Shortcut& s){
|
||||
else {
|
||||
unregisterGlobalShortcut();
|
||||
shortcut = s;
|
||||
oldCode = code;
|
||||
oldMod = mod;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -246,15 +260,14 @@ bool AutoTypeGlobalX11::registerGlobalShortcut(const Shortcut& s){
|
||||
void AutoTypeGlobalX11::unregisterGlobalShortcut(){
|
||||
if (shortcut.key==0) return;
|
||||
|
||||
int code=XKeysymToKeycode(dpy, HelperX11::getKeysym(shortcut.key));
|
||||
uint mod=HelperX11::getShortcutModifierMask(shortcut);
|
||||
|
||||
XUngrabKey(dpy, code, mod, windowRoot);
|
||||
XUngrabKey(dpy, code, mod | Mod2Mask, windowRoot);
|
||||
XUngrabKey(dpy, code, mod | LockMask, windowRoot);
|
||||
XUngrabKey(dpy, code, mod | Mod2Mask | LockMask, windowRoot);
|
||||
XUngrabKey(dpy, oldCode, oldMod, windowRoot);
|
||||
XUngrabKey(dpy, oldCode, oldMod | Mod2Mask, windowRoot);
|
||||
XUngrabKey(dpy, oldCode, oldMod | LockMask, windowRoot);
|
||||
XUngrabKey(dpy, oldCode, oldMod | Mod2Mask | LockMask, windowRoot);
|
||||
|
||||
shortcut.key = 0;
|
||||
oldCode = 0;
|
||||
oldMod = 0;
|
||||
}
|
||||
|
||||
QString AutoTypeGlobalX11::getRootGroupName(IEntryHandle* entry){
|
||||
|
||||
@@ -31,6 +31,7 @@ class AutoTypeGlobalX11 : public AutoTypeX11, public AutoTypeGlobal {
|
||||
bool registerGlobalShortcut(const Shortcut& s);
|
||||
void unregisterGlobalShortcut();
|
||||
QStringList getAllWindowTitles();
|
||||
void updateKeymap();
|
||||
inline int maskAlt() { return alt_mask; };
|
||||
inline int maskAltGr() { return altgr_mask; };
|
||||
inline int maskMeta() { return meta_mask; };
|
||||
@@ -44,6 +45,8 @@ class AutoTypeGlobalX11 : public AutoTypeX11, public AutoTypeGlobal {
|
||||
QSet<QString> classBlacklist;
|
||||
Atom wm_state;
|
||||
Window focusedWindow;
|
||||
int oldCode;
|
||||
uint oldMod;
|
||||
};
|
||||
|
||||
#endif // _AUTOTYPEGLOBALX11_H_
|
||||
|
||||
@@ -45,9 +45,16 @@ AutoTypeX11::AutoTypeX11(KeepassMainWindow* mainWin) {
|
||||
altgr_mask = 0;
|
||||
altgr_keysym = NoSymbol;
|
||||
|
||||
updateKeymap();
|
||||
reReadKeymap = false;
|
||||
}
|
||||
|
||||
void AutoTypeX11::updateKeymap() {
|
||||
ReadKeymap();
|
||||
if (!altgr_mask)
|
||||
AddModifier(XK_Mode_switch);
|
||||
if (!meta_mask)
|
||||
meta_mask = Mod4Mask;
|
||||
}
|
||||
|
||||
void AutoTypeX11::perform(IEntryHandle* entry, bool hideWindow, int nr, bool wasLocked){
|
||||
@@ -109,6 +116,14 @@ void AutoTypeX11::perform(IEntryHandle* entry, bool hideWindow, int nr, bool was
|
||||
}
|
||||
}
|
||||
|
||||
/* Re-read keymap before first auto-type,
|
||||
seems to be necessary on X.Org Server 1.6,
|
||||
when KeePassX is in autostart */
|
||||
if (!reReadKeymap) {
|
||||
updateKeymap();
|
||||
reReadKeymap = true;
|
||||
}
|
||||
|
||||
if (hideWindow)
|
||||
mainWin->hide();
|
||||
|
||||
@@ -138,8 +153,6 @@ void AutoTypeX11::perform(IEntryHandle* entry, bool hideWindow, int nr, bool was
|
||||
else{
|
||||
if (hideWindow && !(config->showSysTrayIcon() && config->minimizeTray()) )
|
||||
mainWin->showMinimized();
|
||||
if (wasLocked)
|
||||
mainWin->OnUnLockWorkspace();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -557,7 +570,7 @@ void AutoTypeX11::ReadKeymap()
|
||||
XDisplayKeycodes(dpy, &min_keycode, &max_keycode);
|
||||
if (keysym_table != NULL) XFree(keysym_table);
|
||||
keysym_table = XGetKeyboardMapping(dpy,
|
||||
min_keycode, max_keycode - min_keycode + 1,
|
||||
min_keycode, max_keycode - min_keycode + 1,
|
||||
&keysym_per_keycode);
|
||||
for (keycode = min_keycode; keycode <= max_keycode; keycode++) {
|
||||
/* if the first keysym is alphabet and the second keysym is NoSymbol,
|
||||
|
||||
@@ -39,10 +39,11 @@ class AutoTypeX11 : public AutoType {
|
||||
public:
|
||||
AutoTypeX11(KeepassMainWindow* mainWin);
|
||||
void perform(IEntryHandle* entry, bool hideWindow=true, int nr=0, bool wasLocked=false);
|
||||
virtual void updateKeymap();
|
||||
|
||||
protected:
|
||||
void sleepTime(int msec);
|
||||
inline void sleepKeyStrokeDelay(){ sleep(config->autoTypeKeyStrokeDelay()); };
|
||||
inline void sleepKeyStrokeDelay(){ sleepTime(config->autoTypeKeyStrokeDelay()); };
|
||||
void templateToKeysyms(const QString& Template, QList<AutoTypeAction>& KeySymList,IEntryHandle* entry);
|
||||
void stringToKeysyms(const QString& string,QList<AutoTypeAction>& KeySymList);
|
||||
|
||||
@@ -63,6 +64,7 @@ class AutoTypeX11 : public AutoType {
|
||||
int meta_mask;
|
||||
int altgr_mask;
|
||||
KeySym altgr_keysym;
|
||||
bool reReadKeymap;
|
||||
};
|
||||
|
||||
#endif // _AUTOTYPEX11_H_
|
||||
|
||||
@@ -202,7 +202,13 @@ void KeepassEntryView::updateEntry(EntryViewItem* item){
|
||||
}
|
||||
}
|
||||
if (Columns.at(4)){
|
||||
item->setText(j++,entry->comment().section('\n',0,0));}
|
||||
QString comment = entry->comment();
|
||||
int toPos = comment.indexOf(QRegExp("[\\r\\n]"));
|
||||
if (toPos == -1)
|
||||
item->setText(j++,comment);
|
||||
else
|
||||
item->setText(j++,comment.left(toPos));
|
||||
}
|
||||
if (Columns.at(5)){
|
||||
item->setText(j++,entry->expire().dateToString(Qt::SystemLocaleDate));}
|
||||
if (Columns.at(6)){
|
||||
@@ -361,8 +367,8 @@ void KeepassEntryView::OnClipboardTimeOut(){
|
||||
Clipboard->clear(QClipboard::Selection);
|
||||
}
|
||||
#ifdef Q_WS_X11
|
||||
QProcess::execute("dcop klipper klipper clearClipboardHistory");
|
||||
QProcess::execute("dbus-send --type=method_call --dest=org.kde.klipper /klipper org.kde.klipper.klipper.clearClipboardHistory");
|
||||
QProcess::startDetached("dcop klipper klipper clearClipboardHistory");
|
||||
QProcess::startDetached("dbus-send --type=method_call --dest=org.kde.klipper /klipper org.kde.klipper.klipper.clearClipboardHistory");
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -446,7 +452,13 @@ void KeepassEntryView::createItems(QList<IEntryHandle*>& entries){
|
||||
}
|
||||
}
|
||||
if (Columns.at(4)){
|
||||
item->setText(j++,entries[i]->comment().section('\n',0,0));}
|
||||
QString comment = entries[i]->comment();
|
||||
int toPos = comment.indexOf(QRegExp("[\\r\\n]"));
|
||||
if (toPos == -1)
|
||||
item->setText(j++,comment);
|
||||
else
|
||||
item->setText(j++,comment.left(toPos));
|
||||
}
|
||||
if (Columns.at(5)){
|
||||
item->setText(j++,entries[i]->expire().dateToString(Qt::SystemLocaleDate));}
|
||||
if (Columns.at(6)){
|
||||
|
||||
@@ -162,7 +162,8 @@ void KeepassGroupView::OnEditGroup(){
|
||||
|
||||
void KeepassGroupView::contextMenuEvent(QContextMenuEvent* e){
|
||||
if(!(GroupViewItem*)itemAt(e->pos()))
|
||||
setCurrentItem(NULL);
|
||||
return;
|
||||
|
||||
e->accept();
|
||||
if(currentItem()==SearchResultItem)
|
||||
ContextMenuSearchGroup->popup(e->globalPos());
|
||||
@@ -191,6 +192,13 @@ void KeepassGroupView::setCurrentGroup(IGroupHandle* group){
|
||||
setCurrentItem(Items[i]);
|
||||
}
|
||||
|
||||
void KeepassGroupView::selectFirstGroup(){
|
||||
if (Items.isEmpty())
|
||||
return;
|
||||
|
||||
setCurrentItem(Items[0]);
|
||||
}
|
||||
|
||||
void KeepassGroupView::dragEnterEvent ( QDragEnterEvent * event ){
|
||||
LastHoverItem=NULL;
|
||||
InsLinePos=-1;
|
||||
|
||||
@@ -37,6 +37,7 @@ class KeepassGroupView:public QTreeWidget{
|
||||
void createItems();
|
||||
void showSearchResults();
|
||||
void setCurrentGroup(IGroupHandle* group);
|
||||
void selectFirstGroup();
|
||||
|
||||
public slots:
|
||||
void createGroup(const QString& title, quint32 image, GroupViewItem* group=NULL);
|
||||
|
||||
Reference in New Issue
Block a user