Some code cleanup

git-svn-id: https://svn.code.sf.net/p/keepassx/code/trunk@278 b624d157-de02-0410-bad0-e51aec6abb33
master
sniperbeamer 16 years ago
parent 5944e2620f
commit df17d76ce7
  1. 8
      src/dialogs/AddBookmarkDlg.cpp
  2. 6
      src/dialogs/CustomizeDetailViewDlg.cpp
  3. 3
      src/dialogs/DatabaseSettingsDlg.cpp
  4. 4
      src/dialogs/DatabaseSettingsDlg.h
  5. 82
      src/dialogs/EditEntryDlg.cpp
  6. 5
      src/dialogs/EditGroupDlg.cpp
  7. 66
      src/dialogs/ManageBookmarksDlg.cpp
  8. 3
      src/dialogs/SearchDlg.cpp
  9. 2
      src/lib/EntryView.cpp
  10. 36
      src/lib/UrlLabel.cpp

@ -46,10 +46,10 @@ AddBookmarkDlg::AddBookmarkDlg(QWidget* parent, QString DefaultFilename, int _It
}
void AddBookmarkDlg::paintEvent(QPaintEvent *event){
QDialog::paintEvent(event);
QPainter painter(this);
painter.setClipRegion(event->region());
painter.drawPixmap(QPoint(0,0),BannerPixmap);
QDialog::paintEvent(event);
QPainter painter(this);
painter.setClipRegion(event->region());
painter.drawPixmap(QPoint(0,0),BannerPixmap);
}
void AddBookmarkDlg::OnButtonBrowse(){

@ -77,7 +77,7 @@ void CustomizeDetailViewDialog::OnTabChanged(int index){
RichEdit->setHtml(HtmlEdit->toPlainText());
}
if(index==1){
HtmlEdit->setPlainText(RichEdit->toHtml());
HtmlEdit->setPlainText(RichEdit->toHtml());
}
}
@ -85,8 +85,8 @@ void CustomizeDetailViewDialog::OnFontSizeChanged(const QString& text){
bool ok=false;
int size=text.toInt(&ok);
if(ok && size > 0){
RichEdit->setFontPointSize(size);
}
RichEdit->setFontPointSize(size);
}
}

@ -42,8 +42,7 @@ CDbSettingsDlg::CDbSettingsDlg(QWidget* parent,IDatabase* db, bool modal, Qt::W
connect( ButtonBench, SIGNAL( clicked() ), this, SLOT( OnBenchmark() ) );
}
CDbSettingsDlg::~CDbSettingsDlg()
{
CDbSettingsDlg::~CDbSettingsDlg(){
}
void CDbSettingsDlg::paintEvent(QPaintEvent *event){

@ -27,8 +27,8 @@ class CDbSettingsDlg : public QDialog, private Ui_DatabaseSettingsDlg
{
Q_OBJECT
public:
CDbSettingsDlg(QWidget* parent,IDatabase* db, bool modal = FALSE, Qt::WFlags fl = 0 );
~CDbSettingsDlg();
CDbSettingsDlg(QWidget* parent,IDatabase* db, bool modal = FALSE, Qt::WFlags fl = 0 );
~CDbSettingsDlg();
virtual void paintEvent(QPaintEvent *);
private slots:

@ -238,64 +238,55 @@ void CEditEntryDlg::OnButtonCancel()
void CEditEntryDlg::ChangeEchoMode()
{
if(Edit_Password->echoMode()==QLineEdit::Normal){
Edit_Password->setEchoMode(QLineEdit::Password);
Edit_Password_w->setEchoMode(QLineEdit::Password);
ButtonEchoMode->setIcon(getIcon("pwd_hide"));
}
else
{
Edit_Password->setEchoMode(QLineEdit::Normal);
Edit_Password_w->setEchoMode(QLineEdit::Normal);
ButtonEchoMode->setIcon(getIcon("pwd_show"));
}
if(Edit_Password->echoMode()==QLineEdit::Normal){
Edit_Password->setEchoMode(QLineEdit::Password);
Edit_Password_w->setEchoMode(QLineEdit::Password);
ButtonEchoMode->setIcon(getIcon("pwd_hide"));
}
else
{
Edit_Password->setEchoMode(QLineEdit::Normal);
Edit_Password_w->setEchoMode(QLineEdit::Normal);
ButtonEchoMode->setIcon(getIcon("pwd_show"));
}
}
void CEditEntryDlg::OnTitleTextChanged(const QString& txt)
{
setWindowTitle((txt=="") ? tr("[Untitled Entry]") : txt);
setWindowTitle((txt=="") ? tr("[Untitled Entry]") : txt);
}
void CEditEntryDlg::OnPasswordTextChanged()
{
Edit_Password_w->setText(QString());
int bits=(Edit_Password->text().length()*8);
Label_Bits->setText(QString::number(bits)+" Bit");
if(bits>128)bits=128;
Progress_Quali->setValue(100*bits/128);
Edit_Password_w->setText(QString());
int bits=(Edit_Password->text().length()*8);
Label_Bits->setText(QString::number(bits)+" Bit");
if(bits>128)bits=128;
Progress_Quali->setValue(100*bits/128);
}
void CEditEntryDlg::OnPasswordwTextChanged()
{
if(QString::compare(Edit_Password_w->text(),Edit_Password->text().mid(0,(Edit_Password_w->text().length())))!=0){
QPalette palette;
palette.setColor(Edit_Password_w->backgroundRole(),QColor(255,125,125));
Edit_Password_w->setPalette(palette);
}else
{
Edit_Password_w->setPalette(QApplication::palette());
}
if(QString::compare(Edit_Password_w->text(),Edit_Password->text().mid(0,(Edit_Password_w->text().length())))!=0){
QPalette palette;
palette.setColor(Edit_Password_w->backgroundRole(),QColor(255,125,125));
Edit_Password_w->setPalette(palette);
}
else {
Edit_Password_w->setPalette(QApplication::palette());
}
}
void CEditEntryDlg::OnPasswordwLostFocus()
{
if(QString::compare(Edit_Password_w->text(),Edit_Password->text())!=0){
QPalette palette;
palette.setColor(Edit_Password_w->backgroundRole(),QColor(255,125,125));
Edit_Password_w->setPalette(palette);
}
else
{
Edit_Password_w->setPalette(QApplication::palette ());
}
if (QString::compare(Edit_Password_w->text(),Edit_Password->text())!=0){
QPalette palette;
palette.setColor(Edit_Password_w->backgroundRole(),QColor(255,125,125));
Edit_Password_w->setPalette(palette);
}
else {
Edit_Password_w->setPalette(QApplication::palette ());
}
}
void CEditEntryDlg::OnNewAttachment()
@ -303,7 +294,7 @@ void CEditEntryDlg::OnNewAttachment()
QString filename=QFileDialog::getOpenFileName(this,tr("Add Attachment..."),QDir::homePath());
if(filename=="")return;
QFile file(filename);
if(file.open(QIODevice::ReadOnly)==false){
if(!file.open(QIODevice::ReadOnly)){
file.close();
QMessageBox::warning(NULL,tr("Error"),tr("Could not open file."),tr("OK"));
return;
@ -353,12 +344,13 @@ void CEditEntryDlg::saveAttachment(IEntryHandle* pEntry, QWidget* ParentWidget)
return;
}
file.close();
}
void CEditEntryDlg::OnDeleteAttachment()
{
int r=QMessageBox::warning(this,tr("Delete Attachment?"),tr("You are about to delete the attachment of this entry.\nAre you sure?"),tr("Yes"),tr("No, Cancel"),NULL,1,1);
int r=QMessageBox::warning(this,tr("Delete Attachment?"),
tr("You are about to delete the attachment of this entry.\nAre you sure?"),
tr("Yes"),tr("No, Cancel"),NULL,1,1);
if(r==0){
ModFlag=true;
entry->setBinary(QByteArray());

@ -52,8 +52,7 @@ CEditGroupDialog::CEditGroupDialog(IDatabase* database,CGroup* Group,QWidget* pa
connect( Button_Icon, SIGNAL( clicked() ), this, SLOT( OnIconDlg() ));
}
CEditGroupDialog::~CEditGroupDialog()
{
CEditGroupDialog::~CEditGroupDialog(){
}
void CEditGroupDialog::showEvent(QShowEvent *event){
@ -76,7 +75,7 @@ void CEditGroupDialog::OnOK()
if(ComboIconPicker->currentIndex()!=group->Image){
group->Image=ComboIconPicker->currentIndex();
r=2;
}
}
if(handle){
handle->setTitle(group->Title);
handle->setImage(group->Image);

@ -30,26 +30,26 @@ ManageBookmarksDlg::ManageBookmarksDlg(QWidget* parent):QDialog(parent)
item->setData(Qt::UserRole,i);
item->setText(KpxBookmarks::title(i));
}
connect(Button_Add,SIGNAL(clicked()),this,SLOT(OnButtonAdd()));
connect(Button_Edit,SIGNAL(clicked()),this,SLOT(OnButtonEdit()));
connect(Button_Delete,SIGNAL(clicked()),this,SLOT(OnButtonDelete()));
connect(Button_Up,SIGNAL(clicked()),this,SLOT(OnButtonUp()));
connect(Button_Add,SIGNAL(clicked()),this,SLOT(OnButtonAdd()));
connect(Button_Edit,SIGNAL(clicked()),this,SLOT(OnButtonEdit()));
connect(Button_Delete,SIGNAL(clicked()),this,SLOT(OnButtonDelete()));
connect(Button_Up,SIGNAL(clicked()),this,SLOT(OnButtonUp()));
connect(Button_Down,SIGNAL(clicked()),this,SLOT(OnButtonDown()));
connect(ListWidget,SIGNAL(itemDoubleClicked(QListWidgetItem*)),this,SLOT(edit(QListWidgetItem*)));
connect(buttonBox->button(QDialogButtonBox::Close),SIGNAL(clicked()),this,SLOT(close()));
Button_Add->setIcon(getIcon("bookmark_add"));
Button_Add->setIcon(getIcon("bookmark_add"));
Button_Edit->setIcon(getIcon("bookmark_edit"));
Button_Delete->setIcon(getIcon("bookmark_del"));
Button_Up->setIcon(getIcon("up"));
Button_Down->setIcon(getIcon("down"));
Button_Delete->setIcon(getIcon("bookmark_del"));
Button_Up->setIcon(getIcon("up"));
Button_Down->setIcon(getIcon("down"));
}
void ManageBookmarksDlg::paintEvent(QPaintEvent *event){
QDialog::paintEvent(event);
QPainter painter(this);
painter.setClipRegion(event->region());
painter.drawPixmap(QPoint(0,0),BannerPixmap);
QDialog::paintEvent(event);
QPainter painter(this);
painter.setClipRegion(event->region());
painter.drawPixmap(QPoint(0,0),BannerPixmap);
}
void ManageBookmarksDlg::resizeEvent(QResizeEvent* event){
@ -58,33 +58,33 @@ void ManageBookmarksDlg::resizeEvent(QResizeEvent* event){
}
void ManageBookmarksDlg::OnButtonAdd(){
AddBookmarkDlg dlg(this);
if(dlg.exec()){
int i=dlg.ItemID;
QListWidgetItem* item=new QListWidgetItem(ListWidget);
item->setData(Qt::UserRole,i);
item->setText(KpxBookmarks::title(i));
}
return;
AddBookmarkDlg dlg(this);
if(dlg.exec()){
int i=dlg.ItemID;
QListWidgetItem* item=new QListWidgetItem(ListWidget);
item->setData(Qt::UserRole,i);
item->setText(KpxBookmarks::title(i));
}
return;
}
void ManageBookmarksDlg::OnButtonEdit(){
QListWidgetItem* item=ListWidget->currentItem();
if(!item)return;
edit(item);
QListWidgetItem* item=ListWidget->currentItem();
if(!item)return;
edit(item);
}
void ManageBookmarksDlg::OnButtonDelete(){
QListWidgetItem* item=ListWidget->currentItem();
if(!item)return;
int index=item->data(Qt::UserRole).toInt();
KpxBookmarks::remove(index);
delete item;
for(int i=0;i<ListWidget->count();i++){
int itemindex=ListWidget->item(i)->data(Qt::UserRole).toInt();
if(itemindex>index)
ListWidget->item(i)->setData(Qt::UserRole,itemindex-1);
}
QListWidgetItem* item=ListWidget->currentItem();
if(!item)return;
int index=item->data(Qt::UserRole).toInt();
KpxBookmarks::remove(index);
delete item;
for(int i=0;i<ListWidget->count();i++){
int itemindex=ListWidget->item(i)->data(Qt::UserRole).toInt();
if(itemindex>index)
ListWidget->item(i)->setData(Qt::UserRole,itemindex-1);
}
}

@ -90,6 +90,3 @@ void SearchDialog::paintEvent(QPaintEvent *event){
painter.setClipRegion(event->region());
painter.drawPixmap(QPoint(0,0),BannerPixmap);
}

@ -251,7 +251,7 @@ void KeepassEntryView::editEntry(EntryViewItem* item){
void KeepassEntryView::OnNewEntry(){
IEntryHandle* NewEntry = NULL;
if (!CurrentGroup){// We must be viewing search results. Add the new entry to the first group.
if (!CurrentGroup){ // We must be viewing search results. Add the new entry to the first group.
if (db->groups().size() > 0)
NewEntry=db->newEntry(db->sortedGroups()[0]);
else{

@ -22,25 +22,27 @@
#include "UrlLabel.h"
LinkLabel::LinkLabel(QWidget *parent,const QString& text, int x, int y,Qt::WFlags f) : QLabel(parent,f){
QFont font(parentWidget()->font()); font.setUnderline(true);
setFont(font);
QPalette palette;
palette.setColor(foregroundRole(),QColor(20,20,255));
setPalette(palette);
setCursor(Qt::PointingHandCursor);
setText(text);
setPos(x,y);
QFont font(parentWidget()->font());
font.setUnderline(true);
setFont(font);
QPalette palette;
palette.setColor(foregroundRole(),QColor(20,20,255));
setPalette(palette);
setCursor(Qt::PointingHandCursor);
setText(text);
setPos(x,y);
}
LinkLabel::~LinkLabel(){
}
QString LinkLabel::url(){
if(URL!=QString())return URL;
if(text().contains("@"))
return QString("mailto:")+text();
else return text();
if(URL!=QString())
return URL;
else if(text().contains("@"))
return QString("mailto:")+text();
else
return text();
}
void LinkLabel::mouseReleaseEvent(QMouseEvent* event){
@ -51,11 +53,11 @@ void LinkLabel::mouseReleaseEvent(QMouseEvent* event){
}
void LinkLabel::setPos(int x,int y){
QFontMetrics fm(font());
setGeometry(x,y,fm.width(text()),fm.height());
QFontMetrics fm(font());
setGeometry(x,y,fm.width(text()),fm.height());
}
void LinkLabel::setText(const QString& text){
QLabel::setText(text);
setPos(geometry().x(),geometry().y());
QLabel::setText(text);
setPos(geometry().x(), geometry().y());
}