bool GCF::ActionContainerWidget::event(QEvent* e) { switch(e->type()) { case QEvent::ActionAdded: { QActionEvent* ae = (QActionEvent*)e; QAction* action = ae->action(); QWidget* actionWidget = 0; int row=-1, col=-1; int rowSpan = action->property("rowSpan").toInt(); int colSpan = action->property("colSpan").toInt(); if(!rowSpan) rowSpan = 1; if(!colSpan) colSpan = 1; if(rowSpan > d->maxRows) rowSpan = d->maxRows; actionWidget = createWidget(action, rowSpan, colSpan); d->gridLayout->findCell(rowSpan, colSpan, &row, &col); d->gridLayout->addWidget(actionWidget, row, col, rowSpan, colSpan, Qt::AlignJustify); d->actionWidgetMap[action] = actionWidget; action->setProperty("row", row); action->setProperty("col", col); actionWidget->show(); } return true; case QEvent::ActionRemoved: { QActionEvent* ae = (QActionEvent*)e; QAction* action = ae->action(); QWidget* actionWidget = d->actionWidgetMap.contains(action) ? d->actionWidgetMap[action] : 0; int row = action->property("row").toInt(); int col = action->property("col").toInt(); int rowSpan = action->property("rowSpan").toInt(); int colSpan = action->property("colSpan").toInt(); if(actionWidget && qobject_cast<QToolButton*>(actionWidget)) delete actionWidget; d->actionWidgetMap.remove(action); d->gridLayout->markCells(false, row, col, rowSpan, colSpan); } return true; default: break; } return QWidget::event(e); }
void MainWindow::actionResolution(){ QAction *action = (QAction*)sender(); setWidth( action->property("width").toInt()); setHeight(action->property("height").toInt()); updateResolution(); }
void SettingsWindow::onAction() { QAction *triggeredAction = static_cast<QAction*>(sender()); foreach (QAction *action, ui->toolBar->actions()) action->setIcon(action->property("iconNormal").value<QIcon>()); triggeredAction->setIcon(triggeredAction->property("iconActive").value<QIcon>()); ui->stackedWidget->slideInIdx(triggeredAction->property("page").toInt()); }
void CustomWebView::savePixmap () { QAction *action = qobject_cast<QAction*> (sender ()); if (!action) { qWarning () << Q_FUNC_INFO << "sender is not an action" << sender (); return; } const QPixmap& px = action->property ("Poshuku/OrigPX").value<QPixmap> (); if (px.isNull ()) return; const QUrl& url = action->property ("Poshuku/OrigURL").value<QUrl> (); const QString origName = url.scheme () == "data" ? QString () : QFileInfo (url.path ()).fileName (); QString filter; QString fname = QFileDialog::getSaveFileName (0, tr ("Save pixmap"), QDir::homePath () + '/' + origName, tr ("PNG image (*.png);;JPG image (*.jpg);;All files (*.*)"), &filter); if (fname.isEmpty ()) return; if (QFileInfo (fname).suffix ().isEmpty ()) { if (filter.contains ("png")) fname += ".png"; else if (filter.contains ("jpg")) fname += ".jpg"; } QFile file (fname); if (!file.open (QIODevice::WriteOnly)) { emit gotEntity (Util::MakeNotification ("Poshuku", tr ("Unable to save the image. Unable to open file for writing: %1.") .arg (file.errorString ()), PCritical_)); return; } const QString& suf = QFileInfo (fname).suffix (); const bool isLossless = suf.toLower () == "png"; px.save (&file, suf.toUtf8 ().constData (), isLossless ? 0 : 100); }
void TrayIcon::nextWallpaper() { try { WallpaperResult result; QRect desktopSize = Desktop::GetSize(); _trayIcon->setIcon(*_iconLoading); QAction *action = qobject_cast<QAction *>(sender()); if (action && action->property("categoryIndex") != QVariant::Invalid) { int categoryIndex = action->property("categoryIndex").toInt(); QList<SourceViewModel*> sources; sources.append(_settingsViewModel->GetSources()[categoryIndex]); result = _providersManager->DownloadRandomImage( sources, desktopSize.width(), desktopSize.height()); } else { result = _providersManager->DownloadRandomImage( _settingsViewModel->GetSources(), desktopSize.width(), desktopSize.height()); } if (result.image.length() > 0) { Desktop::SetWallpaper(result.image); } updateTrayIcon(); _currentUrl = result.url; _currentDescription = result.urlDescription; _currentName = result.name; _trayIcon->showMessage(result.name, result.urlDescription, QSystemTrayIcon::Information, 4000); _timeCounter = 0; updateToolTip(); } catch (...) { } }
void FilterExpressionToolBar::onCustomMenuHandler(const QPoint& pos) { QAction * filterAction = actionAt(pos); if ( ! filterAction ) return; QMenu * filterMenu = new QMenu(this); QAction *actFilter = filterMenu->addAction(tr("Filter Button Preferences...")); connect(actFilter, SIGNAL(triggered()), this, SLOT(toolBarShowPreferences())); actFilter->setProperty(dfe_property_label_, filterAction->property(dfe_property_label_)); actFilter->setProperty(dfe_property_expression_, filterAction->property(dfe_property_expression_)); actFilter->setData(filterAction->data()); filterMenu->addSeparator(); QAction * actEdit = filterMenu->addAction(tr("Edit")); connect(actEdit, SIGNAL(triggered()), this, SLOT(editFilter())); actEdit->setProperty(dfe_property_label_, filterAction->property(dfe_property_label_)); actEdit->setProperty(dfe_property_expression_, filterAction->property(dfe_property_expression_)); actEdit->setData(filterAction->data()); QAction * actDisable = filterMenu->addAction(tr("Disable")); connect(actDisable, SIGNAL(triggered()), this, SLOT(disableFilter())); actDisable->setProperty(dfe_property_label_, filterAction->property(dfe_property_label_)); actDisable->setProperty(dfe_property_expression_, filterAction->property(dfe_property_expression_)); actDisable->setData(filterAction->data()); QAction * actRemove = filterMenu->addAction(tr("Remove")); connect(actRemove, SIGNAL(triggered()), this, SLOT(removeFilter())); actRemove->setProperty(dfe_property_label_, filterAction->property(dfe_property_label_)); actRemove->setProperty(dfe_property_expression_, filterAction->property(dfe_property_expression_)); actRemove->setData(filterAction->data()); filterMenu->exec(mapToGlobal(pos)); }
void MainWindow::columnMenuChanged() { QAction* action = static_cast<QAction*>(sender()); if (action->isChecked()) { QSettings().setValue(action->property("setting").toString(), true); ui->tableView->showColumn(action->property("columnIndex").toInt()); } else { QSettings().setValue(action->property("setting").toString(), false); ui->tableView->hideColumn(action->property("columnIndex").toInt()); } }
void OBSBasic::ChangeSceneCollection() { QAction *action = reinterpret_cast<QAction*>(sender()); std::string fileName; if (!action) return; fileName = QT_TO_UTF8(action->property("fileName").value<QString>()); if (fileName.empty()) return; const char *oldName = config_get_string(App()->GlobalConfig(), "Basic", "SceneCollection"); if (action->text().compare(QT_UTF8(oldName)) == 0) { action->setChecked(true); return; } SaveProjectNow(); Load(fileName.c_str()); RefreshSceneCollections(); const char *newName = config_get_string(App()->GlobalConfig(), "Basic", "SceneCollection"); const char *newFile = config_get_string(App()->GlobalConfig(), "Basic", "SceneCollectionFile"); blog(LOG_INFO, "Switched to scene collection '%s' (%s.json)", newName, newFile); blog(LOG_INFO, "------------------------------------------------"); UpdateTitleBar(); }
void MainWindow::actionScale(){ QAction *action = (QAction*)sender(); int scaleProperty = action->property("scale").toInt(); int scaleCurrent = scale(); switch(scaleProperty){ case(eZoomIn): scaleProperty = scaleCurrent; ++scaleProperty; break; case(eZoomOut): scaleProperty = scaleCurrent; if(scaleProperty > 1) --scaleProperty; break; case(eFitToWindow): int width = scale() * ui.centralWidget->width() / ui.glCanvas->width(); int height = scale() * ui.centralWidget->height() / ui.glCanvas->height(); scaleProperty = std::min(width, height); break; } setScale(scaleProperty); updateResolution(); }
void MainWindow::actionOrientation(){ QAction *action = (QAction*)sender(); setOrientation(static_cast<Orientation>(action->property("orientation").toInt())); updateOrientation(); }
void MainWindow::actionFps(){ QAction *action = (QAction*)sender(); setFps(action->property("fps").toInt()); updateFps(); }
void MediaView::updateSubscriptionAction(Video *video, bool subscribed) { QAction *subscribeAction = MainWindow::instance()->getAction("subscribeChannel"); QString subscribeTip; QString subscribeText; if (!video) { subscribeText = subscribeAction->property("originalText").toString(); subscribeAction->setEnabled(false); } else if (subscribed) { subscribeText = tr("Unsubscribe from %1").arg(video->getChannelTitle()); subscribeTip = subscribeText; subscribeAction->setEnabled(true); } else { subscribeText = tr("Subscribe to %1").arg(video->getChannelTitle()); subscribeTip = subscribeText; subscribeAction->setEnabled(true); } subscribeAction->setText(subscribeText); subscribeAction->setStatusTip(subscribeTip); if (subscribed) { subscribeAction->setIcon(IconUtils::icon("bookmark-remove")); } else { subscribeAction->setIcon(IconUtils::icon("bookmark-new")); } MainWindow::instance()->setupAction(subscribeAction); }
void DatasetsListWidget::sl_renameDataset() { GCOUNTER(cvar, tvar, "WD::Dataset::Rename Dataset"); QAction *a = dynamic_cast<QAction*>(sender()); CHECK(NULL != a, ); int idx = a->property("idx").toInt(); CHECK(idx < tabs->count(), ); bool error = false; QString text = tabs->tabText(idx); do { bool ok = false; text = QInputDialog::getText(this, tr("Rename Dataset"), tr("New dataset name:"), QLineEdit::Normal, text, &ok); if (!ok) { return; } U2OpStatusImpl os; ctrl->renameDataset(idx, text, os); if (os.hasError()) { QMessageBox::critical(this, tr("Error"), os.getError()); } error = os.hasError(); } while (error); tabs->setTabText(idx, text); }
void MainWidget::handleChangeStatusRequested () { QAction *action = qobject_cast<QAction*> (sender ()); if (!action) { qWarning () << Q_FUNC_INFO << sender () << "is not an action"; return; } QVariant stateVar = action->property ("Azoth/TargetState"); EntryStatus status; if (!stateVar.isNull ()) { const auto state = stateVar.value<State> (); status = EntryStatus (state, AccountActsMgr_->GetStatusText (action, state)); } else { SetStatusDialog ssd ("global", this); if (ssd.exec () != QDialog::Accepted) return; status = EntryStatus (ssd.GetState (), ssd.GetStatusText ()); } for (IAccount *acc : Core::Instance ().GetAccounts ()) if (acc->IsShownInRoster ()) acc->ChangeState (status); updateFastStatusButton (status.State_); }
void CSceneWidget::contextMenuEvent(QContextMenuEvent *event) { if(QGraphicsItem *item = itemAt(event->pos())) { _currentItem = qgraphicsitem_cast<CGraphicsItem *>(item); if(!qFuzzyCompare(item->zValue(), qreal(0.0))) // ignore first item, first item is background { QListIterator<QAction *> it(_itemsMenu->actions()); while(it.hasNext()) { QAction *action = it.next(); if(action->property("action").toString().compare("hidebox") == 0) { action->setChecked(!_currentItem->isEditMode()); action->setText(_currentItem->isEditMode()?tr("Hide box"):tr("Show box")); break; } } _itemsMenu->exec(event->globalPos()); } else { _sceneMenu->exec(event->globalPos()); } } _currentItem = 0; update(); }
void PythonGroupCommand::activated(int iMsg) { try { Gui::ActionGroup* pcAction = qobject_cast<Gui::ActionGroup*>(_pcAction); QList<QAction*> a = pcAction->actions(); assert(iMsg < a.size()); QAction* act = a[iMsg]; Base::PyGILStateLocker lock; Py::Object cmd(_pcPyCommand); if (cmd.hasAttr("Activated")) { Py::Callable call(cmd.getAttr("Activated")); Py::Tuple args(1); args.setItem(0, Py::Int(iMsg)); Py::Object ret = call.apply(args); } // If the command group doesn't implement the 'Activated' method then invoke the command directly else { Gui::CommandManager &rcCmdMgr = Gui::Application::Instance->commandManager(); rcCmdMgr.runCommandByName(act->property("CommandName").toByteArray()); } // Since the default icon is reset when enabing/disabling the command we have // to explicitly set the icon of the used command. pcAction->setIcon(a[iMsg]->icon()); } catch(Py::Exception&) { Base::PyGILStateLocker lock; Base::PyException e; Base::Console().Error("Running the Python command '%s' failed:\n%s\n%s", sName, e.getStackTrace().c_str(), e.what()); } }
void MainWindow::updateAutoScale(){ if(autoScale()){ ui.centralWidget->setMinimumSize(1, 1); }else{ ui.centralWidget->setMinimumSize(0, 0); QAction *action = resolutionGroup_->checkedAction(); if(action){ setWidth(action->property("width").toInt()); setHeight(action->property("height").toInt()); } } resolutionGroup_->setEnabled(!autoScale()); updateResolution(); }
static void addActionsToToolBar(const ActionList &actions, QToolBar *t) { const ActionList::const_iterator cend = actions.constEnd(); for (ActionList::const_iterator it = actions.constBegin(); it != cend; ++it) { QAction *action = *it; if (action->property(QDesignerActions::defaultToolbarPropertyName).toBool()) t->addAction(action); } }
void MainWindow::checkLoadedSettings(){ QAction *action; action = resolutionGroup_->checkedAction(); if(action) action->setChecked(false); QList<QAction*> resolutionListActions = resolutionGroup_->actions(); foreach(QAction *action, resolutionListActions){ if(action->property("width").toInt() == width() && action->property("height").toInt() == height()){ action->setChecked(true); break; } } action = fpsGroup_->checkedAction(); if(action) action->setChecked(false); QList<QAction*> fpsListActions = fpsGroup_->actions(); foreach(QAction *action, fpsListActions){ if(action->property("fps").toInt() == fps()){ action->setChecked(true); break; } } action = orientationGroup_->checkedAction(); if(action) action->setChecked(false); QList<QAction*> orientationListActions = orientationGroup_->actions(); foreach(QAction *action, orientationListActions){ if(static_cast<Orientation>(action->property("orientation").toInt()) == orientation()){ action->setChecked(true); break; } } ui.actionDraw_Infos->setChecked(drawInfos()); ui.actionAlways_on_Top->setChecked(alwaysOnTop()); ui.actionAuto_Scale->setChecked(autoScale()); }
void CSceneWidget::onOpacityTriggered() { QAction *action = qobject_cast<QAction*>(sender()); if(_currentItem != 0 && action != 0) { qreal opacity = action->property("opacity").toReal(); _currentItem->setOpacity(opacity/qreal(100.0)); qDebug() << "opacity: " << opacity/qreal(100.0); } }
void MainWindow::on_actionRemove_plot_triggered() { QAction * action = qobject_cast<QAction *>(sender()); PlotWidget * plot =qobject_cast<PlotWidget*> (action->property("Plot").value<QWidget*>()); Q_ASSERT(plot); PlotList.removeOne(plot); plot->deleteLater(); }
int SampleActionsManager::getValidClickedActionId(U2OpStatus &os) const { QAction *a = qobject_cast<QAction*>(sender()); CHECK_EXT(NULL != a, os.setError(L10N::internalError("Unexpected method call")), -1); bool ok = false; int id = a->property(ID_PROPERTY).toInt(&ok); CHECK_EXT(ok, os.setError(L10N::internalError("Wrong action ID")), -1); CHECK_EXT(id >=0 && id < actions.size(), os.setError(L10N::internalError("Out of range action ID")), -1); return id; }
void PackagesDelegate::handleAction () { return; QAction *sAction = qobject_cast<QAction*> (sender ()); if (!sAction) { qWarning () << Q_FUNC_INFO << "sender is not an action" << sender (); return; } int packageID = sAction->data ().toInt (); QString role = sAction->property ("Role").toString (); bool checked = sAction->isChecked (); try { if (role == "InstallRemove") { bool installed = sAction->property ("Installed").toBool (); Core::Instance ().GetPendingManager ()->ToggleInstallRemove (packageID, checked, installed); } else if (role == "Update") Core::Instance ().GetPendingManager ()->ToggleUpdate (packageID, checked); else qWarning () << Q_FUNC_INFO << "unknown role" << role; } catch (const std::exception& e) { qWarning () << Q_FUNC_INFO << e.what (); QMessageBox::critical (Core::Instance ().GetProxy ()->GetMainWindow (), tr ("LeechCraft"), tr ("Unable to mark package, reverting.") + "<br />" + QString::fromUtf8 (e.what ())); sAction->setChecked (false); } }
void QtMenu::addMenuAction(QMenu& qMenu, QAction& qAction, const char* path) { QMenu* menu = addMenuPath(qMenu, path); TF_ASSERT(menu != nullptr); auto order = qAction.property("order").toInt(); auto actions = menu->actions(); auto it = std::find_if(actions.begin(), actions.end(), [&](QAction* action) { return action->property("order").toInt() > order; }); menu->insertAction(it == actions.end() ? nullptr : *it, &qAction); }
void FileItemLinkingPlugin::Private::actionTriggered() { QAction *action = dynamic_cast<QAction *>(sender()); if (!action) { return; } bool link = action->property("link").toBool(); QString activity = action->property("activity").toString(); KAMD_DBUS_DECL_INTERFACE(service, Resources/Linking, ResourcesLinking); foreach (const auto &item, items.urlList()) { service.asyncCall( link ? "LinkResourceToActivity" : "UnlinkResourceFromActivity", QString(), item.toLocalFile(), activity); } }
void FilesWidget::onLabel() { m_contextMenu->close(); QAction *action = static_cast<QAction*>(QObject::sender()); if (!action) return; int color = action->property("color").toInt(); foreach (Movie *movie, selectedMovies()) { movie->setLabel(color); Manager::instance()->database()->setLabel(movie->files(), color); }
void OBSBasic::ChangeProfile() { QAction *action = reinterpret_cast<QAction*>(sender()); ConfigFile config; std::string path; if (!action) return; path = QT_TO_UTF8(action->property("file_name").value<QString>()); if (path.empty()) return; const char *oldName = config_get_string(App()->GlobalConfig(), "Basic", "Profile"); if (action->text().compare(QT_UTF8(oldName)) == 0) { action->setChecked(true); return; } size_t path_len = path.size(); path += "/basic.ini"; if (config.Open(path.c_str(), CONFIG_OPEN_ALWAYS) != 0) { blog(LOG_ERROR, "ChangeProfile: Failed to load file '%s'", path.c_str()); return; } path.resize(path_len); const char *newName = config_get_string(config, "General", "Name"); const char *newDir = strrchr(path.c_str(), '/') + 1; config_set_string(App()->GlobalConfig(), "Basic", "Profile", newName); config_set_string(App()->GlobalConfig(), "Basic", "ProfileDir", newDir); config.Swap(basicConfig); InitBasicConfigDefaults(); ResetProfileData(); RefreshProfiles(); config_save_safe(App()->GlobalConfig(), "tmp", nullptr); UpdateTitleBar(); blog(LOG_INFO, "Switched to profile '%s' (%s)", newName, newDir); blog(LOG_INFO, "------------------------------------------------"); if (api) api->on_event(OBS_FRONTEND_EVENT_PROFILE_CHANGED); }
ModeStripe::ModeStripe(QAction &modeAction, const QString &text, QWidget *parent) : QLabel((" <b>%1</b> - " + tr("press %2 or click here to switch to %3")) .arg(text, modeAction.shortcut().toString(), modeAction.property("modeName").toString()), parent) , mAction(modeAction) { setFrameShape(QFrame::NoFrame); setFrameShadow(QFrame::Plain); setLineWidth(0); addAction(&modeAction); connect(&modeAction, &QAction::changed, this, [&modeAction, this]() { setVisible(modeAction.isVisible() && !modeAction.isChecked()); }); }
void UEditorWindow::openLastFile() { QAction * from = qobject_cast<QAction*>(sender()); if(!from) { return; } QString filename = from->property("absolutePath").toString(); if(filename.isEmpty() || !QFileInfo(filename).exists()) { return; } openFile(filename); }
void MainWindow::on_actionEdit_plot_triggered() { QAction * action = qobject_cast<QAction *>(sender()); PlotWidget * plot =qobject_cast<PlotWidget*> (action->property("Plot").value<QWidget*>()); Q_ASSERT(plot); PlotConfigurationDialog dlg(*plot,variables,this); if(dlg.exec() == QDialog::Accepted) { plot->replot(); } }