]> Shamusworld >> Repos - ttedit/blobdiff - src/ttedit.cpp
Converted project from wxWidgets to Qt. This will be the LAST time this
[ttedit] / src / ttedit.cpp
index 17617f167e9c2a225070a9f517cdcfbefc4eb52a..c8123773ce2bfd885d23197e36a42ae2f99c9c74 100755 (executable)
@@ -13,6 +13,7 @@
 // JLH  11/18/2006  Initial port to Linux
 // JLH  08/27/2008  Fixed tool palette focus problems
 // JLH  08/28/2008  Split out classes defined here into separate files
+// JLH  03/05/2009  Initial conversion from wxWidgets to Qt
 //
 
 // FIXED:
 #define DEBUGFOO                       // Various tool debugging...
 #define DEBUGTP                                // Toolpalette debugging...
 
+//#include <QtGui>
+#include "ttedit.h"
+#include <QApplication>
+#include "editwindow.h"
+
+// Here's the main application loop--short and simple...
+int main(int argc, char * argv[])
+{
+       Q_INIT_RESOURCE(ttedit);        // This must the same name as the exe filename
+
+       QApplication app(argc, argv);
+       TTEMainWindow TTEWin;
+       TTEWin.show();
+       return app.exec();
+}
+
+
+TTEMainWindow::TTEMainWindow()
+{
+       editWnd = new EditWindow(this);
+       setCentralWidget(editWnd);
+       setWindowIcon(QIcon(":/res/ttedit.png"));
+       setWindowTitle("TTEdit!");
+
+#if 0
+//     createActions();
+       newAct = new QAction(QIcon(":/images/new.png"), tr("&New"), this);
+       newAct->setShortcuts(QKeySequence::New);
+       newAct->setStatusTip(tr("Create a new file"));
+       connect(newAct, SIGNAL(triggered()), this, SLOT(newFile()));
+
+       openAct = new QAction(QIcon(":/images/open.png"), tr("&Open..."), this);
+       openAct->setShortcuts(QKeySequence::Open);
+       openAct->setStatusTip(tr("Open an existing file"));
+       connect(openAct, SIGNAL(triggered()), this, SLOT(open()));
+
+       aboutQtAct = new QAction(tr("About &Qt"), this);
+       aboutQtAct->setStatusTip(tr("Show the Qt library's About box"));
+       connect(aboutQtAct, SIGNAL(triggered()), qApp, SLOT(aboutQt()));
+
+//     createMenus();
+       fileMenu = menuBar()->addMenu(tr("&File"));
+       fileMenu->addAction(newAct);
+       fileMenu->addAction(openAct);
+       fileMenu->addAction(saveAct);
+       fileMenu->addAction(saveAsAct);
+       fileMenu->addSeparator();
+       fileMenu->addAction(exitAct);
+
+       editMenu = menuBar()->addMenu(tr("&Edit"));
+       editMenu->addAction(cutAct);
+       editMenu->addAction(copyAct);
+       editMenu->addAction(pasteAct);
+
+       menuBar()->addSeparator();
+
+       helpMenu = menuBar()->addMenu(tr("&Help"));
+       helpMenu->addAction(aboutAct);
+       helpMenu->addAction(aboutQtAct);
+
+//     createToolBars();
+       fileToolBar = addToolBar(tr("File"));
+       fileToolBar->addAction(newAct);
+       fileToolBar->addAction(openAct);
+       fileToolBar->addAction(saveAct);
+
+       editToolBar = addToolBar(tr("Edit"));
+       editToolBar->addAction(cutAct);
+       editToolBar->addAction(copyAct);
+       editToolBar->addAction(pasteAct);
+#endif
+
+       //      Create status bar
+       statusBar()->showMessage(tr("Ready"));
+
+       ReadSettings();
+
+//     connect(textEdit->document(), SIGNAL(contentsChanged()),
+//                     this, SLOT(documentWasModified()));
+
+//     setCurrentFile("");
+       setUnifiedTitleAndToolBarOnMac(true);
+}
+
+void TTEMainWindow::closeEvent(QCloseEvent * event)
+{
+       WriteSettings();
+       event->accept(); // ignore() if can't close for some reason
+}
+
+void TTEMainWindow::Open(void)
+{
+}
+
+void TTEMainWindow::ReadSettings(void)
+{
+       QSettings settings("Underground Software", "TTEdit");
+       QPoint pos = settings.value("pos", QPoint(200, 200)).toPoint();
+       QSize size = settings.value("size", QSize(400, 400)).toSize();
+       resize(size);
+       move(pos);
+}
+
+void TTEMainWindow::WriteSettings(void)
+{
+       QSettings settings("Underground Software", "TTEdit");
+       settings.setValue("pos", pos());
+       settings.setValue("size", size());
+}
+
+
+#if 0
 #include "ttedit.h"
 #include "charwindow.h"
 #include "toolwindow.h"
@@ -237,3 +350,4 @@ void TTEditFrame::OnCloseWindow(wxCloseEvent &e)
        app.toolPalette->Destroy();
        this->Destroy();
 }
+#endif