void tst_QStackedWidget::dynamicPages() { QStackedWidget *sw = new QStackedWidget; TestPage *w1 = new TestPage(true); w1->setN(3); TestPage *w2 = new TestPage; w2->setN(3); sw->addWidget(w1); sw->addWidget(w2); QLineEdit *le11 = w1->findChild<QLineEdit*>(QLatin1String("lineEdit1")); le11->setFocus(); // set focus to second widget in the page sw->resize(200, 200); sw->show(); qApp->setActiveWindow(sw); QTest::qWaitForWindowActive(sw); QTRY_COMPARE(QApplication::focusWidget(), le11); sw->setCurrentIndex(1); QLineEdit *le22 = w2->findChild<QLineEdit*>(QLatin1String("lineEdit2")); le22->setFocus(); QTRY_COMPARE(QApplication::focusWidget(), le22); // Going back should move focus back to le11 sw->setCurrentIndex(0); QTRY_COMPARE(QApplication::focusWidget(), le11); }
void RevsView::setTabLogDiffVisible(bool b) { QStackedWidget* s = tab()->stackedPanes; QTabWidget* t = tab()->tabLogDiff; bool isTabPage = (s->currentIndex() == 0); int idx = (isTabPage ? t->currentIndex() : s->currentIndex()); container->setUpdatesEnabled(false); if (b && !isTabPage) { t->addTab(tab()->textBrowserDesc, "Log"); t->addTab(tab()->textEditDiff, "Diff"); t->setCurrentIndex(idx - 1); s->setCurrentIndex(0); } if (!b && isTabPage) { s->addWidget(tab()->textBrowserDesc); s->addWidget(tab()->textEditDiff); // manually remove the two remaining empty pages t->removeTab(0); t->removeTab(0); s->setCurrentIndex(idx + 1); } container->setUpdatesEnabled(true); }
void PagePalette::startMasterPageMode(QString masterPage) { m_view->Deselect(true); QStackedWidget* stackedWidget = this->stackedWidget(); if (stackedWidget->count() < 2) { PagePalette_MasterPages* mpWidget = new PagePalette_MasterPages(stackedWidget, m_view, masterPage); mpWidget->setObjectName(QString::fromLocal8Bit("PagePalette_MasterPages")); stackedWidget->addWidget(mpWidget); connect(mpWidget, SIGNAL(removePage(int )), m_scMW, SLOT(deletePage2(int ))); connect(mpWidget, SIGNAL(finished()) , m_scMW, SLOT(manageMasterPagesEnd())); } else { ScribusDoc* doc = m_view->Doc; PagePalette_MasterPages* mpWidget = this->masterpageWidget(); if (mpWidget->currentView != m_view) mpWidget->setView(m_view, masterPage); mpWidget->updateMasterPageList(masterPage); if (doc->currentPage()->pageName() != masterPage) mpWidget->selectMasterPage(masterPage); } // Set focus to page palette or focus may be set to wrong document window this->setFocus(); stackedWidget->setCurrentIndex(1); }
void GoToStackPageAction::slotTriggered() { QStackedWidget *stack = qobject_cast<QStackedWidget*>(m_receiver); if (stack && stack->widget(nextWidgetIndex())) { stack->setCurrentIndex(nextWidgetIndex()); } }
void RemoveStackPageAction::slotTriggered() { if ( !KexiUtils::objectIsA(m_receiver, "QStackedWidget") && /* compat */ !KexiUtils::objectIsA(m_receiver, "QWidgetStack")) { return; } QStackedWidget *stack = qobject_cast<QStackedWidget*>(m_receiver); QWidget *page = stack->currentWidget(); QWidgetList list; list.append(page); KFormDesigner::Command *com = new KFormDesigner::DeleteWidgetCommand(*m_container->form(), list); // raise prev/next widget int index = stack->indexOf(page); if (index > 0) { index--; } else if (index < (stack->count()-1)) { index++; } else { index = -1; } if (index >= 0) { stack->setCurrentIndex(index); } stack->removeWidget(page); m_container->form()->addCommand(com); }
void InsertPageCommand::undo() { QWidget *page = m_form->objectTree()->lookup(m_name)->widget(); QWidget *parent = m_form->objectTree()->lookup(m_parentname)->widget(); QWidgetList list; list.append(page); KFormDesigner::Command *com = new KFormDesigner::DeleteWidgetCommand(*m_form, list); QByteArray classname = parent->metaObject()->className(); if (classname == "KFDTabWidget") { TabWidgetBase *tab = dynamic_cast<TabWidgetBase*>(parent); tab->removeTab(tab->indexOf(page)); } else if (classname == "QStackedWidget" || /* compat */ classname == "QWidgetStack") { QStackedWidget *stack = dynamic_cast<QStackedWidget*>(parent); int index = stack->indexOf(page); if (index > 0) index--; else if (index < (stack->count()-1)) index++; else index = -1; if (index >= 0) stack->setCurrentIndex(index); stack->removeWidget(page); } com->execute(); delete com; }
//----------------------------------------------------------------------------- // Function: ComponentEditorSettingsPage::setupLayout() //----------------------------------------------------------------------------- void ComponentEditorSettingsPage::setupLayout() { SettingsPage::settings().beginGroup("Workspaces"); QString currentWorkspaceName = SettingsPage::settings().value("CurrentWorkspace").toString(); QStringList workspaceNames = SettingsPage::settings().childGroups(); SettingsPage::settings().endGroup(); // Workspaces QStackedWidget* workspaces = createWorkspacePages(currentWorkspaceName, workspaceNames); QComboBox* workspaceCombo = new QComboBox; workspaceCombo->addItems(workspaceNames); connect(workspaceCombo, SIGNAL(activated(int)), workspaces, SLOT(setCurrentIndex(int))); connect(workspaceCombo, SIGNAL(activated(int)), this, SLOT(onWorkspaceChanged(int))); QHBoxLayout* topLayout = new QHBoxLayout; QLabel* workspaceLabel = new QLabel(tr("Select workspace:")); topLayout->addWidget(workspaceLabel); topLayout->addWidget(workspaceCombo); topLayout->addStretch(1); QVBoxLayout* workspaceLayout = new QVBoxLayout(this); workspaceLayout->addLayout(topLayout); workspaceLayout->addWidget(workspaces); onWorkspaceChanged(workspaceNames.indexOf(currentWorkspaceName)); workspaceCombo->setCurrentIndex(currentWorkspaceIndex_); workspaces->setCurrentIndex(currentWorkspaceIndex_); }
void PropertyWidgetBuilder::visitAdvancedList(AdvancedListProperty & property) { QComboBox * comboBox = new QComboBox(m_active_widget); comboBox->addItems(property.choices()); m_active_layout->addRow(property.description(), comboBox); QStackedWidget * groupBoxesStack = new QStackedWidget(m_active_widget); m_active_layout->addRow(groupBoxesStack); for (PropertyList * propertyList : property.propertyLists()) { QGroupBox * groupBox = new QGroupBox(m_active_widget); groupBox->setAlignment(Qt::AlignVCenter); QFormLayout * groupboxlayout = new QFormLayout(groupBox); if (propertyList->isEmpty()) { QLabel * label = new QLabel("No Properties to display", groupBox); label->setAlignment(Qt::AlignCenter); groupboxlayout->addWidget(label); } QWidget * former_active_widget = m_active_widget; QFormLayout * former_active_layout = m_active_layout; m_active_widget = groupBox; m_active_layout = groupboxlayout; this->iterateOverProperties(propertyList->list()); m_active_widget = former_active_widget; m_active_layout = former_active_layout; groupBoxesStack->addWidget(groupBox); } QObject::connect(comboBox, static_cast<void (QComboBox::*)(const QString &)>(&QComboBox::currentIndexChanged), [&property, groupBoxesStack] (const QString & text) { property.select(text); groupBoxesStack->setCurrentIndex(property.selection()); qDebug("Set Property %s = \"%s\"", qPrintable(property.name()), qPrintable(property.selectedChoice())); } ); }
void RevsView::toggleDiffView() { QStackedWidget* s = tab()->stackedPanes; QTabWidget* t = tab()->tabLogDiff; bool isTabPage = (s->currentIndex() == 0); int idx = (isTabPage ? t->currentIndex() : s->currentIndex()); bool old = container->updatesEnabled(); container->setUpdatesEnabled(false); if (isTabPage) t->setCurrentIndex(1 - idx); else s->setCurrentIndex(3 - idx); container->setUpdatesEnabled(old); }
MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow) { ui->setupUi(this); QStackedWidget *stackedWidget = this->findChild<QStackedWidget *>(tr("stackedWidget")); if (stackedWidget) { stackedWidget->setCurrentIndex(0); } LuaEngine *pEngine = LuaEngine::getInstance(); L = pEngine->getLuaStack()->getLuaState(); tabWidget = this->findChild<QTabWidget *>(tr("tabWidget")); setValidator(); }
void PagePalette::startMasterPageMode(QString masterPage) { ScribusDoc* doc = m_view->Doc; bool mustDeselect = false; mustDeselect |= (!doc->masterPageMode()); mustDeselect |= (doc->masterPageMode() && doc->currentPage()->pageName() != masterPage); if (mustDeselect) { // We must avoid deselecting directly if doc is in an edit mode, // otherwise that would cause an inconsistent state. In such case, // fallback to normal mode by precaution if (doc->appMode != modeNormal) m_view->requestMode(modeNormal); m_view->Deselect(true); } QStackedWidget* stackedWidget = this->stackedWidget(); if (stackedWidget->count() < 2) { PagePalette_MasterPages* mpWidget = new PagePalette_MasterPages(stackedWidget, m_view, masterPage); mpWidget->setObjectName(QString::fromLocal8Bit("PagePalette_MasterPages")); stackedWidget->addWidget(mpWidget); connect(mpWidget, SIGNAL(removePage(int )), m_scMW, SLOT(deletePage2(int ))); connect(mpWidget, SIGNAL(finished()) , m_scMW, SLOT(editMasterPagesEnd())); } else { ScribusDoc* doc = m_view->Doc; PagePalette_MasterPages* mpWidget = this->masterpageWidget(); if (mpWidget->m_view != m_view) mpWidget->setView(m_view, masterPage); mpWidget->updateMasterPageList(masterPage); if (doc->currentPage()->pageName() != masterPage) mpWidget->selectMasterPage(masterPage); } // Set focus to page palette or focus may be set to wrong document window this->setFocus(); stackedWidget->setCurrentIndex(1); }
void interface::on_clicked_item(){ iisIconLabel * btn = dynamic_cast<iisIconLabel*>(sender()); int id = list.find(btn).value(); QStackedWidget *st = listWindow.find(currentTab).value(); st->setCurrentIndex(id); }
void Form3::keyPressEvent(QKeyEvent * ev) { QStackedWidget *sw = ui->stackedWidget; //if(!testEnabled) return; bool ok; ix = sw->currentIndex(); int key = ev->key(); if(key == Qt::Key_F12) { if(testMode == true) { QMessageBox mb; //mb.setText(tr("Ручная правка данных отключена")); //mb.setInformativeText( tr("Чтение из аппаратуры восстановлено") ); mb.exec(); testMode=false; } } else if(key == Qt::Key_F11) { QString text = QInputDialog::getText(this, "",//tr("Ручная правка данных"), "",//tr("Чтение из аппаратуры выключено. Введите через запятую: адрес, значение"), QLineEdit::Normal, 0, &ok); if (ok && !text.isEmpty()) { QStringList slist = text.split(","); int dev=slist[0].toInt(&ok); if(!ok) return; int adr=slist[1].toInt(&ok); if(!ok) return; int val=slist[2].toInt(&ok); if(!ok) return; valData[dev][adr] = val; } testMode = true; } else if(key == Qt::Key_Backspace) { ref->show(); ref->setFocus(); } else if(key == Qt::Key_Slash) { // меню ППН if(ix==12) { // только для ppnRef->show(); ppnRef->setFocus(); } } else if(key == Qt::Key_Right) { // след.страница // если были на слайде алгоритма, переходим сразу на 14й слайд (параметры ИК) if((ix>=1 && ix<=11)) sw->setCurrentIndex(12); else sw->setCurrentIndex( (ix<(sw->count()-1))? ix+1 : 0); } else if(key == Qt::Key_Left) {// предыд.страница // если были на слайде алгоритма, переходим на 1й слайд if(ix>=1 && ix<=11) sw->setCurrentIndex(0); else if(ix==12) // если были на таблице ИК, на первый слайд с алгоритмами sw->setCurrentIndex(1); else sw->setCurrentIndex(ix > 0? ix-1 : sw->count()-1); } else if(key == Qt::Key_Down) { // след.слайд в группе слайдов if(ix==12) { // если мы на таблице ППН ui->sw2->setCurrentIndex(( ui->sw2->currentIndex() <ui->sw2->count()-1 )? ui->sw2->currentIndex() + 1 : 0); } else if(ix>=1 && ix<=11) { // если на алгоритмах защит sw->setCurrentIndex( (ix<11)? ix+1 : 1); } else if(ix==13) { // слайд дискр сигналов discrSlideCurr<3?discrSlideCurr++:discrSlideCurr=0; // switch(discrSlideCurr) { // case 0: // вх 151,152 // paintEvent1(in151); // break; // case 1: // paintEvent1(out155az); // break; // case 2: // paintEvent1(out155pz); // break; // case 3: // paintEvent1(pca); // break; // } update(); } } else if(key == Qt::Key_Up) { // предыд.страница if(ix==12) { // если мы на таблице ППН ui->sw2->setCurrentIndex((ui->sw2->currentIndex() > 0 )? ui->sw2->currentIndex()-1 : ui->sw2->count()-1); } else if(ix>=1 && ix<=11) { // если на алгоритмах защит sw->setCurrentIndex( (ix>1)? ix-1 : 11); } else if(ix==13) { // слайд дискр сигналов discrSlideCurr>0?discrSlideCurr--:discrSlideCurr=3; update(); } } // слайд дискретных сигналов // (ix==14)? discrSlide = true : discrSlide = false; // else if(key >= Qt::Key_0 && key <= Qt::Key_9) { // двузначный номер слайда // sw->setCurrentIndex(ev->key()-Qt::Key_0); // } #if 0 else if(key >= Qt::Key_0 && ev->key() <= Qt::Key_9) { // двузначный номер слайда dig[digCnt] = ev->key(); if (digCnt==0) { QTimer::singleShot(2000,Qt::CoarseTimer , this, SLOT(onHideFrameNumbers())); hideFrameNumbersTimerEnabled = true; hide2DigitTimerEnabled = false; digCnt++; lbFrameNum->setText(QString::number(dig[0]-Qt::Key_0)); lbFrameNum->setVisible(true); } else { hideFrameNumbersTimerEnabled = false; hide2DigitTimerEnabled = true; sw->setCurrentIndex( ((dig[0]-Qt::Key_0) * 10) + (dig[1]-Qt::Key_0) ); lbFrameNum->setText( QString::number((dig[0]-Qt::Key_0) *10) + QString::number( dig[1]-Qt::Key_0) ); QTimer::singleShot(1000,Qt::CoarseTimer , this, SLOT(onHide2Digit())); digCnt=0; } } #endif }
int main(int argc, char **argv) { Vals vals; /* the application */ QApplication app(argc, argv); app.setApplicationName(APP_NAME); app.setWindowIcon(QIcon(":/icon")); Window window; /* translations */ QTranslator qtr; if (qtr.load("qt_" + QLocale::system().name(), QTR_PATH)) app.installTranslator(&qtr); QTranslator htr; if (htr.load("H4KvT_" + QLocale::system().name(), ":/")) app.installTranslator(&htr); /* display information */ QTextEdit *text = new QTextEdit; text->setReadOnly(true); text->setLineWrapMode(QTextEdit::NoWrap); text->setToolTip(Window::tr("Drop any file for hashing")); QObject::connect(&window, &Window::idle, text, &QWidget::setEnabled); /* compare hash */ QLineEdit *test = new QLineEdit; HexVal hexval; test->setValidator(&hexval); test->installEventFilter(&window); test->setToolTip(Window::tr("Compare hashes")); QObject::connect(test, &QLineEdit::textChanged, [&](const QString &newValue) { if (vals.name != "") { std::string hashVal = newValue.toStdString(); std::transform(hashVal.begin(), hashVal.end(), hashVal.begin(), ::tolower); std::stringstream html; if (hashVal != "") html << "<style>.h" << hashVal << "{color:green}</style>"; html << "<div style='margin-bottom:2; font-size:27px'><i><b>" << vals.name << "</b></i></div>"; html << "<div style='margin-bottom:7; margin-left:23; font-size:13px'>" << vals.path << "</div>"; if (!ALL(vals,"")) { html << "<div style='font-size:13px'><table>"; if (vals.md5 != "") html << "<tr><td>md5: </td><td class='h" << vals.md5 << "'>" << vals.md5 << "</td</tr>"; if (vals.sha1 != "") html << "<tr><td>sha1: </td><td class='h" << vals.sha1 << "'>" << vals.sha1 << "</td</tr>"; if (vals.sha224 != "") html << "<tr><td>sha224: </td><td class='h" << vals.sha224 << "'>" << vals.sha224 << "</td</tr>"; if (vals.sha256 != "") html << "<tr><td>sha256: </td><td class='h" << vals.sha256 << "'>" << vals.sha256 << "</td</tr>"; if (vals.sha384 != "") html << "<tr><td>sha384: </td><td class='h" << vals.sha384 << "'>" << vals.sha384 << "</td</tr>"; if (vals.sha512 != "") html << "<tr><td>sha512: </td><td class='h" << vals.sha512 << "'>" << vals.sha512 << "</td</tr>"; html << "</table></div>"; } int horizontal = text->horizontalScrollBar()->value(); int vertical = text->verticalScrollBar()->value(); text->setHtml(QString::fromStdString(html.str())); text->horizontalScrollBar()->setValue(horizontal); text->verticalScrollBar()->setValue(vertical); test->setStyleSheet(ANY(vals,hashVal) ? "color:green" : ""); }}); /* error messages */ QLabel *error = new QLabel; error->setStyleSheet("color:red"); /* test or error */ QStackedWidget *stack = new QStackedWidget; delete stack->layout(); stack->setLayout(new Stack); stack->addWidget(error); stack->addWidget(test); stack->setCurrentIndex(1); /* toggle test or error */ QPushButton *hash = new QPushButton(QIcon(":/icon"), ""); hash->setCheckable(true); hash->setChecked(true); hash->setToolTip(Window::tr("Compare hashes")); QObject::connect(hash, &QPushButton::toggled, stack, &QStackedWidget::setCurrentIndex); /* store method */ QSettings settings("H4KvT", "H4KvT"); /* more methods */ bool more; try { settings.setValue("MoreHashingMethods", more = moreOrLess()); } catch (...) { more = settings.value("MoreHashingMethods", false).toBool(); } /* hashing method */ QComboBox *meth = new QComboBox; meth->addItem("md5"); meth->addItem("sha1"); if (more) meth->addItem("sha224"); meth->addItem("sha256"); if (more) meth->addItem("sha384"); meth->addItem("sha512"); meth->setToolTip(Window::tr("Hashing method")); meth->setCurrentText(settings.value("HashingMethod", "md5").toString()); QObject::connect(&window, &Window::idle, meth, &QWidget::setEnabled); QObject::connect(meth, &QComboBox::currentTextChanged, [&](const QString &text) { settings.setValue("HashingMethod", text); }); /* toolbar */ QHBoxLayout *pane = new QHBoxLayout; pane->addWidget(hash, 0, Qt::AlignLeft); pane->addWidget(stack); pane->addWidget(meth, 0, Qt::AlignRight); /* main layout */ QVBoxLayout *layout = new QVBoxLayout; layout->addWidget(text); layout->addLayout(pane); /* the window */ window.centralWidget()->setLayout(layout); window.show(); /* future hashing */ QFutureWatcher<Vals> zu; QObject::connect(&zu, &QFutureWatcher<Vals>::finished, [&]() { Vals valsi = zu.future().result(); window.idle(true); if (valsi.path == "") { error->setText(QString::fromStdString(valsi.name)); hash->setChecked(false); } else { error->clear(); vals += valsi; test->textChanged(test->text()); } }); QObject::connect(meth, &QComboBox::currentTextChanged, [&](const QString &text) { if (vals.name != "") { window.idle(false); zu.setFuture(QtConcurrent::run(&update, text, vals)); }}); QObject::connect(&window, &Window::fileDroped, [&](const QString &name, const QString &path) { window.idle(false); zu.setFuture(QtConcurrent::run(&update, meth->currentText(), Vals(name, path))); }); /* hashing info */ QGraphicsBlurEffect blur; blur.setBlurHints(QGraphicsBlurEffect::AnimationHint); QPropertyAnimation anim(&blur, "blurRadius"); anim.setDuration(2000); anim.setLoopCount(-1); anim.setKeyValueAt(0, 0); anim.setKeyValueAt(0.5, 3); anim.setKeyValueAt(1, 0); QLabel *hashing = new QLabel; hashing->setPixmap(QPixmap(":/icon")); hashing->setAttribute(Qt::WA_TransparentForMouseEvents); hashing->setGraphicsEffect(&blur); hashing->hide(); (new QHBoxLayout(text))->addWidget(hashing, 0, Qt::AlignCenter); QObject::connect(&blur, &QGraphicsBlurEffect::blurRadiusChanged, hashing, static_cast<void(QWidget::*)()>(&QWidget::update)); QObject::connect(&window, &Window::idle, [&](bool idle) { if (idle) { hashing->hide(); anim.stop(); } else { hashing->show(); anim.start(); } }); /* about app */ QMenu about; QAction *action = about.addAction(QIcon(":/icon"), Window::tr("About %1").arg(APP_NAME)); action->setMenuRole(QAction::AboutRole); QObject::connect(action, &QAction::triggered, &window, &Window::about); error->setContextMenuPolicy(Qt::NoContextMenu); hash->setContextMenuPolicy(Qt::NoContextMenu); meth->setContextMenuPolicy(Qt::NoContextMenu); window.setContextMenuPolicy(Qt::CustomContextMenu); QObject::connect(&window, &QWidget::customContextMenuRequested, [&about, &window](const QPoint &pos) { about.popup(window.mapToGlobal(pos)); }); text->setContextMenuPolicy(Qt::CustomContextMenu); QObject::connect(text, &QWidget::customContextMenuRequested, [action, text](const QPoint &pos) { if (QMenu *m = text->createStandardContextMenu()) { m->insertAction(m->insertSeparator(m->actions()[0]), action); m->popup(text->mapToGlobal(pos)); } }); test->setContextMenuPolicy(Qt::CustomContextMenu); QObject::connect(test, &QWidget::customContextMenuRequested, [action, test](const QPoint &pos) { if (QMenu *m = test->createStandardContextMenu()) { m->insertAction(m->insertSeparator(m->actions()[0]), action); m->popup(test->mapToGlobal(pos)); } }); return app.exec(); }
//FIXME: keep loaded plugins in own plugin manager and //unload plugins to let load new version without //the need to restart the application void RackWindow::loadPlugin(QWidget *pluginHost) { QDir pluginsDir(qApp->applicationDirPath()); #if defined(Q_OS_WIN) if (pluginsDir.dirName().toLower() == "debug" || pluginsDir.dirName().toLower() == "release") pluginsDir.cdUp(); #elif defined(Q_OS_MAC) if (pluginsDir.dirName() == "MacOS") { pluginsDir.cdUp(); pluginsDir.cdUp(); pluginsDir.cdUp(); } #endif if (!pluginsDir.cd("plugins")) { QMessageBox::information(this, "Error", "No plugin folder found"); return; } QStringList pluginList = pluginsDir.entryList(QDir::Files); RSelectPluginDialog pluginDialog(this); pluginDialog.pluginListWidget->addItems(pluginList); pluginDialog.pluginListWidget->setCurrentRow(0); if (pluginDialog.exec()) { // bool ok; // int newPluginIndex = RSelectPluginDialog::getIndex(this, pluginList, &ok); // if (ok) { //QString fileName = pluginsDir.entryList(QDir::Files).at(newPluginIndex); QString fileName = pluginsDir.entryList(QDir::Files).at(pluginDialog.pluginListWidget->currentRow()); QPluginLoader pluginLoader(pluginsDir.absoluteFilePath(fileName)); QObject *plugin = pluginLoader.instance(); ///test // QList<QPluginLoader *> loadedPlugins = findChildren<QPluginLoader *>(); // QObject *plugin = 0; // for (int i = 0; i < loadedPlugins.size(); ++i) { // if (loadedPlugins.at(i)->fileName() == pluginsDir.absoluteFilePath(fileName)) { // plugin = loadedPlugins.at(i)->instance(); // break; // } // } // if (!plugin) { // QPluginLoader *pluginLoader = new QPluginLoader(pluginsDir.absoluteFilePath(fileName), this); // plugin = pluginLoader->instance(); // } //debug code qDebug() << "we have the following plugins loaded:"; QList<QPluginLoader *> debugPlugins = findChildren<QPluginLoader *>(); for (int i = 0; i < debugPlugins.size(); ++i) { qDebug() << debugPlugins.at(i)->fileName(); } ////////// // m_pluginLoader = new QPluginLoader(pluginsDir.absoluteFilePath(fileName), this); // QObject *plugin = m_pluginLoader->instance(); ///////////////// if (plugin) { IWidgetPlugin *widgetPlugin = qobject_cast<IWidgetPlugin *>(plugin); if (widgetPlugin) { QWidget *newWidget = widgetPlugin->createRWidget(m_coreImpl, this); //get pointers from pluginhost: QStackedWidget *pluginStack = pluginHost->findChild<QStackedWidget *>("rackPluginStack"); QToolBar *pluginHostToolBar = pluginHost->findChild<QToolBar *>("rackPluginHostToolBar"); QToolBar *pluginToolBar = pluginHost->property("pluginToolBar").value<QToolBar *>(); QSignalMapper *sm = pluginHost->findChild<QSignalMapper *>("rackPluginSwitchMapper"); QActionGroup *ag = pluginHostToolBar->findChild<QActionGroup *>(); //add plugin widget to the widget stack: pluginStack->setCurrentIndex(pluginStack->addWidget(newWidget)); //create action for the toolbars: QAction *act = new QAction(widgetPlugin->name(), ag); act->setCheckable(true); act->setChecked(true); //qt bugfix: set transparent dummy icon to move button text down or right act->setIcon(QIcon(":/images/transparent-icon.png")); //create button for pluginhost toolbar: QToolButton *tb = new QToolButton; tb->setObjectName(QLatin1String(newWidget->metaObject()->className()) + "ToolButton"); tb->setToolButtonStyle(Qt::ToolButtonTextBesideIcon); tb->setFocusPolicy(Qt::NoFocus); tb->setDefaultAction(act); RPushButton *settingsButton = new RPushButton; settingsButton->setObjectName("rackPluginHostToolBarSettingsButton"); RPushButton *deleteButton = new RPushButton; deleteButton->setObjectName("rackPluginHostToolBarDeleteButton"); QHBoxLayout *hl = new QHBoxLayout(tb); hl->setSpacing(0); hl->setContentsMargins(0,0,1,0); hl->addStretch(); hl->addWidget(settingsButton); hl->addWidget(deleteButton); pluginHostToolBar->addWidget(tb); //create button for plugin toolbar: QToolButton *tb1 = new QToolButton; tb1->setObjectName(QLatin1String(newWidget->metaObject()->className()) + "ToolButton"); tb1->setToolButtonStyle(Qt::ToolButtonTextUnderIcon); tb1->setFocusPolicy(Qt::NoFocus); tb1->setDefaultAction(act); pluginToolBar->addWidget(tb1); //connect action trigger to PluginSwitchMapper; QObject::connect(act, SIGNAL(triggered()), sm, SLOT(map())); sm->setMapping(act, newWidget); //connect delete signal //remove act from actiongroup and delete it: QObject::connect(deleteButton, SIGNAL(clicked()), m_mapperClosePlugin, SLOT(map())); m_mapperClosePlugin->setMapping(deleteButton, act); QObject::connect(deleteButton, SIGNAL(clicked()), newWidget, SLOT(deleteLater())); QObject::connect(deleteButton, SIGNAL(clicked()), tb1, SLOT(deleteLater())); QObject::connect(deleteButton, SIGNAL(clicked()), tb, SLOT(deleteLater())); //connect settings signal //if (plugin has settings) ... //QObject::connect(settingsButton, SIGNAL(clicked()), } } else { QMessageBox::information(this, "Error", "Could not load the plugin"); qDebug() << pluginLoader.errorString(); } } }
/* * Exposure bracketing page. * * Purpose: * 1. selecting best shot, and * 2. increase dynamic range (HDR). * * For both of these purposes, it is best to maintain a fixed aperture, * focal distance, focal length, ISO setting, subject distance, and white * balance. That means Manual mode or Av mode, and no auto ISO, no auto * white balance, no auto focus (or turn off auto focus once focus has * been achieved when setting up the shot) and use a tripod if available * (turn off image stabilization). * * For purpose 2, want to take the frames as quickly as the exposure can * be adjusted between images (to minimize movement of the subject). * For static subjects, the exposure is usually adjusted by altering the * shutter speed. For dynamic subjects, the exposure can be adjusted by * altering the ISO (not yet implemented, but if shooting RAW this can * be done in post-processing). */ QWidget * MultiShot::getExposureBracketingPage() { /* * Settings. */ const int MAX_Frames = 7; // range is 1 .. 2*MAX + 1 QLabel *eFramesLabel = new QLabel( tr("Images:" ) ); eFramesLabel->setAlignment( Qt::AlignRight | Qt::AlignVCenter ); QStackedWidget *eFramesDisplay = new QStackedWidget(); eFramesDisplay->setFont( QFont("Calibri", 12) ); QLabel *eFramePage[MAX_Frames+1]; for( int i = 0; i <= MAX_Frames; i++ ) { eFramePage[i] = new QLabel( eFramesDisplay ); eFramePage[i]->setText( QString::number((2*i)+1) ); eFramePage[i]->setAlignment( Qt::AlignLeft ); eFramesDisplay->insertWidget( i, eFramePage[i] ); } eFramesDisplay->setCurrentIndex( 0 ); eFrames = new QSlider(); eFrames->setCursor( QCursor(Qt::SizeHorCursor) ); eFrames->setValue( 0 ); eFrames->setMinimum( 0 ); eFrames->setMaximum( MAX_Frames ); eFrames->setPageStep( 1 ); eFrames->setOrientation( Qt::Horizontal ); eFrames->setTickPosition( QSlider::TicksBelow ); eFrames->setTickInterval( 1 ); QObject::connect( eFrames, SIGNAL(valueChanged(int)), eFramesDisplay, SLOT(setCurrentIndex(int))); QLabel *eIncrementLabel = new QLabel( tr("Increment:" ) ); eIncrementLabel->setAlignment( Qt::AlignRight | Qt::AlignVCenter ); QStackedWidget *eIncrementDisplay = new QStackedWidget(); eIncrementDisplay->setFont( QFont("Calibri", 12) ); for( int i = 0; i < 10; i++ ) { eIncrementPage[i] = new QLabel( eIncrementDisplay ); eIncrementPage[i]->setAlignment( Qt::AlignLeft ); eIncrementDisplay->insertWidget( i, eIncrementPage[i] ); } eIncrementDisplay->setCurrentIndex( 0 ); eIncrement = new QSlider(); eIncrement->setCursor( QCursor(Qt::SizeHorCursor) ); eIncrement->setValue( 0 ); eIncrement->setMinimum( 0 ); eIncrement->setPageStep( 1 ); eIncrement->setOrientation( Qt::Horizontal ); eIncrement->setTickPosition( QSlider::TicksBelow ); eIncrement->setTickInterval( 1 ); setIncrementPages(); QObject::connect( eIncrement, SIGNAL(valueChanged(int)), eIncrementDisplay, SLOT(setCurrentIndex(int))); //QPushButton *autoButton = new QPushButton( tr("Auto") ); eCompensation = new ExposureComp( camera, 5 ); QObject::connect( eCompensation, SIGNAL(propertyChanged(int,int)), this, SIGNAL(propertyChanged(int,int))); QObject::connect( eFrames, SIGNAL(valueChanged(int)), eCompensation, SLOT(updateExposures(int))); QObject::connect( eIncrement, SIGNAL(valueChanged(int)), eCompensation, SLOT(updateIncrement(int))); /* * Final layout. */ QGridLayout *settingsLayout = new QGridLayout(); settingsLayout->addWidget( eFramesLabel, 0, 0 ); settingsLayout->addWidget( eFrames, 0, 1 ); settingsLayout->addWidget( eFramesDisplay, 0, 2 ); settingsLayout->addWidget( eIncrementLabel, 1, 0 ); settingsLayout->addWidget( eIncrement, 1, 1 ); settingsLayout->addWidget( eIncrementDisplay, 1, 2 ); //settingsLayout->addWidget( autoButton, 2, 1 ); settingsLayout->setColumnStretch( 3, 1 ); settingsLayout->setColumnMinimumWidth( 0, 100 ); QGroupBox *settingsGroupBox = new QGroupBox( tr("Settings") ); settingsGroupBox->setLayout( settingsLayout ); QHBoxLayout *bracketingLayout = new QHBoxLayout(); bracketingLayout->addSpacing( 35 ); bracketingLayout->addWidget( eCompensation, 0, Qt::AlignLeft ); QGroupBox *bracketingGroupBox = new QGroupBox( tr("Exposure compensation and bracketing") ); bracketingGroupBox->setLayout( bracketingLayout ); QVBoxLayout *layout = new QVBoxLayout(); layout->addWidget( settingsGroupBox ); layout->addWidget( bracketingGroupBox ); layout->addStretch( 1 ); QWidget *widget = new QWidget( this ); widget->setLayout( layout ); return( widget ); }
// Update associated QWidget / QObject based on treeGuiWidget_ data void QtWidgetObject::updateQt() { // Check treeGuiWidget_ pointer first if (treeGuiWidget_ == NULL) { printf("Critical Error: treeGuiWidget_ pointer has not been set in QtWidgetObject.\n"); return; } // Do generic properties here if (qWidget_ != NULL) { qWidget_->setEnabled(treeGuiWidget_->enabled()); qWidget_->setVisible(treeGuiWidget_->visible()); // And corresponding label if (labelWidget_ != NULL) { labelWidget_->setEnabled(treeGuiWidget_->enabled()); labelWidget_->setVisible(treeGuiWidget_->visible()); } } // Now, check widget type to see what we do if (treeGuiWidget_->type() == TreeGuiWidget::ButtonWidget) { QPushButton *button = static_cast<QPushButton*>(qWidget_); if (!button) printf("Critical Error: Couldn't cast stored qWidget_ pointer into QPushButton.\n"); } else if (treeGuiWidget_->type() == TreeGuiWidget::CheckWidget) { QCheckBox *check = static_cast<QCheckBox*>(qWidget_); if (!check) printf("Critical Error: Couldn't cast stored qWidget_ pointer into QCheckBox.\n"); else { check->setChecked(treeGuiWidget_->valueI() == 1); } } else if (treeGuiWidget_->type() == TreeGuiWidget::ComboWidget) { QComboBox* combo = static_cast<QComboBox*>(qWidget_); if (!combo) printf("Critical Error: Couldn't cast stored qWidget_ pointer into QComboBox.\n"); else { // Has items list been modified since last update if (treeGuiWidget_->propertyChanged(TreeGuiWidgetEvent::ItemsProperty)) { combo->clear(); for (int n=0; n<treeGuiWidget_->comboItems().count(); ++n) combo->addItem(treeGuiWidget_->comboItems().at(n)); treeGuiWidget_->resetChanged(TreeGuiWidgetEvent::ItemsProperty); } // Set current index combo->setCurrentIndex(treeGuiWidget_->valueI()-1); } } else if (treeGuiWidget_->type() == TreeGuiWidget::DoubleSpinWidget) { QDoubleSpinBox* spin = static_cast<QDoubleSpinBox*>(qWidget_); if (!spin) printf("Critical Error: Couldn't cast stored qWidget_ pointer into QDoubleSpinBox.\n"); else { spin->setRange(treeGuiWidget_->minimumD(), treeGuiWidget_->maximumD()); spin->setValue(treeGuiWidget_->valueD()); } } else if (treeGuiWidget_->type() == TreeGuiWidget::EditWidget) { QLineEdit *edit = static_cast<QLineEdit*>(qWidget_); if (!edit) printf("Critical Error: Couldn't cast stored qWidget_ pointer into QTextEdit.\n"); else { edit->setText(treeGuiWidget_->text()); } } else if (treeGuiWidget_->type() == TreeGuiWidget::IntegerSpinWidget) { QSpinBox *spin = static_cast<QSpinBox*>(qWidget_); if (!spin) printf("Critical Error: Couldn't cast stored qWidget_ pointer into QSpinBox.\n"); else { spin->setRange(treeGuiWidget_->minimumI(), treeGuiWidget_->maximumI()); spin->setValue(treeGuiWidget_->valueI()); } } else if (treeGuiWidget_->type() == TreeGuiWidget::LabelWidget) { QLabel *label = static_cast<QLabel*>(qWidget_); if (!label) printf("Critical Error: Couldn't cast stored qWidget_ pointer into QLabel.\n"); else { label->setText(treeGuiWidget_->text()); } } else if (treeGuiWidget_->type() == TreeGuiWidget::RadioButtonWidget) { QRadioButton *button = static_cast<QRadioButton*>(qWidget_); if (!button) printf("Critical Error: Couldn't cast stored qWidget_ pointer into QRadioButton.\n"); else { button->setChecked(treeGuiWidget_->valueI() == 1); } } else if (treeGuiWidget_->type() == TreeGuiWidget::RadioGroupWidget) { QButtonGroup *butgroup = static_cast<QButtonGroup*>(qObject_); if (!butgroup) printf("Critical Error: Couldn't cast stored qObject_ pointer into QButtonGroup.\n"); else { QAbstractButton *button = butgroup->button(treeGuiWidget_->valueI()); if (!button) printf("Critical Error: Couldn't find button with id %i in button group.\n", treeGuiWidget_->valueI()); else button->setChecked(true); } } else if (treeGuiWidget_->type() == TreeGuiWidget::TabWidget) { QTabWidget *tabs = static_cast<QTabWidget*>(qWidget_); if (!tabs) printf("Critical Error: Couldn't cast stored qWidget_ pointer into QTabWidget.\n"); else { tabs->setCurrentIndex(treeGuiWidget_->valueI()-1); } } else if (treeGuiWidget_->type() == TreeGuiWidget::StackWidget) { QStackedWidget *stack = static_cast<QStackedWidget*>(qWidget_); if (!stack) printf("Critical Error: Couldn't cast stored qWidget_ pointer into QStackedWidget.\n"); else { stack->setCurrentIndex(treeGuiWidget_->valueI()-1); } } }