void WindowsManager::setActiveWindow(int index) { if (index < 0 || index >= m_tabBar->count()) { index = 0; } if (index != m_tabBar->currentIndex()) { m_tabBar->setCurrentIndex(index); return; } Window *window = m_mdi->getActiveWindow(); if (window) { if (window->getContentsWidget()->getUndoStack()) { disconnect(window->getContentsWidget()->getUndoStack(), SIGNAL(undoTextChanged(QString)), this, SIGNAL(actionsChanged())); disconnect(window->getContentsWidget()->getUndoStack(), SIGNAL(redoTextChanged(QString)), this, SIGNAL(actionsChanged())); disconnect(window->getContentsWidget()->getUndoStack(), SIGNAL(canUndoChanged(bool)), this, SIGNAL(actionsChanged())); disconnect(window->getContentsWidget()->getUndoStack(), SIGNAL(canRedoChanged(bool)), this, SIGNAL(actionsChanged())); } disconnect(window, SIGNAL(actionsChanged()), this, SIGNAL(actionsChanged())); disconnect(window, SIGNAL(statusMessageChanged(QString)), m_statusBar, SLOT(showMessage(QString))); disconnect(window, SIGNAL(zoomChanged(int)), m_statusBar, SLOT(setZoom(int))); disconnect(window, SIGNAL(canZoomChanged(bool)), m_statusBar, SLOT(setZoomEnabled(bool))); disconnect(m_statusBar, SIGNAL(requestedZoomChange(int)), window->getContentsWidget(), SLOT(setZoom(int))); }
void TransfersContentsWidget::updateActions() { TransferInformation *transfer = getTransfer(m_ui->transfersView->selectionModel()->hasSelection() ? m_ui->transfersView->selectionModel()->currentIndex() : QModelIndex()); m_ui->stopResumeButton->setEnabled(transfer && (transfer->state == RunningTransfer || transfer->state == ErrorTransfer)); m_ui->stopResumeButton->setText((transfer && transfer->state == ErrorTransfer) ? tr("Resume") : tr("Stop")); m_ui->redownloadButton->setEnabled(transfer); getAction(CopyAction)->setEnabled(transfer); getAction(DeleteAction)->setEnabled(transfer); if (transfer) { m_ui->sourceLabelWidget->setText(transfer->source.toHtmlEscaped()); m_ui->targetLabelWidget->setText(transfer->target.toHtmlEscaped()); m_ui->sizeLabelWidget->setText((transfer->bytesTotal > 0) ? tr("%1 (%n B)", "", transfer->bytesTotal).arg(Utils::formatUnit(transfer->bytesTotal)) : QString('?')); m_ui->downloadedLabelWidget->setText(tr("%1 (%n B)", "", transfer->bytesReceived).arg(Utils::formatUnit(transfer->bytesReceived))); m_ui->progressLabelWidget->setText(QString("%1%").arg(((transfer->bytesTotal > 0) ? (((qreal) transfer->bytesReceived / transfer->bytesTotal) * 100) : 0.0), 0, 'f', 1)); } else { m_ui->sourceLabelWidget->clear(); m_ui->targetLabelWidget->clear(); m_ui->sizeLabelWidget->clear(); m_ui->downloadedLabelWidget->clear(); m_ui->progressLabelWidget->clear(); } emit actionsChanged(); }
void SettingsBase::initApplication() { // Prepare the menu of all modules categories = KServiceTypeTrader::self()->query("SystemSettingsCategory"); modules = KServiceTypeTrader::self()->query("KCModule", "[X-KDE-System-Settings-Parent-Category] != ''"); modules += KServiceTypeTrader::self()->query("SystemSettingsExternalApp"); rootModule = new MenuItem( true, 0 ); initMenuList(rootModule); // Handle lost+found modules... if (lostFound) { for (int i = 0; i < modules.size(); ++i) { const KService::Ptr entry = modules.at(i); MenuItem * infoItem = new MenuItem(false, lostFound); infoItem->setService( entry ); qDebug() << "Added " << entry->name(); } } // Prepare the Base Data BaseData::instance()->setMenuItem( rootModule ); // Load all possible views const KService::List pluginObjects = KServiceTypeTrader::self()->query( "SystemSettingsView" ); const int nbPlugins = pluginObjects.count(); for( int pluginsDone = 0; pluginsDone < nbPlugins ; ++pluginsDone ) { KService::Ptr activeService = pluginObjects.at( pluginsDone ); QString error; BaseMode * controller = activeService->createInstance<BaseMode>(this, QVariantList(), &error); if( error.isEmpty() ) { possibleViews.insert( activeService->library(), controller ); controller->init( activeService ); connect(controller, SIGNAL(changeToolBarItems(BaseMode::ToolBarItems)), this, SLOT(changeToolBar(BaseMode::ToolBarItems))); connect(controller, SIGNAL(actionsChanged()), this, SLOT(updateViewActions())); connect(searchText, SIGNAL(textChanged(QString)), controller, SLOT(searchChanged(QString))); connect(controller, SIGNAL(viewChanged(bool)), this, SLOT(viewChange(bool))); } else {
void MainWindow::configureToolBarSlot() { qDebug() << "configure toolbars"; EditToolBar etb; etb.setActionsList(actionsManager->getActions(), settings->getActionsLoaded()); connect(&etb, SIGNAL(actionsChanged(QStringList)), this, SLOT(configureToolBarSlot2(QStringList))); etb.exec(); }
void SharedUnityMenuModel::setActions(const QVariantMap& actions) { if (m_actions != actions) { m_actions = actions; Q_EMIT actionsChanged(); initialize(); } }
void LineEditor::actionMove() { if (!mLine) return; mPrevState = mLine->getState(); mState = PICK_REF; mRefPt = mPos; emit actionsChanged(); }
void MockNotification::setActions(const QStringList &actions) { if(p->actions != actions) { p->actions = actions; Q_EMIT actionsChanged(p->actions); for (int i = 0; i < p->actions.size(); i += 2) { p->actionsModel->append(p->actions[i], p->actions[i+1]); } } }
void LineEditor::init() { if (mLine) { ctrl()->hideObj(mLine); } else { if (!mDialog) mDialog = QSharedPointer<EditLineDialog>(new EditLineDialog(ctrl()->view())); if (mDialog->exec() == QDialog::Rejected) { emit editorFinished(); return; } mWidth = mDialog->width(); mLayer = mDialog->layer(); newLine(); mState = LINE_NEW_FIRST; } emit actionsChanged(); }
void QtWebKitWebWidget::triggerAction(WindowAction action, bool checked) { const QWebPage::WebAction webAction = mapAction(action); if (webAction != QWebPage::NoWebAction) { m_webView->triggerPageAction(webAction, checked); return; } switch (action) { case RewindBackAction: m_webView->page()->history()->goToItem(m_webView->page()->history()->itemAt(0)); break; case RewindForwardAction: m_webView->page()->history()->goToItem(m_webView->page()->history()->itemAt(m_webView->page()->history()->count() - 1)); break; case CopyAddressAction: QApplication::clipboard()->setText(getUrl().toString()); break; case ZoomInAction: setZoom(qMin((getZoom() + 10), 10000)); break; case ZoomOutAction: setZoom(qMax((getZoom() - 10), 10)); break; case ZoomOriginalAction: setZoom(100); break; case ReloadOrStopAction: if (isLoading()) { triggerAction(StopAction); } else { triggerAction(ReloadAction); } break; case OpenLinkInNewTabAction: if (m_hitResult.linkUrl().isValid()) { emit requestedOpenUrl(m_hitResult.linkUrl(), false, false); } break; case OpenLinkInNewTabBackgroundAction: if (m_hitResult.linkUrl().isValid()) { emit requestedOpenUrl(m_hitResult.linkUrl(), true, false); } break; case OpenLinkInNewWindowAction: if (m_hitResult.linkUrl().isValid()) { emit requestedOpenUrl(m_hitResult.linkUrl(), false, true); } break; case OpenLinkInNewWindowBackgroundAction: if (m_hitResult.linkUrl().isValid()) { emit requestedOpenUrl(m_hitResult.linkUrl(), true, true); } break; case BookmarkLinkAction: if (m_hitResult.linkUrl().isValid()) { emit requestedAddBookmark(m_hitResult.linkUrl(), m_hitResult.element().attribute(QLatin1String("title"))); } break; case OpenSelectionAsLinkAction: emit requestedOpenUrl(m_webView->selectedText(), false, false); break; case ImagePropertiesAction: { ImagePropertiesDialog dialog(m_hitResult.imageUrl(), m_hitResult.element().attribute(QLatin1String("alt")), m_hitResult.element().attribute(QLatin1String("longdesc")), m_hitResult.pixmap(), (m_networkAccessManager->cache() ? m_networkAccessManager->cache()->data(m_hitResult.imageUrl()) : NULL), this); QEventLoop eventLoop; m_parent->showDialog(&dialog); connect(&dialog, SIGNAL(finished(int)), &eventLoop, SLOT(quit())); connect(this, SIGNAL(destroyed()), &eventLoop, SLOT(quit())); eventLoop.exec(); m_parent->hideDialog(&dialog); } break; case InspectPageAction: if (!m_inspector) { m_inspector = new QWebInspector(this); m_inspector->setPage(m_webView->page()); m_inspector->setContextMenuPolicy(Qt::NoContextMenu); m_inspector->setMinimumHeight(200); m_splitter->addWidget(m_inspector); } m_inspector->setVisible(checked); getAction(InspectPageAction)->setChecked(checked); emit actionsChanged(); emit progressBarGeometryChanged(); break; case SaveLinkToDownloadsAction: TransfersManager::startTransfer(m_hitResult.linkUrl().toString(), QString(), isPrivate(), true); break; case OpenFrameInThisTabAction: if (m_hitResult.frame()) { setUrl(m_hitResult.frame()->url().isValid() ? m_hitResult.frame()->url() : m_hitResult.frame()->requestedUrl()); } break; case OpenFrameInNewTabBackgroundAction: if (m_hitResult.frame()) { emit requestedOpenUrl((m_hitResult.frame()->url().isValid() ? m_hitResult.frame()->url() : m_hitResult.frame()->requestedUrl()), true, false); } break; case CopyFrameLinkToClipboardAction: if (m_hitResult.frame()) { QGuiApplication::clipboard()->setText((m_hitResult.frame()->url().isValid() ? m_hitResult.frame()->url() : m_hitResult.frame()->requestedUrl()).toString()); } break; case ReloadFrameAction: if (m_hitResult.frame()) { const QUrl url = (m_hitResult.frame()->url().isValid() ? m_hitResult.frame()->url() : m_hitResult.frame()->requestedUrl()); m_hitResult.frame()->setUrl(QUrl()); m_hitResult.frame()->setUrl(url); } break; case SearchAction: search(getAction(SearchAction)); break; case CreateSearchAction: { QWebElement parentElement = m_hitResult.element().parent(); while (!parentElement.isNull() && parentElement.tagName().toLower() != "form") { parentElement = parentElement.parent(); } const QWebElementCollection inputs = parentElement.findAll(QLatin1String("input:not([disabled])[name], select:not([disabled])[name], textarea:not([disabled])[name]")); if (!parentElement.isNull() && parentElement.hasAttribute(QLatin1String("action")) && inputs.count() > 0) { QUrlQuery parameters; for (int i = 0; i < inputs.count(); ++i) { QString value; if (inputs.at(i).tagName().toLower() == QLatin1String("textarea")) { value = inputs.at(i).toPlainText(); } else if (inputs.at(i).tagName().toLower() == QLatin1String("select")) { const QWebElementCollection options = inputs.at(i).findAll(QLatin1String("option")); for (int j = 0; j < options.count(); ++j) { if (options.at(j).hasAttribute(QLatin1String("selected"))) { value = options.at(j).attribute(QLatin1String("value"), options.at(j).toPlainText()); break; } } } else { if ((inputs.at(i).attribute(QLatin1String("type")) == QLatin1String("checkbox") || inputs.at(i).attribute(QLatin1String("type")) == QLatin1String("radio")) && !inputs.at(i).hasAttribute(QLatin1String("checked"))) { continue; } value = inputs.at(i).attribute(QLatin1String("value")); } parameters.addQueryItem(inputs.at(i).attribute(QLatin1String("name")), ((inputs.at(i) == m_hitResult.element()) ? QLatin1String("{searchTerms}") : value)); } const QStringList identifiers = SearchesManager::getSearchEngines(); QStringList shortcuts; QList<SearchInformation*> engines; for (int i = 0; i < identifiers.count(); ++i) { SearchInformation *engine = SearchesManager::getSearchEngine(identifiers.at(i)); if (!engine) { continue; } engines.append(engine); const QString shortcut = engine->shortcut; if (!shortcut.isEmpty()) { shortcuts.append(shortcut); } } QString identifier = getUrl().host().toLower().remove(QRegularExpression(QLatin1String("[^a-z0-9]"))); while (identifier.isEmpty() || identifiers.contains(identifier)) { identifier = QInputDialog::getText(this, tr("Select Identifier"), tr("Input Unique Search Engine Identifier:")); if (identifier.isEmpty()) { return; } } const QIcon icon = m_webView->icon(); const QUrl url(parentElement.attribute(QLatin1String("action"))); QVariantHash engineData; engineData[QLatin1String("identifier")] = identifier; engineData[QLatin1String("isDefault")] = false; engineData[QLatin1String("encoding")] = QLatin1String("UTF-8"); engineData[QLatin1String("selfUrl")] = QString(); engineData[QLatin1String("resultsUrl")] = (url.isEmpty() ? getUrl() : (url.isRelative() ? getUrl().resolved(url) : url)).toString(); engineData[QLatin1String("resultsEnctype")] = parentElement.attribute(QLatin1String("enctype")); engineData[QLatin1String("resultsMethod")] = ((parentElement.attribute(QLatin1String("method"), QLatin1String("get")).toLower() == QLatin1String("post")) ? QLatin1String("post") : QLatin1String("get")); engineData[QLatin1String("resultsParameters")] = parameters.toString(QUrl::FullyDecoded); engineData[QLatin1String("suggestionsUrl")] = QString(); engineData[QLatin1String("suggestionsEnctype")] = QString(); engineData[QLatin1String("suggestionsMethod")] = QLatin1String("get"); engineData[QLatin1String("suggestionsParameters")] = QString(); engineData[QLatin1String("shortcut")] = QString(); engineData[QLatin1String("title")] = getTitle(); engineData[QLatin1String("description")] = QString(); engineData[QLatin1String("icon")] = (icon.isNull() ? Utils::getIcon(QLatin1String("edit-find")) : icon); SearchPropertiesDialog dialog(engineData, shortcuts, this); if (dialog.exec() == QDialog::Rejected) { return; } engineData = dialog.getEngineData(); if (shortcuts.contains(engineData[QLatin1String("shortcut")].toString())) { engineData[QLatin1String("shortcut")] = QString(); } SearchInformation *engine = new SearchInformation(); engine->identifier = engineData[QLatin1String("identifier")].toString(); engine->title = engineData[QLatin1String("title")].toString(); engine->description = engineData[QLatin1String("description")].toString(); engine->shortcut = engineData[QLatin1String("shortcut")].toString(); engine->encoding = engineData[QLatin1String("encoding")].toString(); engine->selfUrl = engineData[QLatin1String("selfUrl")].toString(); engine->resultsUrl.url = engineData[QLatin1String("resultsUrl")].toString(); engine->resultsUrl.enctype = engineData[QLatin1String("resultsEnctype")].toString(); engine->resultsUrl.method = engineData[QLatin1String("resultsMethod")].toString(); engine->resultsUrl.parameters = QUrlQuery(engineData[QLatin1String("resultsParameters")].toString()); engine->icon = engineData[QLatin1String("icon")].value<QIcon>(); engines.append(engine); if (SearchesManager::setSearchEngines(engines) && engineData[QLatin1String("isDefault")].toBool()) { SettingsManager::setValue(QLatin1String("Browser/DefaultSearchEngine"), engineData[QLatin1String("identifier")].toString()); } } } break; case ClearAllAction: triggerAction(SelectAllAction); triggerAction(DeleteAction); break; default: break; } }
void EditToolBar::okSlot() { qDebug()<<"ok slot"; emit actionsChanged(tbe->getActionsList()); this->close(); }
void EditToolBar::applySlot() { qDebug()<<"apply slot"; emit actionsChanged(tbe->getActionsList()); }
void LineEditor::mouseReleaseEvent(QMouseEvent *event) { switch(mState) { case SELECTED: case VTX_SEL_START: case VTX_SEL_END: { // check if a vertex was hit QPoint start = ctrl()->view()->transform().map(mLine->start()); QPoint end = ctrl()->view()->transform().map(mLine->end()); if ((start - event->pos()).manhattanLength() <= 20) { mState = VTX_SEL_START; event->accept(); emit actionsChanged(); emit overlayChanged(); } else if ((end - event->pos()).manhattanLength() <= 20 ) { mState = VTX_SEL_END; event->accept(); emit actionsChanged(); emit overlayChanged(); } else if (mState != SELECTED) { QPoint pos = ctrl()->view()->transform().inverted().map(event->pos()); if (mLine->testHit(pos, ctrl()->hitRadius(), mLine->layer())) { mState = SELECTED; event->accept(); emit actionsChanged(); emit overlayChanged(); } else event->ignore(); } else event->ignore(); } break; case LINE_NEW_FIRST: { mLine->setStart(mPos); mLine->setEnd(mPos); mState = LINE_NEW_SECOND; emit actionsChanged(); emit overlayChanged(); } break; case LINE_NEW_SECOND: { mLine->setEnd(mPos); if (mLine->start() != mLine->end()) { QUndoCommand* cmd = new LineNewCmd(NULL, mLine, dynamic_cast<FPDoc*>(ctrl()->doc())); ctrl()->doc()->doCommand(cmd); } newLine(); mLine->setStart(mPos); mLine->setEnd(mPos); emit overlayChanged(); } break; case VTX_MOVE_START: case VTX_MOVE_END: { QUndoCommand* cmd = new PCBObjEditCmd(NULL, mLine, mPrevState); ctrl()->doc()->doCommand(cmd); mState = (mState == VTX_MOVE_START) ? VTX_SEL_START : VTX_SEL_END; emit overlayChanged(); emit actionsChanged(); } break; case PICK_REF: { mRefPt = mPos; mState = LINE_MOVE; emit overlayChanged(); emit actionsChanged(); } break; case LINE_MOVE: { mLine->setStart(mLine->start() + mPos - mRefPt); mLine->setEnd(mLine->end() + mPos - mRefPt); QUndoCommand* cmd = new PCBObjEditCmd(NULL, mLine, mPrevState); ctrl()->doc()->doCommand(cmd); mState = SELECTED; emit overlayChanged(); emit actionsChanged(); } break; default: break; } }
/** * @brief Constructor * * This is the constructor of the main-UI class - the Simon View class. * It displays a little splash screen and initializes the member-variables * * @author Peter Grasch * @param Qwidget *parent * The parent which is passed on to the QMainWindow initialization - Default: 0 * @param Qt::WFlags flags * The flags which are also passed on to the QMainWindow constructor - as before: Default: 0 * */ SimonView::SimonView(QWidget* parent, Qt::WFlags flags) : KXmlGuiWindow(parent, flags), ScenarioDisplay(), backButtonAnimation(new QTimeLine(700, this)) { Logger::log ( i18n ( "Starting Simon..." ) ); //showing splash bool showSplash = KCmdLineArgs::parsedArgs()->isSet("splash"); SimonInfo *info = 0; if (showSplash) { info = new SimonInfo(); Logger::log ( i18n ( "Displaying Splashscreen..." ) ); info->showSplash(); info->writeToSplash ( i18n ( "Loading core..." ) ); } KGlobal::locale()->insertCatalog("simonlib"); control = (new SimonControl(this)); if (!control->firstRunWizardCompleted()) { QPointer<FirstRunWizard> firstRun = new FirstRunWizard(this); bool firstRunWizardCompleted = firstRun->exec(); delete firstRun; if (firstRunWizardCompleted || KMessageBox::questionYesNo(this, i18n("You did not complete the initial configuration. Simon will continue with default values.\n\nDo you want Simon to display the wizard again on the next start?"))==KMessageBox::No) control->setFirstRunWizardCompleted(true); } trayManager = new TrayIconManager(this); this->trayManager->createIcon ( KIcon ( KIconLoader().loadIcon("simon", KIconLoader::Panel, KIconLoader::SizeMedium, KIconLoader::DisabledState) ), i18n ( "Simon - Deactivated" ) ); QMainWindow ( parent,flags ); qApp->setQuitOnLastWindowClosed(false); ui.setupUi ( this ); statusBar()->insertItem(i18n("Not connected"),0); statusBar()->insertItem("",1,10); statusBar()->insertPermanentWidget(2,StatusManager::global(this)->createWidget(this)); ScenarioManager::getInstance()->registerScenarioDisplay(this); ScenarioManager::getInstance()->installScenarioOfferUi(this); //Preloads all Dialogs if (showSplash) info->writeToSplash ( i18n ( "Loading training..." ) ); trainDialog = new TrainingView(this); ScenarioManager::getInstance()->registerScenarioDisplay(trainDialog); if (showSplash) info->writeToSplash ( i18n ( "Loading vocabulary..." ) ); vocabularyView = new VocabularyView(this); ScenarioManager::getInstance()->registerScenarioDisplay(vocabularyView); if (showSplash) info->writeToSplash ( i18n ( "Loading grammar..." ) ); grammarView = new GrammarView(this); ScenarioManager::getInstance()->registerScenarioDisplay(grammarView); if (showSplash) info->writeToSplash ( i18n ( "Loading context..." ) ); contextDialog = new ContextView(this); ScenarioManager::getInstance()->registerScenarioDisplay(contextDialog); if (showSplash) info->writeToSplash ( i18n ( "Loading run..." ) ); runDialog = new RunCommandView(this); connect(runDialog, SIGNAL(actionsChanged()), this, SLOT(updateActionList())); ScenarioManager::getInstance()->registerScenarioDisplay(runDialog); if (showSplash) info->writeToSplash ( i18n ( "Loading interface..." ) ); setupActions(); setupGUI(); displayScenarioPrivate(ScenarioManager::getInstance()->getCurrentScenario()); welcomePage = new WelcomePage(actionCollection()->action("activate")); ScenarioManager::getInstance()->registerScenarioDisplay(welcomePage); connect(welcomePage, SIGNAL(editScenario()), this, SLOT(editScenario())); ui.swMain->insertWidget(0, welcomePage); ui.swMain->setCurrentIndex(0); ui.inlineView->registerPage(vocabularyView); ui.inlineView->registerPage(trainDialog); ui.inlineView->registerPage(grammarView); ui.inlineView->registerPage(contextDialog); ui.inlineView->registerPage(runDialog); ui.frmBackToOverview->setMaximumHeight(0); connect(backButtonAnimation, SIGNAL(frameChanged(int)), this, SLOT(backButtonAnimationStep(int))); { QPalette p = ui.frmBackToOverview->palette(); p.setBrush(QPalette::Window, p.alternateBase()); ui.frmBackToOverview->setPalette(p); } connect(ui.pbBackToOverview, SIGNAL(clicked()), this, SLOT(backToOverview())); setupSignalSlots(); control->startup(); //hiding splash again after loading if (showSplash) { info->hideSplash(); delete info; } if (!control->startMinimized()) { show(); #ifdef Q_OS_MAC raise(); #endif } }