X-Git-Url: http://shamusworld.gotdns.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Fmainwindow.cpp;fp=src%2Fmainwindow.cpp;h=ef738e95102f56ae4ec784ecc84b86949b297f2d;hb=7fde5a077bc9bbce28662fa2e5aa5043f3b4747f;hp=dea9087af7bf9496ed81a93fd60475091567f55e;hpb=0c01fa32c7e0629ae61992e0419f03724fc18487;p=ttedit diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index dea9087..ef738e9 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -6,7 +6,7 @@ // JLH = James L. Hammons // // Who When What -// --- ---------- ------------------------------------------------------------- +// --- ---------- ----------------------------------------------------------- // JLH 04/10/2002 Created this file // JLH 05/10/2004 Translated file from ASM to CPP // JLH 05/14/2004 Added rudimentary editing capability to tool palette tools @@ -18,7 +18,8 @@ // FIXED: // -// - Fix problem with tool palette not getting focus 1st time it's called up [DONE] +// - Fix problem with tool palette not getting focus 1st time it's called up +// [DONE] // - Split out windows/classes defined here into their own files [DONE] // // STILL TO BE DONE: @@ -47,7 +48,7 @@ MainWindow::MainWindow() setCentralWidget(editWnd); editWnd->setFocus(); setWindowIcon(QIcon(":/res/ttedit.png")); - setWindowTitle("TTEdit!"); + setWindowTitle("TTEdit! - Untitled"); #if 0 // createActions(); @@ -102,6 +103,8 @@ MainWindow::MainWindow() #endif // Create status bar + scaleIndicator = new QLabel("Scale: 100%"); + statusBar()->addPermanentWidget(scaleIndicator); statusBar()->showMessage(tr("Ready")); ReadSettings(); @@ -119,8 +122,8 @@ MainWindow::MainWindow() // // Consolidates action creation from a multi-step process to a single-step one. // -QAction * MainWindow::CreateAction(QString name, QString tooltip, QString statustip, - QIcon icon, QKeySequence key, bool checkable/*= false*/) +QAction * MainWindow::CreateAction(QString name, QString tooltip, QString + statustip, QIcon icon, QKeySequence key, bool checkable/*= false*/) { QAction * action = new QAction(icon, name, this); action->setToolTip(tooltip); @@ -136,8 +139,9 @@ QAction * MainWindow::CreateAction(QString name, QString tooltip, QString status // This is essentially the same as the previous function, but this allows more // than one key sequence to be added as key shortcuts. // -QAction * MainWindow::CreateAction(QString name, QString tooltip, QString statustip, - QIcon icon, QKeySequence key1, QKeySequence key2, bool checkable/*= false*/) +QAction * MainWindow::CreateAction(QString name, QString tooltip, QString + statustip, QIcon icon, QKeySequence key1, QKeySequence key2, bool + checkable/*= false*/) { QAction * action = new QAction(icon, name, this); action->setToolTip(tooltip); @@ -155,12 +159,18 @@ QAction * MainWindow::CreateAction(QString name, QString tooltip, QString status void MainWindow::CreateActions(void) { newGlyphAct = CreateAction("&New Glyph", "New Glyph", "Create a new glyph", QIcon(), QKeySequence()); - openFileAct = CreateAction("&Open File", "Open File", "Open a glyph file", QIcon(), QKeySequence()); - saveFileAct = CreateAction("&Save File", "Save File", "Save a glyph file", QIcon(), QKeySequence()); + openFileAct = CreateAction("&Open File", "Open File", "Open a glyph file", QIcon(), QKeySequence("ctrl+o")); + saveFileAct = CreateAction("&Save File", "Save File", "Save a glyph file", QIcon(), QKeySequence("ctrl+s")); + quitAct = CreateAction("&Quit", "Quit", "Exits from the TTEdit application", QIcon(), QKeySequence("ctrl+q")); + zoomInAct = CreateAction("Zoom In", "Zoom In", "Zoom into the canvas", QIcon(), QKeySequence("+"), QKeySequence("=")); + zoomOutAct = CreateAction("Zoom Out", "Zoom Out", "Zoom out of canvas", QIcon(), QKeySequence("-")); connect(newGlyphAct, SIGNAL(triggered()), this, SLOT(NewGlyph())); connect(openFileAct, SIGNAL(triggered()), this, SLOT(OpenFile())); connect(saveFileAct, SIGNAL(triggered()), this, SLOT(SaveFile())); + connect(quitAct, SIGNAL(triggered()), this, SLOT(close())); + connect(zoomInAct, SIGNAL(triggered()), this, SLOT(ZoomIn())); + connect(zoomOutAct, SIGNAL(triggered()), this, SLOT(ZoomOut())); } @@ -170,8 +180,13 @@ void MainWindow::CreateMenus(void) menu->addAction(newGlyphAct); menu->addAction(openFileAct); menu->addAction(saveFileAct); + menu->addSeparator(); + menu->addAction(quitAct); // menu->addAction(fileSaveAsAct); // menu->addAction(fileCloseAct); + menu = menuBar()->addMenu(tr("&View")); + menu->addAction(zoomInAct); + menu->addAction(zoomOutAct); } @@ -194,6 +209,8 @@ void MainWindow::NewGlyph(void) ((TTEdit *)qApp)->charWnd->update(); // editWnd->polyFirstPoint = true; editWnd->update(); + setWindowTitle("TTEdit! - Untitled"); + editWnd->setFocus(); } @@ -213,6 +230,8 @@ void MainWindow::OpenFile(void) ((TTEdit *)qApp)->charWnd->MakePathFromPoints(&(editWnd->pts)); ((TTEdit *)qApp)->charWnd->update(); editWnd->update(); + setWindowTitle(QString("TTEdit! - %1").arg(filename)); + editWnd->setFocus(); } @@ -228,6 +247,30 @@ void MainWindow::SaveFile(void) editWnd->pts.SaveGlyphToFile(file); fclose(file); + setWindowTitle(QString("TTEdit! - %1").arg(filename)); + editWnd->setFocus(); +} + + +void MainWindow::ZoomIn(void) +{ + if (editWnd->scale == 4.0) + return; + + editWnd->scale *= 2.0; + scaleIndicator->setText(QString("Scale: %1%").arg(editWnd->scale * 100.0)); + editWnd->update(); +} + + +void MainWindow::ZoomOut(void) +{ + if (editWnd->scale == 0.25) + return; + + editWnd->scale *= 0.5; + scaleIndicator->setText(QString("Scale: %1%").arg(editWnd->scale * 100.0)); + editWnd->update(); }