summaryrefslogtreecommitdiff
path: root/src/frontend/bookmarks/bteditbookmarkdialog.cpp
blob: 1291f5622332aa6d40237c7043b5865dba278d49 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
/*********
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
* Copyright 1999-2014 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/

#include "bteditbookmarkdialog.h"

#include <QDialogButtonBox>
#include <QVBoxLayout>
#include <QFormLayout>
#include <QLabel>
#include <QLineEdit>
#include <QTextEdit>
#include <QWidget>
#include "bibletimeapp.h"
#include "util/cresmgr.h"
#include "frontend/messagedialog.h"
#include "util/geticon.h"


BtEditBookmarkDialog::BtEditBookmarkDialog(const QString &key,
                                           const QString &title,
                                           const QString &description,
                                           QWidget *parent,
                                           Qt::WindowFlags wflags)
    : QDialog(parent, wflags)
{
    QVBoxLayout *mainLayout = new QVBoxLayout(this);

    resize(400, 300);
    setWindowIcon(util::getIcon(CResMgr::mainIndex::bookmark::icon));

    m_layout = new QFormLayout;

    m_keyLabel = new QLabel(this);
    m_keyTextLabel = new QLabel(key, this);
    m_layout->addRow(m_keyLabel, m_keyTextLabel);

    m_titleLabel = new QLabel(this);
    m_titleEdit = new QLineEdit(title, this);
    m_layout->addRow(m_titleLabel, m_titleEdit);

    m_descriptionLabel = new QLabel(this);
    m_descriptionEdit = new QTextEdit(description, this);
    m_descriptionEdit->setWordWrapMode(QTextOption::WordWrap);
    m_layout->addRow(m_descriptionLabel, m_descriptionEdit);

    mainLayout->addLayout(m_layout);

    m_buttonBox = new QDialogButtonBox(QDialogButtonBox::Cancel
                                       | QDialogButtonBox::NoButton
                                       | QDialogButtonBox::Ok,
                                       Qt::Horizontal,
                                       this);
    message::prepareDialogBox(m_buttonBox);
    mainLayout->addWidget(m_buttonBox);

    QObject::connect(m_buttonBox, SIGNAL(accepted()), this, SLOT(accept()));
    QObject::connect(m_buttonBox, SIGNAL(rejected()), this, SLOT(reject()));

    retranslateUi();

    m_titleEdit->setFocus();
}

void BtEditBookmarkDialog::retranslateUi() {
    setWindowTitle(tr("Edit Bookmark"));
    m_keyLabel->setText(tr("Location:"));
    m_titleLabel->setText(tr("Title:"));
    m_descriptionLabel->setText(tr("Description:"));

    /// \todo Add tooltips and what's this texts etc.
}