void CatalogForm::edit( Q3ListViewItem * item, bool afterNew) { // QWidget *wd = topLevelWidget(); aLog::print(aLog::Debug, tr("Catalog Form edit element start")); MainForm * mw = (MainForm*) topLevelWidget(); if(mw) { qulonglong id = getElementId(item); if(id) { aLog::print(aLog::Debug, tr("Catalog Form edit element with id=%1").arg(id)); cat->select(id); if(idElementForm) { if(!cat->isElementMarkDeleted()) { aForm *editForm = new aForm(mw->ws, &mw->engine, (long int) idElementForm); if(editForm) { if(afterNew) editForm->setMode(0); else editForm->setMode(1); editForm->Select(id); connect(editForm, SIGNAL(closeForm(qulonglong)), this, SLOT(Refresh(qulonglong))); editForm->show(); } else { aLog::print(aLog::Error, tr("Catalog Form edit element form is null")); } } else cfg_message(0, tr("Can't edit mark deleted element")); } else cfg_message(1,tr("Catalog haven't edit element form")); } else { id = getGroupId(item); aLog::print(aLog::Debug, tr("Catalog Form edit group with id = %1").arg(id)); if(id) { cat->groupSelect(id); if(idGroupForm) { if(!cat->isGroupMarkDeleted()) { aForm *editForm = new aForm(mw->ws, &mw->engine, (long int) idGroupForm); if(editForm) { if(afterNew) editForm->setMode(0); else editForm->setMode(1); editForm->SelectGroup(id); connect(editForm, SIGNAL(closeForm(qulonglong)), this, SLOT(Refresh(qulonglong))); editForm->show(); } else { aLog::print(aLog::Error, tr("Catalog Form edit group form is null")); } } else cfg_message(0, tr("Can't edit mark deleted group")); } else cfg_message(1,tr("Catalog haven't edit group form")); } } } else { aLog::print(aLog::Error, tr("Catalog Form main widget is not 'MainForm'")); } }
bool InternalLink::processItemLink(bool &badLink, std::vector<gcString> &list, const char* link) { if (list.size() < 3) { badLink = true; return true; } std::string key = list[1] + list[2]; std::map<gcString, gcFrame*>::iterator it = m_mWaitingItemFromMap.find(key); if (it != m_mWaitingItemFromMap.end()) { it->second->Raise(); return false; } UI::Forms::ItemForm *form = new UI::Forms::ItemForm(m_pParent, list[0].c_str(), list[2].c_str()); m_mWaitingItemFromMap[key] = form; form->Show(); DesuraId id; try { id = GetWebCore()->nameToId(list[2].c_str(), list[1].c_str()); } catch (gcException &e) { DesuraId idAsNum(list[2].c_str(), list[1].c_str()); if (idAsNum.getItem() == 0) { Warning(gcString("Failed to resolve item name {0} for link {2}: {1}\n", list[2], e, link)); gcErrorBox(form, Managers::GetString("#MF_ERRTITLE"), Managers::GetString("#MF_NAMERESOLVE"), e); m_mWaitingItemFromMap.erase(m_mWaitingItemFromMap.find(key)); form->Show(false); form->Destroy(); return false; } else { id = idAsNum; } } m_mWaitingItemFromMap.erase(m_mWaitingItemFromMap.find(key)); bool destroyForm = false; std::vector<std::string> argList; if (id.isOk()) { UI::Forms::ItemForm *formFind = findForm<UI::Forms::ItemForm>(id, m_vSubForms); if (!formFind) { form->setItemId(id); regForm(id, form); } else { formFind->SetPosition(form->GetPosition()); form->Show(false); destroyForm = true; } if (list[0] == "install" || list[0] == "launch") { std::string branch; if (list.size() >= 4) branch = list[3]; if (branch.size() > 0) { argList.push_back(std::string("global=") + branch); handleInternalLink(id, ACTION_INSTALL, argList); } else { bool isInstall = (list[0] == "install"); handleInternalLink(id, isInstall?ACTION_INSTALL:ACTION_LAUNCH, argList); } } else if (list[0] == "uninstall" || list[0] == "remove") { handleInternalLink(id, ACTION_UNINSTALL); } else if (list[0] == "verify") { handleInternalLink(id, ACTION_VERIFY); } else if (list[0] == "upload") { destroyForm = true; handleInternalLink(id, ACTION_UPLOAD); } else if (list[0] == "resumeupload" && list.size() >= 4) { destroyForm = true; argList.push_back(std::string("key=") + list[3]); handleInternalLink(id, ACTION_RESUPLOAD, argList); // } else if (list[0] == "makemcf") { destroyForm = true; handleInternalLink(id, ACTION_CREATE); } else if (list[0] == "test" && list.size() >= 5) { argList.push_back(std::string("branch=") + list[3]); argList.push_back(std::string("build=") + list[4]); handleInternalLink(id, ACTION_TEST, argList); } else { badLink = true; } } else { badLink = true; } if (badLink || destroyForm) { closeForm(form->GetId()); form->Show(false); form->Destroy(); } return true; }
QDesignerActions::QDesignerActions(QDesignerWorkbench *workbench) : QObject(workbench), m_workbench(workbench), m_assistantClient(0), m_openDirectory(QString()) { Q_ASSERT(m_workbench != 0); m_core = m_workbench->core(); Q_ASSERT(m_core != 0); QDesignerFormWindowManagerInterface *formWindowManager = m_core->formWindowManager(); Q_ASSERT(formWindowManager != 0); QDesignerSettings settings; m_fileActions = new QActionGroup(this); m_fileActions->setExclusive(false); m_recentFilesActions = new QActionGroup(this); m_recentFilesActions->setExclusive(false); m_editActions = new QActionGroup(this); m_editActions->setExclusive(false); m_formActions = new QActionGroup(this); m_formActions->setExclusive(false); m_windowActions = new QActionGroup(this); m_windowActions->setExclusive(false); m_toolActions = new QActionGroup(this); m_toolActions->setExclusive(true); m_helpActions = new QActionGroup(this); m_helpActions->setExclusive(false); // // file actions // m_newFormAction = new QAction(tr("&New Form..."), this); m_newFormAction->setShortcut(tr("CTRL+N")); connect(m_newFormAction, SIGNAL(triggered()), this, SLOT(createForm())); m_fileActions->addAction(m_newFormAction); m_openFormAction = new QAction(tr("&Open Form..."), this); m_openFormAction->setShortcut(tr("CTRL+O")); connect(m_openFormAction, SIGNAL(triggered()), this, SLOT(openForm())); m_fileActions->addAction(m_openFormAction); QAction *act; // Need to insert this into the QAction. for (int i = 0; i < MaxRecentFiles; ++i) { act = new QAction(this); act->setVisible(false); connect(act, SIGNAL(triggered()), this, SLOT(openRecentForm())); m_recentFilesActions->addAction(act); } updateRecentFileActions(); act = new QAction(this); act->setSeparator(true); m_recentFilesActions->addAction(act); act = new QAction(tr("Clear &Menu"), this); connect(act, SIGNAL(triggered()), this, SLOT(clearRecentFiles())); m_recentFilesActions->addAction(act); QAction *sep = new QAction(this); sep->setSeparator(true); m_fileActions->addAction(sep); m_saveFormAction = new QAction(tr("&Save Form"), this); m_saveFormAction->setShortcut(tr("CTRL+S")); connect(m_saveFormAction, SIGNAL(triggered()), this, SLOT(saveForm())); m_fileActions->addAction(m_saveFormAction); m_saveFormAsAction = new QAction(tr("Save Form &As..."), this); connect(m_saveFormAsAction, SIGNAL(triggered()), this, SLOT(saveFormAs())); m_fileActions->addAction(m_saveFormAsAction); m_saveFormAsTemplateAction = new QAction(tr("Save Form As &Template..."), this); connect(m_saveFormAsTemplateAction, SIGNAL(triggered()), this, SLOT(saveFormAsTemplate())); m_fileActions->addAction(m_saveFormAsTemplateAction); sep = new QAction(this); sep->setSeparator(true); m_fileActions->addAction(sep); m_closeFormAction = new QAction(tr("&Close Form"), this); m_closeFormAction->setShortcut(tr("CTRL+W")); connect(m_closeFormAction, SIGNAL(triggered()), this, SLOT(closeForm())); m_fileActions->addAction(m_closeFormAction); sep = new QAction(this); sep->setSeparator(true); m_fileActions->addAction(sep); m_quitAction = new QAction(tr("&Quit"), this); m_quitAction->setShortcut(tr("CTRL+Q")); connect(m_quitAction, SIGNAL(triggered()), this, SLOT(shutdown())); m_fileActions->addAction(m_quitAction); // // edit actions // m_undoAction = formWindowManager->actionUndo(); m_undoAction->setShortcut(tr("CTRL+Z")); m_editActions->addAction(m_undoAction); m_redoAction = formWindowManager->actionRedo(); m_redoAction->setShortcut(tr("CTRL+SHIFT+Z")); m_editActions->addAction(m_redoAction); sep = new QAction(this); sep->setSeparator(true); m_editActions->addAction(sep); m_cutAction = formWindowManager->actionCut(); m_editActions->addAction(m_cutAction); m_copyAction = formWindowManager->actionCopy(); m_editActions->addAction(m_copyAction); m_pasteAction = formWindowManager->actionPaste(); m_editActions->addAction(m_pasteAction); m_deleteAction = formWindowManager->actionDelete(); m_editActions->addAction(m_deleteAction); m_selectAllAction = formWindowManager->actionSelectAll(); m_editActions->addAction(m_selectAllAction); sep = new QAction(this); sep->setSeparator(true); m_editActions->addAction(sep); m_sendToBackAction = formWindowManager->actionLower(); m_editActions->addAction(m_sendToBackAction); m_bringToFrontAction = formWindowManager->actionRaise(); m_editActions->addAction(m_bringToFrontAction); // // edit mode actions // m_editWidgetsAction = new QAction(tr("Edit Widgets"), this); m_editWidgetsAction->setCheckable(true); m_editWidgetsAction->setShortcut(tr("F3")); m_editWidgetsAction->setIcon(QIcon(m_core->resourceLocation() + QLatin1String("/widgettool.png"))); connect(formWindowManager, SIGNAL(activeFormWindowChanged(QDesignerFormWindowInterface*)), this, SLOT(activeFormWindowChanged(QDesignerFormWindowInterface*))); connect(m_editWidgetsAction, SIGNAL(triggered()), this, SLOT(editWidgetsSlot())); m_toolActions->addAction(m_editWidgetsAction); m_editWidgetsAction->setChecked(true); m_editWidgetsAction->setEnabled(false); QList<QObject*> builtinPlugins = QPluginLoader::staticInstances(); builtinPlugins += m_core->pluginManager()->instances(); foreach (QObject *plugin, builtinPlugins) { if (QDesignerFormEditorPluginInterface *formEditorPlugin = qobject_cast<QDesignerFormEditorPluginInterface*>(plugin)) { m_toolActions->addAction(formEditorPlugin->action()); formEditorPlugin->action()->setCheckable(true); } } m_uiMode = new QActionGroup(this); m_uiMode->setExclusive(true); m_sdiAction = m_uiMode->addAction(tr("Multiple Top-Level Windows")); m_sdiAction->setCheckable(true); m_dockedMdiAction = m_uiMode->addAction(tr("Docked Window")); m_dockedMdiAction->setCheckable(true); switch (settings.uiMode()) { default: Q_ASSERT(0); break; case QDesignerWorkbench::TopLevelMode: m_sdiAction->setChecked(true); break; case QDesignerWorkbench::DockedMode: m_dockedMdiAction->setChecked(true); break; } connect(m_uiMode, SIGNAL(triggered(QAction*)), this, SLOT(updateUIMode(QAction*))); // // form actions // m_layoutHorizontallyAction = formWindowManager->actionHorizontalLayout(); m_formActions->addAction(m_layoutHorizontallyAction); m_layoutVerticallyAction = formWindowManager->actionVerticalLayout(); m_formActions->addAction(m_layoutVerticallyAction); m_layoutHorizontallyInSplitterAction = formWindowManager->actionSplitHorizontal(); m_formActions->addAction(m_layoutHorizontallyInSplitterAction); m_layoutVerticallyInSplitterAction = formWindowManager->actionSplitVertical(); m_formActions->addAction(m_layoutVerticallyInSplitterAction); m_layoutGridAction = formWindowManager->actionGridLayout(); m_formActions->addAction(m_layoutGridAction); m_breakLayoutAction = formWindowManager->actionBreakLayout(); m_formActions->addAction(m_breakLayoutAction); m_adjustSizeAction = formWindowManager->actionAdjustSize(); m_formActions->addAction(m_adjustSizeAction); sep = new QAction(this); sep->setSeparator(true); m_formActions->addAction(sep); m_previewFormAction = new QAction(tr("&Preview"), this); m_previewFormAction->setShortcut(tr("CTRL+R")); connect(m_previewFormAction, SIGNAL(triggered()), this, SLOT(previewFormLater())); m_formActions->addAction(m_previewFormAction); m_styleActions = new QActionGroup(this); m_styleActions->setExclusive(true); connect(m_styleActions, SIGNAL(triggered(QAction*)), this, SLOT(previewForm(QAction*))); QAction *sep2 = new QAction(this); sep2->setSeparator(true); m_formActions->addAction(sep2); m_formSettings = new QAction(tr("Form &Settings..."), this); m_formSettings->setEnabled(false); connect(m_formSettings, SIGNAL(triggered()), this, SLOT(showFormSettings())); m_formActions->addAction(m_formSettings); QStringList availableStyleList = QStyleFactory::keys(); foreach (QString style, availableStyleList) { QAction *a = new QAction(this); a->setText(tr("%1 Style").arg(style)); a->setObjectName(QLatin1String("__qt_action_style_") + style); m_styleActions->addAction(a); }
AskPassphraseDialog::AskPassphraseDialog(Mode mode, QWidget *parent) : QDialog(parent), ui(new Ui::AskPassphraseDialog), mode(mode), model(0), fCapsLock(false) { ui->setupUi(this); ui->passEdit1->setMaxLength(MAX_PASSPHRASE_SIZE); ui->passEdit2->setMaxLength(MAX_PASSPHRASE_SIZE); ui->passEdit3->setMaxLength(MAX_PASSPHRASE_SIZE); // Setup Caps Lock detection. ui->passEdit1->installEventFilter(this); ui->passEdit2->installEventFilter(this); ui->passEdit3->installEventFilter(this); bool addUnlockButton = false; bool addUnlockStakingOnlyButton = false; bool addCancelButton = true; bool addOkButton = false; buttonOk = NULL; buttonCancel = NULL; buttonUnlock = NULL; buttonUnlockStakingOnly = NULL; switch(mode) { case Encrypt: // Ask passphrase x2 addOkButton = true; ui->passLabel1->hide(); ui->passEdit1->hide(); ui->warningLabel->setText(tr("Enter the new passphrase to the vault.<br/>Please use a passphrase of <b>10 or more random characters</b>, or <b>eight or more words</b>.")); setWindowTitle(tr("Encrypt Vault")); break; case UnlockFullOnly: addUnlockButton = true; addUnlockStakingOnlyButton = false; ui->warningLabel->setText(tr("This operation needs your vault passphrase to unlock the vault.")); ui->passLabel2->hide(); ui->passEdit2->hide(); ui->passLabel3->hide(); ui->passEdit3->hide(); setWindowTitle(tr("Unlock vault")); break; case Unlock: // Ask passphrase addUnlockButton = true; addUnlockStakingOnlyButton = true; ui->warningLabel->setText(tr("This operation needs your vault passphrase to unlock the vault.")); ui->passLabel2->hide(); ui->passEdit2->hide(); ui->passLabel3->hide(); ui->passEdit3->hide(); setWindowTitle(tr("Unlock vault")); break; case Decrypt: // Ask passphrase ui->warningLabel->setText(tr("This operation needs your vault passphrase to decrypt the vault.")); ui->passLabel2->hide(); ui->passEdit2->hide(); ui->passLabel3->hide(); ui->passEdit3->hide(); setWindowTitle(tr("Decrypt Vault")); break; case ChangePass: // Ask old passphrase + new passphrase x2 addOkButton = true; setWindowTitle(tr("Change passphrase")); ui->warningLabel->setText(tr("Enter the old and new passphrase to the vault.")); break; } if (addUnlockButton){ buttonUnlock = new QPushButton(tr("&Unlock")); buttonUnlock->setDefault(true); ui->buttonBox->addButton(buttonUnlock, QDialogButtonBox::ActionRole); connect(buttonUnlock, SIGNAL(clicked()), this, SLOT(unlockWallet())); GUIUtil::SetupPushButton(buttonUnlock); } if (addUnlockStakingOnlyButton && !fWalletUnlockMintOnly){ buttonUnlockStakingOnly = new QPushButton(tr("U&nlock for Staking only")); buttonUnlockStakingOnly->setDefault(true); ui->buttonBox->addButton(buttonUnlockStakingOnly, QDialogButtonBox::ActionRole); connect(buttonUnlockStakingOnly, SIGNAL(clicked()), this, SLOT(unlockWalletForStakingOnly())); GUIUtil::SetupPushButton(buttonUnlockStakingOnly); } if (addOkButton){ buttonOk = new QPushButton(tr("&Ok")); buttonOk->setDefault(false); ui->buttonBox->addButton(buttonOk, QDialogButtonBox::ActionRole); connect(buttonOk, SIGNAL(clicked()), this, SLOT(encryptWallet())); GUIUtil::SetupPushButton(buttonOk); } if (addCancelButton){ buttonCancel = new QPushButton(tr("&Cancel")); buttonCancel->setDefault(true); ui->buttonBox->addButton(buttonCancel, QDialogButtonBox::ActionRole); connect(buttonCancel, SIGNAL(clicked()), this, SLOT(closeForm())); GUIUtil::SetupPushButton(buttonCancel); } textChanged(); connect(ui->passEdit1, SIGNAL(textChanged(QString)), this, SLOT(textChanged())); connect(ui->passEdit2, SIGNAL(textChanged(QString)), this, SLOT(textChanged())); connect(ui->passEdit3, SIGNAL(textChanged(QString)), this, SLOT(textChanged())); }