[f84224]: main.cpp Maximize Restore History

Download this file

main.cpp    189 lines (174 with data), 6.6 kB

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
#include "main.h"
#include "qkeycode.h"
MSignal *clipboard=0;
QList<TopWidget>*topwidget=0;
//*****************************************************************************************
TopWidget::TopWidget (const char *name) : KTopLevelWidget (name)
{
QPopupMenu *file= new QPopupMenu ();
QPopupMenu *edit= new QPopupMenu ();
QPopupMenu *clip= new QPopupMenu ();
QPopupMenu *effects= new QPopupMenu ();
QPopupMenu *help= new QPopupMenu ();
status=new KStatusBar (this,"Main Status Bar");
status->insertItem ("Length: 0 ms ",1);
status->insertItem ("Rate: 0 kHz ",2);
status->insertItem ("Samples: 0 ",3);
status->insertItem ("selected: 0 ms ",4);
status->insertItem ("Clipboard: 0 ms ",5);
bar= new KMenuBar (this,"MainMenu");
mainwidget= new MainWidget (this,"MainView",status);
file->insertItem (klocale->translate("&New..."), this,SLOT(file_new()),CTRL+Key_N);
file->insertItem (klocale->translate("New &Instance"),this,SLOT(inst_new()),CTRL+Key_I);
file->insertSeparator ();
file->insertItem (klocale->translate("&Open"), this,SLOT(openFile()),CTRL+Key_O);
file->insertItem (klocale->translate("&Save"), this,SLOT(saveFile()),CTRL+Key_S);
file->insertItem (klocale->translate("Save &As"),this,SLOT(saveFileas()),CTRL+Key_A);
file->insertItem (klocale->translate("Save Se&lection"),this,SLOT(saveSelection()),CTRL+Key_L);
file->insertSeparator ();
file->insertItem (klocale->translate("&Quit"), this,SLOT(inst_quit()),CTRL+Key_Q);
edit->insertItem (klocale->translate("Cut"), this,SLOT(cutOp()),CTRL+Key_X);
edit->insertItem (klocale->translate("Copy"), this,SLOT(copyOp()),CTRL+Key_C);
edit->insertItem (klocale->translate("Paste"), this,SLOT(pasteOp()),CTRL+Key_V);
edit->insertItem (klocale->translate("Crop"), this,SLOT(cropOp()));
edit->insertItem (klocale->translate("Delete"), this,SLOT(deleteOp()),Key_Delete);
edit->insertItem (klocale->translate("Flip"), this,SLOT(flipOp()));
edit->insertSeparator ();
clip->insertItem (klocale->translate("Flush"), this,SLOT(flushClip()));
clip->insertItem (klocale->translate("to new Window"),this,SLOT(cliptoNew()));
edit->insertItem (klocale->translate("Clipboard"),clip);
effects->insertItem (klocale->translate("Zero"), this,SLOT(zeroOp()));
effects->insertItem (klocale->translate("Reverse"), this,SLOT(reverseOp()));
help->insertItem (klocale->translate("About"), this,SLOT(about()));
bar->insertItem (klocale->translate("File"), file);
bar->insertItem (klocale->translate("Edit"), edit);
bar->insertItem (klocale->translate("Effects"), effects);
bar->insertItem (klocale->translate("Help"), help);
setView (mainwidget);
setMenu (bar);
setStatusBar (status);
}
//*****************************************************************************************
void TopWidget::file_new ()
{
QDialog *select=new QDialog (this,"ParamSelector",true);
QPushButton *ok=new QPushButton ("Ok",select);
QObject::connect (ok,SIGNAL(clicked()),select,SLOT (accept()));
select->exec();
delete select;
}
//*****************************************************************************************
void TopWidget::about ()
{
printf ("by Martin Wilz\n");
}
//*****************************************************************************************
void TopWidget::inst_quit ()
{
int index;
this->hide();
index=topwidget->find (this); //remove this instance
if (index!=-1) topwidget->remove(index); //from list of widgets
if (!topwidget->isEmpty())
{
qApp->setMainWidget(topwidget->last());
}
else
{
printf ("last Instance !\n");
qApp->exit (0);
}
}
//*****************************************************************************************
void TopWidget::inst_new ()
{
TopWidget *tnew=new TopWidget();
topwidget->append (tnew);
tnew->show();
}
//*****************************************************************************************
void TopWidget::cliptoNew ()
{
if (clipboard)
{
TopWidget *tnew=new TopWidget();
topwidget->append (tnew);
tnew->setSignal (clipboard);
tnew->show();
tnew->setCaption ("Copy of Clipboard");
}
}
//*****************************************************************************************
void TopWidget::flushClip ()
{
if (clipboard) delete clipboard;
clipboard=0;
}
//*****************************************************************************************
void TopWidget::deleteOp() {mainwidget->setRangeOp (DELETE);}
void TopWidget::cutOp () {mainwidget->setRangeOp (CUT);}
void TopWidget::copyOp () {mainwidget->setRangeOp (COPY);}
void TopWidget::pasteOp () {mainwidget->setRangeOp (PASTE);}
void TopWidget::cropOp () {mainwidget->setRangeOp (CROP);}
void TopWidget::zeroOp () {mainwidget->setRangeOp (ZERO);}
void TopWidget::flipOp() {mainwidget->setRangeOp (FLIP);}
void TopWidget::reverseOp() {mainwidget->setRangeOp (REVERSE);}
//*****************************************************************************************
void TopWidget::openFile ()
{
name=QFileDialog::getOpenFileName ();
if (!name.isNull())
mainwidget->setSignal (&name);
setCaption (name.data());
}
//*****************************************************************************************
void TopWidget::saveFile ()
{
if (!name.isEmpty())
{
mainwidget->saveSignal (&name);
}
}
//*****************************************************************************************
void TopWidget::saveFileas ()
{
name=QFileDialog::getSaveFileName ();
if (!name.isNull())
mainwidget->saveSignal (&name);
}
//*****************************************************************************************
void TopWidget::saveSelection ()
{
name=QFileDialog::getSaveFileName ();
if (!name.isNull())
mainwidget->saveSelectedSignal (&name);
}
//*****************************************************************************************
void TopWidget::setSignal (QString name)
{
mainwidget->setSignal (&name);
setCaption (name.data());
}
//*****************************************************************************************
void TopWidget::setSignal (MSignal *signal)
{
mainwidget->setSignal (signal);
}
//*****************************************************************************************
int main( int argc, char **argv )
{
KApplication a( argc, argv);
TopWidget *tnew;
tnew=new TopWidget();
topwidget=new QList<TopWidget>();
topwidget->append (tnew);
printf ("%d\n",argc);
if (argc==2)
{
QString filename=argv[1];
tnew->setSignal (filename);
}
a.setMainWidget( tnew );
tnew->show();
return a.exec();
}