source: projects/punch-card/punch-card-editor/src/app/mainwindow.ui.cc @ 52

Last change on this file since 52 was 52, checked in by sven, 10 years ago

Punch Card Editor: Code reordering and class renaming, rewriting.
Now using the namespace QPunchCard everywhere.

Parted the whole application into 5 parts/directories:

  • app: The application core with MainWindow and main() function
  • qpunchcard: Everything directly binary card related (no interpretation): modeling, input/output, view. Most important classes are Card, Deck, FileFormat, Widget
  • text: Everything related to text interpretation of Cards/Card Decks. Having the abstract Codec classes and the Text::Editor, Text::EditorDock
  • deckviewer: Application components like binary card editing central widget (CardEditor) and Navigator (Model View Controller classes)
  • driver: Basis for the driver framework, must be written soon.

Deck now hides the complete Storage to implement frontend methods that
implement versioning (Undo framework). All code was cleaned up, but doesn't
compile right now (still quite some non heavy errors).

-- Sven @ workstation

File size: 6.3 KB
Line 
1#include "mainwindow.h"
2#include "qpunchcard/card.h"
3#include "qpunchcard/widget.h"
4#include "deckviewer/navigatormodel.h"
5
6#include <QApplication>
7#include <QLabel>
8#include <QtDebug>
9#include <QListView>
10#include <QDockWidget>
11#include <QHBoxLayout>
12#include <QPushButton>
13#include <QMessageBox>
14#include <QFileDialog>
15#include <QFileInfo>
16
17using namespace QPunchCard;
18using namespace App;
19
20void MainWindow::createActions() {
21        new_file_action = new QAction(tr("&New File (Empty Card Deck)"), this);
22        new_file_action->setShortcuts(QKeySequence::New);
23        new_file_action->setStatusTip(tr("Create a new empty card deck"));
24        connect(new_file_action, SIGNAL(triggered()), this, SLOT(newFile()));
25
26        new_window_action = new QAction(tr("&New Window"), this);
27        new_window_action->setStatusTip(tr("Open a new Application window to edit two card decks concurrently"));
28        connect(new_window_action, SIGNAL(triggered()), this, SLOT(newWindow()));
29
30        open_file_action = new QAction(tr("&Open File..."), this);
31        open_file_action->setShortcuts(QKeySequence::Open);
32        open_file_action->setStatusTip(tr("Open existing card file (any card deck file or text file)"));
33        connect(open_file_action, SIGNAL(triggered()), this, SLOT(openFile()));
34
35        save_file_action = new QAction(tr("&Save File"), this);
36        save_file_action->setShortcuts(QKeySequence::Save);
37        save_file_action->setStatusTip(tr("Save the current file as card deck"));
38        connect(save_file_action, SIGNAL(triggered()), this, SLOT(saveFile()));
39
40        save_file_as_action = new QAction(tr("&Save File as..."), this);
41        save_file_as_action->setShortcuts(QKeySequence::SaveAs);
42        save_file_as_action->setStatusTip(tr("Save the current card deck as another file"));
43        connect(save_file_as_action, SIGNAL(triggered()), this, SLOT(saveFileAs()));
44
45        export_text_action = new QAction(tr("&Export Text..."), this);
46        export_text_action->setStatusTip(tr("Save the decoded plaintext of the current card deck"));
47        connect(export_text_action, SIGNAL(triggered()), this, SLOT(exportText()));
48
49        export_picture_action = new QAction(tr("&Export Picture of Card..."), this);
50        export_picture_action->setStatusTip(tr("Save the visualisation of one or more cards as a picture"));
51        connect(export_picture_action, SIGNAL(triggered()), this, SLOT(exportPicture()));
52
53        close_file_action = new QAction(tr("&Close File"), this);
54        close_file_action->setStatusTip(tr("Close current file while staying in the application"));
55        connect(close_file_action, SIGNAL(triggered()), this, SLOT(closeFile()));
56
57        quit_action = new QAction(tr("&Quit"), this);
58        quit_action->setStatusTip(tr("Quit Application"));
59        connect(quit_action, SIGNAL(triggered()), qApp, SLOT(closeAllWindows()));
60
61        help_action = new QAction(tr("&Help"), this);
62        help_action->setStatusTip(tr("Get Help about the usage of this program"));
63        connect(help_action, SIGNAL(triggered()), this, SLOT(help()));
64
65        about_action = new QAction(tr("&About"), this);
66        about_action->setStatusTip(tr("Display some information about the author and program version"));
67        connect(about_action, SIGNAL(triggered()), this, SLOT(about()));
68
69        new_text_editor_action = new QAction(tr("Open new &Text editor"), this);
70        new_text_editor_action->setStatusTip(tr("Display another text editor for editing the dock using a card code"));
71        connect(new_text_editor_action, SIGNAL(triggered()), this, SLOT(newTextEditor()));
72
73        undo_action = new QAction(tr("&Undo"), this);
74        redo_action = new QAction(tr("&Redo"), this);
75        undo_action->setStatusTip(tr("Undo latest changes"));
76        redo_action->setStatusTip(tr("Redo latest changes"));
77
78        next_card_action = new QAction(tr("&Next Card"), this);
79        next_card_action->setStatusTip(tr("Go to next Card"));
80        connect(next_card_action, SIGNAL(triggered()), this, SLOT(nextCard()));
81
82        prev_card_action = new QAction(tr("&Previous Card"), this);
83        prev_card_action->setStatusTip(tr("Go to previous Card"));
84        connect(prev_card_action, SIGNAL(triggered()), this, SLOT(prevCard()));
85
86        new_card_action = new QAction(tr("Insert &new Card"), this);
87        new_card_action->setStatusTip(tr("Insert new blanco card after current card"));
88        connect(new_card_action, SIGNAL(triggered()), this, SLOT(newCard()));
89
90        move_forwards_action = new QAction(tr("Move forwards"), this);
91        move_forwards_action->setStatusTip(tr("Move current card forwards"));
92        connect(move_forwards_action, SIGNAL(triggered()), this, SLOT(moveCardForwards()));
93
94        move_backwards_action = new QAction(tr("Move backwards"), this);
95        move_backwards_action->setStatusTip(tr("Move current card backwards"));
96        connect(move_backwards_action, SIGNAL(triggered()), this, SLOT(moveCardBackwards()));
97
98        // mehr Signale erst beim oeffnen/schliessen einer Datei
99}
100
101void MainWindow::createMenus() {
102        file_menu = menuBar()->addMenu(tr("&File"));
103        file_menu->addAction(new_file_action);
104        file_menu->addSeparator();
105        file_menu->addAction(open_file_action);
106        file_menu->addAction(save_file_action);
107        file_menu->addAction(save_file_as_action);
108        file_menu->addSeparator();
109        file_menu->addAction(export_text_action);
110        file_menu->addAction(export_picture_action);
111        file_menu->addSeparator();
112        file_menu->addAction(close_file_action);
113        file_menu->addAction(quit_action);
114
115        edit_menu = menuBar()->addMenu(tr("&Edit"));
116        edit_menu->addAction(undo_action);
117        edit_menu->addAction(redo_action);
118        edit_menu->addSeparator();
119        // ---
120        // Cut, Copy, Insert
121        // --
122        // Insert punch card
123        // usw.
124
125        view_menu = menuBar()->addMenu(tr("&View"));
126        view_menu->addAction(new_text_editor_action);
127        view_menu->addSeparator();
128        // Ansichten:
129        // - Neue Textansicht hinzufuegen
130        // - Eigenschaften der Lochkarten-Ansicht hinzufuegen
131        // - Visualisierungsansicht aendern und so (Qualitaet)
132        // Navigation
133        // - Vor/Zurueck bei Lochkarte oder Spalte (letzteres doof)
134
135        devices_menu = menuBar()->addMenu(tr("&Devices"));
136        // hier alle Geraete auflisten, fuer die es Treiber gibt (=> driver, DriverOverview oder so)
137
138        help_menu = menuBar()->addMenu(tr("&Help"));
139        help_menu->addAction(help_action);
140        help_menu->addAction(tr("About &Qt"), qApp, SLOT(aboutQt()));
141        help_menu->addAction(about_action);
142}
143
144void MainWindow::createToolBars() {
145        // ja ne... waere momentan noch das gleiche wie die Menus, also
146        // schon irgendwie iditisch. Egal:
147
148        navi_bar = addToolBar(tr("Navigation"));
149        navi_bar->addAction(prev_card_action);
150        navi_bar->addAction(next_card_action);
151        navi_bar->addAction(new_card_action);
152        navi_bar->addAction(this->move_backwards_action);
153        navi_bar->addAction(this->move_forwards_action);
154}
Note: See TracBrowser for help on using the repository browser.
© 2008 - 2013 technikum29 • Sven Köppel • Some rights reserved
Powered by Trac
Expect where otherwise noted, content on this site is licensed under a Creative Commons 3.0 License