-
Notifications
You must be signed in to change notification settings - Fork 1
/
AddDictDialog.cpp
63 lines (56 loc) · 1.35 KB
/
AddDictDialog.cpp
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
#include "AddDictDialog.h"
#include "ui_AddDictDialog.h"
#include "QFileInfo"
#include "QFileDialog"
#include "PathMgr.h"
#include "QMessageBox"
AddDictDialog::AddDictDialog(QWidget *parent) :
QDialog(parent),
ui(new Ui::AddDictDialog)
{
ui->setupUi(this);
ui->OKButton->setEnabled(false);
}
AddDictDialog::~AddDictDialog()
{
delete ui;
}
void AddDictDialog::on_OKButton_clicked()
{
accept();
}
void AddDictDialog::on_QuitButton_clicked()
{
reject();
}
void AddDictDialog::on_ImportButton_clicked()
{
dictPath = PathManage::makePathStr("/AnsleDict/MyDict/Dict/");
QString filename = QFileDialog::getOpenFileName(this,
tr("添加新词典"), dictPath, tr("数据库文件(*.db)"));
if (filename.isEmpty())
return;
else if(!filename.contains(".db", Qt::CaseInsensitive))
{
QMessageBox::warning(this, tr("出错了"),
(QString("请把词典文件放到%1目录下并将其打开!").arg(dictPath)));
return;
}
else
{
QFileInfo fd(filename);
dictName = fd.baseName();
dictPath = fd.filePath();
ui->DictNameLineEdit->setText(dictName);
ui->DictPathLineEdit->setText(dictPath);
ui->OKButton->setEnabled(true);
}
}
QString AddDictDialog::getDictName()
{
return ui->DictNameLineEdit->text();
}
QString AddDictDialog::getDictPath()
{
return dictPath;
}