1 /***************************************************************************
2 * Copyright (C) 2007 by Tarek Saidi *
3 * tarek.saidi@arcor.de *
5 * This program is free software; you can redistribute it and/or modify *
6 * it under the terms of the GNU General Public License as published by *
7 * the Free Software Foundation; version 2 of the License. *
9 * This program is distributed in the hope that it will be useful, *
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
12 * GNU General Public License for more details. *
14 * You should have received a copy of the GNU General Public License *
15 * along with this program; if not, write to the *
16 * Free Software Foundation, Inc., *
17 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
18 ***************************************************************************/
21 #include "AddBookmarkDlg.h"
24 AddBookmarkDlg::AddBookmarkDlg(QWidget* parent, QString DefaultFilename, int _ItemID):QDialog(parent)
28 connect(Button_Browse,SIGNAL(clicked()),this,SLOT(OnButtonBrowse()));
29 connect(buttonBox->button(QDialogButtonBox::Ok),SIGNAL(clicked()),this,SLOT(OnButtonOk()));
30 connect(buttonBox->button(QDialogButtonBox::Cancel),SIGNAL(clicked()),this,SLOT(reject()));
32 createBanner(&BannerPixmap,getPixmap("bookmark_add"),tr("Add Bookmark"),width());
34 if(DefaultFilename.isEmpty())
35 QMetaObject::invokeMethod(this, "OnButtonBrowse", Qt::QueuedConnection);
37 Edit_Filename->setText(DefaultFilename);
40 createBanner(&BannerPixmap,getPixmap("bookmark_edit"),tr("Edit Bookmark"),width());
42 Edit_Title->setText(KpxBookmarks::title(ItemID));
43 Edit_Filename->setText(KpxBookmarks::path(ItemID));
44 setWindowTitle(tr("Edit Bookmark"));
48 void AddBookmarkDlg::paintEvent(QPaintEvent *event){
49 QDialog::paintEvent(event);
50 QPainter painter(this);
51 painter.setClipRegion(event->region());
52 painter.drawPixmap(QPoint(0,0),BannerPixmap);
55 void AddBookmarkDlg::OnButtonBrowse(){
56 QString path=KpxFileDialogs::openExistingFile(this,"AddBookmarkDlg", tr("Add Bookmark"),
57 QStringList() << tr("KeePass Databases (*.kdb)") << tr("All Files (*)"));
59 Edit_Filename->setText(path);
62 void AddBookmarkDlg::OnButtonOk(){
64 ItemID=KpxBookmarks::add(Edit_Title->text(),Edit_Filename->text());
66 KpxBookmarks::edit(Edit_Title->text(),Edit_Filename->text(),ItemID);