valuetreeeditor drag&drop abd recent files support
This commit is contained in:
@@ -6,6 +6,7 @@
|
|||||||
#include <QActionGroup>
|
#include <QActionGroup>
|
||||||
#include <QFileInfo>
|
#include <QFileInfo>
|
||||||
#include <QMetaEnum>
|
#include <QMetaEnum>
|
||||||
|
#include <QMimeData>
|
||||||
#include <pifile.h>
|
#include <pifile.h>
|
||||||
#include <pijson.h>
|
#include <pijson.h>
|
||||||
#include <pivaluetree.h>
|
#include <pivaluetree.h>
|
||||||
@@ -14,6 +15,8 @@
|
|||||||
|
|
||||||
MainWindow::MainWindow(QWidget * parent): EMainWindow(parent), Ui::MainWindow() {
|
MainWindow::MainWindow(QWidget * parent): EMainWindow(parent), Ui::MainWindow() {
|
||||||
setupUi(this);
|
setupUi(this);
|
||||||
|
setRecentMenu(menuOpen_recent);
|
||||||
|
setAcceptDrops(true);
|
||||||
session.setFile(QAD::userPath(QAD::ltConfig, "session_valuetreeeditor"));
|
session.setFile(QAD::userPath(QAD::ltConfig, "session_valuetreeeditor"));
|
||||||
session.addEntry(this);
|
session.addEntry(this);
|
||||||
session.load();
|
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() {
|
QString MainWindow::loadFilter() {
|
||||||
return "All types(*.conf *.ini *.json *.bin);;INI format(*.conf *.ini);;JSON(*.json);;Binary(*.bin)";
|
return "All types(*.conf *.ini *.json *.bin);;INI format(*.conf *.ini);;JSON(*.json);;Binary(*.bin)";
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -20,7 +20,11 @@ public:
|
|||||||
|
|
||||||
protected:
|
protected:
|
||||||
void changeEvent(QEvent * e) override;
|
void changeEvent(QEvent * e) override;
|
||||||
|
void dragEnterEvent(QDragEnterEvent * e) override;
|
||||||
|
void dropEvent(QDropEvent * e) override;
|
||||||
|
|
||||||
|
void loadingSession(QPIConfig & conf) override;
|
||||||
|
void savingSession(QPIConfig & conf) override;
|
||||||
QString loadFilter() override;
|
QString loadFilter() override;
|
||||||
QString saveFilter() override { return loadFilter(); }
|
QString saveFilter() override { return loadFilter(); }
|
||||||
|
|
||||||
|
|||||||
@@ -44,12 +44,12 @@
|
|||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>780</width>
|
<width>780</width>
|
||||||
<height>444</height>
|
<height>437</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<layout class="QVBoxLayout" name="verticalLayout">
|
<layout class="QVBoxLayout" name="verticalLayout">
|
||||||
<item>
|
<item>
|
||||||
<widget class="PIValueTreeEdit" name="widget" native="true"/>
|
<widget class="PIValueTreeEdit" name="widget"/>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<spacer name="verticalSpacer">
|
<spacer name="verticalSpacer">
|
||||||
@@ -91,15 +91,25 @@
|
|||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>780</width>
|
<width>780</width>
|
||||||
<height>31</height>
|
<height>29</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<widget class="QMenu" name="menuFile">
|
<widget class="QMenu" name="menuFile">
|
||||||
<property name="title">
|
<property name="title">
|
||||||
<string>File</string>
|
<string>File</string>
|
||||||
</property>
|
</property>
|
||||||
|
<widget class="QMenu" name="menuOpen_recent">
|
||||||
|
<property name="title">
|
||||||
|
<string>Open recent</string>
|
||||||
|
</property>
|
||||||
|
<property name="icon">
|
||||||
|
<iconset resource="../../libs/widgets/qad_widgets.qrc">
|
||||||
|
<normaloff>:/icons/document-open-recent.png</normaloff>:/icons/document-open-recent.png</iconset>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
<addaction name="actionNew"/>
|
<addaction name="actionNew"/>
|
||||||
<addaction name="actionOpen"/>
|
<addaction name="actionOpen"/>
|
||||||
|
<addaction name="menuOpen_recent"/>
|
||||||
<addaction name="actionSave"/>
|
<addaction name="actionSave"/>
|
||||||
<addaction name="actionSaveAs"/>
|
<addaction name="actionSaveAs"/>
|
||||||
</widget>
|
</widget>
|
||||||
@@ -152,7 +162,7 @@
|
|||||||
</action>
|
</action>
|
||||||
<action name="actionNew">
|
<action name="actionNew">
|
||||||
<property name="icon">
|
<property name="icon">
|
||||||
<iconset resource="../../libs/widgets/qad_widgets.qrc">
|
<iconset resource="../../libs/qglview/qglview.qrc">
|
||||||
<normaloff>:/icons/document-new.png</normaloff>:/icons/document-new.png</iconset>
|
<normaloff>:/icons/document-new.png</normaloff>:/icons/document-new.png</iconset>
|
||||||
</property>
|
</property>
|
||||||
<property name="text">
|
<property name="text">
|
||||||
@@ -164,7 +174,7 @@
|
|||||||
</action>
|
</action>
|
||||||
<action name="actionAbout">
|
<action name="actionAbout">
|
||||||
<property name="icon">
|
<property name="icon">
|
||||||
<iconset resource="../../../cd/utils/pult/cdpult.qrc">
|
<iconset resource="../../libs/graphic_analysis/qad_graphic_analysis.qrc">
|
||||||
<normaloff>:/icons/dialog-information.png</normaloff>:/icons/dialog-information.png</iconset>
|
<normaloff>:/icons/dialog-information.png</normaloff>:/icons/dialog-information.png</iconset>
|
||||||
</property>
|
</property>
|
||||||
<property name="text">
|
<property name="text">
|
||||||
@@ -201,8 +211,9 @@
|
|||||||
</customwidget>
|
</customwidget>
|
||||||
</customwidgets>
|
</customwidgets>
|
||||||
<resources>
|
<resources>
|
||||||
<include location="../../../cd/utils/pult/cdpult.qrc"/>
|
|
||||||
<include location="../../libs/blockview/qad_blockview.qrc"/>
|
<include location="../../libs/blockview/qad_blockview.qrc"/>
|
||||||
|
<include location="../../libs/graphic_analysis/qad_graphic_analysis.qrc"/>
|
||||||
|
<include location="../../libs/qglview/qglview.qrc"/>
|
||||||
<include location="../../libs/widgets/qad_widgets.qrc"/>
|
<include location="../../libs/widgets/qad_widgets.qrc"/>
|
||||||
</resources>
|
</resources>
|
||||||
<connections>
|
<connections>
|
||||||
|
|||||||
Reference in New Issue
Block a user