auto-type delays
git-svn-id: https://svn.code.sf.net/p/keepassx/code/trunk@137 b624d157-de02-0410-bad0-e51aec6abb33
This commit is contained in:
@@ -17,13 +17,15 @@
|
||||
* Free Software Foundation, Inc., *
|
||||
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
|
||||
***************************************************************************/
|
||||
|
||||
|
||||
#include "KpxConfig.h"
|
||||
#include <QApplication>
|
||||
#include "AutoType.h"
|
||||
#include <QTime>
|
||||
#include <QList>
|
||||
#include <QChar>
|
||||
|
||||
|
||||
QWidget* AutoType::MainWin=NULL;
|
||||
|
||||
|
||||
@@ -64,13 +66,21 @@ void AutoType::pressModifiers(Display* d,int mods,bool press){
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void AutoType::perform(IEntryHandle* entry, QString& err){
|
||||
void sleepKeyStrokeDelay(){
|
||||
if(config->autoTypeKeyStrokeDelay()==0)return;
|
||||
struct timespec timeOut,remains;
|
||||
timeOut.tv_sec = 0;
|
||||
timeOut.tv_nsec = 30000000; /* 300 milliseconds */
|
||||
timeOut.tv_nsec = config->autoTypeKeyStrokeDelay()*100000;
|
||||
nanosleep(&timeOut, &remains);
|
||||
}
|
||||
|
||||
|
||||
void AutoType::perform(IEntryHandle* entry, QString& err){
|
||||
struct timespec timeOut,remains;
|
||||
timeOut.tv_sec = 0;
|
||||
timeOut.tv_nsec = config->autoTypePreGap()*100000;
|
||||
for(int i=0;i<10;i++)nanosleep(&timeOut, &remains);
|
||||
|
||||
|
||||
QString str;
|
||||
QString comment=entry->comment();
|
||||
int c=comment.count("Auto-Type:");
|
||||
@@ -119,9 +129,13 @@ void AutoType::pressModifiers(Display* d,int mods,bool press){
|
||||
int keycode=XKeysymToKeycode(pDisplay,Keys[i]);
|
||||
int mods=getModifiers(pDisplay,Keys[i],keycode);
|
||||
pressModifiers(pDisplay,mods);
|
||||
sleepKeyStrokeDelay();
|
||||
XTestFakeKeyEvent(pDisplay,keycode,True,0);
|
||||
sleepKeyStrokeDelay();
|
||||
XTestFakeKeyEvent(pDisplay,keycode,False,1);
|
||||
sleepKeyStrokeDelay();
|
||||
releaseModifiers(pDisplay,mods);
|
||||
sleepKeyStrokeDelay();
|
||||
}
|
||||
XCloseDisplay(pDisplay);
|
||||
MainWin->show();
|
||||
|
||||
@@ -135,36 +135,32 @@ void FileDlgHistory::set(const QString& name,const QString& dir, int filter){
|
||||
}
|
||||
void FileDlgHistory::save(){
|
||||
if(config->saveFileDlgHistory()){
|
||||
//settings->beginGroup("FileDlgHistory");
|
||||
for(unsigned i=0;i<static_cast<unsigned>(History.size());i++){
|
||||
QStringList entry;
|
||||
entry << History.keys().at(i)
|
||||
<< History.values().at(i).Dir
|
||||
<< QString::number(History.values().at(i).Filter);
|
||||
//settings->setValue(QString("ENTRY%1").arg(i),QVariant(entry));
|
||||
config->setFileDlgHistory(i,entry);
|
||||
}
|
||||
//settings->endGroup();
|
||||
}
|
||||
}
|
||||
|
||||
void FileDlgHistory::load(){
|
||||
if(config->saveFileDlgHistory()){
|
||||
//settings->beginGroup("FileDlgHistory");
|
||||
//QStringList keys=settings->childKeys();
|
||||
unsigned count=config->fileDlgHistorySize();
|
||||
for(unsigned i=0;i</*keys.size()*/count;i++){
|
||||
Entry entry;
|
||||
QStringList value=config->fileDlgHistory(i);//settings->value(QString("ENTRY%1").arg(i)).toStringList();
|
||||
QStringList value=config->fileDlgHistory(i);
|
||||
entry.Dir=value[1];
|
||||
entry.Filter=value[2].toInt();
|
||||
History[value[0]]=entry;
|
||||
}
|
||||
//settings->endGroup();
|
||||
}
|
||||
else{
|
||||
else
|
||||
config->clearFileDlgHistory();
|
||||
//settings->remove("FileDlgHistory");
|
||||
}
|
||||
}
|
||||
|
||||
void FileDlgHistory::clear(){
|
||||
History=QHash<QString,Entry>();
|
||||
config->clearFileDlgHistory();
|
||||
}
|
||||
@@ -27,13 +27,16 @@
|
||||
#include "plugins/interfaces/IFileDialog.h"
|
||||
|
||||
|
||||
class FileDlgHistory{
|
||||
class FileDlgHistory:public QObject{
|
||||
Q_OBJECT
|
||||
public:
|
||||
QString getDir(const QString& name);
|
||||
int getFilter(const QString& name);
|
||||
public slots:
|
||||
void set(const QString& name,const QString& dir,int filter);
|
||||
void save();
|
||||
void load();
|
||||
void load();
|
||||
void clear();
|
||||
private:
|
||||
class Entry{
|
||||
public:
|
||||
|
||||
Reference in New Issue
Block a user