// private void kpTool::keyUpdateModifierState (QKeyEvent *e) { #if DEBUG_KP_TOOL && 0 kdDebug () << "kpTool::updateModifierState() e->key=" << e->key () << endl; kdDebug () << "\tshift=" << (e->stateAfter () & Qt::ShiftButton) << " control=" << (e->stateAfter () & Qt::ControlButton) << " alt=" << (e->stateAfter () & Qt::AltButton) << endl; #endif if (e->key () & (Qt::Key_Alt | Qt::Key_Shift | Qt::Key_Control)) { #if DEBUG_KP_TOOL && 0 kdDebug () << "\t\tmodifier changed - use e's claims" << endl; #endif setShiftPressed (e->stateAfter () & Qt::ShiftButton); setControlPressed (e->stateAfter () & Qt::ControlButton); setAltPressed (e->stateAfter () & Qt::AltButton); } else { #if DEBUG_KP_TOOL && 0 kdDebug () << "\t\tmodifiers not changed - figure out the truth" << endl; #endif uint keyState = KApplication::keyboardModifiers (); setShiftPressed (keyState & KApplication::ShiftModifier); setControlPressed (keyState & KApplication::ControlModifier); // TODO: Can't do much about ALT - unless it's always KApplication::Modifier1? // Ditto for everywhere else where I set SHIFT & CTRL but not alt. setAltPressed (e->stateAfter () & Qt::AltButton); } }
MainWindow::MainWindow() : QMainWindow(0) { readSettings(); QString lang = getSettingsGeneralLanguage(); qDebug("language: %s", qPrintable(lang)); if(lang == "system") lang = QLocale::system().languageToString(QLocale::system().language()).toLower(); //Load translations for the Embroidermodder 2 GUI QTranslator translatorEmb; translatorEmb.load("translations/" + lang + "/embroidermodder2_" + lang); qApp->installTranslator(&translatorEmb); //Load translations for the commands QTranslator translatorCmd; translatorCmd.load("translations/" + lang + "/commands_" + lang); qApp->installTranslator(&translatorCmd); //Load translations provided by Qt - this covers dialog buttons and other common things. QTranslator translatorQt; translatorQt.load("qt_" + QLocale::system().name(), QLibraryInfo::location(QLibraryInfo::TranslationsPath)); qApp->installTranslator(&translatorQt); //Init mainWin = this; //Menus fileMenu = new QMenu(tr("&File"), this); editMenu = new QMenu(tr("&Edit"), this); viewMenu = new QMenu(tr("&View"), this); settingsMenu = new QMenu(tr("&Settings"), this); windowMenu = new QMenu(tr("&Window"), this); helpMenu = new QMenu(tr("&Help"), this); //SubMenus recentMenu = new QMenu(tr("Open &Recent"), this); zoomMenu = new QMenu(tr("&Zoom"), this); panMenu = new QMenu(tr("&Pan"), this); //Toolbars toolbarFile = addToolBar(tr("File")); toolbarEdit = addToolBar(tr("Edit")); toolbarView = addToolBar(tr("View")); toolbarZoom = addToolBar(tr("Zoom")); toolbarPan = addToolBar(tr("Pan")); toolbarIcon = addToolBar(tr("Icon")); toolbarHelp = addToolBar(tr("Help")); toolbarLayer = addToolBar(tr("Layer")); toolbarProperties = addToolBar(tr("Properties")); toolbarText = addToolBar(tr("Text")); toolbarPrompt = addToolBar(tr("Command Prompt")); //Selectors layerSelector = new QComboBox(this); colorSelector = new QComboBox(this); linetypeSelector = new QComboBox(this); lineweightSelector = new QComboBox(this); textFontSelector = new QFontComboBox(this); textSizeSelector = new QComboBox(this); numOfDocs = 0; docIndex = 0; shiftKeyPressedState = false; setWindowIcon(QIcon("icons/" + getSettingsGeneralIconTheme() + "/" + "app" + ".png")); //create the mdiArea QFrame* vbox = new QFrame(this); QVBoxLayout* layout = new QVBoxLayout(vbox); layout->setMargin(0); vbox->setFrameStyle(QFrame::StyledPanel | QFrame::Sunken); mdiArea = new MdiArea(this, vbox); mdiArea->useBackgroundLogo(getSettingsGeneralMdiBGUseLogo()); mdiArea->useBackgroundTexture(getSettingsGeneralMdiBGUseTexture()); mdiArea->useBackgroundColor(getSettingsGeneralMdiBGUseColor()); mdiArea->setBackgroundLogo(getSettingsGeneralMdiBGLogo()); mdiArea->setBackgroundTexture(getSettingsGeneralMdiBGTexture()); mdiArea->setBackgroundColor(QColor(getSettingsGeneralMdiBGColor())); mdiArea->setViewMode(QMdiArea::TabbedView); mdiArea->setHorizontalScrollBarPolicy(Qt::ScrollBarAsNeeded); mdiArea->setVerticalScrollBarPolicy(Qt::ScrollBarAsNeeded); mdiArea->setActivationOrder(QMdiArea::ActivationHistoryOrder); layout->addWidget(mdiArea); setCentralWidget(vbox); //create the Command Prompt prompt = new CmdPrompt(this); prompt->setFocus(Qt::OtherFocusReason); this->setFocusProxy(prompt); mdiArea->setFocusProxy(prompt); prompt->setPromptTextColor(QColor(getSettingsPromptTextColor())); prompt->setPromptBackgroundColor(QColor(getSettingsPromptBGColor())); connect(prompt, SIGNAL(startCommand(const QString&)), this, SLOT(runCommandMain(const QString&))); connect(prompt, SIGNAL(runCommand(const QString&, const QString&)), this, SLOT(runCommandPrompt(const QString&, const QString&))); connect(prompt, SIGNAL(deletePressed()), this, SLOT(deletePressed())); //TODO: connect(prompt, SIGNAL(tabPressed()), this, SLOT(someUnknownSlot())); connect(prompt, SIGNAL(escapePressed()), this, SLOT(escapePressed())); connect(prompt, SIGNAL(F1Pressed()), this, SLOT(help())); //TODO: connect(prompt, SIGNAL(F2Pressed()), this, SLOT(floatHistory())); //TODO: connect(prompt, SIGNAL(F3Pressed()), this, SLOT(toggleQSNAP())); connect(prompt, SIGNAL(F4Pressed()), this, SLOT(toggleLwt())); //TODO: typically this is toggleTablet(), make F-Keys customizable thru settings //TODO: connect(prompt, SIGNAL(F5Pressed()), this, SLOT(toggleISO())); //TODO: connect(prompt, SIGNAL(F6Pressed()), this, SLOT(toggleCoords())); connect(prompt, SIGNAL(F7Pressed()), this, SLOT(toggleGrid())); //TODO: connect(prompt, SIGNAL(F8Pressed()), this, SLOT(toggleORTHO())); //TODO: connect(prompt, SIGNAL(F9Pressed()), this, SLOT(toggleSNAP())); //TODO: connect(prompt, SIGNAL(F10Pressed()), this, SLOT(togglePOLAR())); //TODO: connect(prompt, SIGNAL(F11Pressed()), this, SLOT(toggleQTRACK())); connect(prompt, SIGNAL(F12Pressed()), this, SLOT(toggleRuler())); connect(prompt, SIGNAL(cutPressed()), this, SLOT(cut())); connect(prompt, SIGNAL(copyPressed()), this, SLOT(copy())); connect(prompt, SIGNAL(pastePressed()), this, SLOT(paste())); connect(prompt, SIGNAL(selectAllPressed()), this, SLOT(selectAll())); connect(prompt, SIGNAL(undoPressed()), this, SLOT(undo())); connect(prompt, SIGNAL(redoPressed()), this, SLOT(redo())); connect(prompt, SIGNAL(shiftPressed()), this, SLOT(setShiftPressed())); connect(prompt, SIGNAL(shiftReleased()), this, SLOT(setShiftReleased())); //create the Object Property Editor dockPropEdit = new PropertyEditor("icons/" + getSettingsGeneralIconTheme(), getSettingsSelectionModePickAdd(), prompt, this); addDockWidget(Qt::LeftDockWidgetArea, dockPropEdit); connect(dockPropEdit, SIGNAL(pickAddModeToggled()), this, SLOT(pickAddModeToggled())); //create the Command History Undo Editor dockUndoEdit = new UndoEditor("icons/" + getSettingsGeneralIconTheme(), prompt, this); addDockWidget(Qt::LeftDockWidgetArea, dockUndoEdit); //setDockOptions(QMainWindow::AnimatedDocks | QMainWindow::AllowTabbedDocks | QMainWindow::VerticalTabs); //TODO: Load these from settings //tabifyDockWidget(dockPropEdit, dockUndoEdit); //TODO: load this from settings //Javascript initMainWinPointer(this); engine = new QScriptEngine(this); engine->installTranslatorFunctions(); debugger = new QScriptEngineDebugger(this); debugger->attachTo(engine); javaInitNatives(engine); //Load all commands in a loop QDir commandDir("commands"); QStringList cmdList = commandDir.entryList(QDir::Dirs | QDir::NoDotAndDotDot); foreach(QString cmdName, cmdList) { javaLoadCommand(cmdName); }