void ViewProviderTextDocument::setupContextMenu(QMenu* menu, QObject* receiver, const char* member) { Gui::ActionFunction* func = new Gui::ActionFunction(menu); QAction* act = menu->addAction(QObject::tr("Edit text")); func->trigger(act, boost::bind(&ViewProviderTextDocument::doubleClicked, this)); ViewProviderDocumentObject::setupContextMenu(menu, receiver, member); }
void ViewProviderSpline::setupContextMenu(QMenu* menu, QObject* receiver, const char* member) { ViewProviderPartExt::setupContextMenu(menu, receiver, member); // toggle command to display components Gui::ActionFunction* func = new Gui::ActionFunction(menu); QAction* act = menu->addAction(QObject::tr("Show control points")); act->setCheckable(true); act->setChecked(ControlPoints.getValue()); func->toggle(act, boost::bind(&ViewProviderSpline::toggleControlPoints, this, _1)); }
void ViewProviderFemAnalysis::setupContextMenu(QMenu* menu, QObject* receiver, const char* member) { Gui::ActionFunction* func = new Gui::ActionFunction(menu); QAction* act = menu->addAction(tr("Activate analysis")); func->trigger(act, boost::bind(&ViewProviderFemAnalysis::doubleClicked, this)); }
TaskPanelView::TaskPanelView(QWidget *parent) : QWidget(parent) { Gui::ActionFunction* func = new Gui::ActionFunction(this); QAction* action = new QAction(this); func->trigger(action, boost::bind(&TaskPanelView::executeAction, this)); #if defined(QSINT_ACTIONPANEL) QGridLayout* customLayout = new QGridLayout(this); QTabWidget* tabWidget = new QTabWidget(this); customLayout->addWidget(tabWidget, 0, 0); this->resize(642, 850); { Ui_TaskActionBox* ui(new Ui_TaskActionBox); QWidget* page1 = new QWidget(); ui->setupUi(page1); tabWidget->addTab(page1, QLatin1String("Action Box")); // setup ActionBox 1 ui->ActionBox1->setIcon(QPixmap(QString::fromAscii(":/icons/document-open.svg"))); ui->ActionBox1->header()->setText(QString::fromAscii("Header of the group")); connect(ui->ActionBox1->header(), SIGNAL(clicked()), action, SIGNAL(triggered())); QSint::ActionLabel *a1 = ui->ActionBox1->createItem(QString::fromAscii("This action has no icon")); connect(a1, SIGNAL(clicked()), action, SIGNAL(triggered())); QSint::ActionLabel *a2 = ui->ActionBox1->createItem(QPixmap(QString::fromAscii(":/icons/document-print.svg")), QString::fromAscii("This action has icon")); connect(a2, SIGNAL(clicked()), action, SIGNAL(triggered())); QLayout *hbl1 = ui->ActionBox1->createHBoxLayout(); QSint::ActionLabel *a3 = ui->ActionBox1->createItem(QString::fromAscii("1st action in row"), hbl1); connect(a3, SIGNAL(clicked()), action, SIGNAL(triggered())); QSint::ActionLabel *a4 = ui->ActionBox1->createItem(QString::fromAscii("2nd action in row"), hbl1); connect(a4, SIGNAL(clicked()), action, SIGNAL(triggered())); // setup ActionBox 2 ui->ActionBox2->setIcon(QPixmap(QString::fromAscii(":/icons/document-save.png"))); ui->ActionBox2->header()->setText(QString::fromAscii("Checkable actions allowed")); connect(ui->ActionBox2->header(), SIGNAL(clicked()), action, SIGNAL(triggered())); QSint::ActionLabel *b1 = ui->ActionBox2->createItem(QString::fromAscii("Action 1 (Exclusive)")); b1->setCheckable(true); b1->setAutoExclusive(true); b1->setChecked(true); QSint::ActionLabel *b2 = ui->ActionBox2->createItem(QString::fromAscii("Action 2 (Exclusive)")); b2->setCheckable(true); b2->setAutoExclusive(true); QSint::ActionLabel *b3 = ui->ActionBox2->createItem(QString::fromAscii("Action 3 (Exclusive)")); b3->setCheckable(true); b3->setAutoExclusive(true); QSint::ActionLabel *b4 = ui->ActionBox2->createItem(QString::fromAscii("Non-exclusive but still checkable")); b4->setCheckable(true); // setup ActionBox 3 ui->ActionBox3->setIcon(QPixmap(QString::fromAscii(":/icons/document-print.png"))); ui->ActionBox3->header()->setText(QString::fromAscii("Also, widgets allowed as well")); ui->ActionBox3->addWidget(new QPushButton(QString::fromAscii("PushButton"), this)); ui->ActionBox3->addWidget(new QCheckBox(QString::fromAscii("CheckBox"), this)); QLayout *hbl3 = ui->ActionBox3->createHBoxLayout(); ui->ActionBox3->addWidget(new QRadioButton(QString::fromAscii("RadioButton 1"), this), hbl3); ui->ActionBox3->addWidget(new QRadioButton(QString::fromAscii("RadioButton 2"), this), hbl3); // setup ActionBox 4 ui->ActionBox4->setIcon(QPixmap(QString::fromAscii(":/icons/document-open.png"))); ui->ActionBox4->header()->setText(QString::fromAscii("ActionBox with different scheme")); ui->ActionBox4->createItem(QString::fromAscii("This action has no icon")); ui->ActionBox4->createItem(QPixmap(QString::fromAscii(":/icons/document-print.png")), QString::fromAscii("This action has icon")); QLayout *hbl4 = ui->ActionBox4->createHBoxLayout(); ui->ActionBox4->createItem(QString::fromAscii("1st action in row"), hbl4); ui->ActionBox4->createItem(QString::fromAscii("2nd action in row"), hbl4); ui->ActionBox4->createItem(QString::fromAscii("3rd action in row"), hbl4); const char* ActionBoxNewStyle = "QSint--ActionBox {" "background-color: #333333;" "border: 1px solid #000000;" "text-align: left;" "}" "QSint--ActionBox:hover {" "background-color: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 #666666, stop: 1 #333333);" "border: 1px solid #222222;" "}" "QSint--ActionBox QSint--ActionLabel[class='header'] {" "text-align: center;" "font: 14px bold;" "color: #999999;" "background-color: transparent;" "border: 1px solid transparent;" "}" "QSint--ActionBox QSint--ActionLabel[class='header']:hover {" "color: #aaaaaa;" "text-decoration: underline;" "border: 1px dotted #aaaaaa;" "}" "QSint--ActionBox QSint--ActionLabel[class='action'] {" "background-color: transparent;" "border: none;" "color: #777777;" "text-align: left;" "font: 11px;" "}" "QSint--ActionBox QSint--ActionLabel[class='action']:hover {" "color: #888888;" "text-decoration: underline;" "}" "QSint--ActionBox QSint--ActionLabel[class='action']:on {" "background-color: #ddeeff;" "color: #006600;" "}" ; ui->ActionBox4->setStyleSheet(QString::fromAscii(ActionBoxNewStyle)); // setup ActionBox 5 Gui::CommandManager &rcCmdMgr = Gui::Application::Instance->commandManager(); ui->ActionBox5->setIcon(QPixmap(QString::fromAscii(":/icons/document-save.png"))); ui->ActionBox5->header()->setText(QString::fromAscii("TaskGroup with different scheme")); rcCmdMgr.addTo("Std_New", ui->ActionBox5); rcCmdMgr.addTo("Std_Open", ui->ActionBox5); rcCmdMgr.addTo("Std_Save", ui->ActionBox5); ui->ActionBox5->setStyleSheet(QString::fromAscii(ActionBoxNewStyle)); } { Ui_TaskGroup* ui(new Ui_TaskGroup); QWidget* page2 = new QWidget(); ui->setupUi(page2); tabWidget->addTab(page2, QLatin1String("Action Group")); this->actionGroup = ui->ActionPanel; // create ActionGroups on ActionPanel QIcon save = QIcon::fromTheme(QString::fromLatin1("document-save")); QSint::ActionGroup *group1 = ui->ActionPanel->createGroup(save.pixmap(24,24), QString::fromAscii("Expandable Group")); group1->addAction(ui->actionNew); group1->addAction(ui->actionLoad); group1->addWidget(new QPushButton(QString::fromAscii("Just a button"), this)); group1->addAction(ui->actionSave); group1->addAction(ui->actionPrint); group1->addWidget(new QPushButton(QString::fromAscii("Just another button"), this)); QIcon redo = QIcon::fromTheme(QString::fromLatin1("edit-redo")); QSint::ActionGroup *group2 = ui->ActionPanel->createGroup(redo.pixmap(24,24), QString::fromAscii("Non-Expandable Group"), false); group2->addAction(ui->actionNew); group2->addAction(ui->actionLoad); group2->addAction(ui->actionSave); group2->addAction(ui->actionPrint); ui->ActionPanel->addWidget(new QLabel(QString::fromAscii("Action Group without header"), this)); QSint::ActionGroup *group3 = ui->ActionPanel->createGroup(); group3->addAction(ui->actionNew); QHBoxLayout *hbl = new QHBoxLayout(); group3->groupLayout()->addLayout(hbl); hbl->addWidget(group3->addAction(ui->actionLoad, false)); hbl->addWidget(group3->addAction(ui->actionSave, false)); group3->addAction(ui->actionPrint); ui->ActionPanel->addStretch(); // setup standalone ActionGroup ui->ActionGroup1->setScheme(QSint::WinXPPanelScheme::defaultScheme()); ui->ActionGroup1->addWidget(ui->rbDefaultScheme); ui->ActionGroup1->addWidget(ui->rbXPBlueScheme); ui->ActionGroup1->addWidget(ui->rbXPBlue2Scheme); ui->ActionGroup1->addWidget(ui->rbVistaScheme); ui->ActionGroup1->addWidget(ui->rbMacScheme); ui->ActionGroup1->addWidget(ui->rbAndroidScheme); Gui::ActionFunction* func = new Gui::ActionFunction(this); QAction* defaultAction = new QAction(this); connect(ui->rbDefaultScheme, SIGNAL(toggled(bool)), defaultAction, SIGNAL(toggled(bool))); func->toggle(defaultAction, boost::bind(&TaskPanelView::on_rbDefaultScheme_toggled, this, _1)); QAction* xpBlueAction = new QAction(this); connect(ui->rbXPBlueScheme, SIGNAL(toggled(bool)), xpBlueAction, SIGNAL(toggled(bool))); func->toggle(xpBlueAction, boost::bind(&TaskPanelView::on_rbXPBlueScheme_toggled, this, _1)); QAction* xpBlue2Action = new QAction(this); connect(ui->rbXPBlue2Scheme, SIGNAL(toggled(bool)), xpBlue2Action, SIGNAL(toggled(bool))); func->toggle(xpBlue2Action, boost::bind(&TaskPanelView::on_rbXPBlue2Scheme_toggled, this, _1)); QAction* vistaAction = new QAction(this); connect(ui->rbVistaScheme, SIGNAL(toggled(bool)), vistaAction, SIGNAL(toggled(bool))); func->toggle(vistaAction, boost::bind(&TaskPanelView::on_rbVistaScheme_toggled, this, _1)); QAction* macAction = new QAction(this); connect(ui->rbMacScheme, SIGNAL(toggled(bool)), macAction, SIGNAL(toggled(bool))); func->toggle(macAction, boost::bind(&TaskPanelView::on_rbMacScheme_toggled, this, _1)); QAction* androidAction = new QAction(this); connect(ui->rbAndroidScheme, SIGNAL(toggled(bool)), androidAction, SIGNAL(toggled(bool))); func->toggle(androidAction, boost::bind(&TaskPanelView::on_rbAndroidScheme_toggled, this, _1)); } #else setWindowTitle(QLatin1String("Task View")); QGridLayout* gridLayout = new QGridLayout(this); iisTaskPanel *taskPanel = new iisTaskPanel(this); iisTaskBox *tb1 = new iisTaskBox( QPixmap(QString::fromAscii(":/icons/document-save.svg")),QLatin1String("Expandable Group"),true, this); taskPanel->addWidget(tb1); gridLayout->addWidget(taskPanel, 0, 0, 2, 1); iisIconLabel *i1 = new iisIconLabel( Gui::BitmapFactory().iconFromTheme("document-new"), QLatin1String("Create new file"), tb1); tb1->addIconLabel(i1); connect(i1, SIGNAL(activated()), action, SIGNAL(triggered())); iisIconLabel *i2 = new iisIconLabel( Gui::BitmapFactory().iconFromTheme("document-open"), QLatin1String("Load a file"), tb1); tb1->addIconLabel(i2); connect(i2, SIGNAL(activated()), action, SIGNAL(triggered())); tb1->groupLayout()->addWidget(new QPushButton(QLatin1String("Just a button"), this)); iisIconLabel *i3 = new iisIconLabel( Gui::BitmapFactory().iconFromTheme("document-save"), QLatin1String("Save current file"), tb1); tb1->addIconLabel(i3); iisIconLabel *i4 = new iisIconLabel( Gui::BitmapFactory().iconFromTheme("document-print"), QLatin1String("Print file contents"), tb1); tb1->addIconLabel(i4); i4->setColors(Qt::red, Qt::green, Qt::gray); i4->setFocusPen(QPen()); tb1->groupLayout()->addWidget(new QPushButton(QLatin1String("Just another button"), this)); iisTaskBox *tb2 = new iisTaskBox( Gui::BitmapFactory().pixmap("edit-redo"), QLatin1String("Non-expandable Group"), false, this); taskPanel->addWidget(tb2); iisIconLabel *i21 = new iisIconLabel( Gui::BitmapFactory().iconFromTheme("document-new"), QLatin1String("Create new file"), tb2); tb2->addIconLabel(i21); iisIconLabel *i22 = new iisIconLabel( Gui::BitmapFactory().iconFromTheme("document-open"), QLatin1String("Load a file"), tb2); tb2->addIconLabel(i22); iisIconLabel *i23 = new iisIconLabel( Gui::BitmapFactory().iconFromTheme("document-save"), QLatin1String("Save current file"), tb2); tb2->addIconLabel(i23); i23->setEnabled(false); iisIconLabel *i24 = new iisIconLabel( Gui::BitmapFactory().iconFromTheme("document-print"), QLatin1String("Print file contents"), tb2); tb2->addIconLabel(i24); // Other widgets can be also added to the panel QLabel *l1 = new QLabel(QLatin1String("Action Group without header"), this); taskPanel->addWidget(l1); iisTaskGroup *tb3 = new iisTaskGroup(this); taskPanel->addWidget(tb3); iisIconLabel *i31 = new iisIconLabel( Gui::BitmapFactory().iconFromTheme("document-new"), QLatin1String("Create new file"), tb3); tb3->addIconLabel(i31); QHBoxLayout *hb3 = new QHBoxLayout(); tb3->groupLayout()->addLayout(hb3); iisIconLabel *i32 = new iisIconLabel( Gui::BitmapFactory().iconFromTheme("document-open"), QLatin1String("Load a file"), tb3); tb3->addIconLabel(i32); hb3->addWidget(i32); iisIconLabel *i33 = new iisIconLabel( Gui::BitmapFactory().iconFromTheme("document-save"), QLatin1String("Save current file"), tb3); tb3->addIconLabel(i33); i33->setDisabled(true); hb3->addWidget(i33); iisIconLabel *i34 = new iisIconLabel( Gui::BitmapFactory().iconFromTheme("document-print"), QLatin1String("Print file contents"), tb3); tb3->addIconLabel(i34); taskPanel->addStretch(); taskPanel->setScheme(iisWinXPTaskPanelScheme::defaultScheme()); tb1->setScheme(iisWinXPTaskPanelScheme::defaultScheme()); tb2->setScheme(iisWinXPTaskPanelScheme2::defaultScheme()); tb3->setScheme(iisTaskPanelScheme::defaultScheme()); #endif }