Skip to content

Commit

Permalink
some code cleanup + listen for FileOpen events
Browse files Browse the repository at this point in the history
new About window (like in OMEdit)
store ini file in openmodelica folder (like OMEdit)
provide custom Info.plist for OS X to set file extensions
maximize window on start
  • Loading branch information
hkiel committed Dec 9, 2016
1 parent 29e5dff commit 71a78d0
Show file tree
Hide file tree
Showing 10 changed files with 242 additions and 241 deletions.
40 changes: 40 additions & 0 deletions OMNotebook/OMNotebookGUI/Info.plist
@@ -0,0 +1,40 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist SYSTEM "file://localhost/System/Library/DTDs/PropertyList.dtd">
<plist version="0.9">
<dict>
<key>CFBundleDocumentTypes</key>
<array>
<dict>
<key>CFBundleTypeExtensions</key>
<array>
<string>onb</string>
<string>onbz</string>
</array>
<key>CFBundleTypeIconFile</key>
<string>@ICON@</string>
<key>CFBundleTypeName</key>
<string>OpenModelica Notebook</string>
<key>CFBundleTypeRole</key>
<string>Editor</string>
<key>LSIsAppleDefaultForType</key>
<true/>
</dict>
</array>
<key>NSPrincipalClass</key>
<string>NSApplication</string>
<key>CFBundleIconFile</key>
<string>@ICON@</string>
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleGetInfoString</key>
<string>Created by Qt/QMake</string>
<key>CFBundleSignature</key>
<string>@TYPEINFO@</string>
<key>CFBundleExecutable</key>
<string>@EXECUTABLE@</string>
<key>CFBundleIdentifier</key>
<string>com.yourcompany.@EXECUTABLE@</string>
<key>NOTE</key>
<string>This file was generated by Qt/QMake.</string>
</dict>
</plist>
2 changes: 2 additions & 0 deletions OMNotebook/OMNotebookGUI/OMNotebookGUI.pro
Expand Up @@ -182,3 +182,5 @@ CONFIG += warn_off

ICON = Resources/OMNotebook_icon.icns

QMAKE_INFO_PLIST = Info.plist

32 changes: 30 additions & 2 deletions OMNotebook/OMNotebookGUI/cellapplication.cpp
Expand Up @@ -83,10 +83,34 @@ namespace IAEX

// ******************************************************

class MyApp : public QApplication {
private:
CellApplication * ca = NULL;
public:
MyApp(int& argc, char**argv, CellApplication * c): QApplication(argc, argv)
{ca = c;}
bool event(QEvent *event) {
switch(event->type())
{
case QEvent::FileOpen:
{
QFileOpenEvent * fileOpenEvent = static_cast<QFileOpenEvent *>(event);
if(fileOpenEvent) {
ca->open(fileOpenEvent->file());

return true;
}
}
default:
return QApplication::event(event);
}
}
};

CellApplication::CellApplication( int &argc, char *argv[] )
: QObject()
{
app_ = new QApplication(argc, argv);
app_ = new MyApp(argc, argv, this);
mainWindow = new QMainWindow();
QDir dir;

Expand Down Expand Up @@ -379,8 +403,12 @@ namespace IAEX

// 2006-01-31 AF, show window again
v->show();
v->raise(); // for MacOS
v->activateWindow(); // for Windows

v->resize( 801, 600 ); //fjass
QDesktopWidget dw;
v->move(0, 0);
v->resize(dw.geometry().width(),dw.geometry().height());

// 2005-11-30 AF, apply hide() and show() to closed groupcells
// childs in the documentview
Expand Down
18 changes: 0 additions & 18 deletions OMNotebook/OMNotebookGUI/graphcell.cpp
Expand Up @@ -83,24 +83,6 @@
using namespace OMPlot;

namespace IAEX {
/*!
* \class SleeperThread
* \author Anders Ferström
*
* \brief Extends QThread. A small trick to get access to protected
* function in QThread.
*/
class SleeperThread : public QThread
{
public:
static void msleep(unsigned long msecs)
{
QThread::msleep(msecs);
}
};



/*!
* \class MyTextEdit2
* \author Anders Ferström
Expand Down
18 changes: 0 additions & 18 deletions OMNotebook/OMNotebookGUI/inputcell.cpp
Expand Up @@ -73,24 +73,6 @@

namespace IAEX
{
/*!
* \class SleeperThread
* \author Anders Ferström
*
* \brief Extends QThread. A small trick to get access to protected
* function in QThread.
*/
class SleeperThread : public QThread
{
public:
static void msleep(unsigned long msecs)
{
QThread::msleep(msecs);
}
};



/*!
* \class MyTextEdit
* \author Anders Ferström
Expand Down
17 changes: 0 additions & 17 deletions OMNotebook/OMNotebookGUI/latexcell.cpp
Expand Up @@ -84,23 +84,6 @@
#include "indent.h"

namespace IAEX {
/*!
* \class SleeperThread
* \author Anders Ferström
*
* \brief Extends QThread. A small trick to get access to protected
* function in QThread.
*/
class SleeperThread : public QThread
{
public:
static void msleep(unsigned long msecs)
{
QThread::msleep(msecs);
}
};


/*!
* \brief Extends QTextEdit. Mostly so I can catch when a user
* clicks on the editor
Expand Down

0 comments on commit 71a78d0

Please sign in to comment.