diff --git a/qad/blockview/blockeditor/blockeditor.cpp b/qad/blockview/blockeditor/blockeditor.cpp index 2bd4560..a2f6927 100644 --- a/qad/blockview/blockeditor/blockeditor.cpp +++ b/qad/blockview/blockeditor/blockeditor.cpp @@ -12,6 +12,7 @@ BlockEditor::BlockEditor(QWidget *parent) : QWidget(parent), ui(new Ui::BlockEditor) { init = false; ui->setupUi(this); + src_title = windowTitle(); connect(ui->blockView->scene(), SIGNAL(selectionChanged()), this, SLOT(selectionChanged())); block.setFlags(0); ui->blockView->addItem(&block); @@ -50,6 +51,17 @@ BlockEditor::~BlockEditor() { } +void BlockEditor::loadFile(QString path) { + if (path.isEmpty()) return; + QFile f(path); + if (f.open(QIODevice::ReadOnly)) { + cur_file = path; + loadModel(f.readAll()); + } + setWindowTitle(src_title + QString(" - %1").arg(QFileInfo(path).baseName())); +} + + void BlockEditor::loadModel(const QByteArray &model) { BlockItem b; b.loadModel(model); @@ -153,6 +165,7 @@ void BlockEditor::on_buttonSave_clicked() { if (f.open(QIODevice::WriteOnly)) { cur_file = c; f.write(saveModel()); + setWindowTitle(src_title + QString(" - %1").arg(QFileInfo(c).baseName())); } } } @@ -160,13 +173,7 @@ void BlockEditor::on_buttonSave_clicked() { void BlockEditor::on_buttonLoad_clicked() { QString c = QFileDialog::getOpenFileName(this, "Save block model to file", cur_file, "*.blockmodel"); - if (!c.isEmpty()) { - QFile f(c); - if (f.open(QIODevice::ReadOnly)) { - cur_file = c; - loadModel(f.readAll()); - } - } + loadFile(c); } diff --git a/qad/blockview/blockeditor/blockeditor.h b/qad/blockview/blockeditor/blockeditor.h index 71388b8..ee9581a 100644 --- a/qad/blockview/blockeditor/blockeditor.h +++ b/qad/blockview/blockeditor/blockeditor.h @@ -22,6 +22,7 @@ public: public slots: + void loadFile(QString path); void loadModel(const QByteArray & model); QByteArray saveModel(); @@ -48,7 +49,7 @@ private: Ui::BlockEditor *ui; QMap pin_tli; BlockItem block; - QString cur_file; + QString src_title, cur_file; bool init; }; diff --git a/qad/blockview/blockeditor/blockeditor.ui b/qad/blockview/blockeditor/blockeditor.ui index a07c7ce..f8c5efb 100644 --- a/qad/blockview/blockeditor/blockeditor.ui +++ b/qad/blockview/blockeditor/blockeditor.ui @@ -6,12 +6,16 @@ 0 0 - 901 - 861 + 847 + 810 - Form + Block editor + + + + :/icons/blockview.png:/icons/blockview.png @@ -31,6 +35,12 @@ Qt::AlignCenter + + QFormLayout::AllNonFixedFieldsGrow + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + 4 @@ -166,7 +176,7 @@ Add - + :/icons/list-add.png:/icons/list-add.png @@ -177,7 +187,7 @@ Clone - + :/icons/edit-copy.png:/icons/edit-copy.png @@ -204,7 +214,7 @@ Remove selected - + :/icons/edit-delete.png:/icons/edit-delete.png @@ -215,7 +225,7 @@ Remove all - + :/icons/edit-clear.png:/icons/edit-clear.png @@ -289,19 +299,16 @@ - - - 0 - 0 - - - Save + Save ... - + :/icons/document-save.png:/icons/document-save.png + + Ctrl+S + @@ -309,9 +316,12 @@ Qt::Horizontal + + QSizePolicy::Preferred + - 40 + 20 20 @@ -319,19 +329,16 @@ - - - 0 - 0 - - - Load + Load ... - + :/icons/document-open.png:/icons/document-open.png + + Ctrl+O + @@ -353,7 +360,7 @@ Clear - + :/icons/edit-clear.png:/icons/edit-clear.png @@ -363,12 +370,15 @@ - + :/icons/edit-delete.png:/icons/edit-delete.png Remove items + + Del + @@ -384,7 +394,7 @@ - + diff --git a/qad/blockview/blockeditor/blockeditor_main.cpp b/qad/blockview/blockeditor/blockeditor_main.cpp index 24a6356..8d623f2 100644 --- a/qad/blockview/blockeditor/blockeditor_main.cpp +++ b/qad/blockview/blockeditor/blockeditor_main.cpp @@ -5,6 +5,8 @@ int main(int argc, char * argv[]) { QApplication a(argc, argv); BlockEditor w; + if (a.arguments().size() > 1) + w.loadFile(a.arguments().back()); w.show(); return a.exec(); }