feat: add fast open last opened dir logic
This commit is contained in:
@@ -205,20 +205,37 @@ void QDicomViewer::initViewOperation() {
|
||||
void QDicomViewer::initGeneralTool() {
|
||||
// open dir
|
||||
connect(ui->toolBar,&DefaultToolBar::openFolder, [&] {
|
||||
QString cachePath = QDir::currentPath()+"/.cache";
|
||||
if (!QFile::exists(cachePath))
|
||||
{
|
||||
QFile cache(cachePath);
|
||||
cache.open(QFile::NewOnly);
|
||||
cache.close();
|
||||
}
|
||||
QSettings setting(cachePath,QSettings::IniFormat);
|
||||
QString p = QFileDialog::getExistingDirectory(this, tr("Open dicom directory"),
|
||||
m_qs.value("DIR_PATH_ID").toString());
|
||||
setting.contains("LastDir")?setting.value("LastDir").toString():QDir::currentPath());
|
||||
if (!p.isEmpty()) {
|
||||
m_qs.setValue("DIR_PATH_ID", p);
|
||||
openDICOM(p.toLocal8Bit().toStdString(), DIR_OPEN_MODE);
|
||||
setting.setValue("LastDir",p);
|
||||
}
|
||||
});
|
||||
// openfile
|
||||
connect(ui->toolBar,&DefaultToolBar::openFile, [&] {
|
||||
QString fn = QFileDialog::getOpenFileName(this, tr("Open dicom files"), m_qs.value("FILE_PATH_ID").toString());
|
||||
if (!fn.isEmpty()) {
|
||||
m_qs.setValue("FILE_PATH_ID", fn);
|
||||
openDICOM(fn.toLocal8Bit().toStdString(), FILE_OPEN_MODE);
|
||||
}
|
||||
QString cachePath = QDir::currentPath()+"/.cache";
|
||||
if (!QFile::exists(cachePath))
|
||||
{
|
||||
QFile cache(cachePath);
|
||||
cache.open(QFile::NewOnly);
|
||||
cache.close();
|
||||
}
|
||||
QSettings setting(cachePath,QSettings::IniFormat);
|
||||
QString fn = QFileDialog::getOpenFileName(this, tr("Open dicom files"), setting.contains("LastDir")?setting.value("LastDir").toString():QDir::currentPath());
|
||||
if (!fn.isEmpty()) {
|
||||
QFileInfo info(fn);
|
||||
openDICOM(fn.toLocal8Bit().toStdString(), FILE_OPEN_MODE);
|
||||
setting.setValue("LastDir", info.absolutePath());
|
||||
}
|
||||
});
|
||||
// import
|
||||
connect(ui->toolBar, &DefaultToolBar::import, this, [&] {
|
||||
|
||||
Reference in New Issue
Block a user