Пример #1
1
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);

}
Пример #2
0
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);
}
Пример #3
0
static vector_t *create_instruments_widget_state(void){
  vector_t *state = (vector_t *)talloc(sizeof(vector_t));

  //vector_t *names = (vector_t *)talloc(sizeof(vector_t));
  vector_t *pages = (vector_t *)talloc(sizeof(vector_t));

  //VECTOR_push_back(state, names);
  VECTOR_push_back(state, pages);

  QStackedWidget* tabs = instruments_widget->tabs;

  for(int i=0;i<tabs->count();i++){
    //VECTOR_push_back(names, talloc_strdup(tabs->tabText(i).toUtf8().constData()));
    VECTOR_push_back(pages, tabs->widget(i));
  }

  VECTOR_push_back(state, tabs->currentWidget());
  
  return state;
}
Пример #4
0
static void inspectPropertyEditor(ModelNode node, QWidget* propWidget)
{
    if (!propWidget)
        return;

    QStackedWidget * stackedWidget = qobject_cast<QStackedWidget *> (propWidget);
    QVERIFY(stackedWidget);
    QDeclarativeView *view = qobject_cast<QDeclarativeView*>(stackedWidget->currentWidget());
    QVERIFY(view);

    QLineEdit * idLineEdit = view->findChild<QLineEdit* >("IdLineEdit");

    if (!idLineEdit)
        return ;

    QCOMPARE(idLineEdit->text(), node.id());

    if (node.hasProperty("width")) {
         QSpinBox * widthSpinBox = view->findChild<QSpinBox* >("WidthSpinBox");
         QVERIFY(widthSpinBox);
         QCOMPARE(widthSpinBox->value(), node.variantProperty("width").value().toInt());
    }

    if (node.hasProperty("height")) {
        QSpinBox * heightSpinBox = view->findChild<QSpinBox* >("HeightSpinBox");
        QVERIFY(heightSpinBox);
        QCOMPARE(heightSpinBox->value(), node.variantProperty("height").value().toInt());// this can be dangerous
    }

    if (node.hasProperty("x")) {
        QSpinBox * xSpinBox = view->findChild<QSpinBox* >("XSpinBox");
        QVERIFY(xSpinBox);
        QCOMPARE(xSpinBox->value(), node.variantProperty("x").value().toInt()); // this can be dangerous
    }

    if (node.hasProperty("y")) {
        QSpinBox * ySpinBox = view->findChild<QSpinBox* >("YSpinBox");
        QVERIFY(ySpinBox);
        QCOMPARE(ySpinBox->value(), node.variantProperty("y").value().toInt());
    }
}
Пример #5
0
PagePalette::PagePalette(QWidget* parent) : ScDockPalette(parent, "PagePalette", 0)
{
	m_scMW = (ScribusMainWindow*) parent;
	m_view = 0;

	setObjectName(QString::fromLocal8Bit("PagePalette"));

	QStackedWidget* stackedWidget = new QStackedWidget(this);
	stackedWidget->setObjectName(QString::fromLocal8Bit("stackedWidget"));

	PagePalette_Pages* pageWidget = new PagePalette_Pages(stackedWidget);
	pageWidget->setObjectName(QString::fromLocal8Bit("PagePalette_Pages"));
	stackedWidget->addWidget(pageWidget);

	setWidget(stackedWidget);

	connect(pageWidget, SIGNAL(gotoMasterPage(QString)), m_scMW, SLOT(editMasterPagesStart(QString)));
	
	Rebuild();
	languageChange();
}
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);
}
FontSettingsDialog::FontSettingsDialog(QWidget *parent)
    : QDialog(parent)
    , m_windowFontPanel(new FontPanel(this))
    , m_browserFontPanel(new FontPanel(this))
    , m_dialogButtonBox(new QDialogButtonBox(QDialogButtonBox::Ok|QDialogButtonBox::Cancel))
{
    setModal(true);
    setWindowTitle(tr("Font Settings"));
    setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint);

    QVBoxLayout *mainVLayout = new QVBoxLayout(this);
    QHBoxLayout *hboxLayout = new QHBoxLayout;
    mainVLayout->addLayout(hboxLayout);

    QLabel *label = new QLabel(tr("Font settings for:"), this);
    label->setSizePolicy(QSizePolicy::Maximum, QSizePolicy::Preferred);
    hboxLayout->addWidget(label);
    QComboBox *comboBox = new QComboBox(this);
    comboBox->addItem(tr("Browser"));
    comboBox->addItem(tr("Application"));
    hboxLayout->addWidget(comboBox);

    m_windowFontPanel->setCheckable(true);
    m_browserFontPanel->setCheckable(true);

    const QString customSettings(tr("Use custom settings"));
    m_windowFontPanel->setTitle(customSettings);
    m_browserFontPanel->setTitle(customSettings);

    QStackedWidget *stackWidget = new QStackedWidget(this);
    stackWidget->addWidget(m_browserFontPanel);
    stackWidget->addWidget(m_windowFontPanel);

    mainVLayout->addWidget(stackWidget);
    mainVLayout->addWidget(m_dialogButtonBox);

    connect(m_dialogButtonBox , SIGNAL(rejected()), this, SLOT(reject()));
    connect(m_dialogButtonBox , SIGNAL(accepted()), this, SLOT(accept()));
    connect(comboBox, SIGNAL(activated(int)), stackWidget, SLOT(setCurrentIndex(int)));
}
Пример #8
0
void GFX_update_all_instrument_widgets(void){
  QStackedWidget* tabs = g_instruments_widget->tabs;

  //printf("*(((((((((( Calling. Update all %d:\n",tabs->count());
  for(int i=0;i<tabs->count();i++){
    MIDI_instrument_widget *midi_instrument = dynamic_cast<MIDI_instrument_widget*>(tabs->widget(i));
    Audio_instrument_widget *audio_instrument = dynamic_cast<Audio_instrument_widget*>(tabs->widget(i));
    //printf("Update all %d: %p/%p\n",i,midi_instrument,audio_instrument);

    if(midi_instrument!=NULL){

      if(midi_instrument->patch->patchdata!=NULL)
        update_midi_instrument_widget(midi_instrument,midi_instrument->patch.data());

    }else if(audio_instrument!=NULL){

      if(audio_instrument->_patch->patchdata!=NULL)
        update_audio_instrument_widget(audio_instrument,audio_instrument->_patch.data());

    }
  }
}
//-----------------------------------------------------------------------------
// Function: ComponentEditorSettingsPage::createWorkspacePages()
//-----------------------------------------------------------------------------
QStackedWidget* ComponentEditorSettingsPage::createWorkspacePages(QString currentWorkspaceName, 
	QStringList workspaceNames)
{
	SettingsPage::settings().beginGroup("Workspaces");

	SettingsPage::settings().beginGroup(currentWorkspaceName + "/ComponentEditorFilters/HW/Flat");
	QStringList hwCheckBoxNames = SettingsPage::settings().childKeys();
	SettingsPage::settings().endGroup(); // workspaceName/ComponentEditorFilters/HW

	SettingsPage::settings().beginGroup(currentWorkspaceName + "/ComponentEditorFilters/SW");
	QStringList swCheckBoxNames = SettingsPage::settings().childKeys();
	SettingsPage::settings().endGroup(); // workspaceName/ComponentEditorFilters/SW

	SettingsPage::settings().endGroup(); // Workspaces
	
	QStringList hierarchyNames = getHierarchyNames();
	hwCheckBoxNames = changeNameSeparators(hwCheckBoxNames);
	swCheckBoxNames = changeNameSeparators(swCheckBoxNames);
	QStackedWidget* workspaces = new QStackedWidget;

	for (int workspaceIndex = 0; workspaceIndex < workspaceNames.size(); ++workspaceIndex)
	{
	    QTableWidget* hwTable = new QTableWidget (hwCheckBoxNames.size(), hierarchyNames.size(), this);
		setHwTable(hwTable, hierarchyNames, hwCheckBoxNames, workspaceIndex);

		QTableWidget* swTable = new QTableWidget (swCheckBoxNames.size(), 1, this);
		QStringList swHeader("Global");
		setSwTable(swTable, swHeader, swCheckBoxNames, workspaceIndex);
		
		QTabWidget* wareTab = new QTabWidget;
	    wareTab->addTab(hwTable, "Hardware");
    	wareTab->addTab(swTable, "Software");

		workspaces->addWidget(wareTab);
	}

	return (workspaces);
}
Пример #10
0
int main(int argc,char **argv)
{
    QApplication app(argc,argv);

    QCoreApplication::setOrganizationName("Rabitsa");
    QCoreApplication::setApplicationName("filters");
    QApplication::setStyle(new QPlastiqueStyle);

    QSettings s;
    
    IoNetClient net( s.value("/ioserv/hostname","localhost").toString());
    net.setCmode(
#ifdef WIN32
                false
#else
                s.value("/ioserv/cmode",true).toBool()
#endif
    );
    QStackedWidget main;
    QColor cl;
    QPalette pal;
    cl.setRgb(90,132,201);
    pal.setColor(QPalette::Background,cl);
    main.setPalette(pal);

    QTranslator translator;
    translator.load("filters_"+QLocale::system().name(),":/translate");
    app.installTranslator(&translator);

    QTextCodec::setCodecForTr(QTextCodec::codecForName("UTF-8"));
    
    mMainForm *mainForm = new mMainForm(net);
    
    main.addWidget(mainForm);
    main.setCurrentWidget(mainForm);


    if(QApplication::desktop()->size().width()>1366 && QApplication::desktop()->size().height()> 768)
    {
        main.resize(1366,768);
        main.show();
    }
    else
    {
        main.showFullScreen();
    }

    return app.exec();
}
Пример #11
0
static void recreate_instruments_widget_from_state(vector_t *state){
  QStackedWidget* tabs = instruments_widget->tabs;

  while(tabs->count()>0)
    tabs->removeWidget(tabs->currentWidget());

  //vector_t *names = (vector_t*)state->elements[0];
  vector_t *pages = (vector_t*)state->elements[0];

  for(int i=pages->num_elements-1; i>=0; i--){
    QWidget *page = (QWidget*)pages->elements[i];
    tabs->insertWidget(0,page);//,(const char*)names->elements[i]);
  }

  tabs->setCurrentWidget((QWidget*)state->elements[1]);
}
Пример #12
0
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
}
Пример #13
0
ExportOptionsDlg::ExportOptionsDlg(ExporterResource& pExporter, QWidget* pParent) :
   QDialog(pParent),
   mpExporter(pExporter),
   mpTabWidget(NULL),
   mpSubsetPage(NULL),
   mpExporterPage(NULL)
{
   // Options widget
   QStackedWidget* pStack = new QStackedWidget(this);

   // Subset page
   RasterElement* pRasterElement = dynamic_cast<RasterElement*>(mpExporter->getItem());
   RasterFileDescriptor* pRasterWholeCubeFileDescriptor = NULL;
   RasterDataDescriptor* pRasterOrgDataDescriptor = NULL;
   if (pRasterElement != NULL)
   {
      pRasterOrgDataDescriptor = dynamic_cast<RasterDataDescriptor*>(pRasterElement->getDataDescriptor());
      if (pRasterOrgDataDescriptor != NULL)
      {
         // we are creating a file descriptor for export from the original cube, because the SubsetWidget
         // uses DimensionDescriptor::operator= compare's to determine selection which dictate that on-disk,
         // original and active numbers need to be identical, this guarantees that DimensionDescriptors will
         // compare correctly.
         pRasterWholeCubeFileDescriptor = dynamic_cast<RasterFileDescriptor*>(
            RasterUtilities::generateFileDescriptorForExport(pRasterOrgDataDescriptor, "foobar"));
      }
   }
   RasterFileDescriptor* pRasterFileDescriptor = dynamic_cast<RasterFileDescriptor*>(mpExporter->getFileDescriptor());
   if ((pRasterFileDescriptor != NULL) && (pRasterWholeCubeFileDescriptor != NULL) &&
      (pRasterOrgDataDescriptor != NULL))
   {
      mpSubsetPage = new SubsetWidget();
      mpSubsetPage->setExportMode(true);

      // Rows
      const vector<DimensionDescriptor>& orgRows = pRasterWholeCubeFileDescriptor->getRows();
      const vector<DimensionDescriptor>& selectedRows = pRasterFileDescriptor->getRows();
      mpSubsetPage->setRows(orgRows, selectedRows);

      // Columns
      const vector<DimensionDescriptor>& orgColumns = pRasterWholeCubeFileDescriptor->getColumns();
      const vector<DimensionDescriptor>& selectedColumns = pRasterFileDescriptor->getColumns();
      mpSubsetPage->setColumns(orgColumns, selectedColumns);

      // Bands
      const vector<DimensionDescriptor>& orgBands = pRasterWholeCubeFileDescriptor->getBands();
      const vector<DimensionDescriptor>& selectedBands = pRasterFileDescriptor->getBands();
      vector<string> bandNames = RasterUtilities::getBandNames(pRasterOrgDataDescriptor);
      mpSubsetPage->setBands(orgBands, bandNames, selectedBands);

      // Initial bad band file directory
      QString strDirectory;

      string filename = pRasterFileDescriptor->getFilename();
      if (filename.empty() == false)
      {
         QFileInfo fileInfo(QString::fromStdString(filename));
         strDirectory = fileInfo.absolutePath();
      }

      mpSubsetPage->setBadBandFileDirectory(strDirectory);
   }

   // Exporter page
   if (mpExporter->getPlugIn() != NULL)
   {
      mpExporterPage = mpExporter->getExportOptionsWidget();
   }

   // Horizontal line
   QFrame* pLine = new QFrame(this);
   pLine->setFrameStyle(QFrame::HLine | QFrame::Sunken);

   // Buttons
   QDialogButtonBox* pButtonBox = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel,
      Qt::Horizontal, this);

   // Layout
   QVBoxLayout* pLayout = new QVBoxLayout(this);
   pLayout->setMargin(10);
   pLayout->setSpacing(10);
   pLayout->addWidget(pStack, 10);
   pLayout->addWidget(pLine);
   pLayout->addWidget(pButtonBox);

   // Initialization
   QString strWindowTitle = "Export Options";

   SessionItem* pSessionItem = mpExporter->getItem();
   if (pSessionItem != NULL)
   {
      string name = pSessionItem->getDisplayName();
      if (name.empty() == true)
      {
         name = pSessionItem->getName();
      }

      if (name.empty() == false)
      {
         strWindowTitle += ": " + QString::fromStdString(name);
      }
   }

   setWindowTitle(strWindowTitle);
   setModal(true);

   if ((mpSubsetPage != NULL) || (mpExporterPage != NULL))
   {
      QWidget* pSubsetWidget = NULL;
      if (mpSubsetPage != NULL)
      {
         pSubsetWidget = new QWidget();
         mpSubsetPage->setParent(pSubsetWidget);

         QVBoxLayout* pSubsetLayout = new QVBoxLayout(pSubsetWidget);
         if (mpExporterPage != NULL)
         {
            pSubsetLayout->setMargin(10);
         }
         else
         {
            pSubsetLayout->setMargin(0);
         }

         pSubsetLayout->setSpacing(10);
         pSubsetLayout->addWidget(mpSubsetPage);
      }

      QWidget* pExporterWidget = NULL;
      if (mpExporterPage != NULL)
      {
         pExporterWidget = new QWidget();
         mpExporterPage->setParent(pExporterWidget);

         QVBoxLayout* pExporterLayout = new QVBoxLayout(pExporterWidget);
         if (mpSubsetPage != NULL)
         {
            pExporterLayout->setMargin(10);
         }
         else
         {
            pExporterLayout->setMargin(0);
         }

         pExporterLayout->setSpacing(10);
         pExporterLayout->addWidget(mpExporterPage);
      }

      if ((pSubsetWidget != NULL) && (pExporterWidget != NULL))
      {
         QString strExporterCaption = mpExporterPage->windowTitle();
         if (strExporterCaption.isEmpty() == true)
         {
            PlugIn* pPlugIn = mpExporter->getPlugIn();
            if (pPlugIn != NULL)
            {
               strExporterCaption = QString::fromStdString(pPlugIn->getName());
            }

            if (strExporterCaption.isEmpty() == true)
            {
               strExporterCaption = "Exporter";
            }
         }

         mpTabWidget = new QTabWidget(this);
         mpTabWidget->setTabPosition(QTabWidget::North);
         mpTabWidget->addTab(pSubsetWidget, "Subset");
         mpTabWidget->addTab(pExporterWidget, strExporterCaption);
         pStack->addWidget(mpTabWidget);
      }
      else if (pSubsetWidget != NULL)
      {
         pStack->addWidget(pSubsetWidget);
         pButtonBox->setStandardButtons(QDialogButtonBox::Ok | QDialogButtonBox::Cancel);
      }
      else if (pExporterWidget != NULL)
      {
         pStack->addWidget(pExporterWidget);
      }
   }

   if (pStack->count() == 0)
   {
      QLabel* pNoOptionsLabel = new QLabel("No options are available", this);
      pNoOptionsLabel->setAlignment(Qt::AlignCenter);
      pNoOptionsLabel->setMinimumSize(250, 100);

      pStack->addWidget(pNoOptionsLabel);
   }

   // Connections
   VERIFYNR(connect(pButtonBox, SIGNAL(accepted()), this, SLOT(accept())));
   VERIFYNR(connect(pButtonBox, SIGNAL(rejected()), this, SLOT(reject())));
}
Пример #14
0
CleanupSettings::CleanupSettings(QWidget *parent)
	: QWidget(parent), m_attached(false)
{
	QVBoxLayout *vLayout = new QVBoxLayout(this);
	vLayout->setMargin(1); // NOTE: This works to show the 1-pix black border,
						   // because this is a QWidget (not QFrame) heir...
	setLayout(vLayout);

	//   Tabs Container
	// Used to deal with styled background and other stuff

	TabBarContainter *tabBarContainer = new TabBarContainter(this);
	QHBoxLayout *hLayout = new QHBoxLayout(tabBarContainer);

	hLayout->setMargin(0);
	hLayout->setAlignment(Qt::AlignLeft);
	hLayout->addSpacing(6);

	vLayout->addWidget(tabBarContainer);

	//  Tabs Bar

	DVGui::TabBar *tabBar = new DVGui::TabBar(this);
	hLayout->addWidget(tabBar);

	tabBar->addSimpleTab(tr("Cleanup"));
	tabBar->addSimpleTab(tr("Processing"));
	tabBar->addSimpleTab(tr("Camera"));
	tabBar->setDrawBase(false);

	//  Splitter

	QSplitter *split = new QSplitter(Qt::Vertical, this);
	split->setSizePolicy(QSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding));
	vLayout->addWidget(split);

	//  Stacked Widget

	QStackedWidget *stackedWidget = new QStackedWidget(split);
	stackedWidget->setMinimumWidth(300);
	//stackedWidget->setMinimumHeight(250);

	split->addWidget(stackedWidget);
	split->setStretchFactor(0, 1);

	//  Cleanup Tab

	QScrollArea *scrollArea = new QScrollArea(stackedWidget);
	stackedWidget->addWidget(scrollArea);

	scrollArea->setWidgetResizable(true);
	scrollArea->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);

	m_cleanupTab = new CleanupTab;
	scrollArea->setWidget(m_cleanupTab);

	//  Processing Tab

	scrollArea = new QScrollArea(stackedWidget);
	stackedWidget->addWidget(scrollArea);

	scrollArea->setWidgetResizable(true);
	scrollArea->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);

	m_processingTab = new ProcessingTab;
	scrollArea->setWidget(m_processingTab);

	//  Camera Tab

	scrollArea = new QScrollArea(stackedWidget);
	stackedWidget->addWidget(scrollArea);

	scrollArea->setWidgetResizable(true);
	scrollArea->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);

	m_cameraTab = new CameraTab;
	scrollArea->setWidget(m_cameraTab);

	m_cameraTab->setCameraPresetListFile(ToonzFolder::getReslistPath(true));

	//  Swatch

	m_swatch = new CleanupSwatch(split, 200, 150);
	split->addWidget(m_swatch);

	//  ToolBar

	QWidget *toolBarWidget = new QWidget(this);
	vLayout->addWidget(toolBarWidget);

	toolBarWidget->setFixedHeight(22);

	QHBoxLayout *toolBarLayout = new QHBoxLayout(toolBarWidget);
	toolBarWidget->setLayout(toolBarLayout);

	toolBarLayout->setMargin(0);
	toolBarLayout->setSpacing(0);

	QToolBar *leftToolBar = new QToolBar(toolBarWidget);
	toolBarLayout->addWidget(leftToolBar, 0, Qt::AlignLeft);

	leftToolBar->setFixedWidth(110);

	m_swatchAct = new QAction(createQIconOnOffPNG("preview", true), tr("Toggle Swatch Preview"), this);
	m_swatchAct->setCheckable(true);
	leftToolBar->addAction(m_swatchAct);
	leftToolBar->addSeparator();

	m_opacityAct = new QAction(createQIconOnOffPNG("opacitycheck", true), tr("Toggle Opacity Check"), this);
	m_opacityAct->setCheckable(true);
	leftToolBar->addAction(m_opacityAct);

	QToolBar *spacingToolBar1 = new QToolBar(toolBarWidget);
	toolBarLayout->addWidget(spacingToolBar1, 1);

	spacingToolBar1->setMinimumHeight(22);

	QToolBar *rightToolBar = new QToolBar(toolBarWidget);
	toolBarLayout->addWidget(rightToolBar, 0, Qt::AlignRight);

	rightToolBar->setFixedWidth(110);

	QAction *saveAct = new QAction(createQIconOnOffPNG("save", false), tr("Save Settings"), this);
	rightToolBar->addAction(saveAct);
	QAction *loadAct = new QAction(createQIconOnOffPNG("load", false), tr("Load Settings"), this);
	rightToolBar->addAction(loadAct);
	rightToolBar->addSeparator();
	QAction *resetAct = new QAction(createQIconOnOffPNG("resetsize", false), tr("Reset Settings"), this);
	rightToolBar->addAction(resetAct);

	//  Model-related stuff
	CleanupSettingsModel *model = CleanupSettingsModel::instance();
	m_backupParams.assign(model->getCurrentParameters(), false);

	//  Connections

	QAction *opacityCheckCmd = CommandManager::instance()->getAction(MI_OpacityCheck);
	assert(opacityCheckCmd);

	bool ret = true;
	ret = ret && connect(tabBar, SIGNAL(currentChanged(int)), stackedWidget, SLOT(setCurrentIndex(int)));
	ret = ret && connect(m_swatchAct, SIGNAL(toggled(bool)), SLOT(enableSwatch(bool)));
	ret = ret && connect(m_opacityAct, SIGNAL(triggered(bool)), opacityCheckCmd, SLOT(trigger()));
	ret = ret && connect(saveAct, SIGNAL(triggered()), model, SLOT(promptSave()));
	ret = ret && connect(loadAct, SIGNAL(triggered()), model, SLOT(promptLoad()));
	ret = ret && connect(resetAct, SIGNAL(triggered()), this, SLOT(onRestoreSceneSettings()));

	assert(ret);
}
Пример #15
0
void QTodoManager::initUI()
{
    QGridLayout *grid = new QGridLayout(this);
    QWidget *closew = new QWidget(this);
    IconButton *closeB = QAppUtils::ref().getCloseIconBtn(closew);
    QHBoxLayout *hlay = new QHBoxLayout(closew);

    QWidget *tipw = new QWidget(this);
    QVBoxLayout *tiplay = new QVBoxLayout(tipw);
    m_lbtip = new QLabel(tipw);
    tiplay->addWidget(m_lbtip);
    m_lbtip->setText(LOCAL("当前位置>>"));

    hlay->addWidget(closeB);
    connect(closeB,SIGNAL(clicked()),this,SLOT(close()));
    m_stacked =   new QStackedWidget(this);
    m_wid_alldo = new QToDoContent(this);//QWinFactory::ref().createWindow(QWinFactory::Widget);
    m_wid_alldo->setTitle(QStringList()<<LOCAL("所有事项")<<LOCAL("选择"));

    m_wid_todo =  new QToDoContent(this,QToDoContent::ToDo);//QWinFactory::ref().createWindow(QWinFactory::Widget);
    m_wid_todo->setTitle(QStringList()<<LOCAL("待办事项")<<LOCAL("选择"));

    m_wid_done =  new QToDoContent(this,QToDoContent::Done);//QWinFactory::ref().createWindow(QWinFactory::Widget);
    m_wid_done->setTitle(QStringList()<<LOCAL("已办事项")<<LOCAL("选择"));

    m_wid_alldo->flushData(QToDoData::ref().getAll());
    //按钮
    m_allcando = new QPureColorButton(this);
    m_todobtn  = new QPureColorButton(this);
    m_donebtn  = new QPureColorButton(this);

    m_allcando->setButtonText(LOCAL("全部事项"));
    m_todobtn->setButtonText(LOCAL("待办事项"));
    m_donebtn->setButtonText(LOCAL("已办事项"));

    m_allcando->setIndex(ALLTask);
    m_todobtn->setIndex(ToDoTask);
    m_donebtn->setIndex(DoneTask);

    connect(m_allcando,SIGNAL(clicked(int)),this,SLOT(stack_change(int)));
    connect(m_todobtn,SIGNAL(clicked(int)),this,SLOT(stack_change(int)));
    connect(m_donebtn,SIGNAL(clicked(int)),this,SLOT(stack_change(int)));

    m_allcando->setColors(QColor(0,0,100),QColor(0,200,200)
                          ,QColor(0,100,100),QColor(0,150,150));

    m_todobtn->setColors(QColor(0,0,100),QColor(0,200,200)
                          ,QColor(0,100,100),QColor(0,150,150));
    m_donebtn->setColors(QColor(0,0,100),QColor(0,200,200)
                          ,QColor(0,100,100),QColor(0,150,150));

    QStackedWidget *stacked = m_stacked;
    stacked->setContentsMargins(0,0,0,0);
    stacked->addWidget(m_wid_alldo);
    stacked->addWidget(m_wid_todo);
    stacked->addWidget(m_wid_done);

    grid->setSpacing(5);
    grid->setContentsMargins(0,0,0,10);
    grid->addWidget(tipw,0,0,1,1);
    grid->addWidget(closew,0,2,1,1,Qt::AlignRight);
    grid->addWidget(stacked,1,0,1,3);
    grid->addWidget(m_allcando,2,0,1,1);
    grid->addWidget(m_todobtn,2,1,1,1);
    grid->addWidget(m_donebtn,2,2,1,1);

}
Пример #16
0
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();
}
Пример #17
0
ActionForm::ActionForm(QWidget* parent):
    QWidget(parent)
{
    QVBoxLayout* vbox = new QVBoxLayout(this);

    actionType_ = new QComboBox(this);
    actionType_->addItem("press & release key");
    actionType_->addItem("click mouse button");
    actionType_->addItem("move mouse");
    actionType_->addItem("rotate wheel");
    actionType_->addItem("run command");
    actionType_->addItem("wait");
    
    QWidget* keyOptions_ = new QWidget();
    QWidget* mouseButtonOptions_ = new QWidget();
    QWidget* mouseMotionOptions_ = new QWidget();
    QWidget* mouseWheelOptions_ = new QWidget();
    QWidget* commandOptions_ = new QWidget();
    QWidget* waitOptions_ = new QWidget();

    QHBoxLayout* keyHBox = new QHBoxLayout();
    QHBoxLayout* mouseButtonHBox = new QHBoxLayout();
    QHBoxLayout* mouseMotionHBox = new QHBoxLayout();
    QHBoxLayout* mouseWheelHBox = new QHBoxLayout();
    QHBoxLayout* commandHBox = new QHBoxLayout();
    QHBoxLayout* waitHBox = new QHBoxLayout();

    keySelector_ = new QComboBox();
    keySelector_->addItem("A", QVariant::fromValue<FakeInput::KeyType>(FakeInput::Key_A)); 	
	keySelector_->addItem("B", QVariant::fromValue<FakeInput::KeyType>(FakeInput::Key_B)); 	
	keySelector_->addItem("C", QVariant::fromValue<FakeInput::KeyType>(FakeInput::Key_C)); 	
	keySelector_->addItem("D", QVariant::fromValue<FakeInput::KeyType>(FakeInput::Key_D)); 	
	keySelector_->addItem("E", QVariant::fromValue<FakeInput::KeyType>(FakeInput::Key_E)); 	
	keySelector_->addItem("F", QVariant::fromValue<FakeInput::KeyType>(FakeInput::Key_F)); 	
	keySelector_->addItem("G", QVariant::fromValue<FakeInput::KeyType>(FakeInput::Key_G)); 	
	keySelector_->addItem("H", QVariant::fromValue<FakeInput::KeyType>(FakeInput::Key_H)); 	
	keySelector_->addItem("I", QVariant::fromValue<FakeInput::KeyType>(FakeInput::Key_I)); 	
	keySelector_->addItem("J", QVariant::fromValue<FakeInput::KeyType>(FakeInput::Key_J)); 	
	keySelector_->addItem("K", QVariant::fromValue<FakeInput::KeyType>(FakeInput::Key_K)); 	
	keySelector_->addItem("L", QVariant::fromValue<FakeInput::KeyType>(FakeInput::Key_L)); 	
	keySelector_->addItem("M", QVariant::fromValue<FakeInput::KeyType>(FakeInput::Key_M)); 	
	keySelector_->addItem("N", QVariant::fromValue<FakeInput::KeyType>(FakeInput::Key_N)); 	
	keySelector_->addItem("O", QVariant::fromValue<FakeInput::KeyType>(FakeInput::Key_O)); 	
	keySelector_->addItem("P", QVariant::fromValue<FakeInput::KeyType>(FakeInput::Key_P)); 	
	keySelector_->addItem("Q", QVariant::fromValue<FakeInput::KeyType>(FakeInput::Key_Q));
	keySelector_->addItem("R", QVariant::fromValue<FakeInput::KeyType>(FakeInput::Key_R));
	keySelector_->addItem("S", QVariant::fromValue<FakeInput::KeyType>(FakeInput::Key_S));
	keySelector_->addItem("T", QVariant::fromValue<FakeInput::KeyType>(FakeInput::Key_T));
	keySelector_->addItem("U", QVariant::fromValue<FakeInput::KeyType>(FakeInput::Key_U));
	keySelector_->addItem("V", QVariant::fromValue<FakeInput::KeyType>(FakeInput::Key_V));
	keySelector_->addItem("W", QVariant::fromValue<FakeInput::KeyType>(FakeInput::Key_W));
	keySelector_->addItem("X", QVariant::fromValue<FakeInput::KeyType>(FakeInput::Key_X));
	keySelector_->addItem("Y", QVariant::fromValue<FakeInput::KeyType>(FakeInput::Key_Y));
	keySelector_->addItem("Z", QVariant::fromValue<FakeInput::KeyType>(FakeInput::Key_Z));

    mouseButtonSelector_ = new QComboBox();
    mouseButtonSelector_->addItem("Left", QVariant::fromValue<FakeInput::MouseButton>(FakeInput::Mouse_Left));
	mouseButtonSelector_->addItem("Middle", QVariant::fromValue<FakeInput::MouseButton>(FakeInput::Mouse_Middle));
	mouseButtonSelector_->addItem("Right", QVariant::fromValue<FakeInput::MouseButton>(FakeInput::Mouse_Right));

    QLabel* xLabel = new QLabel("dx: ");
    QLabel* yLabel = new QLabel("dy: ");
    mouseMotionX_ = new QSpinBox();
    mouseMotionX_->setSingleStep(50);
    mouseMotionX_->setMinimum(-10000);
    mouseMotionX_->setMaximum(10000);
    mouseMotionY_ = new QSpinBox();
    mouseMotionY_->setSingleStep(50);
    mouseMotionY_->setMinimum(-10000);
    mouseMotionY_->setMaximum(10000);

    mouseWheelDirection_ = new QComboBox();
    mouseWheelDirection_->addItem("Up");
	mouseWheelDirection_->addItem("Down");

    command_ = new QLineEdit();

    QLabel* timeLabel = new QLabel("miliseconds: ");
    waitTime_ = new QSpinBox();
    waitTime_->setSingleStep(50);
    waitTime_->setMaximum(10000);

    keyHBox->addWidget(keySelector_);
    mouseButtonHBox->addWidget(mouseButtonSelector_);
    mouseMotionHBox->addWidget(xLabel);
    mouseMotionHBox->addWidget(mouseMotionX_);
    mouseMotionHBox->addWidget(yLabel);
    mouseMotionHBox->addWidget(mouseMotionY_);
    mouseWheelHBox->addWidget(mouseWheelDirection_);
    commandHBox->addWidget(command_);
    waitHBox->addWidget(timeLabel);
    waitHBox->addWidget(waitTime_);

    keyOptions_->setLayout(keyHBox);
    mouseButtonOptions_->setLayout(mouseButtonHBox);
    mouseMotionOptions_->setLayout(mouseMotionHBox);
    mouseWheelOptions_->setLayout(mouseWheelHBox);
    commandOptions_->setLayout(commandHBox);
    waitOptions_->setLayout(waitHBox);

    QStackedWidget* stack = new QStackedWidget(this);
    stack->addWidget(keyOptions_);
    stack->addWidget(mouseButtonOptions_);
    stack->addWidget(mouseMotionOptions_);
    stack->addWidget(mouseWheelOptions_);
    stack->addWidget(commandOptions_);
    stack->addWidget(waitOptions_);

    vbox->addWidget(actionType_);
    vbox->addWidget(stack);
    vbox->addStretch(1);

    setLayout(vbox);

    connect(actionType_, SIGNAL(currentIndexChanged(int)), stack, SLOT(setCurrentIndex(int)));
}
/*
 *  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 );
}
Пример #19
0
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);
}
Пример #20
0
PropertiesRasterLayer::PropertiesRasterLayer() :
   LabeledSectionGroup(NULL),
   mInitializing(false),
   mpRasterLayer(NULL)
{
   // Display configuration
   QWidget* pDisplayWidget = new QWidget(this);

   QLabel* pDisplayModeLabel = new QLabel("Display Mode:", pDisplayWidget);
   mpDisplayModeCombo = new QComboBox(pDisplayWidget);
   vector<string> modes = StringUtilities::getAllEnumValuesAsDisplayString<DisplayMode>();
   for (vector<string>::iterator it = modes.begin(); it != modes.end(); ++it)
   {
      mpDisplayModeCombo->addItem(QString::fromStdString(*it));
   }
   mpComplexComponentLabel = new QLabel("Complex Component:", pDisplayWidget);
   mpComplexComponentCombo = new ComplexComponentComboBox(pDisplayWidget);
   QLabel* pOpacityLabel = new QLabel("Opacity:", pDisplayWidget);
   mpOpacitySpin = new QSpinBox(pDisplayWidget);
   mpOpacitySpin->setMinimum(0);
   mpOpacitySpin->setMaximum(255);
   mpOpacitySpin->setSingleStep(1);

   LabeledSection* pDisplaySection = new LabeledSection(pDisplayWidget, "Display Configuration", this);

   QGridLayout* pDisplayGrid = new QGridLayout(pDisplayWidget);
   pDisplayGrid->setMargin(0);
   pDisplayGrid->setSpacing(5);
   pDisplayGrid->addWidget(pDisplayModeLabel, 0, 0);
   pDisplayGrid->addWidget(mpDisplayModeCombo, 0, 1, Qt::AlignLeft);
   pDisplayGrid->addWidget(mpComplexComponentLabel, 1, 0);
   pDisplayGrid->addWidget(mpComplexComponentCombo, 1, 1, Qt::AlignLeft);
   pDisplayGrid->addWidget(pOpacityLabel, 2, 0);
   pDisplayGrid->addWidget(mpOpacitySpin, 2, 1, Qt::AlignLeft);
   pDisplayGrid->setRowStretch(3, 10);
   pDisplayGrid->setColumnStretch(1, 10);

   // Grayscale
   QWidget* pGrayscaleWidget = new QWidget(this);

   QLabel* pGrayElementLabel = new QLabel("Display Element:", pGrayscaleWidget);
   mpGrayElementCombo = new QComboBox(pGrayscaleWidget);
   mpGrayElementCombo->setMinimumContentsLength(10);

   QLabel* pGrayBandLabel = new QLabel("Display Band:", pGrayscaleWidget);
   mpGrayBandCombo = new QComboBox(pGrayscaleWidget);

   QLabel* pGrayLowerLabel = new QLabel("Lower Stretch Value:", pGrayscaleWidget);
   mpGrayLowerSpin = new QDoubleSpinBox(pGrayscaleWidget);
   mpGrayLowerSpin->setRange(-1 * numeric_limits<double>::max(), numeric_limits<double>::max());
   mpGrayLowerSpin->setDecimals(6);

   QLabel* pGrayUpperLabel = new QLabel("Upper Stretch Value:", pGrayscaleWidget);
   mpGrayUpperSpin = new QDoubleSpinBox(pGrayscaleWidget);
   mpGrayUpperSpin->setRange(-1 * numeric_limits<double>::max(), numeric_limits<double>::max());
   mpGrayUpperSpin->setDecimals(6);

   QLabel* pGrayUnitsLabel = new QLabel("Stretch Units:", pGrayscaleWidget);
   mpGrayUnitsCombo = new RegionUnitsComboBox(pGrayscaleWidget);

   QLabel* pGrayStretchTypeLabel = new QLabel("Stretch Type:", pGrayscaleWidget);
   mpGrayStretchTypeCombo = new StretchTypeComboBox(pGrayscaleWidget);

   QPushButton* pGrayStretchFavoritesButton = new QPushButton("Favorites", this);
   mpGrayStretchMenu = new QMenu(pGrayStretchFavoritesButton);
   pGrayStretchFavoritesButton->setMenu(mpGrayStretchMenu);

   mpAddFavoriteGrayAction = new QAction("Add Stretch to Favorites", this);
   mpRemoveFavoriteAction = new QAction("Remove Stretch from Favorites...", this);

   LabeledSection* pGrayscaleSection = new LabeledSection(pGrayscaleWidget, "Grayscale", this);

   QGridLayout* pGrayscaleGrid = new QGridLayout(pGrayscaleWidget);
   pGrayscaleGrid->setMargin(0);
   pGrayscaleGrid->setSpacing(5);
   pGrayscaleGrid->addWidget(pGrayElementLabel, 0, 0);
   pGrayscaleGrid->addWidget(mpGrayElementCombo, 0, 1, 1, 2);
   pGrayscaleGrid->addWidget(pGrayBandLabel, 1, 0);
   pGrayscaleGrid->addWidget(mpGrayBandCombo, 1, 1, 1, 2);
   pGrayscaleGrid->addWidget(pGrayLowerLabel, 2, 0);
   pGrayscaleGrid->addWidget(mpGrayLowerSpin, 2, 1);
   pGrayscaleGrid->addWidget(pGrayStretchFavoritesButton, 2, 2, Qt::AlignLeft);
   pGrayscaleGrid->addWidget(pGrayUpperLabel, 3, 0);
   pGrayscaleGrid->addWidget(mpGrayUpperSpin, 3, 1);
   pGrayscaleGrid->addWidget(pGrayUnitsLabel, 4, 0);
   pGrayscaleGrid->addWidget(mpGrayUnitsCombo, 4, 1);
   pGrayscaleGrid->addWidget(pGrayStretchTypeLabel, 5, 0);
   pGrayscaleGrid->addWidget(mpGrayStretchTypeCombo, 5, 1);
   pGrayscaleGrid->setRowStretch(6, 10);
   pGrayscaleGrid->setColumnStretch(2, 10);

   // RGB
   QWidget* pRgbWidget = new QWidget(this);

   QLabel* pRedLabel = new QLabel("Red:", pRgbWidget);
   QLabel* pGreenLabel = new QLabel("Green:", pRgbWidget);
   QLabel* pBlueLabel = new QLabel("Blue:", pRgbWidget);

   QLabel* pRgbElementLabel = new QLabel("Display Element:", pRgbWidget);
   mpRedElementCombo = new QComboBox(pRgbWidget);
   mpRedElementCombo->setMinimumContentsLength(10);
   mpGreenElementCombo = new QComboBox(pRgbWidget);
   mpGreenElementCombo->setMinimumContentsLength(10);
   mpBlueElementCombo = new QComboBox(pRgbWidget);
   mpBlueElementCombo->setMinimumContentsLength(10);

   QLabel* pRgbBandLabel = new QLabel("Display Band:", pRgbWidget);
   mpRedBandCombo = new QComboBox(pRgbWidget);
   mpGreenBandCombo = new QComboBox(pRgbWidget);
   mpBlueBandCombo = new QComboBox(pRgbWidget);

   QLabel* pRgbLowerLabel = new QLabel("Lower Stretch Value:", pRgbWidget);
   mpRedLowerSpin = new QDoubleSpinBox(pRgbWidget);
   mpRedLowerSpin->setRange(-1 * numeric_limits<double>::max(), numeric_limits<double>::max());
   mpRedLowerSpin->setDecimals(6);
   mpGreenLowerSpin = new QDoubleSpinBox(pRgbWidget);
   mpGreenLowerSpin->setRange(-1 * numeric_limits<double>::max(), numeric_limits<double>::max());
   mpGreenLowerSpin->setDecimals(6);
   mpBlueLowerSpin = new QDoubleSpinBox(pRgbWidget);
   mpBlueLowerSpin->setRange(-1 * numeric_limits<double>::max(), numeric_limits<double>::max());
   mpBlueLowerSpin->setDecimals(6);

   QLabel* pRgbUpperLabel = new QLabel("Upper Stretch Value:", pRgbWidget);
   mpRedUpperSpin = new QDoubleSpinBox(pRgbWidget);
   mpRedUpperSpin->setRange(-1 * numeric_limits<double>::max(), numeric_limits<double>::max());
   mpRedUpperSpin->setDecimals(6);
   mpGreenUpperSpin = new QDoubleSpinBox(pRgbWidget);
   mpGreenUpperSpin->setRange(-1 * numeric_limits<double>::max(), numeric_limits<double>::max());
   mpGreenUpperSpin->setDecimals(6);
   mpBlueUpperSpin = new QDoubleSpinBox(pRgbWidget);
   mpBlueUpperSpin->setRange(-1 * numeric_limits<double>::max(), numeric_limits<double>::max());
   mpBlueUpperSpin->setDecimals(6);

   QLabel* pRgbUnitsLabel = new QLabel("Stretch Units:", pRgbWidget);
   mpRedUnitsCombo = new RegionUnitsComboBox(pRgbWidget);
   mpGreenUnitsCombo = new RegionUnitsComboBox(pRgbWidget);
   mpBlueUnitsCombo = new RegionUnitsComboBox(pRgbWidget);

   mpDisplayBandButton = new QPushButton("Presets", pRgbWidget);
   mpDisplayBandButton->setEnabled(false);
   QMenu* pMenu = new QMenu(mpDisplayBandButton);
   mpDisplayBandButton->setMenu(pMenu);

   const DynamicObject* pColorComposites = RasterLayer::getSettingColorComposites();
   if (pColorComposites != NULL)
   {
      vector<string> names;
      pColorComposites->getAttributeNames(names);
      if (names.empty() == false)
      {
         for (vector<string>::const_iterator iter = names.begin(); iter != names.end(); ++iter)
         {
            pMenu->addAction(QString::fromStdString(*iter));
         }

         mpDisplayBandButton->setEnabled(true);
      }
   }

   QLabel* pRgbStretchTypeLabel = new QLabel("Stretch Type:", pRgbWidget);
   mpRgbStretchTypeCombo = new StretchTypeComboBox(pRgbWidget);

   QPushButton* pRgbStretchFavoritesButton = new QPushButton("Favorites", pRgbWidget);
   mpRgbStretchMenu = new QMenu(pRgbStretchFavoritesButton);
   pRgbStretchFavoritesButton->setMenu(mpRgbStretchMenu);

   mpAddFavoriteRedAction = new QAction("Add Red Stretch to Favorites", pRgbWidget);
   mpAddFavoriteGreenAction = new QAction("Add Green Stretch to Favorites", pRgbWidget);
   mpAddFavoriteBlueAction = new QAction("Add Blue Stretch to Favorites", pRgbWidget);

   LabeledSection* pRgbSection = new LabeledSection(pRgbWidget, "RGB", this);

   QGridLayout* pRgbGrid = new QGridLayout(pRgbWidget);
   pRgbGrid->setMargin(0);
   pRgbGrid->setSpacing(5);
   pRgbGrid->addWidget(pRedLabel, 0, 1);
   pRgbGrid->addWidget(pGreenLabel, 0, 2);
   pRgbGrid->addWidget(pBlueLabel, 0, 3);
   pRgbGrid->addWidget(pRgbElementLabel, 1, 0);
   pRgbGrid->addWidget(mpRedElementCombo, 1, 1);
   pRgbGrid->addWidget(mpGreenElementCombo, 1, 2);
   pRgbGrid->addWidget(mpBlueElementCombo, 1, 3);
   pRgbGrid->addWidget(pRgbBandLabel, 2, 0);
   pRgbGrid->addWidget(mpRedBandCombo, 2, 1);
   pRgbGrid->addWidget(mpGreenBandCombo, 2, 2);
   pRgbGrid->addWidget(mpBlueBandCombo, 2, 3);
   pRgbGrid->addWidget(mpDisplayBandButton, 2, 4);
   pRgbGrid->addWidget(pRgbLowerLabel, 3, 0);
   pRgbGrid->addWidget(mpRedLowerSpin, 3, 1, Qt::AlignLeft);
   pRgbGrid->addWidget(mpGreenLowerSpin, 3, 2, Qt::AlignLeft);
   pRgbGrid->addWidget(mpBlueLowerSpin, 3, 3, Qt::AlignLeft);
   pRgbGrid->addWidget(pRgbStretchFavoritesButton, 3, 4);
   pRgbGrid->addWidget(pRgbUpperLabel, 4, 0);
   pRgbGrid->addWidget(mpRedUpperSpin, 4, 1, Qt::AlignLeft);
   pRgbGrid->addWidget(mpGreenUpperSpin, 4, 2, Qt::AlignLeft);
   pRgbGrid->addWidget(mpBlueUpperSpin, 4, 3, Qt::AlignLeft);
   pRgbGrid->addWidget(pRgbUnitsLabel, 5, 0);
   pRgbGrid->addWidget(mpRedUnitsCombo, 5, 1, Qt::AlignLeft);
   pRgbGrid->addWidget(mpGreenUnitsCombo, 5, 2, Qt::AlignLeft);
   pRgbGrid->addWidget(mpBlueUnitsCombo, 5, 3, Qt::AlignLeft);
   pRgbGrid->addWidget(pRgbStretchTypeLabel, 6, 0);
   pRgbGrid->addWidget(mpRgbStretchTypeCombo, 6, 1, Qt::AlignLeft);
   pRgbGrid->setRowStretch(7, 10);
   pRgbGrid->setColumnStretch(1, 10);
   pRgbGrid->setColumnStretch(2, 10);
   pRgbGrid->setColumnStretch(3, 10);

   // Graphics acceleration
   QLabel* pUnsupportedLabel = new QLabel("Dynamic texture generation is not supported on this system.", this);
   pUnsupportedLabel->setAlignment(Qt::AlignLeft | Qt::AlignTop);

   QWidget* pAccelerationWidget = new QWidget(this);
   mpAccelerationCheck = new QCheckBox("Enable Dynamic Generation", pAccelerationWidget);
   mpFilterCheck = new QCheckBox("Filter:", pAccelerationWidget);
   mpFilterList = new QListWidget(pDisplayWidget);
   mpFilterList->setSelectionMode(QAbstractItemView::ExtendedSelection);

   QStringList filterNames;
   Service<ImageFilterManager> pFilterManager;

   vector<string> filters = pFilterManager->getAvailableFilters();
   for (vector<string>::iterator iter = filters.begin(); iter != filters.end(); ++iter)
   {
      string filterName = *iter;
      if (filterName.empty() == false)
      {
         filterNames.append(QString::fromStdString(filterName));
      }
   }

   filterNames.sort();
   mpFilterList->addItems(filterNames);

   QStackedWidget* pAccelerationStack = new QStackedWidget(this);
   LabeledSection* pAccelerationSection = new LabeledSection(pAccelerationStack,
      "Dynamic Texture Generation", this);

   QGridLayout* pAccelerationGrid = new QGridLayout(pAccelerationWidget);
   pAccelerationGrid->setMargin(0);
   pAccelerationGrid->setSpacing(5);
   pAccelerationGrid->addWidget(mpAccelerationCheck, 0, 0, 1, 2);
   pAccelerationGrid->addWidget(mpFilterCheck, 1, 0, Qt::AlignTop);
   pAccelerationGrid->addWidget(mpFilterList, 1, 1, Qt::AlignLeft);
   pAccelerationGrid->setRowStretch(1, 10);
   pAccelerationGrid->setColumnStretch(1, 10);

   bool bUnsupported = true;
#if defined (CG_SUPPORTED)
   if (CgContext::instance() != NULL)
   {
      bUnsupported = false;
   }
#endif

   if (bUnsupported == true)
   {
      pAccelerationStack->addWidget(pUnsupportedLabel);
      pAccelerationWidget->hide();
   }
   else
   {
      pAccelerationStack->addWidget(pAccelerationWidget);
      pUnsupportedLabel->hide();
   }

   // Initialization
   addSection(pDisplaySection);
   addSection(pGrayscaleSection);
   addSection(pRgbSection);
   addSection(pAccelerationSection, 10);
   setSizeHint(600, 610);

   // Connections
   VERIFYNR(mDisplayConfigModifier.attachSignal(mpDisplayModeCombo, SIGNAL(currentIndexChanged(int))));
   VERIFYNR(mDisplayConfigModifier.attachSignal(mpComplexComponentCombo, SIGNAL(valueChanged(ComplexComponent))));
   VERIFYNR(mDisplayConfigModifier.attachSignal(mpOpacitySpin, SIGNAL(valueChanged(int))));

   VERIFYNR(connect(mpGrayElementCombo, SIGNAL(currentIndexChanged(int)), this, SLOT(updateDisplayedBandCombo(int))));
   VERIFYNR(connect(mpGrayBandCombo, SIGNAL(currentIndexChanged(int)), this, SLOT(updateStretchValuesFromBand())));
   VERIFYNR(connect(mpGrayStretchMenu, SIGNAL(aboutToShow()), this, SLOT(initializeStretchMenu())));
   VERIFYNR(connect(mpGrayStretchMenu, SIGNAL(triggered(QAction*)), this, SLOT(setGrayStretch(QAction*))));
   VERIFYNR(connect(mpRemoveFavoriteAction, SIGNAL(triggered()), this, SLOT(removeStretchFavorite())));
   VERIFYNR(connect(mpGrayUnitsCombo, SIGNAL(valueChanged(RegionUnits)), this,
      SLOT(updateStretchValuesFromUnits(RegionUnits))));
   VERIFYNR(mGrayscaleModifier.attachSignal(mpGrayElementCombo, SIGNAL(currentIndexChanged(int))));
   VERIFYNR(mGrayscaleModifier.attachSignal(mpGrayBandCombo, SIGNAL(currentIndexChanged(int))));
   VERIFYNR(mGrayscaleModifier.attachSignal(mpGrayLowerSpin, SIGNAL(valueChanged(double))));
   VERIFYNR(mGrayscaleModifier.attachSignal(mpGrayUpperSpin, SIGNAL(valueChanged(double))));
   VERIFYNR(mGrayscaleModifier.attachSignal(mpGrayUnitsCombo, SIGNAL(valueChanged(RegionUnits))));
   VERIFYNR(mGrayscaleModifier.attachSignal(mpGrayStretchTypeCombo, SIGNAL(valueChanged(StretchType))));

   VERIFYNR(connect(mpRedElementCombo, SIGNAL(currentIndexChanged(int)), this, SLOT(updateDisplayedBandCombo(int))));
   VERIFYNR(connect(mpGreenElementCombo, SIGNAL(currentIndexChanged(int)), this, SLOT(updateDisplayedBandCombo(int))));
   VERIFYNR(connect(mpBlueElementCombo, SIGNAL(currentIndexChanged(int)), this, SLOT(updateDisplayedBandCombo(int))));
   VERIFYNR(connect(mpRedBandCombo, SIGNAL(currentIndexChanged(int)), this, SLOT(updateStretchValuesFromBand())));
   VERIFYNR(connect(mpGreenBandCombo, SIGNAL(currentIndexChanged(int)), this, SLOT(updateStretchValuesFromBand())));
   VERIFYNR(connect(mpBlueBandCombo, SIGNAL(currentIndexChanged(int)), this, SLOT(updateStretchValuesFromBand())));
   VERIFYNR(connect(pMenu, SIGNAL(triggered(QAction*)), this, SLOT(setDisplayBands(QAction*))));
   VERIFYNR(connect(mpRgbStretchMenu, SIGNAL(aboutToShow()), this, SLOT(initializeStretchMenu())));
   VERIFYNR(connect(mpRgbStretchMenu, SIGNAL(triggered(QAction*)), this, SLOT(setRgbStretch(QAction*))));
   VERIFYNR(connect(mpRedUnitsCombo, SIGNAL(valueChanged(RegionUnits)), this,
      SLOT(updateStretchValuesFromUnits(RegionUnits))));
   VERIFYNR(connect(mpGreenUnitsCombo, SIGNAL(valueChanged(RegionUnits)), this,
      SLOT(updateStretchValuesFromUnits(RegionUnits))));
   VERIFYNR(connect(mpBlueUnitsCombo, SIGNAL(valueChanged(RegionUnits)), this,
      SLOT(updateStretchValuesFromUnits(RegionUnits))));
   VERIFYNR(mRgbModifier.attachSignal(mpRedElementCombo, SIGNAL(currentIndexChanged(int))));
   VERIFYNR(mRgbModifier.attachSignal(mpGreenElementCombo, SIGNAL(currentIndexChanged(int))));
   VERIFYNR(mRgbModifier.attachSignal(mpBlueElementCombo, SIGNAL(currentIndexChanged(int))));
   VERIFYNR(mRgbModifier.attachSignal(mpRedBandCombo, SIGNAL(currentIndexChanged(int))));
   VERIFYNR(mRgbModifier.attachSignal(mpGreenBandCombo, SIGNAL(currentIndexChanged(int))));
   VERIFYNR(mRgbModifier.attachSignal(mpBlueBandCombo, SIGNAL(currentIndexChanged(int))));
   VERIFYNR(mRgbModifier.attachSignal(mpRedLowerSpin, SIGNAL(valueChanged(double))));
   VERIFYNR(mRgbModifier.attachSignal(mpGreenLowerSpin, SIGNAL(valueChanged(double))));
   VERIFYNR(mRgbModifier.attachSignal(mpBlueLowerSpin, SIGNAL(valueChanged(double))));
   VERIFYNR(mRgbModifier.attachSignal(mpRedUpperSpin, SIGNAL(valueChanged(double))));
   VERIFYNR(mRgbModifier.attachSignal(mpGreenUpperSpin, SIGNAL(valueChanged(double))));
   VERIFYNR(mRgbModifier.attachSignal(mpBlueUpperSpin, SIGNAL(valueChanged(double))));
   VERIFYNR(mRgbModifier.attachSignal(mpRedUnitsCombo, SIGNAL(valueChanged(RegionUnits))));
   VERIFYNR(mRgbModifier.attachSignal(mpGreenUnitsCombo, SIGNAL(valueChanged(RegionUnits))));
   VERIFYNR(mRgbModifier.attachSignal(mpBlueUnitsCombo, SIGNAL(valueChanged(RegionUnits))));
   VERIFYNR(mRgbModifier.attachSignal(mpRgbStretchTypeCombo, SIGNAL(valueChanged(StretchType))));

   VERIFYNR(connect(mpAccelerationCheck, SIGNAL(toggled(bool)), this, SLOT(enableFilterCheck(bool))));
   VERIFYNR(connect(mpFilterCheck, SIGNAL(toggled(bool)), this, SLOT(enableFilterCombo(bool))));
   VERIFYNR(mGraphicsAccModifier.attachSignal(mpAccelerationCheck, SIGNAL(toggled(bool))));
   VERIFYNR(mGraphicsAccModifier.attachSignal(mpFilterCheck, SIGNAL(toggled(bool))));
   VERIFYNR(mGraphicsAccModifier.attachSignal(mpFilterList, SIGNAL(itemSelectionChanged())));
}
Пример #21
0
QWidget *SplitGrid2::getCell(int row, int col) const
{
    QStackedWidget* cell = getCellImp( row, col );
    Q_ASSERT( cell != 0 );
    return cell->currentWidget();
}
Пример #22
0
int main(int argc, char *argv[])
{
    QApplication app(argc, argv);
    auto *proxyStyle = new TabBarProxyStyle;
    app.setStyle(proxyStyle);

    QWidget widget;
    QStackedWidget stackedWidget;
    QTabBar tabBar;
    tabBar.setDocumentMode(true);
    tabBar.setTabsClosable(true);
    tabBar.setMovable(true);
    tabBar.setExpanding(false);

    // top
    tabBar.setShape(QTabBar::RoundedNorth);
    // bottom
//    tabBar.setShape(QTabBar::RoundedSouth);
    // left
//    tabBar.setShape(QTabBar::RoundedWest);
    // right
//    tabBar.setShape(QTabBar::RoundedEast);

    const auto shortLabel = QStringLiteral("Tab %1");
    const auto longLabel = QStringLiteral("An Extremely Long Tab Label %1");

    QMap<int, QWidget*> tabs;
    for (int i = 0; i < TabCount; i++) {
        QString tabNumberString = QString::number(i);
        QLabel *label = new QLabel(QStringLiteral("Tab %1 content").arg(tabNumberString));
        tabs[i] = label;
        label->setAlignment(Qt::AlignCenter);
        stackedWidget.addWidget(label);
        tabBar.addTab(shortLabel.arg(tabNumberString));
    }

    QObject::connect(&tabBar, &QTabBar::tabMoved, [&tabs](int from, int to) {
        QWidget *thisWidget = tabs[from];
        QWidget *thatWidget = tabs[to];
        tabs[from] = thatWidget;
        tabs[to] = thisWidget;
    });

    QObject::connect(&tabBar, &QTabBar::currentChanged, [&stackedWidget, &tabs](int index) {
        if (index >= 0)
            stackedWidget.setCurrentWidget(tabs[index]);
    });

    QObject::connect(&tabBar, &QTabBar::tabCloseRequested, [&stackedWidget, &tabBar, &tabs](int index) {
        QWidget *widget = tabs[index];
        tabBar.removeTab(index);
        for (int i = index + 1; i < TabCount; i++)
            tabs[i-1] = tabs[i];
        int currentIndex = tabBar.currentIndex();
        if (currentIndex >= 0)
            stackedWidget.setCurrentWidget(tabs[currentIndex]);
        delete widget;
    });

    QLayout *layout;
    switch (tabBar.shape()) {
    case QTabBar::RoundedEast:
    case QTabBar::TriangularEast:
        tabBar.setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Expanding);
        layout = new QHBoxLayout(&widget);
        layout->addWidget(&stackedWidget);
        layout->addWidget(&tabBar);
        break;
    case QTabBar::RoundedWest:
    case QTabBar::TriangularWest:
        tabBar.setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Expanding);
        layout = new QHBoxLayout(&widget);
        layout->addWidget(&tabBar);
        layout->addWidget(&stackedWidget);
        break;
    case QTabBar::RoundedNorth:
    case QTabBar::TriangularNorth:
        tabBar.setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Minimum);
        layout = new QVBoxLayout(&widget);
        layout->addWidget(&tabBar);
        layout->addWidget(&stackedWidget);
        break;
    case QTabBar::RoundedSouth:
    case QTabBar::TriangularSouth:
        tabBar.setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Minimum);
        layout = new QVBoxLayout(&widget);
        layout->addWidget(&stackedWidget);
        layout->addWidget(&tabBar);
        break;
    }

    TabBarForm form;
    layout->addWidget(&form);
    layout->setAlignment(&form, Qt::AlignHCenter);

    form.ui->documentModeButton->setChecked(tabBar.documentMode());
    QObject::connect(form.ui->documentModeButton, &QCheckBox::toggled, [&] {
        tabBar.setDocumentMode(form.ui->documentModeButton->isChecked());
        // QMacStyle (and maybe other styles) requires a re-polish to get the right font
        QApplication::sendEvent(&tabBar, new QEvent(QEvent::ThemeChange));
    });

    form.ui->movableTabsButton->setChecked(tabBar.isMovable());
    QObject::connect(form.ui->movableTabsButton, &QCheckBox::toggled, [&] {
        tabBar.setMovable(form.ui->movableTabsButton->isChecked());
        tabBar.update();
    });

    form.ui->closableTabsButton->setChecked(tabBar.tabsClosable());
    QObject::connect(form.ui->closableTabsButton, &QCheckBox::toggled, [&] {
        tabBar.setTabsClosable(form.ui->closableTabsButton->isChecked());
        tabBar.update();
    });

    form.ui->expandingTabsButton->setChecked(tabBar.expanding());
    QObject::connect(form.ui->expandingTabsButton, &QCheckBox::toggled, [&] {
        tabBar.setExpanding(form.ui->expandingTabsButton->isChecked());
        tabBar.update();
    });

    form.ui->displayIconButton->setChecked(!tabBar.tabIcon(0).isNull());
    QObject::connect(form.ui->displayIconButton, &QCheckBox::toggled, [&] {
        const auto icon = form.ui->displayIconButton->isChecked() ?
                          tabBar.style()->standardIcon(QStyle::SP_ComputerIcon) : QIcon();
        for (int i = 0; i < tabBar.count(); i++)
            tabBar.setTabIcon(i, icon);
    });

    form.ui->longLabelButton->setChecked(false);
    QObject::connect(form.ui->longLabelButton, &QCheckBox::toggled, [&] {
        const auto &label = form.ui->longLabelButton->isChecked() ? longLabel : shortLabel;
        for (int i = 0; i < tabBar.count(); i++)
            tabBar.setTabText(i, label.arg(i));
    });

    QObject::connect(form.ui->shapeComboBox, QOverload<int>::of(&QComboBox::currentIndexChanged), [&](int index) {
        Q_UNUSED(index);
        // TODO
    });

    if (proxyStyle->alignment == Qt::AlignLeft)
        form.ui->leftAlignedButton->setChecked(true);
    else if (proxyStyle->alignment == Qt::AlignRight)
        form.ui->rightAlignedButton->setChecked(true);
    else
        form.ui->centeredButton->setChecked(true);
    QObject::connect(form.ui->textAlignmentGroup, QOverload<QAbstractButton *>::of(&QButtonGroup::buttonClicked), [&](QAbstractButton *b) {
        proxyStyle->alignment = b == form.ui->leftAlignedButton ? Qt::AlignLeft :
                                b == form.ui->rightAlignedButton ? Qt::AlignRight : Qt::AlignCenter;
        QApplication::sendEvent(&tabBar, new QEvent(QEvent::StyleChange));
    });

    layout->setMargin(12);
    widget.show();

    return app.exec();
}
void RackWindow::createPluginHost(int position)
{
    //layout settings widget:
    QWidget *settingsWidget = new QWidget;
    settingsWidget->setPalette(QPalette(QColor(0,0,0,160)));
    settingsWidget->setAutoFillBackground(true);

    RPushButton *leftButton = new RPushButton;
    leftButton->setObjectName("rackSettingsLeftArrowButton");
    RPushButton *rightButton = new RPushButton;
    rightButton->setObjectName("rackSettingsRightArrowButton");
    RPushButton *topButton = new RPushButton;
    topButton->setObjectName("rackSettingsTopArrowButton");
    RPushButton *bottomButton = new RPushButton;
    bottomButton->setObjectName("rackSettingsBottomArrowButton");
    RPushButton *closeButton = new RPushButton;
    closeButton->setObjectName("rackSettingsCloseButton");

    //vertical toolbar for plugin buttons:
    QToolBar *pluginHostToolBar = new QToolBar;
    pluginHostToolBar->setObjectName("rackPluginHostToolBar");
    pluginHostToolBar->setOrientation(Qt::Vertical);
    //actiongroup for exclusive handling of buttons:
    QActionGroup *ag = new QActionGroup(pluginHostToolBar);
    ag->setExclusive(true);

    RPushButton *addPluginWidgetButton = new RPushButton(tr("Add Widget ..."));
    addPluginWidgetButton->setObjectName("rackAddPluginWidgetButton");

    QWidget *middleWidget = new QWidget;
    QVBoxLayout *middleLayout = new QVBoxLayout(middleWidget);
    middleLayout->setSpacing(0);
    middleLayout->setContentsMargins(0,0,0,0);
    middleLayout->addWidget(pluginHostToolBar, 0, Qt::AlignHCenter);
    middleLayout->addWidget(addPluginWidgetButton, 0, Qt::AlignHCenter);

    QGridLayout *settingsLayout = new QGridLayout(settingsWidget);
    settingsLayout->setSpacing(0);
    settingsLayout->setContentsMargins(0,0,0,0);
    settingsLayout->addWidget(topButton,0,1, Qt::AlignTop | Qt::AlignHCenter);
    settingsLayout->addWidget(closeButton,0,2, Qt::AlignTop | Qt::AlignRight);
    settingsLayout->addWidget(leftButton,1,0, Qt::AlignLeft);
    settingsLayout->addWidget(rightButton,1,2, Qt::AlignRight);
    settingsLayout->addWidget(bottomButton,2,1, Qt::AlignBottom| Qt::AlignHCenter);
    settingsLayout->addWidget(middleWidget,1,1);

    QStackedWidget *pluginStack = new QStackedWidget;
    pluginStack->setObjectName("rackPluginStack");
    pluginStack->setAutoFillBackground(true);

    QWidget *pluginHost = new QWidget;
    pluginHost->setMinimumSize(200,80);

    QStackedLayout *overlayLayout = new QStackedLayout(pluginHost);
    overlayLayout->setStackingMode(QStackedLayout::StackAll);
    overlayLayout->addWidget(pluginStack);
    overlayLayout->addWidget(settingsWidget);
    overlayLayout->setCurrentIndex(1);

    //enter/leave settings signals:
    QSignalMapper *mapperShowSettingsMode = new QSignalMapper(pluginHost);
    QObject::connect(this, SIGNAL(enterSettingsMode()), mapperShowSettingsMode, SLOT(map()));
    mapperShowSettingsMode->setMapping(this, 1);
    QSignalMapper *mapperHideSettingsMode = new QSignalMapper(pluginHost);
    QObject::connect(this, SIGNAL(leaveSettingsMode()), mapperHideSettingsMode, SLOT(map()));
    mapperHideSettingsMode->setMapping(this, 0);
    QObject::connect(mapperShowSettingsMode, SIGNAL(mapped(int)), overlayLayout, SLOT(setCurrentIndex(int)));
    QObject::connect(mapperHideSettingsMode, SIGNAL(mapped(int)), overlayLayout, SLOT(setCurrentIndex(int)));

    //create plugin host widget signals:
    QSignalMapper *mapperCreatePluginHost = new QSignalMapper(pluginHost);
    QObject::connect(leftButton, SIGNAL(clicked()), mapperCreatePluginHost, SLOT(map()));
    QObject::connect(rightButton, SIGNAL(clicked()), mapperCreatePluginHost, SLOT(map()));
    QObject::connect(topButton, SIGNAL(clicked()), mapperCreatePluginHost, SLOT(map()));
    QObject::connect(bottomButton, SIGNAL(clicked()), mapperCreatePluginHost, SLOT(map()));
    mapperCreatePluginHost->setMapping(leftButton, NewSplitterLeft);
    mapperCreatePluginHost->setMapping(rightButton, NewSplitterRight);
    mapperCreatePluginHost->setMapping(topButton, NewSplitterTop);
    mapperCreatePluginHost->setMapping(bottomButton, NewSplitterBottom);
    QObject::connect(mapperCreatePluginHost, SIGNAL(mapped(int)), SLOT(createPluginHost(int)));

    //load plugin signal:
    QObject::connect(addPluginWidgetButton, SIGNAL(clicked()), m_mapperLoadNewPlugin, SLOT(map()));
    m_mapperLoadNewPlugin->setMapping(addPluginWidgetButton, pluginHost);

    //close plugin host signal:
    QObject::connect(closeButton, SIGNAL(clicked()), m_mapperClosePluginHost, SLOT(map()));
    m_mapperClosePluginHost->setMapping(closeButton, pluginHost);

    //create plugin switch signalmapper
    QSignalMapper *mapperSwitchPlugin = new QSignalMapper(pluginHost);
    mapperSwitchPlugin->setObjectName("rackPluginSwitchMapper");
    QObject::connect(mapperSwitchPlugin, SIGNAL(mapped(QWidget *)), pluginStack, SLOT(setCurrentWidget(QWidget *)));


    ////test show/hide plugin widget

    ////QObject::connect(mapperSwitchPlugin, SIGNAL(mapped(QWidget *)), this, SLOT(showHidePluginWidget(QWidget*)));


    //////


    //create plugin toolbar for mainwindow
    QToolBar *pluginToolBar = new QToolBar;
    pluginToolBar->setObjectName("rackPluginToolBar");
    pluginToolBar->setMovable(false);
    pluginToolBar->hide();
    addToolBar(Qt::BottomToolBarArea, pluginToolBar);

    //store the toolbar pointer as dynamic property to access later when creating plugin toolbar buttons
    pluginHost->setProperty("pluginToolBar", qVariantFromValue((QWidget *)pluginToolBar));

    //plugin bar signals & slots:
    QObject::connect(this, SIGNAL(enterSettingsMode()), pluginToolBar, SLOT(hide()));
    QObject::connect(this, SIGNAL(leaveSettingsMode()), pluginToolBar, SLOT(show()));







    //insert new pluginhost widget in splitter, create new splitter if necessary
    if (position == 0)
    {
        m_mainSplitter->addWidget(pluginHost);
        return;
    }
    QSignalMapper *sm = qobject_cast<QSignalMapper *>(sender());
    QWidget *senderPluginHost = qobject_cast<QWidget *>(sm->mapping(position)->parent()->parent());
    RSplitter *parentSplitter = qobject_cast<RSplitter *>(senderPluginHost->parent());
    QList<int> widgetsizes;
    int senderpos = parentSplitter->indexOf(senderPluginHost);
    int newposition;
    if ((position == NewSplitterLeft) or (position == NewSplitterTop)) newposition = senderpos;
    else newposition = senderpos + 1;
    switch (position + parentSplitter->orientation()) {             //horizontal=1 vertical=2
    case 0:                                                         //left   horizontal / top vertical
    case 2:                                                         //right  horizontal
    case 4:                                                         //bottom vertical
        widgetsizes = parentSplitter->sizes();
        widgetsizes.replace(senderpos, int(widgetsizes.at(senderpos)/2));
        widgetsizes.insert(senderpos + 1, widgetsizes.at(senderpos));
        parentSplitter->insertWidget(newposition, pluginHost);
        parentSplitter->setSizes(widgetsizes);
        break;
    case  1:                                                        //left  vertical
    case  3:                                                        //right vertical / bottom horizontal
    case -1:                                                        //top   horizontal
        if (parentSplitter->count() == 1)
        {
            parentSplitter->setOrientation(Qt::Orientation(abs(position)));
            widgetsizes = parentSplitter->sizes();
            widgetsizes.replace(0, int(widgetsizes.at(0)/2));
            widgetsizes.append(widgetsizes.at(0));
            parentSplitter->insertWidget(newposition, pluginHost);
            parentSplitter->setSizes(widgetsizes);
        }
        else if (parentSplitter->count() > 1)
        {
            RSplitter *newSplitter = new RSplitter(Qt::Orientation(abs(position)));
            QObject::connect(this, SIGNAL(enterSettingsMode()), newSplitter, SIGNAL(enterSettingsMode()));
            QObject::connect(this, SIGNAL(leaveSettingsMode()), newSplitter, SIGNAL(leaveSettingsMode()));
            widgetsizes = parentSplitter->sizes();
            parentSplitter->insertWidget(parentSplitter->indexOf(senderPluginHost), newSplitter);
            newSplitter->addWidget(senderPluginHost);
            QList<int> newsizes = newSplitter->sizes();
            newsizes.replace(0, int(newsizes.at(0)/2));
            newsizes.append(newsizes.at(0));
            if ((position == NewSplitterLeft) or (position == NewSplitterTop)) newSplitter->insertWidget(0, pluginHost);
            else newSplitter->addWidget(pluginHost);
            newSplitter->setSizes(newsizes);
            parentSplitter->setSizes(widgetsizes);
        }
        break;
    }
}
Пример #24
0
void interface::CreateWidgets(){
    QString name, type, title, wight, image, id, act;

    xmlItem childItem;
    xmlItem md          = xml.find(xml_root,md_metadata);
    xmlItem ifTabs      = xml.find(xml_root,md_tabs);
    xmlItem itActions   = xml.find(xml_root,md_actions);

    currentTab = 0;
    int idTab = 0;
    int idVal = 0;
    while (!ifTabs.isNull()){
        name = xml.attr(ifTabs,mda_name);
        type = xml.attr(ifTabs,mda_type);
        title = xml.attr(ifTabs,mda_title);

        QGridLayout *l = new QGridLayout(this);
        QTabWidget *root = new QTabWidget;

        l->addWidget(root);
        connect(root,SIGNAL(currentChanged(int)),this,SLOT(on_clicked_tab(int)));
        //—оздаем вкладки разделов
        childItem = xml.find(ifTabs,md_tab);

        while (!childItem.isNull()){
            name = xml.attr(childItem,mda_name);
            type = xml.attr(childItem,mda_type);
            title = xml.attr(childItem,mda_title);
            image = xml.attr(childItem,mda_image);
            QWidget *Tab = UIload.createWidget(type,root,name);
            Tab->setObjectName(name);
            QIcon ic(":/"+image);
            root->setIconSize(QSize(50,50));
            root->addTab(Tab,ic,title);

            QHBoxLayout *vb = new QHBoxLayout(Tab);

            QStackedWidget *stWidget = new QStackedWidget();
            listWindow.insert(idTab,stWidget);
            idTab++;
            //idVal = 0;

            // —оздаем левое меню
            xmlItem childrenItem = xml.find(childItem,md_left_menu,0);
            while (!childrenItem.isNull() && childrenItem.nodeName() == md_left_menu){
                name = xml.attr(childrenItem,mda_name);
                type = xml.attr(childrenItem,mda_type);
                title = xml.attr(childrenItem,mda_title);
                wight = xml.attr(childrenItem,mda_width);

                iisTaskPanel *tskPanel = new iisTaskPanel(Tab);
                if (!wight.isEmpty())
                    tskPanel->setMinimumWidth(wight.toInt());

                vb->addWidget(tskPanel,0);
                vb->setAlignment(tskPanel,Qt::AlignLeft);
                // √руппы меню
                tskPanel->layout()->setAlignment(Qt::AlignTop);
                xmlItem xmlGr = xml.find(childrenItem,md_group);
                while (!xmlGr.isNull()){
                    name = xml.attr(xmlGr,mda_name);
                    type = xml.attr(xmlGr,mda_type);
                    title = xml.attr(xmlGr,mda_title);


                    //QGroupBox *Gr = new QGroupBox(name,prev);
                    iisTaskBox *Gr = new iisTaskBox(title);
                    tskPanel->addWidget(Gr);
                    Gr->setObjectName(name);

                    //Ёлементы меню
                    xmlItem xmlValue = xml.find(xmlGr,md_value);
                    while (!xmlValue.isNull()){
                        name    = xml.attr(xmlValue,mda_name);
                        id      = xml.attr(xmlValue,mda_id);
                        title   = xml.attr(xmlValue,mda_title);
                        act     = xml.sText(xmlValue,md_comaction);

                        iisIconLabel *val = new iisIconLabel(title);
                        val->setObjectName(name);
                        connect(val,SIGNAL(clicked()),this,SLOT(on_clicked_item()));
                        Gr->addIconLabel(val);
                        list.insert(val,idVal);

                        xmlItem iact = xml.findId(itActions,"",act);
                        xmlItem iObj, iFrm;
                        if (!iact.isNull()){
                            QString idObj = xml.sText(iact,md_objectid);
                            xmlItem tmp =  xml.firstChild(md);
                            while (!tmp.isNull()){
                                iObj = xml.findId(tmp,"",idObj);
                                tmp = xml.nextSibling(tmp);
                                if (!iObj.isNull()) break;
                            }
                        }
                        if (!iObj.isNull()){
                            QString idFrm = xml.sText(iact,md_formid);
                            iObj = xml.find(iObj,md_forms);
                            iFrm = xml.findId(iObj,"",idFrm);
                            // —оздаем форму
                            QWidget *form =eng->OpenForm(iFrm);
                            if (form){
                                stWidget->insertWidget(idVal,form);
                                idVal++;
                            }
                        }

                        xmlValue = xml.nextSibling(xmlValue);
                    }

                    xmlGr = xml.nextSibling(xmlGr);
                }
                childrenItem = xml.nextSibling(childrenItem);
            }


            // ѕрава¤ панель
            childrenItem = xml.find(childItem,md_panel);
            while (!childrenItem.isNull()){
                name = xml.attr(childrenItem,mda_name);
                type = xml.attr(childrenItem,mda_type);
                title = xml.attr(childrenItem,mda_title);
                wight = xml.attr(childrenItem,mda_width);
                if (!wight.isEmpty())
                    stWidget->setMinimumWidth(wight.toInt());
                stWidget->setObjectName(name);
                stWidget->setFrameStyle(1);
                stWidget->setFrameShadow(QFrame::Raised);
                vb->addWidget(stWidget,2);

                childrenItem = xml.nextSibling(childrenItem);
            }
            childItem = xml.nextSibling(childItem);
        }
        ifTabs = xml.nextSibling(ifTabs);
    }

}
Пример #25
0
QWidget *ConfigDialog::centerWidget()
{
/*
	m_pagesTabWidget = new QTabWidget;
	for (int i = 0; i < m_pageWidgets.size(); ++i)
		m_pagesTabWidget->addTab(m_pageWidgets.at(i), m_pageTitles.at(i));
	return m_pagesTabWidget;
*/
	// create list
	QListWidget *pagesListWidget = new QListWidget;
	pagesListWidget->setViewMode(QListView::IconMode);
	pagesListWidget->setMovement(QListView::Static);
	pagesListWidget->setFlow(QListView::TopToBottom);
	pagesListWidget->setWordWrap(true);
	pagesListWidget->setUniformItemSizes(true);
	pagesListWidget->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Preferred);

	// add items to list
	QFontMetrics fm(qApp->font());
	int iconWidth = 0;
	for (int i = 0; i < m_pagesListWidgetItems.size(); ++i)
		iconWidth = qMax(iconWidth, fm.boundingRect(0, 0, 0, 0, Qt::AlignCenter, m_pagesListWidgetItems.at(i)->text()).width());
	iconWidth += 20;
	const int iconHeight = fm.height() + 42;
	for (int i = 0; i < m_pagesListWidgetItems.size(); ++i)
	{
		m_pagesListWidgetItems.at(i)->setSizeHint(QSize(iconWidth, iconHeight));
		pagesListWidget->addItem(m_pagesListWidgetItems.at(i));
	}
	pagesListWidget->setFixedWidth(m_pagesListWidgetItems.at(0)->sizeHint().width() + 6);

	// create title
	QFrame *titleFrame = new QFrame(this);
//	titleFrame->setAutoFillBackground(true);
//	titleFrame->setFrameShape(QFrame::StyledPanel);
	titleFrame->setFrameShape(QFrame::Box);
//	titleFrame->setFrameShadow(QFrame::Plain);
//	titleFrame->setBackgroundRole(QPalette::Base);
	m_pagesTitleLabel = new QLabel(titleFrame);
	m_pagesTitleLabel->setStyleSheet("QLabel { font-weight: bold; }");
	QGridLayout *titleLayout = new QGridLayout(titleFrame);
	titleLayout->setColumnStretch(0, 1);
	titleLayout->setMargin(6);
	titleLayout->addWidget(m_pagesTitleLabel);

	// add pages
	QStackedWidget *pagesStackedWidget = new QStackedWidget;
	for (int i = 0; i < m_pageWidgets.size(); ++i)
		pagesStackedWidget->addWidget(m_pageWidgets.at(i));
	connect(pagesListWidget, SIGNAL(currentRowChanged(int)), pagesStackedWidget, SLOT(setCurrentIndex(int)));
	connect(pagesListWidget, SIGNAL(currentRowChanged(int)), this, SLOT(setCurrentPage(int)));
	pagesListWidget->setCurrentRow(0);

	QWidget *mainWidget = new QWidget;
	QGridLayout *mainLayout = new QGridLayout;
	mainLayout->addWidget(pagesListWidget, 0, 0, 2, 1);
	mainLayout->addWidget(titleFrame, 0, 1);
	mainLayout->addWidget(pagesStackedWidget, 1, 1);
	mainWidget->setLayout(mainLayout);

	return mainWidget;
}
Пример #26
0
void
msg_list_window::add_msgs_page(const msgs_filter* f, bool if_results _UNUSED_)
{
  m_filter = new msgs_filter(*f);
  QFont body_font;
  QFont list_font;
  QByteArray headerview_setup;

  msgs_page* current = m_pages->current_page();
  // current may be null if we're instantiating the first page
  if (current) {
    body_font = m_msgview->font();
    list_font = m_qlist->font();
    if (m_qlist->sender_recipient_swapped())
      m_qlist->swap_sender_recipient(false);    
    headerview_setup = m_qlist->header()->saveState();
  }

  // new splitter
  QStackedWidget* stackw = m_pages->stacked_widget();
  QSplitter* l=new QSplitter(Qt::Vertical, this);
  stackw->addWidget(l);

  m_qlist = new mail_listview(l);
  m_qlist->set_threaded(display_vars.m_threaded);
  m_qlist->m_msg_window=this;
  if (current)
    m_qlist->setFont(list_font);
  m_qlist->init_columns();
  if (current)
    m_qlist->header()->restoreState(headerview_setup);

  if (!m_filter->m_fetched)
    m_filter->fetch(m_qlist);
  else
    m_filter->make_list(m_qlist);
  msg_list_postprocess();

  m_msgview = new message_view(l, this);

  if (current)
    m_msgview->setFont(body_font);

  connect(m_msgview, SIGNAL(on_demand_show_request()), this, SLOT(display_msg_contents()));
  connect(m_msgview, SIGNAL(popup_body_context_menu()), this, SLOT(body_menu()));
  connect(m_msgview, SIGNAL(page_back()), this, SLOT(move_backward()));
  connect(m_msgview, SIGNAL(page_forward()), this, SLOT(move_forward()));

  m_qAttch = new attch_listview(l);
  connect(m_qAttch, SIGNAL(itemDoubleClicked(QTreeWidgetItem*,int)),
	  this, SLOT(attch_selected(QTreeWidgetItem*,int)));
  connect(m_qAttch, SIGNAL(init_progress(const QString)),
	  this, SLOT(install_progressbar(const QString)));
  connect(m_qAttch, SIGNAL(progress(int)), this, SLOT(show_progress(int)));
  connect(m_qAttch, SIGNAL(finish_progress()), this, SLOT(uninstall_progressbar()));
  connect(this, SIGNAL(abort_progress()), m_qAttch, SLOT(download_aborted()));

  // splitter for 3 panes: list of messages / body / attachments list
  static const int splitter_default_sizes[3] = {100,400,25};
  QList<int> lsizes;
  if (current) {
    lsizes = current->m_page_splitter->sizes();
    // don't allow any zero size for panels. This is necessary to avoid having the
    // attachment list being almost invisible to the user
    for (int i=0; i<3; i++) {
      if (lsizes.at(i)==0) {
	lsizes.replace(i, splitter_default_sizes[i]);
      }
    }
  }
  else {
    for (int i=0; i<3; i++) {
      int sz;
      QString key;
      key.sprintf("display/msglist/panel%d_size", i+1);
      if (get_config().exists(key)) {
	sz=get_config().get_number(key);
	if (sz==0)
	  sz=splitter_default_sizes[i];
      }
      else
	sz=splitter_default_sizes[i];
      lsizes.append(sz);
    }
  }

  /* avoid changing the listview's height each time the attachments view
     is shown or hidden */
  l->setStretchFactor(l->indexOf(m_qlist), 0);
  l->setStretchFactor(l->indexOf(m_msgview), 1);
  l->setStretchFactor(l->indexOf(m_qAttch), 0);

  l->setSizes(lsizes);
  m_qAttch->hide();
  m_wSearch=NULL;

  connect(m_qlist,SIGNAL(selection_changed()), this,SLOT(mails_selected()));

  connect(m_qlist,SIGNAL(doubleClicked(const QModelIndex&)),
	  this,SLOT(mail_reply_all()));

  connect(m_qlist, SIGNAL(clicked(const QModelIndex&)),
	  this, SLOT(action_click_msg_list(const QModelIndex&)));

  connect(m_qlist, SIGNAL(scroll_page_down()), m_msgview, SLOT(page_down()));

  if (m_pages->next_page()) {
    // we're in the middle of a page list, and asked to go forward.
    // let's remove all the pages that are after the current position
    m_pages->cut_pages(m_pages->next_page());
  }
  int max_pages=get_config().get_number("msg_window_pages");
  if (max_pages<2) max_pages=2;
  if (m_pages->count() >= max_pages) {
    free_msgs_page();
    if (m_pages->count() >= max_pages) {
      // Still no room for a new page? OK, forget it
      DBG_PRINTF(5,"not enough pages!");
      return;
    }
  }

  // allocate and use a new page
  msgs_page* page = new msgs_page();
  page->m_page_filter = m_filter;
  page->m_page_msgview = m_msgview;
  page->m_page_attach = m_qAttch;
  page->m_page_qlist = m_qlist;
  page->m_page_current_item = NULL;
  page->m_page_splitter = l;
  page->m_msgs_window = this;
  page->m_query_lvitem_id = m_query_lv->current_id();
  m_pages->add_page(page);
  m_pages->raise_page(page);
  m_tags_box->reset_tags();
  enable_forward_backward();
}
QDockWidget *TikzCommandInserter::getDockWidget(QWidget *parent)
{
	QDockWidget *tikzDock = new QDockWidget(parent);
	tikzDock->setObjectName("CommandsDock");
	tikzDock->setAllowedAreas(Qt::AllDockWidgetAreas);
	tikzDock->setFeatures(QDockWidget::DockWidgetClosable | QDockWidget::DockWidgetMovable | QDockWidget::DockWidgetFloatable);
	tikzDock->setWindowTitle(m_tikzSections.title);
	tikzDock->setWhatsThis(tr("<p>This is a list of TikZ "
	                          "commands.  You can insert these commands in your code by "
	                          "clicking on them.  You can obtain more commands by "
	                          "changing the category in the combo box.</p>"));

	QAction *focusTikzDockAction = new QAction(parent);
	focusTikzDockAction->setShortcut(QKeySequence(tr("Alt+I")));
	tikzDock->addAction(focusTikzDockAction);
	connect(focusTikzDockAction, SIGNAL(triggered()), tikzDock, SLOT(setFocus()));

	QLabel *commandsComboLabel = new QLabel(tr("Category:"));
	ComboBox *commandsCombo = new ComboBox;
	commandsCombo->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred);
	QStackedWidget *commandsStack = new QStackedWidget;
	connect(commandsCombo, SIGNAL(currentIndexChanged(int)), commandsStack, SLOT(setCurrentIndex(int)));

	QListWidget *tikzListWidget = new QListWidget;
	addListWidgetItems(tikzListWidget, m_tikzSections, false); // don't add children
	tikzListWidget->setMouseTracking(true);
	connect(tikzListWidget, SIGNAL(currentItemChanged(QListWidgetItem*,QListWidgetItem*)), this, SLOT(setListStatusTip(QListWidgetItem*)));
	connect(tikzListWidget, SIGNAL(itemEntered(QListWidgetItem*)), this, SLOT(setListStatusTip(QListWidgetItem*)));
	connect(tikzListWidget, SIGNAL(itemActivated(QListWidgetItem*)), this, SLOT(insertTag(QListWidgetItem*)));
//	connect(tikzListWidget, SIGNAL(itemClicked(QListWidgetItem*)), this, SLOT(insertTag(QListWidgetItem*)));
	commandsCombo->addItem(tr("General"));
	commandsStack->addWidget(tikzListWidget);

	for (int i = 0; i < m_tikzSections.children.size(); ++i)
	{
		QListWidget *tikzListWidget = new QListWidget;
		addListWidgetItems(tikzListWidget, m_tikzSections.children.at(i));
		tikzListWidget->setMouseTracking(true);
		connect(tikzListWidget, SIGNAL(currentItemChanged(QListWidgetItem*,QListWidgetItem*)), this, SLOT(setListStatusTip(QListWidgetItem*)));
		connect(tikzListWidget, SIGNAL(itemEntered(QListWidgetItem*)), this, SLOT(setListStatusTip(QListWidgetItem*)));
		connect(tikzListWidget, SIGNAL(itemActivated(QListWidgetItem*)), this, SLOT(insertTag(QListWidgetItem*)));
//		connect(tikzListWidget, SIGNAL(itemClicked(QListWidgetItem*)), this, SLOT(insertTag(QListWidgetItem*)));

		QString comboItemText = m_tikzSections.children.at(i).title;
		commandsCombo->addItem(comboItemText.remove('&'));
		commandsStack->addWidget(tikzListWidget);
	}

	QGridLayout *tikzLayout = new QGridLayout;
	tikzLayout->addWidget(commandsComboLabel, 0, 0);
	tikzLayout->addWidget(commandsCombo, 0, 1);
	tikzLayout->addWidget(commandsStack, 1, 0, 1, 2);
	tikzLayout->setMargin(5);

	TikzCommandWidget *tikzWidget = new TikzCommandWidget;
	tikzWidget->setLayout(tikzLayout);
	tikzDock->setWidget(tikzWidget);
	tikzDock->setFocusProxy(commandsCombo);

	return tikzDock;
}
//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();

        }
    }
}
Пример #29
0
void QStackedWidgetProto::removeWidget(QWidget *widget)
{
  QStackedWidget *item = qscriptvalue_cast<QStackedWidget*>(thisObject());
  if (item)
    item->removeWidget(widget);
}
Пример #30
0
MainWindow::MainWindow(QWidget *parent, QFlag flags)
:   QMainWindow(parent, flags)
{
    // Set window title
    setWindowTitle("3D Computergrafik I - SS2015 - Aufgabenblatt 1");

    // Create main container
    QWidget *container = new QWidget();
    setCentralWidget(container);

    // Add list (on the left)
    QListWidget *list = new QListWidget(container);
    list->addItem("Beispiel");
    list->addItem("Aufgabe 1");
    list->addItem("Aufgabe 2");
    list->addItem("Aufgabe 3");
    list->addItem("Aufgabe 4a");
    list->addItem("Aufgabe 4b");
    list->setMaximumWidth(150);

    // Add stack of exercise windows (on the right)
    QStackedWidget *stack = new QStackedWidget(container);

    // Add exercises
    Exercise123 *orig = new Exercise123(Exercise123::ORIGINAL);

    QList<ImageView*> e1Views;
    e1Views.append(new Exercise123(Exercise123::GRAYSCALE));
    e1Views.append(new Exercise123(Exercise123::INVERT));

    QList<ImageView*> e2Views;
    e2Views.append(new Exercise123(Exercise123::LAPLACE));
    e2Views.append(new Exercise123(Exercise123::GAUSS));
    e2Views.append(new Exercise123(Exercise123::SOBEL));
    e2Views.append(new Exercise123(Exercise123::MEANFILTER));

    Exercise123 *e3 = new Exercise123(Exercise123::DITHERED);

    Exercise4a *e4a = new Exercise4a();
    Exercise4b *e4b = new Exercise4b();


    QWidget *e1Window = createMultiViewWidget(e1Views,orig);
    QWidget *e2Window = createMultiViewWidget(e2Views,orig);

    stack->addWidget(orig);
    stack->addWidget(e1Window);
    stack->addWidget(e2Window);
    stack->addWidget(e3);
    stack->addWidget(e4a);
    stack->addWidget(e4b);

    // Create layout
    QHBoxLayout *layout = new QHBoxLayout;
    layout->addWidget(list);
    layout->addWidget(stack);
    container->setLayout(layout);

    // Connect selection-event of list to select the current visible window
    connect(list, SIGNAL(currentRowChanged(int)), stack, SLOT(setCurrentIndex(int)));
}