Example #1
0
void MainWindowPlugin::onOptionsChanged(const OptionsNode &ANode)
{
	QWidget * widget = FMainWindowBorder ? (QWidget*)FMainWindowBorder : (QWidget*)FMainWindow;
	if (ANode.path() == OPV_MAINWINDOW_STAYONTOP)
	{
		bool show = widget->isVisible();
		if (ANode.value().toBool())
			widget->setWindowFlags(widget->windowFlags() | Qt::WindowStaysOnTopHint);
		else
			widget->setWindowFlags(widget->windowFlags() & ~Qt::WindowStaysOnTopHint);
		if (show)
			showMainWindow();
	}
#ifdef Q_OS_WIN
	else if (ANode.path() == OPV_MAINWINDOW_MINIMIZETOTRAY_W7)
	{
		if (QSysInfo::windowsVersion() == QSysInfo::WV_WINDOWS7)
		{
			bool minimize = ANode.value().toBool();
			FMainWindowBorder->setMinimizeOnClose(!minimize);
			FMainWindowBorder->setShowInTaskBar(!minimize);
			if (minimize)
				disconnect(FMainWindowBorder ? (QObject*)FMainWindowBorder : (QObject*)FMainWindow, SIGNAL(closed()), this, SLOT(onMainWindowClosed()));
			else
				connect(FMainWindowBorder ? (QObject*)FMainWindowBorder : (QObject*)FMainWindow, SIGNAL(closed()), SLOT(onMainWindowClosed()));
		}
		else
			FMainWindowBorder->setShowInTaskBar(false);
	}
#endif
}
void MainWindowPlugin::onOptionsChanged(const OptionsNode &ANode)
{
	if (ANode.path() == OPV_MAINWINDOW_STAYONTOP)
	{
#ifdef Q_WS_MAC
		setWindowOntop(FMainWindow, ANode.value().toBool());
#else
		QWidget *widget = mainWindowTopWidget();
		bool show = widget->isVisible();
		if (ANode.value().toBool())
			widget->setWindowFlags(widget->windowFlags() | Qt::WindowStaysOnTopHint);
		else
			widget->setWindowFlags(widget->windowFlags() & ~Qt::WindowStaysOnTopHint);
		if (show)
			showMainWindow();
#endif
	}
	else if (ANode.path() == OPV_MAINWINDOW_MINIMIZETOTRAY_W7)
	{
		if (isMinimizeToTray())
		{
			Options::node(OPV_MAINWINDOW_MINIMIZENOTIFY_SHOWCOUNT).setValue(MINIMIZENOTIFY_MAX_SHOWCOUNT+1);
		}
		if (FMainWindowBorder)
		{
			FMainWindowBorder->setMinimizeOnClose(!isMinimizeToTray());
		}
		if (!isMinimizeToTray() && !mainWindowTopWidget()->isVisible())
		{
			hideMainWindow();
		}
	}
}
Example #3
0
void WaitForWindowTest::testWaitEndedWithDefaultConstructor() {
    WaitForWindow waitForWindow;
    waitForWindow.setWindowObjectName("theName");
    waitForWindow.setActive(true);

    //WaitFor* must be registered in order to be used with QSignalSpy
    int waitForStarType = qRegisterMetaType<WaitFor*>("WaitFor*");
    QSignalSpy waitEndedSpy(&waitForWindow, SIGNAL(waitEnded(WaitFor*)));

    QWidget* otherWindow = new QWidget(mMainWindow);
    otherWindow->setObjectName("otherName");
    otherWindow->setWindowFlags(Qt::Window);
    otherWindow->show();

    otherWindow->deleteLater();

    QVERIFY(!waitForWindow.conditionMet());
    QCOMPARE(waitEndedSpy.count(), 0);

    QWidget* window = new QWidget(mMainWindow);
    window->setObjectName("theName");
    window->setWindowFlags(Qt::Window);
    window->show();

    window->deleteLater();

    QVERIFY(waitForWindow.conditionMet());
    QCOMPARE(waitEndedSpy.count(), 1);
    QVariant argument = waitEndedSpy.at(0).at(0);
    QCOMPARE(argument.userType(), waitForStarType);
    QCOMPARE(qvariant_cast<WaitFor*>(argument), &waitForWindow);
}
void SAChasyAppSettingsDialog::apply()
{
    mSettingsForm->applySettings();

    bool pravSutKur, dStrelka, ignoreDST, simpleView, showDate;
    int updateInterval, side;
    QColor backgroundColor;
    QColor shadowColor = mShadowColorButton->color();

    mSettingsForm->getSettings(pravSutKur, dStrelka, ignoreDST, simpleView,
                               showDate, updateInterval, backgroundColor, side);

    QSettings s;
    s.beginGroup("/SAKalendar/SAChasyApp");
    s.setValue("PravSutKrug", pravSutKur);
    s.setValue("ShowDoly", dStrelka);
    s.setValue("IgnoreDST", ignoreDST);
    s.setValue("SimpleView", simpleView);
    s.setValue("ShowDate", showDate);
    s.setValue("UpdateInterval", updateInterval);
    s.setValue("BackgroundColor", backgroundColor);
    s.setValue("SideSize", side);
    s.setValue("StayOnTop", mWindowStaysOnTopCheckBox->isChecked());
    s.setValue("ShadowColor", shadowColor);
    s.endGroup();

    QWidget *parentW = parentWidget();
    parentW->resize(side, side);
    parentW->setWindowFlags(mWindowStaysOnTopCheckBox->isChecked() ?
                            parentW->windowFlags() | Qt::WindowStaysOnTopHint
                                : parentW->windowFlags() ^ Qt::WindowStaysOnTopHint);
    parentW->show();

    mDropShadowEffect->setColor(shadowColor);
}
Example #5
0
File: offset.cpp Project: Qmax/PT6
void offset::openNumKBPanel(short int pValue,double incRatio,char type,double max,double min,QWidget* parent) {

        QWidget *w = INumberPanel->getNumKBPanelIncDec(pValue,incRatio,type,max,min,parent);
        w->setStyleSheet("");
        w->setWindowFlags(Qt::WindowCloseButtonHint | Qt::Dialog);
        w->show();
}
Example #6
0
void DDSWidget::openNumKBPanelminmax(short int pValue, double pMax, double pMin) {
	QWidget *w = INumberPanel->getNumKBPanelIncDec(pValue, 1, 'T', pMax, pMin,
			this);
	w->setWindowFlags(Qt::WindowCloseButtonHint | Qt::Dialog);
	w->show();

}
Example #7
0
File: offset.cpp Project: Qmax/PT6
void offset::openNumKBPanel(short int pValue) {

        QWidget *w = INumberPanel->getNumKBPanel(pValue, this);
        w->setStyleSheet("border:1px solid rgba(0,0,0,255); color:black;");
        w->setWindowFlags(Qt::WindowCloseButtonHint | Qt::Dialog);
        w->show();
}
Example #8
0
void MainWindow::callSlot(QString text)
{
	ui.scrollArea->setWidget(new QWidget());
	QWidget* camera = CameraFactory::CreateCamera();	

	if(text == QStringLiteral("全屏显示"))
	{
		CameraFactory::SetLBScreen(QStringLiteral("屏幕恢复"));

		camera->setParent(this);
		camera->setWindowFlags(Qt::Window);
		camera->showFullScreen();
		camera->setFocus();
	}	
	else
	{
		CameraFactory::SetLBScreen(QStringLiteral("全屏显示"));
		ui.scrollArea->setWidget(camera);
		camera->setFocus();
		//camera->setParent(ui.scrollArea);
		//camera->show();
		//camera->setFocus();
	}

	connect(camera, SIGNAL(backSignal()), this, SLOT(reportSlot()));
	connect(camera, SIGNAL(imageSignal(QString)), this, SLOT(loadNewImage(QString)));
	connect(camera, SIGNAL(fullScreenSignal(QString)), this, SLOT(fullScreenSlot(QString)));
}
Example #9
0
void DDSWidget::callDDSVoltageEdit()
{
	double m_nVoltRangeArray[5]={0.6,1.5,3.5,7.0,13.0};
	QWidget *w = INumberPanel->getNumKBPanelIncDec(1, 1, 'V', m_nVoltRangeArray[ui->cmbVoltRanges->currentIndex()], 0,this);
	w->setWindowFlags(Qt::WindowCloseButtonHint | Qt::Dialog);
	w->show();
	m_nLineEditIndex = 11;
}
Example #10
0
void DDSWidget::callDDSCycle(){
    if (m_objLE_DDSCycle->hasFocus()) {
    	QWidget *w = INumberPanel->getNumKBPanelIncDec(2, 1, 'A', 255, 1,this);
    	w->setWindowFlags(Qt::WindowCloseButtonHint | Qt::Dialog);
    	w->show();
         m_nLineEditIndex = 10;
    }
}
Example #11
0
void DDSWidget::callOPPhaseEdit() {
	if (m_objLE_OPPhase->hasFocus()) {
		QWidget *w = INumberPanel->getNumKBPanelIncDec(1, 1, 'D', 360, 0, this);
		w->setWindowFlags(Qt::WindowCloseButtonHint | Qt::Dialog);
		w->show();
		m_nLineEditIndex = 9;
	}
}
Example #12
0
void DACFWidget::callOffsetValue()
{
        double m_nVoltRangeArray[5]={0.6,1.5,3.5,7.0,13.0};
        QWidget *w = INumberPanel->getNumKBPanelIncDec(1, 1, 'v', m_nVoltRangeArray[ui->cmgRanges->currentIndex()],m_nVoltRangeArray[ui->cmgRanges->currentIndex()]*-1,this);
        w->setWindowFlags(Qt::WindowCloseButtonHint | Qt::Dialog);
        w->show();
        m_nLineEditIndex = 1;
}
Example #13
0
void DDSWidget::callOPFrequencyEdit() {
	if (m_objLE_OPFreq->hasFocus()) {
		//          openNumKBPanel(2);
		QWidget *w = INumberPanel->getNumKBPanelIncDec(1, 1, 'F', 10000000, 0,
				this);
		w->setWindowFlags(Qt::WindowCloseButtonHint | Qt::Dialog);
		w->show();
		m_nLineEditIndex = 4;
	}

}
Example #14
0
 void HeightMapEditor::onShowSrcButtonClicked()
 {
   Json::Value graphJson = myUi->graphBuilder->toJson();
   QWidget * window = new QWidget(this);
   QVBoxLayout * layout = new QVBoxLayout(window);
   QTextEdit * edit = new QTextEdit(window);
   layout->addWidget(edit);
   window->setLayout(layout);
   window->setWindowFlags(Qt::WindowFlags(Qt::WindowType::Dialog));
   window->setAttribute(Qt::WA_DeleteOnClose);
   edit->setText(graphJson.toStyledString().c_str());
   window->show();
 }
Example #15
0
int main( int argc, char **argv )
{
	QApplication a( argc, argv );

	QWidget window;
	//设置窗口没有标题栏
	//window.setFrameStyle(QFrame::NoFrame)
	window.setWindowFlags(Qt::FramelessWindowHint);

	window.resize(320, 240);
	window.show();

	return a.exec();
}
Example #16
0
void WaitForWindowTest::testWaitEndedNotActive() {
    WaitForWindow waitForWindow("theName");

    qRegisterMetaType<WaitFor*>("WaitFor*");
    QSignalSpy waitEndedSpy(&waitForWindow, SIGNAL(waitEnded(WaitFor*)));

    QWidget* window = new QWidget(mMainWindow);
    window->setObjectName("theName");
    window->setWindowFlags(Qt::Window);
    window->show();

    window->deleteLater();

    QVERIFY(!waitForWindow.conditionMet());
    QCOMPARE(waitEndedSpy.count(), 0);
}
Example #17
0
/**
 * Forward the QKeyEvent to the QsciScintilla base class. 
 * Under Gnome on Linux with Qscintilla versions < 2.4.2 there is a bug with the autocomplete
 * box that means the editor loses focus as soon as it the box appears. This functions
 * forwards the call and sets the correct flags on the resulting window so that this does not occur
 */
void ScriptEditor::forwardKeyPressToBase(QKeyEvent *event)
{
  // Hack to get around a bug in QScitilla
  //If you pressed ( after typing in a autocomplete command the calltip does not appear, you have to delete the ( and type it again
  //This does that for you!
  if (event->text()=="(")
  {
    QKeyEvent * backspEvent = new QKeyEvent(QEvent::KeyPress, Qt::Key_Backspace, Qt::NoModifier);
    QKeyEvent * bracketEvent = new QKeyEvent(*event);
    QsciScintilla::keyPressEvent(bracketEvent);
    QsciScintilla::keyPressEvent(backspEvent);

    delete backspEvent;
    delete bracketEvent;
  }


  QsciScintilla::keyPressEvent(event);
  
  // Only need to do this for Unix and for QScintilla version < 2.4.2. Moreover, only Gnome but I don't think we can detect that
#ifdef Q_OS_LINUX
#if QSCINTILLA_VERSION < 0x020402
  // If an autocomplete box has surfaced, correct the window flags. Unfortunately the only way to 
  // do this is to search through the child objects.
  if( isListActive() )
  {
    QObjectList children = this->children();
    QListIterator<QObject*> itr(children);
    // Search is performed in reverse order as we want the last one created
    itr.toBack();
    while( itr.hasPrevious() )
    {
      QObject *child = itr.previous();
      if( child->inherits("QListWidget") )
      {
        QWidget *w = qobject_cast<QWidget*>(child);
        w->setWindowFlags(Qt::ToolTip|Qt::WindowStaysOnTopHint);
        w->show();
        break;
      }
    }
  }  
#endif
#endif

}
Example #18
0
  virtual QObjectProxy *newInstance( PyrObject *po, QList<QVariant> & arguments ){

    if( arguments.count() < 5 ) return 0;

    bool scroll = arguments[4].value<bool>();

    QWidget *window;
    QWidget *canvas;
    if( scroll ) {
      QcScrollArea *scroll = new QcScrollArea();
      window = scroll;
      canvas = scroll->widget();
    }
    else {
      window = canvas = new QcCustomPainted();
    }

    QString name = arguments[0].toString();
    window->setWindowTitle( name );

    QRect geom = arguments[1].value<QRect>();
    bool resizable = arguments[2].value<bool>();
    if( resizable ) {
      window->setGeometry( geom );
    } else {
      window->move( geom.topLeft() );
      window->setFixedSize( geom.size() );
    }

    bool border = arguments[3].value<bool>();
    if( !border )
      window->setWindowFlags( window->windowFlags() | Qt::FramelessWindowHint );

    QShortcut *closeShortcut =
      new QShortcut( QKeySequence( Qt::CTRL | Qt::Key_W ), window );
    QObject::connect( closeShortcut, SIGNAL(activated()),
                      window, SLOT(close()) );

    QWidgetProxy *proxy = new QWidgetProxy( window, po );

    QObject::connect( canvas, SIGNAL(painting(QPainter*)),
                      proxy, SLOT(customPaint(QPainter*)) );

    return proxy;
  }
Example #19
0
void VstPlugin::showEditor( QWidget * _parent, bool isEffect )
{
	QWidget * w = pluginWidget();
	if( w )
	{
#ifdef LMMS_BUILD_WIN32
		// hide sw, plugin window wrapper on win32
		// this is obtained from pluginWidget()
		if( isEffect )
		{
			w->setWindowFlags( Qt::FramelessWindowHint );
			w->setAttribute( Qt::WA_TranslucentBackground );
		}
		else
		{
			w->setWindowFlags( Qt::WindowCloseButtonHint );
		}
#endif
		w->show();
		return;
	}

#ifdef LMMS_BUILD_LINUX
	if( m_pluginWindowID == 0 )
	{
		return;
	}

	m_pluginWidget = new QWidget( _parent );
	m_pluginWidget->setFixedSize( m_pluginGeometry );
	m_pluginWidget->setWindowTitle( name() );
	if( _parent == NULL )
	{
		vstSubWin * sw = new vstSubWin(
					gui->mainWindow()->workspace() );
		if( isEffect )
		{
			sw->setAttribute( Qt::WA_TranslucentBackground );
			sw->setWindowFlags( Qt::FramelessWindowHint );
			sw->setWidget( m_pluginWidget );
#if QT_VERSION < 0x050000
			QX11EmbedContainer * xe = new QX11EmbedContainer( sw );
			xe->embedClient( m_pluginWindowID );
			xe->setFixedSize( m_pluginGeometry );
			xe->show();
#endif
		} 
		else
		{
			sw->setWindowFlags( Qt::WindowCloseButtonHint );
			sw->setWidget( m_pluginWidget );

#if QT_VERSION < 0x050000
			QX11EmbedContainer * xe = new QX11EmbedContainer( sw );
			xe->embedClient( m_pluginWindowID );
			xe->setFixedSize( m_pluginGeometry );
			xe->move( 4, 24 );
			xe->show();
#endif
		}
	}

#endif

	if( m_pluginWidget )
	{
		m_pluginWidget->show();
	}
}
Example #20
0
void HY3131Calibration::openNumKBPanel(short int pValue) {

    QWidget *w = INumberPanel->getNumKBPanel(pValue, this);
    w->setWindowFlags(Qt::WindowCloseButtonHint | Qt::Dialog);
    w->show();
}
Example #21
0
bool EventFilter::eventFilter(QObject *watched, QEvent *event)
{
    //qDebug("EventFilter::eventFilter to %p", watched);
    Q_UNUSED(watched);
    /*if (watched == reinterpret_cast<QObject*>(player->renderer)) {
        qDebug("Event target is renderer: %s", watched->objectName().toAscii().constData());
    }*/
    //TODO: if not send to QWidget based class, return false; instanceOf()?
    QEvent::Type type = event->type();
    switch (type) {
    case QEvent::MouseButtonPress:
        qDebug("EventFilter: Mouse press");
        static_cast<QMouseEvent*>(event)->button();
        //TODO: wheel to control volume etc.
        return false;
        break;
    case QEvent::KeyPress: {
        //qDebug("Event target = %p %p", watched, player->renderer);
        //avoid receive an event multiple times
        int key = static_cast<QKeyEvent*>(event)->key();
        switch (key) {
        case Qt::Key_C: //capture
            player->captureVideo();
            break;
        case Qt::Key_N: //check playing?
            player->playNextFrame();
            break;
        case Qt::Key_P:
            player->play();
            break;
        case Qt::Key_S:
            player->stop(); //check playing?
            break;
        case Qt::Key_Space: //check playing?
            qDebug("isPaused = %d", player->isPaused());
            player->pause(!player->isPaused());
            break;
        case Qt::Key_F: { //TODO: move to gui
            QWidget *w = qApp->activeWindow();
            if (!w)
                return false;
            if (w->isFullScreen())
                w->showNormal();
            else
                w->showFullScreen();
        }
            break;
        case Qt::Key_Up:
            if (player->audio) {
                qreal v = player->audio->volume();
                if (v > 0.5)
                    v += 0.1;
                else if (v > 0.1)
                    v += 0.05;
                else
                    v += 0.025;
                player->audio->setVolume(v);
                qDebug("vol = %.3f", player->audio->volume());
            }
            break;
        case Qt::Key_Down:
            if (player->audio) {
                qreal v = player->audio->volume();
                if (v > 0.5)
                    v -= 0.1;
                else if (v > 0.1)
                    v -= 0.05;
                else
                    v -= 0.025;
                player->audio->setVolume(v);
                qDebug("vol = %.3f", player->audio->volume());
            }
            break;
        case Qt::Key_O: {
            //TODO: emit a signal so we can use custome dialogs
            QString file = QFileDialog::getOpenFileName(0, tr("Open a video"));
            if (!file.isEmpty())
                player->play(file);
        }
            break;
        case Qt::Key_Left:
            qDebug("<-");
            player->seekBackward();
            break;
        case Qt::Key_Right:
            qDebug("->");
            player->seekForward();
            break;
        case Qt::Key_M:
            if (player->audio) {
                player->audio->setMute(!player->audio->isMute());
            }
            break;
        case Qt::Key_T: {
            QWidget *w = qApp->activeWindow();
            if (!w)
                return false;
            Qt::WindowFlags wf = w->windowFlags();
            if (wf & Qt::WindowStaysOnTopHint) {
                qDebug("Window not stays on top");
                w->setWindowFlags(wf & ~Qt::WindowStaysOnTopHint);
            } else {
                qDebug("Window stays on top");
                w->setWindowFlags(wf | Qt::WindowStaysOnTopHint);
            }
            //call setParent() when changing the flags, causing the widget to be hidden
            w->show();
        }
            break;
        default:
            return false;
        }
        break;
    }
    default:
        return false;
    }
    return true; //false: for text input
}
Example #22
0
void NWidgetPrototype::setWindowFlags(int flags)
{
	QWidget *widget = qscriptvalue_cast<QWidget *>(thisObject());
	if (widget)
		widget->setWindowFlags((Qt::WindowFlags)flags);
}
int Dialog::showDialog(const QString& view, QObject* viewModel, int type)
{
    QDialog* dialog = NULL;
    QMainWindow* mainWindow = NULL;
    QWidget* windowWidget = NULL;
    QWidget* layoutWidget = NULL;

    switch (type)
    {
    case Dialog::MainWindow:
        mainWindow = new QMainWindow();
        windowWidget = mainWindow;
        layoutWidget = new QWidget(windowWidget);
        mainWindow->setCentralWidget(layoutWidget);
        break;

    case Dialog::ModalDialog:
        dialog = new QDialog(QApplication::activeWindow());
        windowWidget = dialog;
        layoutWidget = dialog;
        break;

    default:
        dialog = new QDialog();
        windowWidget = dialog;
        layoutWidget = dialog;
        break;
    }

    QGridLayout* layout = new QGridLayout(layoutWidget);

    // Create view

    QDeclarativeView* v = new QDeclarativeView(layoutWidget);

    if (viewModel)
    {
        int count = viewModel->metaObject()->propertyCount();
        for (int i = 0; i < count; ++i)
        {
            QMetaProperty p = viewModel->metaObject()->property(i);
            if (p.isReadable() && p.typeName() == QString("QDeclarativeImageProvider*"))
            {
                QString name = p.name();
                QDeclarativeImageProvider* value = p.read(viewModel).value<QDeclarativeImageProvider*>();

                v->engine()->addImageProvider(name.toLatin1(), new ProxyImageProvider(value));
            }
        }

        v->rootContext()->setContextProperty("dataContext", viewModel);
    }

    QString path;
    foreach (path, importPaths)
        v->engine()->addImportPath(path);
    foreach (path, pluginPaths)
        v->engine()->addPluginPath(path);

    v->setSource(QUrl(view));
    v->setResizeMode(QDeclarativeView::SizeRootObjectToView);

    // Initialize dialog

    QGraphicsObject* root = v->rootObject();

    QVariant property = root->property("dialogTitle");
    if (property.isValid())
        windowWidget->setWindowTitle(property.toString());

    property = root->property("dialogMinWidth");
    if (property.isValid())
        layoutWidget->setMinimumWidth(property.toInt());

    property = root->property("dialogMinHeight");
    if (property.isValid())
        layoutWidget->setMinimumHeight(property.toInt());

    property = root->property("dialogMaxWidth");
    if (property.isValid())
        layoutWidget->setMaximumWidth(property.toInt());

    property = root->property("dialogMaxHeight");
    if (property.isValid())
        layoutWidget->setMaximumHeight(property.toInt());

    property = root->property("dialogResizable");
    if (property.isValid() && !property.toBool())
        layout->setSizeConstraint(QLayout::SetFixedSize);

    Qt::WindowStates states = windowWidget->windowState();
    Qt::WindowFlags flags = windowWidget->windowFlags();

    property = root->property("dialogMinimizeButton");
    if (property.isValid())
        flags = property.toBool() ? flags | Qt::WindowMinimizeButtonHint : flags & ~Qt::WindowMinimizeButtonHint;

    property = root->property("dialogMaximizeButton");
    if (property.isValid())
        flags = property.toBool() ? flags | Qt::WindowMaximizeButtonHint : flags & ~Qt::WindowMaximizeButtonHint;

    property = root->property("dialogCloseButton");
    if (property.isValid())
        flags = property.toBool() ? flags | Qt::WindowCloseButtonHint : flags & ~Qt::WindowCloseButtonHint;

    property = root->property("dialogFullScreen");
    if (property.isValid())
        states = property.toBool() ? states | Qt::WindowFullScreen : states & ~Qt::WindowFullScreen;

    flags = flags & ~Qt::WindowContextHelpButtonHint;

    windowWidget->setWindowFlags(flags);
    windowWidget->setWindowState(states);

    property = root->property("dialogToolBar");
    if (type == Dialog::MainWindow && property.isValid() && property.typeName() == QString("QDeclarativeListProperty<QDeclarativeItem>"))
    {
        QToolBar* toolbar = new QToolBar(mainWindow);
        toolbar->setMovable(false);
        toolbar->setFloatable(false);
        toolbar->setToolButtonStyle(Qt::ToolButtonTextUnderIcon);
        toolbar->setAllowedAreas(Qt::TopToolBarArea);

        QDeclarativeListProperty<QDeclarativeItem> btnList = property.value< QDeclarativeListProperty<QDeclarativeItem> >();
        int btnCount = btnList.count(&btnList);

        for (int i = 0; i < btnCount; ++i)
        {
            QDeclarativeItem* item = btnList.at(&btnList, i);

            if (!item->property("text").isValid())
                continue;

            QString itemText = item->property("text").toString();
            QString itemTooltip = item->property("tooltip").isValid() ? item->property("tooltip").toString() : "";
            QString itemIconSource = item->property("iconSource").isValid() ? item->property("iconSource").toString() : "";
            int itemIconSize = item->property("iconSize").isValid() ? item->property("iconSize").toInt() : -1;

            if (itemText == "|")
            {
                toolbar->addSeparator();
            }
            else if (itemText == "-")
            {
                QWidget* spacer = new QWidget();
                spacer->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Minimum);
                toolbar->addWidget(spacer);
            }
            else
            {
                QAction* action = new QAction(mainWindow);
                action->setText(itemText);
                action->setToolTip(itemTooltip);
                action->setIcon(QIcon(itemIconSource));
                QObject::connect(action, SIGNAL(triggered()), item, SLOT(trigger()));

                if (item->property("enabled").isValid())
                    new PropertyBinding(action, "enabled", item, "enabled", PropertyBinding::OneWay, NULL, this);

                if (item->property("visible").isValid())
                    new PropertyBinding(action, "visible", item, "visible", PropertyBinding::OneWay, NULL, this);

                toolbar->addAction(action);
            }

            if (itemIconSize != -1)
                toolbar->setIconSize(QSize(itemIconSize, itemIconSize));
        }

        mainWindow->setUnifiedTitleAndToolBarOnMac(true);
        mainWindow->addToolBar(toolbar);
    }

    property = root->property("dialogMenu");
    if (type == Dialog::MainWindow && property.isValid() && property.typeName() == QString("QDeclarativeListProperty<QDeclarativeItem>"))
    {
        QDeclarativeListProperty<QDeclarativeItem> list = property.value< QDeclarativeListProperty<QDeclarativeItem> >();
        int count = list.count(&list);

        for (int i = 0; i < count; ++i)
        {
            QDeclarativeItem* item = list.at(&list, i);

            if (!item->property("text").isValid())
                continue;

            QString itemText = item->property("text").toString();
            QMenu * menuItem = mainWindow->menuBar()->addMenu(itemText);

            if (!item->property("submenu").isValid() || item->property("submenu").typeName() != QString("QDeclarativeListProperty<QDeclarativeItem>"))
                continue;

            QDeclarativeListProperty<QDeclarativeItem> innerList = item->property("submenu").value< QDeclarativeListProperty<QDeclarativeItem> >();
            int innerCount = innerList.count(&innerList);

            for (int j = 0; j < innerCount; ++j)
            {
                QDeclarativeItem* innerItem = innerList.at(&innerList, j);

                if (!innerItem->property("text").isValid())
                    continue;

                QString innerItemText = innerItem->property("text").toString();
                QString innerItemShortcut = innerItem->property("shortcut").isValid() ? innerItem->property("shortcut").toString() : "";
                QString innerItemIconSource = innerItem->property("iconSource").isValid() ? innerItem->property("iconSource").toString() : "";

                if (innerItemText == "-")
                {
                    menuItem->addSeparator();
                }
                else
                {
                    QAction * action = menuItem->addAction(QIcon(innerItemIconSource), innerItemText);
                    action->setShortcut(QKeySequence(innerItemShortcut));

                    QObject::connect(action, SIGNAL(triggered()), innerItem, SLOT(trigger()));

                    if (innerItem->property("enabled").isValid())
                        new PropertyBinding(action, "enabled", innerItem, "enabled", PropertyBinding::OneWay, NULL, this);

                    if (innerItem->property("visible").isValid())
                        new PropertyBinding(action, "visible", innerItem, "visible", PropertyBinding::OneWay, NULL, this);
                }
            }
        }
    }

    new DialogCallbacks(windowWidget, v, root);

    // Initialize layout

    layout->setMargin(0);
    layout->addWidget(v, 0, 0);

    // Execute

    switch (type)
    {
    case Dialog::ModalDialog:
        dialog->exec();
        break;

    case Dialog::MainWindow:
    {
        if (mainWindowGeometry.isEmpty())
        {
            mainWindow->adjustSize();
            mainWindow->move(QApplication::desktop()->screen()->rect().center() - mainWindow->rect().center());
        }
        else
            mainWindow->restoreGeometry(mainWindowGeometry);
    }

    default:
        windowWidget->setAttribute(Qt::WA_DeleteOnClose);
        windowWidget->show();
        break;
    }

    int result = 0;

    property = root->property("dialogResult");
    if (property.isValid())
        result = property.toInt();

    if (type == Dialog::ModalDialog)
        delete dialog;

    return result;
}
bool VideoOutputEventFilter::eventFilter(QObject *watched, QEvent *event)
{
    // a widget shown means it's available and not deleted
    if (event->type() == QEvent::Show || event->type() == QEvent::ShowToParent) {
        mRendererIsQObj = !!mpRenderer->widget();
        return false;
    }
    if (!mRendererIsQObj)
        return false;
    /*
     * deleted renderer (after destroyed()) can not access it's member, so we must mark it as invalid.
     * hide event is sent when close. what about QEvent::Close?
     */
    if (event->type() == QEvent::Close || event->type() == QEvent::Hide) {
        mRendererIsQObj = false;
        return true;
    }
    if (!mpRenderer)
        return false;
    if (!mpRenderer->isDefaultEventFilterEnabled())
        return false;
    if (watched != mpRenderer->widget()
            /* && watched != mpRenderer->graphicsWidget()*/ //no showFullScreen() etc.
            )
        return false;
    switch (event->type()) {
    case QEvent::KeyPress: {
        QKeyEvent *key_event = static_cast<QKeyEvent*>(event);
        int key = key_event->key();
        //Qt::KeyboardModifiers modifiers = key_event->modifiers();
        switch (key) {
        case Qt::Key_F:
            switchFullScreen();
            break;
        case Qt::Key_I:
            mpRenderer->setQuality(VideoRenderer::Quality(((int)mpRenderer->quality()+1)%3));
            break;
        case Qt::Key_T: {
            QWidget *w = mpRenderer->widget()->window();
            Qt::WindowFlags wf = w->windowFlags();
            if (wf & Qt::WindowStaysOnTopHint) {
                qDebug("Window not stays on top");
                w->setWindowFlags(wf & ~Qt::WindowStaysOnTopHint);
            } else {
                qDebug("Window stays on top");
                w->setWindowFlags(wf | Qt::WindowStaysOnTopHint);
            }
            //call setParent() when changing the flags, causing the widget to be hidden
            w->show();
        }
            break;
        }
    }
        break;
    case QEvent::MouseButtonDblClick:
        switchFullScreen();
        break;
    case QEvent::MouseButtonPress: {
        QMouseEvent *me = static_cast<QMouseEvent*>(event);
        Qt::MouseButton mbt = me->button();
        if (mbt == Qt::LeftButton) {
            gMousePos = me->globalPos();
            iMousePos = me->pos();
        }
    }
        break;
    case QEvent::MouseButtonRelease: {
        QMouseEvent *me = static_cast<QMouseEvent*>(event);
        Qt::MouseButton mbt = me->button();
        if (mbt != Qt::LeftButton)
            return false;
        iMousePos = QPoint();
        gMousePos = QPoint();
    }
        break;
    case QEvent::MouseMove: {
        if (iMousePos.isNull() || gMousePos.isNull())
            return false;
        QMouseEvent *me = static_cast<QMouseEvent*>(event);
        QWidget *window = mpRenderer->widget()->window();
        int x = window->pos().x();
        int y = window->pos().y();
        int dx = me->globalPos().x() - gMousePos.x();
        int dy = me->globalPos().y() - gMousePos.y();
        gMousePos = me->globalPos();
        window->move(x + dx, y + dy);
    }
        break;
    default:
        break;
    }
    return false;
}
Example #25
0
void ControllerWindow::updatePreview()
{
    Qt::WindowFlags flags = 0;

    if (windowRadioButton->isChecked()) {
        flags = Qt::Window;
    } else if (dialogRadioButton->isChecked()) {
        flags = Qt::Dialog;
    } else if (sheetRadioButton->isChecked()) {
        flags = Qt::Sheet;
    } else if (drawerRadioButton->isChecked()) {
        flags = Qt::Drawer;
    } else if (popupRadioButton->isChecked()) {
        flags = Qt::Popup;
    } else if (toolRadioButton->isChecked()) {
        flags = Qt::Tool;
    } else if (toolTipRadioButton->isChecked()) {
        flags = Qt::ToolTip;
    } else if (splashScreenRadioButton->isChecked()) {
        flags = Qt::SplashScreen;
    }

    if (msWindowsFixedSizeDialogCheckBox->isChecked())
        flags |= Qt::MSWindowsFixedSizeDialogHint;
    if (x11BypassWindowManagerCheckBox->isChecked())
        flags |= Qt::X11BypassWindowManagerHint;
    if (framelessWindowCheckBox->isChecked())
        flags |= Qt::FramelessWindowHint;
    if (windowTitleCheckBox->isChecked())
        flags |= Qt::WindowTitleHint;
    if (windowSystemMenuCheckBox->isChecked())
        flags |= Qt::WindowSystemMenuHint;
    if (windowMinimizeButtonCheckBox->isChecked())
        flags |= Qt::WindowMinimizeButtonHint;
    if (windowMaximizeButtonCheckBox->isChecked())
        flags |= Qt::WindowMaximizeButtonHint;
    if (windowCloseButtonCheckBox->isChecked())
        flags |= Qt::WindowCloseButtonHint;
    if (windowContextHelpButtonCheckBox->isChecked())
        flags |= Qt::WindowContextHelpButtonHint;
    if (windowShadeButtonCheckBox->isChecked())
        flags |= Qt::WindowShadeButtonHint;
    if (windowStaysOnTopCheckBox->isChecked())
        flags |= Qt::WindowStaysOnTopHint;
    if (windowStaysOnBottomCheckBox->isChecked())
        flags |= Qt::WindowStaysOnBottomHint;
    if (customizeWindowHintCheckBox->isChecked())
        flags |= Qt::CustomizeWindowHint;

    previewWindow->hide();
    previewDialog->hide();
    QWidget *widget = 0;
    if (previewWidgetButton->isChecked())
        widget = previewWindow;
    else
        widget = previewDialog;

    if (modalWindowCheckBox->isChecked()) {
        parentWindow->show();
        widget->setWindowModality(Qt::WindowModal);
        widget->setParent(parentWindow);
    } else {
        widget->setWindowModality(Qt::NonModal);
        widget->setParent(0);
        parentWindow->hide();
    }

    widget->setWindowFlags(flags);

    if (fixedSizeWindowCheckBox->isChecked()) {
        widget->setFixedSize(300, 300);
    } else {
        widget->setFixedSize(QWIDGETSIZE_MAX, QWIDGETSIZE_MAX);
    }

    QPoint pos = widget->pos();
    if (pos.x() < 0)
        pos.setX(0);
    if (pos.y() < 0)
        pos.setY(0);
    widget->move(pos);
    widget->show();
}
Example #26
0
bool EventFilter::eventFilter(QObject *watched, QEvent *event)
{
    Q_UNUSED(watched);
    AVPlayer *player = static_cast<AVPlayer*>(parent());
    if (!player || !player->renderer() || !player->renderer()->widget())
        return false;
    if (qobject_cast<QWidget*>(watched) != player->renderer()->widget()) {
        return false;
    }
#ifndef QT_NO_DYNAMIC_CAST //dynamic_cast is defined as a macro to force a compile error
    if (player->renderer() != dynamic_cast<VideoRenderer*>(watched)) {
       // return false;
    }
#endif
    QEvent::Type type = event->type();
    switch (type) {
    case QEvent::KeyPress: {
        QKeyEvent *key_event = static_cast<QKeyEvent*>(event);
        int key = key_event->key();
        Qt::KeyboardModifiers modifiers = key_event->modifiers();
        switch (key) {
        case Qt::Key_C: //capture
            player->captureVideo();
            break;
        case Qt::Key_N: //check playing?
            player->playNextFrame();
            break;
        case Qt::Key_P:
            player->play();
            break;
        case Qt::Key_Q:
        case Qt::Key_Escape:
            qApp->quit();
            break;
        case Qt::Key_S:
            player->stop(); //check playing?
            break;
        case Qt::Key_Space: //check playing?
            qDebug("isPaused = %d", player->isPaused());
            player->pause(!player->isPaused());
            break;
        case Qt::Key_F: { //TODO: move to gui
            QWidget *w = qApp->activeWindow();
            if (!w)
                return false;
            if (w->isFullScreen())
                w->showNormal();
            else
                w->showFullScreen();
        }
            break;
        case Qt::Key_Up: {
            AudioOutput *ao = player->audio();
            if (modifiers == Qt::ControlModifier) {
                qreal s = player->speed();
                if (s < 1.4)
                    s += 0.02;
                else
                    s += 0.05;
                if (qAbs<qreal>(s-1.0) <= 0.01)
                    s = 1.0;
                player->setSpeed(s);
                return true;
            }
            if (ao && ao->isAvailable()) {
                qreal v = player->audio()->volume();
                if (v > 0.5)
                    v += 0.1;
                else if (v > 0.1)
                    v += 0.05;
                else
                    v += 0.025;
                player->audio()->setVolume(v);
                qDebug("vol = %.3f", player->audio()->volume());
            }
        }
            break;
        case Qt::Key_Down: {
            AudioOutput *ao = player->audio();
            if (modifiers == Qt::ControlModifier) {
                qreal s = player->speed();
                if (s < 1.4)
                    s -= 0.02;
                else
                    s -= 0.05;
                if (qAbs<qreal>(s-1.0) <= 0.01)
                    s = 1.0;
                s = qMax<qreal>(s, 0.0);
                player->setSpeed(s);
                return true;
            }
            if (ao && ao->isAvailable()) {
                qreal v = player->audio()->volume();
                if (v > 0.5)
                    v -= 0.1;
                else if (v > 0.1)
                    v -= 0.05;
                else
                    v -= 0.025;
                player->audio()->setVolume(v);
                qDebug("vol = %.3f", player->audio()->volume());
            }
        }
            break;
        case Qt::Key_O: {
            if (modifiers == Qt::ControlModifier) {
                //TODO: emit a signal so we can use custome dialogs?
                openLocalFile();
            } else/* if (m == Qt::NoModifier) */{
                emit showNextOSD();
            }
        }
            break;
        case Qt::Key_Left:
            qDebug("<-");
            player->seekBackward();
            break;
        case Qt::Key_Right:
            qDebug("->");
            player->seekForward();
            break;
        case Qt::Key_M:
            if (player->audio()) {
                player->audio()->setMute(!player->audio()->isMute());
            }
            break;
        case Qt::Key_R: {
            VideoRenderer* renderer = player->renderer();
            VideoRenderer::OutAspectRatioMode r = renderer->outAspectRatioMode();
            renderer->setOutAspectRatioMode(VideoRenderer::OutAspectRatioMode(((int)r+1)%2));
        }
            break;
        case Qt::Key_T: {
            QWidget *w = qApp->activeWindow();
            if (!w)
                return false;
            Qt::WindowFlags wf = w->windowFlags();
            if (wf & Qt::WindowStaysOnTopHint) {
                qDebug("Window not stays on top");
                w->setWindowFlags(wf & ~Qt::WindowStaysOnTopHint);
            } else {
                qDebug("Window stays on top");
                w->setWindowFlags(wf | Qt::WindowStaysOnTopHint);
            }
            //call setParent() when changing the flags, causing the widget to be hidden
            w->show();
        }
            break;
        case Qt::Key_F1:
            help();
            break;
        default:
            return false;
        }
        break;
    }
    case QEvent::DragEnter:
    case QEvent::DragMove: {
        QDropEvent *e = static_cast<QDropEvent*>(event);
        e->acceptProposedAction();
    }
        break;
    case QEvent::Drop: {
        QDropEvent *e = static_cast<QDropEvent*>(event);
        QString path = e->mimeData()->urls().first().toLocalFile();
        player->stop();
        player->load(path);
        player->play();
        e->acceptProposedAction();
    }
        break;
    case QEvent::GraphicsSceneContextMenu: {
        QGraphicsSceneContextMenuEvent *e = static_cast<QGraphicsSceneContextMenuEvent*>(event);
        showMenu(e->screenPos());
    }
        break;
    case QEvent::ContextMenu: {
        QContextMenuEvent *e = static_cast<QContextMenuEvent*>(event);
        showMenu(e->globalPos());
    }
        break;
    default:
        return false;
    }
    return true; //false: for text input
}
Example #27
0
bool GCodeObject::loadFile(const QString &fileName)
{
   GCodeParser parser;

   if (!parser.loadFile(fileName))
   {
      mError = "File not found.";
      return false;
   }

   QWidget* progressWindow = new QWidget();
   progressWindow->setWindowFlags(Qt::CustomizeWindowHint);
   QVBoxLayout* progressLayout = new QVBoxLayout();
   QProgressDialog* progressDialog = new QProgressDialog("Importing...", "Cancel", 0, 100);
   progressDialog->setWindowModality(Qt::WindowModal);
   progressLayout->addWidget(progressDialog);
   progressWindow->setLayout(progressLayout);
   progressWindow->setFixedSize(progressWindow->sizeHint());
   progressWindow->show();

   bool queueFinalizeTempBuffer = false;
   std::vector<GCodeCommand> tempLayerBuffer;
   std::vector<GCodeCommand> layer;
   GCodeCommand code;

   double dValue = 0.0;
   long lValue = 0;
   double coordConversion = 1.0;
   bool findingFirstLayer = true;
   bool firstBounds = true;
   int averageCount = 0;

   bool absoluteMode = mPrefs.exportAbsoluteMode;
   bool absoluteEMode = mPrefs.exportAbsoluteEMode;
   double currentPos[AXIS_NUM] = {0.0,};
   double offsetPos[AXIS_NUM] = {0.0,};
   double homeOffset[AXIS_NUM_NO_E] = {0.0,};

   double layerZ = currentPos[Z];
   double lastZ = currentPos[Z];
   double lastE = currentPos[E];
   double mostE = currentPos[E];

   // Parse the gcode file, at the same time any codes we care about will have
   // special treatment while any codes we don't care about will simply be preserved
   // and included in the final product as is.
   while (parser.parseNext())
   {
      progressDialog->setValue(int(parser.getProgress() * 100.0));
      progressDialog->show();

      if (progressDialog->wasCanceled())
      {
         if (progressWindow)
         {
            progressWindow->hide();
            delete progressWindow;
         }

         mError = "Import was cancelled.";
         return false;
      }

      code.clear();
      code.command = parser.getLine();
      code.comment = parser.getComment();

      bool changeLayers = false;

      if (parser.codeSeen('G'))
      {
         lValue = 1000 + parser.codeValueLong();

         code.type = lValue;

         // Codes we care about:
         // 0 or 1: Extruder movement.
         if (lValue == GCODE_EXTRUDER_MOVEMENT0 || lValue == GCODE_EXTRUDER_MOVEMENT1)
         {
            code.hasAxis = true;

            for (int axis = 0; axis < AXIS_NUM; ++axis)
            {
               if (parser.codeSeen(AXIS_NAME[axis]))
               {
                  if (axis == E? absoluteEMode: absoluteMode)
                  {
                     currentPos[axis] = (parser.codeValue() * coordConversion) + offsetPos[axis];
                  }
                  else
                  {
                     currentPos[axis] += (parser.codeValue() * coordConversion);
                  }
               }
               code.axisValue[axis] = currentPos[axis];
            }
            code.axisValue[E] = code.axisValue[E] - lastE;
            lastE = currentPos[E];

            if (parser.codeSeen('F'))
            {
               code.f = parser.codeValue();
               code.hasF = true;
            }

            // Our first extruder move command should
            // not be part of our header data.
            if (mData.empty())
            {
               // Move our temp code to our current layer code
               // and iterate to our next layer.
               finalizeTempBuffer(tempLayerBuffer, layer);
               changeLayers = true;
            }
            // If we are extruding some material,
            // determine if the layer has changed.
            else if (mostE < currentPos[E])
            {
               mostE = currentPos[E];

               if (layerZ < currentPos[Z])
               {
                  double height = currentPos[Z] - layerZ;
                  mAverageLayerHeight += height;
                  averageCount++;

                  layerZ = currentPos[Z];
                  lastZ = layerZ;

                  // Because we don't start the extruder's first layer at
                  // position 0, we need to assume that our first height
                  // above 0 is all part of the first layer, so don't start
                  // a new one just yet.
                  if (findingFirstLayer)
                  {
                     findingFirstLayer = false;
                  }
                  else
                  {
                     changeLayers = true;
                  }
               }

               // Update the bounding volume.
               if (!firstBounds)
               {
                  for (int axis = 0; axis < AXIS_NUM_NO_E; ++axis)
                  {
                     if (mMinBounds[axis] > currentPos[axis])
                     {
                        mMinBounds[axis] = currentPos[axis];
                     }
                     if (mMaxBounds[axis] < currentPos[axis])
                     {
                        mMaxBounds[axis] = currentPos[axis];
                     }
                  }
               }
               else
               {
                  for (int axis = 0; axis < AXIS_NUM_NO_E; ++axis)
                  {
                     mMinBounds[axis] = currentPos[axis];
                     mMaxBounds[axis] = currentPos[axis];
                  }
                  firstBounds = false;
               }
            }
            // Extruder has increased height.
            else if (layerZ < currentPos[Z])
            {
               if (lastZ < currentPos[Z])
               {
                  lastZ = currentPos[Z];
                  finalizeTempBuffer(tempLayerBuffer, layer);
               }
            }
            else
            {
               queueFinalizeTempBuffer = true;
            }
         }

         // 4: Dwell
         if (lValue == GCODE_DWELL)
         {
            if (parser.codeSeen('S'))
            {
               code.s = parser.codeValue();
               code.hasS = true;
            }
            if (parser.codeSeen('P'))
            {
               code.p = parser.codeValue();
               code.hasP = true;
            }
         }

         // 28: Home axes.
         if (lValue == GCODE_HOME)
         {
            code.hasAxis = true;

            // The extruder position does not change from this command.
            code.axisValue[E] = 0.0;

            bool foundAny = false;
            for (int axis = 0; axis < AXIS_NUM_NO_E; ++axis)
            {
               if (parser.codeSeen(AXIS_NAME[axis]))
               {
                  foundAny = true;

                  currentPos[axis] = 0.0;
                  offsetPos[axis] = 0.0;

                  // Not sure if this is correct, as it is contrary to Marlin's
                  // documentation, but according to the source code, this is what
                  // happens when a value is specified along with the axis to home.
                  dValue = parser.codeValue();
                  if (dValue != 0.0)
                  {
                     offsetPos[axis] = dValue + homeOffset[axis];
                  }
               }

               code.axisValue[axis] = currentPos[axis];
            }

            // If the code was used without specifying any
            // particular axis, reset all axes instead.
            if (!foundAny)
            {
               for (int axis = 0; axis < AXIS_NUM_NO_E; ++axis)
               {
                  code.axisValue[axis] = 0.0;
                  currentPos[axis] = 0.0;
                  offsetPos[axis] = 0.0;
               }
            }
         }

         // 90: Absolute coordinate system.
         if (lValue == GCODE_ABSOLUTE_COORDS)
         {
            absoluteMode = true;

            // Everything is converted to absolute coordinates, so any
            // gcode that changes the coordinate system will not be
            // propagated to the final result.
            continue;
         }

         // 91: Relative coordinate system.
         if (lValue == GCODE_RELATIVE_COORDS)
         {
            absoluteMode = false;

            // Everything is converted to absolute coordinates, so any
            // gcode that changes the coordinate system will not be
            // propagated to the final result.
            continue;
         }

         // 92: Set current position to coordinates given.
         if (lValue == GCODE_CURRENT_POSITION)
         {
            for (int axis = 0; axis < AXIS_NUM; ++axis)
            {
               offsetPos[axis] = 0.0;

               if (parser.codeSeen(AXIS_NAME[axis]))
               {
                  // The offset is always the difference between our actual
                  // current position and the position our gcode is
                  // specifying as the current, since we don't care what
                  // the gcode thinks is the current position, we only
                  // care about our current actual position in a global
                  // sense.  Our offset is used to convert any subsequent
                  // position given to an actual global position.
                  offsetPos[axis] = currentPos[axis] - (parser.codeValue() * coordConversion);
               }
            }

            // This command is not propagated to our final result as everything
            // is converted to global absolute coordinates.
            continue;
         }

         // Codes we care about, but are not supported by Marlin:
         // 20: Set units to inches.
         if (lValue == GCODE_INCHES_MODE)
         {
            // If we find this code, it means we need to convert any subsequent
            // gcode coordinate from inches back to millimeters since all of
            // our internal coordinates are in mm.
            coordConversion = INCHES_TO_MM;
            continue;
         }

         // 21: Set units to millimeters.
         if (lValue == GCODE_MILLIMETERS_MODE)
         {
            // If we find this code, we can undo our conversion from inches
            // to millimeters if necessary.
            coordConversion = 1.0;
            continue;
         }
      }
      else if (parser.codeSeen('M'))
      {
         lValue = 2000 + parser.codeValueLong();

         code.type = lValue;

         // Codes we care about:
         // 104 & 109: Set Extruder temp.
         if (lValue == MCODE_SET_EXTRUDER_TEMP ||
             lValue == MCODE_SET_EXTRUDER_TEMP_WAIT)
         {
            // Temperature changes are handled by the splicer.
            continue;
         }

         // Marlin custom codes:
         // 82: Set E codes absolute
         if (lValue == MCODE_E_ABSOLUTE_COORDS)
         {
            absoluteEMode = true;
            continue;
         }

         // 83: Set E codes relative while in Absolute Coordinates (G90) mode
         if (lValue == MCODE_E_RELATIVE_COORDS)
         {
            absoluteEMode = false;
            continue;
         }

         // 206: Set additional homing offset.
         if (lValue == MCODE_SET_HOMING_OFFSET)
         {
            for (int axis = 0; axis < AXIS_NUM_NO_E; ++axis)
            {
               if (parser.codeSeen(AXIS_NAME[axis]))
               {
                  homeOffset[axis] = parser.codeValue();
               }
            }
         }

         // 221: Set extruder speed factor.
         if (lValue == MCODE_SET_EXTRUDE_FACTOR)
         {
            if (parser.codeSeen('S'))
            {
               // factor in percentage.
               // It's possible that I may have to account for this
               // when calculating my own custom retraction values.
            }
         }

         // Codes we care about, but are not supported by Marlin:
         // 0: Stop
         if (lValue == MCODE_EMERGENCY_STOP)
         {
            // Not sure if this code will actually appear in any gcode file,
            // but just in case we don't want it to be included in our
            // final splice.
            continue;
         }
      }
      else if (parser.codeSeen('T'))
      {
         // A T0 code is valid as it does not change extruders...
         if (parser.codeValueLong() != 0)
         {
            if (progressWindow)
            {
               progressWindow->hide();
               delete progressWindow;
            }

            // We should not find any extruder change commands as we are assuming
            // all the gcode in any given file are for a single extruder.
            // We are unequipped to deal with this case so we must fail the load.
            mError = "Import does not support gcode files that already contain extruder changes.";
            return false;
         }
      }
      // If we get here then we found no valid code type,
      // if we also don't have a comment then it is a blank line
      // and can be discarded.
      else if (code.comment.isEmpty())
      {
         continue;
      }

      // If we have changed layers, put the current layer's data into the
      // layer stack and begin a new one.
      if (changeLayers)
      {
         changeLayers = false;

         if (!layer.empty())
         {
            addLayer(layer);
            layer.clear();
         }
      }

      // Add the current code value to the current layer.
      tempLayerBuffer.push_back(code);

      if (queueFinalizeTempBuffer)
      {
         queueFinalizeTempBuffer = false;
         finalizeTempBuffer(tempLayerBuffer, layer);
      }
   }

   // Finalize any remaining temp codes.
   finalizeTempBuffer(tempLayerBuffer, layer, false);

   // Add our final layer.
   if (!layer.empty())
   {
      addLayer(layer);
   }

   // Calculate our bounding center.
   for (int axis = 0; axis < AXIS_NUM_NO_E; ++axis)
   {
      mCenter[axis] = mMinBounds[axis] + ((mMaxBounds[axis] - mMinBounds[axis]) / 2.0);
   }

   // Offset the object so it is in the center of the build platform.
   mOffsetPos[X] = (mPrefs.platformWidth / 2.0) - mCenter[X];
   mOffsetPos[Y] = (mPrefs.platformHeight / 2.0) - mCenter[Y];
   mOffsetPos[Z] = 0.0;

   if (averageCount > 1)
   {
      mAverageLayerHeight /= averageCount;
   }

   if (progressWindow)
   {
      progressWindow->hide();
      delete progressWindow;
   }

   // We need to 'heal' our layers to remove any extruder
   // retractions and primes that may have been separated
   // between multiple layers.  Since they have been
   // separated, we need to remove them entirely because
   // we can't guarantee that those two layers will be
   // spliced together consecutively again.
   return healLayerRetraction();
}