#include "Ermixer.h" Ermixer::Ermixer(QWidget* parent, const char* name, WFlags fl) : QMainWindow(parent, name, fl) { (void)statusBar(); fileLoadAction = new QAction(this); fileSaveAction = new QAction(this); fileExitAction = new QAction(this); helpAboutAction = new QAction(this); fileDeleteAction = new QAction(this); menubar = new QMenuBar(this); fileMenu = new QPopupMenu(this); fileLoadAction->addTo(fileMenu); fileSaveAction->addTo(fileMenu); fileDeleteAction->addTo(fileMenu); fileMenu->insertSeparator(); fileExitAction->addTo(fileMenu); menubar->insertItem("", fileMenu, 0); helpMenu = new QPopupMenu(this); helpAboutAction->addTo(helpMenu); menubar->insertItem("", helpMenu, 1); mixer = new Mixer(this); setCentralWidget(mixer); languageChange(); connect(fileLoadAction, SIGNAL(activated()), this, SLOT(fileOpen())); connect(fileSaveAction, SIGNAL(activated()), this, SLOT(fileSave())); connect(fileDeleteAction, SIGNAL(activated()), this, SLOT(fileDelete())); connect(fileExitAction, SIGNAL(activated()), this, SLOT(fileExit())); connect(helpAboutAction, SIGNAL(activated()), this, SLOT(helpAbout())); connect(qApp, SIGNAL(lastWindowClosed()), qApp, SLOT(quit())); } void Ermixer::languageChange() { setCaption(tr("Ermixer")); fileLoadAction->setText(tr("Load Profile")); fileLoadAction->setMenuText(tr("&Load Profile")); fileLoadAction->setAccel(tr("Ctrl+L")); fileSaveAction->setText(tr("Save Profile")); fileSaveAction->setMenuText(tr("&Save Profile")); fileSaveAction->setAccel(tr("Ctrl+S")); fileExitAction->setText(tr("Exit")); fileExitAction->setMenuText(tr("E&xit")); fileExitAction->setAccel(tr("Ctrl+X")); helpAboutAction->setText(tr("About")); helpAboutAction->setMenuText(tr("&About")); helpAboutAction->setAccel(tr("Ctrl+A")); fileDeleteAction->setText(tr("Erase Profile")); fileDeleteAction->setMenuText(tr("&Erase Profile")); fileDeleteAction->setAccel(tr("Ctrl+E")); menubar->findItem(0)->setText(tr("&File")); menubar->findItem(1)->setText(tr("&Help")); } void Ermixer::fileOpen() { QStringList profileList; getProfiles(); for(int i=0; i < 10 && ret[i][0] != 0; i++) { profileList << QString(ret[i]); } bool ok; QString profileToLoad = QInputDialog::getItem("Load Profile", "Select a profile:", profileList, 0, FALSE, &ok, this); if (ok) { parseFile(profileToLoad.ascii()); initMask(); } } void Ermixer::fileSave() { bool ok; QString fileName = QInputDialog::getText("Save Profile", "Insert profile's name:", QLineEdit::Normal, QString::null, &ok, this); if (ok && !fileName.isEmpty()) { int error=writeFile(fileName.ascii()); switch (error) { case NOSPACE: QMessageBox::warning(this, "Warning!", "Sorry, all 10 slots are full", QMessageBox::Ok, 0); break; case ERROR: QMessageBox::warning(this, "Warning!", "Invalid profile name", QMessageBox::Ok, 0); fileSave(); break; } } } void Ermixer::fileDelete() { QStringList profileList; getProfiles(); for(int i=0; i < 10 && ret[i][0] != 0; i++) { profileList << QString(ret[i]); } bool ok; QString profileToDelete = QInputDialog::getItem("Load Profile", "Select a profile:", profileList, 0, FALSE, &ok, this); if (ok) { deleteFile(profileToDelete.ascii()); } } void Ermixer::fileExit() { qApp->quit(); } void Ermixer::helpAbout() { QMessageBox::about(this, "Ermixer", "Ermixer 0.8\nby NerdSoft (C) 2002"); } #include "Ermixer.moc.cpp"