summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYorhel <git@yorhel.nl>2009-02-03 19:35:52 +0100
committerYorhel <git@yorhel.nl>2009-02-03 19:35:52 +0100
commit91dab729c4acebb57b49f121b01464da02a11005 (patch)
treece3fb518e7b1023805a3f8c5a2f7d2a975f9ee10
parentbc795c675f93b8e46dd524c3b4500c26e66c63c6 (diff)
Opening/closing script files + more interaction
-rw-r--r--seentl.cpp25
-rw-r--r--seentl.h4
-rw-r--r--seentl.ui24
3 files changed, 51 insertions, 2 deletions
diff --git a/seentl.cpp b/seentl.cpp
index d9f808c..8c6e84e 100644
--- a/seentl.cpp
+++ b/seentl.cpp
@@ -2,7 +2,6 @@
#include "ui_seentl.h"
#include <QHeaderView>
#include <QFileDialog>
-#include <QFileInfo>
#include <QMessageBox>
#include <QDebug>
@@ -23,6 +22,8 @@ SEENTL::SEENTL(QWidget *parent)
ui->lines->horizontalHeader()->resizeSection(3, 100);
connect(ui->actionOpen, SIGNAL(triggered()), this, SLOT(openScript()));
+ connect(ui->actionClose, SIGNAL(triggered()), this, SLOT(closeScript()));
+ connect(ui->actionExit, SIGNAL(triggered()), this, SLOT(closeApp()));
}
SEENTL::~SEENTL()
@@ -32,6 +33,7 @@ SEENTL::~SEENTL()
void SEENTL::openScript()
{
+ closeScript();
QString fn = QFileDialog::getOpenFileName(this, "Open File", "", "Script files (*.utf)");
if(fn == "")
return;
@@ -41,4 +43,25 @@ void SEENTL::openScript()
return;
}
script.openScript(fn);
+ file = fi;
+
+ setWindowTitle(QString("%1 - SEENTL").arg(file.fileName()));
+ ui->actionClose->setEnabled(1);
+}
+
+void SEENTL::closeScript()
+{
+ if(file.fileName() == "")
+ return;
+ // TODO; ask if opened script has changes
+ script.closeScript();
+ file.setFile("");
+ ui->actionClose->setEnabled(0);
+ setWindowTitle(QString("SEENTL"));
+}
+
+void SEENTL::closeApp()
+{
+ closeScript();
+ close();
}
diff --git a/seentl.h b/seentl.h
index 1bfad73..455971c 100644
--- a/seentl.h
+++ b/seentl.h
@@ -2,6 +2,7 @@
#define SEENTL_H
#include <QtGui/QMainWindow>
+#include <QFileInfo>
#include "utfscriptmodel.h"
namespace Ui
@@ -19,10 +20,13 @@ public:
public slots:
void openScript();
+ void closeScript();
+ void closeApp();
private:
Ui::SEENTLClass *ui;
utfScriptModel script;
+ QFileInfo file;
};
diff --git a/seentl.ui b/seentl.ui
index 536e094..93c51af 100644
--- a/seentl.ui
+++ b/seentl.ui
@@ -33,7 +33,7 @@
<x>0</x>
<y>0</y>
<width>600</width>
- <height>23</height>
+ <height>24</height>
</rect>
</property>
<widget class="QMenu" name="menu_File">
@@ -42,6 +42,9 @@
</property>
<addaction name="actionOpen"/>
<addaction name="actionSave"/>
+ <addaction name="actionClose"/>
+ <addaction name="separator"/>
+ <addaction name="actionExit"/>
</widget>
<addaction name="menu_File"/>
</widget>
@@ -62,6 +65,25 @@
<string>Ctrl+S</string>
</property>
</action>
+ <action name="actionExit">
+ <property name="text">
+ <string>Exit</string>
+ </property>
+ <property name="shortcut">
+ <string>Ctrl+Q</string>
+ </property>
+ </action>
+ <action name="actionClose">
+ <property name="enabled">
+ <bool>false</bool>
+ </property>
+ <property name="text">
+ <string>Close</string>
+ </property>
+ <property name="shortcut">
+ <string>Ctrl+W</string>
+ </property>
+ </action>
</widget>
<layoutdefault spacing="6" margin="11"/>
<resources/>