valuetreeeditor drag&drop abd recent files support
This commit is contained in:
@@ -6,6 +6,7 @@
|
||||
#include <QActionGroup>
|
||||
#include <QFileInfo>
|
||||
#include <QMetaEnum>
|
||||
#include <QMimeData>
|
||||
#include <pifile.h>
|
||||
#include <pijson.h>
|
||||
#include <pivaluetree.h>
|
||||
@@ -14,6 +15,8 @@
|
||||
|
||||
MainWindow::MainWindow(QWidget * parent): EMainWindow(parent), Ui::MainWindow() {
|
||||
setupUi(this);
|
||||
setRecentMenu(menuOpen_recent);
|
||||
setAcceptDrops(true);
|
||||
session.setFile(QAD::userPath(QAD::ltConfig, "session_valuetreeeditor"));
|
||||
session.addEntry(this);
|
||||
session.load();
|
||||
@@ -91,6 +94,34 @@ void MainWindow::changeEvent(QEvent * e) {
|
||||
}
|
||||
|
||||
|
||||
void MainWindow::dragEnterEvent(QDragEnterEvent * e) {
|
||||
if (!e->mimeData()) return;
|
||||
QString str = e->mimeData()->text();
|
||||
if (str.isEmpty()) return;
|
||||
static QStringList exts({"conf", "ini", "json", "bin"});
|
||||
if (exts.contains(QFileInfo(str).suffix().toLower().trimmed())) {
|
||||
e->accept();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void MainWindow::dropEvent(QDropEvent * e) {
|
||||
if (!e->mimeData()) return;
|
||||
auto path = QUrl(e->mimeData()->text()).toLocalFile();
|
||||
if (load(path)) addToRecent(path);
|
||||
}
|
||||
|
||||
|
||||
void MainWindow::loadingSession(QPIConfig & conf) {
|
||||
setRecentFiles(conf.getValue("recent files").toStringList());
|
||||
}
|
||||
|
||||
|
||||
void MainWindow::savingSession(QPIConfig & conf) {
|
||||
conf.setValue("recent files", recentFiles());
|
||||
}
|
||||
|
||||
|
||||
QString MainWindow::loadFilter() {
|
||||
return "All types(*.conf *.ini *.json *.bin);;INI format(*.conf *.ini);;JSON(*.json);;Binary(*.bin)";
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user