OSDN Git Service

[denncoCreator] minor improvements for window titles and application close behavior.
[dennco/denncoCreator.git] / Source / uieditor / dcuieditor.h
1 //  Copyright (c) 2012 Dennco Project
2 //
3 // This program is free software: you can redistribute it and/or modify
4 // it under the terms of the GNU General Public License as published by
5 // the Free Software Foundation, either version 3 of the License, or
6 // (at your option) any later version.
7 //
8 // This program is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11 // GNU General Public License for more details.
12 //
13 // You should have received a copy of the GNU General Public License
14 // along with this program.  If not, see <http://www.gnu.org/licenses/>.
15
16 //
17 //  Created by tkawata on Oct-20, 2012.
18 //
19 #ifndef DCUIEDITOR_H
20 #define DCUIEDITOR_H
21
22 #include <QDialog>
23 #include <QTabWidget>
24 #include <QWebView>
25 #include <QPushButton>
26
27 class DCUITextEditor;
28
29 class DCUIJSInterface : public QObject
30 {
31     Q_OBJECT
32 public:
33     DCUIJSInterface();
34     virtual ~DCUIJSInterface();
35
36 signals:
37
38 public slots:
39     void    setValue(const QString name, float value);
40     float   getValue(const QString name) const;
41 };
42
43 class DCUIEditor : public QDialog
44 {
45     Q_OBJECT
46
47     QTabWidget      *d_tabWidget;
48     QWebView        *d_webView;
49     DCUITextEditor  *d_textEditor;
50     QString         d_originalSource;
51
52     QString         d_editingFile;
53     bool            d_isEditing;
54     bool            d_isInInitialization;
55     bool            d_isChangeMade;
56     QObject         *d_jsInterface;
57
58     QPushButton     *d_saveButton;
59     QPushButton     *d_closeButton;
60
61     bool            getIsModified() const;
62     bool            maybeSave();
63
64     void            updateWindowTitle(bool fileModified);
65 public:
66     explicit DCUIEditor(QWidget *parent = 0);
67
68     static DCUIEditor* getEditor();
69     static void destroyEditor();
70
71     virtual void closeEvent(QCloseEvent *event);
72
73     bool startEditing(const QString& sysFilePath);
74
75 signals:
76     
77 private slots:
78     bool saveChange();
79     void javaScriptWindowObjectCleared();
80     void tabChanged(int index);
81     void textChanged();
82 };
83
84 #endif // DCUIEDITOR_H