summaryrefslogtreecommitdiff
path: root/src/dic-options/DictionaryOptionsDialog.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/dic-options/DictionaryOptionsDialog.cpp')
-rw-r--r--src/dic-options/DictionaryOptionsDialog.cpp62
1 files changed, 62 insertions, 0 deletions
diff --git a/src/dic-options/DictionaryOptionsDialog.cpp b/src/dic-options/DictionaryOptionsDialog.cpp
new file mode 100644
index 0000000..46bb245
--- /dev/null
+++ b/src/dic-options/DictionaryOptionsDialog.cpp
@@ -0,0 +1,62 @@
+#include "DictionaryOptionsDialog.h"
+#include "../dictionary/CardPack.h"
+#include "FieldsPage.h"
+#include "PacksPage.h"
+#include "FieldsListModel.h"
+
+DictionaryOptionsDialog::DictionaryOptionsDialog( Dictionary* aDict, QWidget* aParent ):
+ QDialog( aParent ), m_origDictPtr( aDict )
+ {
+ initData();
+ createPages();
+
+ QDialogButtonBox* okCancelBox = new QDialogButtonBox( QDialogButtonBox::Ok | QDialogButtonBox::Cancel,
+ Qt::Horizontal );
+ connect( okCancelBox, SIGNAL(accepted()), this, SLOT(accept()) );
+ connect( okCancelBox, SIGNAL(rejected()), this, SLOT(reject()) );
+
+ QVBoxLayout *mainLayout = new QVBoxLayout;
+ mainLayout->addWidget(createDictPathLabel());
+ mainLayout->addWidget( m_pages );
+ mainLayout->addWidget( okCancelBox );
+ setLayout( mainLayout );
+
+ setWindowTitle( tr("Dictionary options") );
+ }
+
+DictionaryOptionsDialog::~DictionaryOptionsDialog()
+{
+ delete m_emptyField;
+}
+
+QSize DictionaryOptionsDialog::sizeHint() const
+{
+ return QSize(700, 400);
+}
+
+QLabel* DictionaryOptionsDialog::createDictPathLabel()
+{
+ const int MaxPathLength = 500;
+ QLabel* dictPathLabel = new QLabel;
+ QFontMetrics metrics(dictPathLabel->font());
+ QString dictPath = QDir::toNativeSeparators(m_origDictPtr->getFilePath());
+ dictPath = metrics.elidedText(dictPath, Qt::ElideMiddle, MaxPathLength);
+ dictPathLabel->setText("<b>" + tr("File name") + "</b>: " + dictPath);
+ return dictPathLabel;
+}
+
+void DictionaryOptionsDialog::initData()
+ {
+ m_dict.setDictConfig( m_origDictPtr );
+ m_emptyField = new Field();
+ m_fieldsListModel = new FieldsListModel( this );
+ }
+
+void DictionaryOptionsDialog::createPages()
+ {
+ m_pages = new QTabWidget;
+ m_pages->addTab( new FieldsPage( this ), QIcon(":/images/fields.png"), tr("Fields") );
+ m_pages->addTab( new PacksPage( this ), QIcon(":/images/word-drill.png"), tr("Card packs") );
+ }
+
+