Example #1
0
Q_DECL_EXPORT
#endif
int main(int argc, char *argv[])
{
#ifdef MEEGO_EDITION
	QScopedPointer<QApplication> app(MDeclarativeCache::qApplication(argc, argv));
#else
	QScopedPointer<QApplication> app(new QApplication(argc, argv));
#endif
	QTextCodec::setCodecForTr(QTextCodec::codecForName("utf-8"));
	QTextCodec::setCodecForCStrings(QTextCodec::codecForName("utf-8"));

#ifdef Q_WS_MAEMO_5
	QWidget *loadingWindow = new QWidget();
	loadingWindow->setAttribute(Qt::WA_Maemo5AutoOrientation, true);
	loadingWindow->setAttribute(Qt::WA_Maemo5ShowProgressIndicator, Qt::Checked);
	loadingWindow->show();
	app->processEvents();
#endif

	Core::ModuleManagerImpl core;
	Q_UNUSED(core);

	// At first time use current time with pointers to initiators
	qsrand(uint(std::time(0)) ^ qHash(qApp));
	// At second random value
	qsrand(uint(qrand()));
	// It looks like Qt doesn't always use srand as backend of qsrand
	srand(uint(qrand()));

#ifdef Q_WS_MAEMO_5
	loadingWindow->close();
#endif
	return app->exec();
}
Example #2
0
void KDecoration::createMainWidget(Qt::WFlags flags)
{
    // FRAME check flags?
    QWidget *w = new QWidget(initialParentWidget(), initialWFlags() | flags);
    w->setObjectName(QLatin1String("decoration widget"));
    w->setAttribute(Qt::WA_PaintOnScreen);
    if (options()->showTooltips())
        w->setAttribute(Qt::WA_AlwaysShowToolTips);
    setMainWidget(w);
}
HeadbandWidget::HeadbandWidget(QWidget *parent):QWidget(parent)
{
    setPalette(QPalette(Qt::cyan));
    setAutoFillBackground(true);

    bL = new QHBoxLayout();

    QWidget* w = new QWidget(this);
    w->setAttribute(Qt::WA_TransparentForMouseEvents);
    w->setPalette(QPalette(Qt::red));
    w->setAutoFillBackground(true);
    w->setFixedWidth(500);

    QWidget* w1 = new QWidget(this);
    w1->setAttribute(Qt::WA_TransparentForMouseEvents);
    w1->setPalette(QPalette(Qt::green));
    w1->setAutoFillBackground(true);
    w1->setFixedWidth(300);

    //Ajout des widget au layout
    bL->addWidget(w);
    bL->addWidget(w1);

    this->setLayout(bL);
}
void ControllerViewsTools::createView(const string &name,Graph *,DataSet,QWidget *parent,string *createdViewName, View **createdView, QWidget **createdWidget) {
  string verifiedName=name;
  View *newView=ViewPluginsManager::getInst().createView(name);

  // if we can not create a view with given name : create a Node Link Diagram Component
  if(!newView) {
    verifiedName=mainViewName;
    newView=ViewPluginsManager::getInst().createView(mainViewName);
  }

  // Get interactors for this view and add them to view
  list<string> interactorsNameList;

  if(newView->getRealViewName()=="")
    interactorsNameList=InteractorManager::getInst().getSortedCompatibleInteractors(verifiedName);
  else
    interactorsNameList=InteractorManager::getInst().getSortedCompatibleInteractors(newView->getRealViewName());

  list<Interactor *> interactorsList;

  for(list<string>::iterator it=interactorsNameList.begin(); it!=interactorsNameList.end(); ++it) {
    interactorsList.push_back(InteractorManager::getInst().getInteractor(*it));
  }

  newView->setInteractors(interactorsList);

  QWidget *widget;
  widget=newView->construct(parent);
  widget->setObjectName(QString("ViewMainWidget p:")+QString::number((long)widget));
  widget->setAttribute(Qt::WA_DeleteOnClose,true);

  *createdViewName=verifiedName;
  *createdView=newView;
  *createdWidget=widget;
}
Example #5
0
void FixtureManager::create(QWidget* parent)
{
	QWidget* window;

	/* Must not create more than one instance */
	if (s_instance != NULL)
		return;

#ifdef __APPLE__
	/* Create a separate window for OSX */
	s_instance = new FixtureManager(parent, Qt::Window);
	window = s_instance;
#else
	/* Create an MDI window for X11 & Win32 */
	QMdiArea* area = qobject_cast<QMdiArea*> (_app->centralWidget());
	Q_ASSERT(area != NULL);
	s_instance = new FixtureManager(parent);
	window = area->addSubWindow(s_instance);
#endif

	/* Set some common properties for the window and show it */
	window->setAttribute(Qt::WA_DeleteOnClose);
	window->setWindowIcon(QIcon(":/fixture.png"));
	window->setWindowTitle(tr("Fixture Manager"));
	window->setContextMenuPolicy(Qt::CustomContextMenu);
        window->show();

	QSettings settings;
	QVariant w = settings.value("fixturemanager/width");
	QVariant h = settings.value("fixturemanager/height");
	if (w.isValid() == true && h.isValid() == true)
		window->resize(w.toInt(), h.toInt());
	else
		window->resize(600, 400);
}
Example #6
0
void QgsCompassPlugin::about()
{
  QString title = QString( "About Internal Compass" );
  // sort by date of contribution
  QString text = QString( "<center><b>Internal Compass</b></center>"
                          "<center>%1</center>"
                          "<p>Shows reading of an internal compass using QtSensors<br/>"
                          "<b>Developer:</b>"
                          "<ol type=disc>"
                          "<li>Marco Bernasocchi"
                          "</ol>"
                          "<p><b>Homepage:</b><br>"
                          "<a href=\"http://opengis.ch\">http://opengis.ch</a></p>"
                          "<p><b>Compass calibration:</b><br/>"
                          "To calibrate the compass slowly rotate the device three times around each axis or "
                          "rotate it like a on a Mobius strip.<br/>"
                          "This <a href='http://www.youtube.com/watch?v=oNJJPeoG8lQ'>Video</a> demonstrates the process "
                          "(this can be done from within QGIS as well).</p>"
                        ).arg( sPluginVersion );

  // create dynamicaly because on Mac this dialog is modeless
  QWidget *w = new QWidget;
  w->setAttribute( Qt::WA_DeleteOnClose );
  w->setWindowIcon( getThemeIcon( "/compass.png" ) );
  QMessageBox::about( w, title, text );
}
Example #7
0
TutorPage::TutorPage(QWidget *parent) :
    QWidget(parent),
    m_nTutorMode(-1),
    ui(new Ui::TutorPage)
{
    double dXfactor = (double)g_pResManModule->m_pProjectParm->m_nWidth / 800;//因为在UI文件中布局时候是假设面板大小为800*600;
    ui->setupUi(this);

    //设置视图模型
    TutorModel *pModel = new TutorModel(this);
    ui->tableView->setModel(pModel);
    ui->tableView->setColumnWidth(0,500*dXfactor);

    ui->tableView->horizontalHeader()->hide();
    ui->tableView->verticalHeader()->hide();
    ui->tableView->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOn);
    //ui->tableView->verticalScrollBar()->setStyleSheet("QScrollBar:vertical{background:transparent;width:30px; border: 2px solid transparent;}");
    //ui->tableView->horizontalScrollBar()->setStyleSheet("QScrollBar:horizantal{background:transparent;width:30px; border: 2px solid transparent;}");

    setAttribute(Qt::WA_TranslucentBackground);
    QObjectList childList = children();
    foreach (QObject *obj, childList) {
        QWidget *w = qobject_cast<QWidget *>(obj);
        if(w)
            w->setAttribute(Qt::WA_TranslucentBackground);
    }
Example #8
0
void MapView::setUseOpenGL(bool useOpenGL)
{
#ifndef QT_NO_OPENGL
    if (useOpenGL) {
        if (!qobject_cast<QOpenGLWidget*>(viewport())) {
            QSurfaceFormat format = QSurfaceFormat::defaultFormat();
            format.setDepthBufferSize(0);   // No need for a depth buffer
            format.setSamples(4);           // Enable anti-aliasing

            QOpenGLWidget *openGLWidget = new QOpenGLWidget(this);
            openGLWidget->setFormat(format);
            setViewport(openGLWidget);
        }
    } else {
        if (qobject_cast<QOpenGLWidget*>(viewport()))
            setViewport(nullptr);
    }

    QWidget *v = viewport();
    if (mMode == StaticContents)
        v->setAttribute(Qt::WA_StaticContents);
    v->setMouseTracking(true);
#else
    Q_UNUSED(useOpenGL)
#endif
}
Example #9
0
void Monitor::create(QWidget* parent)
{
	QWidget* window;

	/* Must not create more than one instance */
	if (s_instance != NULL)
		return;

#ifdef __APPLE__
	/* Create a separate window for OSX */
	s_instance = new Monitor(parent, Qt::Window);
	window = s_instance;
#else
	/* Create an MDI window for X11 & Win32 */
	QMdiArea* area = qobject_cast<QMdiArea*> (_app->centralWidget());
	Q_ASSERT(area != NULL);
	s_instance = new Monitor(parent);
	window = area->addSubWindow(s_instance);
#endif

	/* Set some common properties for the window and show it */
	window->setAttribute(Qt::WA_DeleteOnClose);
	window->setWindowIcon(QIcon(":/monitor.png"));
	window->setWindowTitle(tr("Fixture Monitor"));
	window->setContextMenuPolicy(Qt::CustomContextMenu);

	QSettings settings;
	QVariant var = settings.value(SETTINGS_GEOMETRY);
	if (var.isValid() == true)
		window->restoreGeometry(var.toByteArray());
	window->show();
}
void tst_QWidget_window::tst_qtbug35600()
{
    QWidget w;
    w.show();

    QWidget *wA = new QWidget;
    QHBoxLayout *layoutA = new QHBoxLayout;

    QWidget *wB = new QWidget;
    layoutA->addWidget(wB);

    QWidget *wC = new QWidget;
    layoutA->addWidget(wC);

    wA->setLayout(layoutA);

    QWidget *wD = new QWidget;
    wD->setAttribute(Qt::WA_NativeWindow);
    wD->setParent(wB);

    QWidget *wE = new QWidget(wC, Qt::Tool | Qt::FramelessWindowHint | Qt::WindowTransparentForInput);
    wE->show();

    wA->setParent(&w);

    // QTBUG-35600: program may crash here or on exit
}
Example #11
0
MapView::MapView(QWidget *parent)
    : QGraphicsView(parent)
    , mHandScrolling(false)
    , mZoomable(new Zoomable(this))
{
    setTransformationAnchor(QGraphicsView::AnchorViewCenter);
#ifdef Q_OS_MAC
    setFrameStyle(QFrame::NoFrame);
#endif

#ifndef QT_NO_OPENGL
    Preferences *prefs = Preferences::instance();
    setUseOpenGL(prefs->useOpenGL());
    connect(prefs, SIGNAL(useOpenGLChanged(bool)), SLOT(setUseOpenGL(bool)));
#endif

    QWidget *v = viewport();

    /* Since Qt 4.5, setting this attribute yields significant repaint
     * reduction when the view is being resized. */
    v->setAttribute(Qt::WA_StaticContents);

    /* Since Qt 4.6, mouse tracking is disabled when no graphics item uses
     * hover events. We need to set it since our scene wants the events. */
    v->setMouseTracking(true);

    // Adjustment for antialiasing is done by the items that need it
    setOptimizationFlags(QGraphicsView::DontAdjustForAntialiasing);

    grabGesture(Qt::PinchGesture);

    connect(mZoomable, SIGNAL(scaleChanged(qreal)), SLOT(adjustScale(qreal)));
}
Example #12
0
    virtual void IMENotification(int aIstate, bool aOpen, int aCause, int aFocusChange)
    {
        LOGT("imeState:%i", aIstate);
        q->setInputMethodHints(aIstate == 2 ? Qt::ImhHiddenText : Qt::ImhPreferLowercase);
        QWidget* focusWidget = qApp->focusWidget();
        if (focusWidget && aFocusChange) {
#if (QT_VERSION <= QT_VERSION_CHECK(5, 0, 0))
            QInputContext *inputContext = qApp->inputContext();
            if (!inputContext) {
                LOGT("Requesting SIP: but no input context");
                return;
            }
            if (aIstate) {
                QEvent request(QEvent::RequestSoftwareInputPanel);
                inputContext->filterEvent(&request);
                focusWidget->setAttribute(Qt::WA_InputMethodEnabled, true);
                inputContext->setFocusWidget(focusWidget);
            } else {
                QEvent request(QEvent::CloseSoftwareInputPanel);
                inputContext->filterEvent(&request);
                inputContext->reset();
            }
#else
            LOGT("Fixme IME for Qt5");
#endif
        }
    }
Example #13
0
void VideoOutputOpenGL::CreatePainter(void)
{
    QMutexLocker locker(&gl_context_lock);

    gl_created_painter = false;
    MythMainWindow *win = MythMainWindow::getMainWindow();
    if (gl_context && !gl_context->IsShared())
    {
        QWidget *device = QWidget::find(gl_parent_win);
        gl_painter = new MythOpenGLPainter(gl_context, device);
        if (!gl_painter)
        {
            LOG(VB_GENERAL, LOG_ERR, LOC + "Failed to create painter");
            return;
        }
        gl_created_painter = true;
#ifdef USE_OPENGL_QT5
        if (device)
            device->setAttribute(Qt::WA_PaintOnScreen);
#endif
    }
    else
    {
        gl_painter = (MythOpenGLPainter*)win->GetCurrentPainter();
        if (!gl_painter)
        {
            LOG(VB_GENERAL, LOG_ERR, LOC + "Failed to get painter");
            return;
        }
        LOG(VB_PLAYBACK, LOG_INFO, LOC + "Using main UI painter");
    }
    gl_painter->SetSwapControl(false);
}
Example #14
0
void MozQWidget::showVKB()
{
    // skip showing of keyboard if not pending
    if (!gPendingVKBOpen) {
        return;
    }

    gPendingVKBOpen = false;

#if (QT_VERSION >= QT_VERSION_CHECK(4, 6, 0)) && (QT_VERSION < QT_VERSION_CHECK(5, 0, 0))
    QWidget* focusWidget = qApp->focusWidget();

    if (focusWidget) {
        QInputContext *inputContext = qApp->inputContext();
        if (!inputContext) {
            NS_WARNING("Requesting SIP: but no input context");
            return;
        }

        QEvent request(QEvent::RequestSoftwareInputPanel);
        inputContext->filterEvent(&request);
        focusWidget->setAttribute(Qt::WA_InputMethodEnabled, true);
        inputContext->setFocusWidget(focusWidget);
        gKeyboardOpen = true;
        gFailedOpenKeyboard = false;
    }
    else
    {
        // No focused widget yet, so we have to open the VKB later on.
        gFailedOpenKeyboard = true;
    }
#else
    LOG(("VKB not supported in Qt < 4.6\n"));
#endif
}
Example #15
0
void VideoOutputOpenGL::DestroyGPUResources(void)
{
    gl_context_lock.lock();
    if (gl_context)
        gl_context->makeCurrent();

#ifdef USE_OPENGL_QT5
    if (gl_created_painter)
    {
        QWidget *device = QWidget::find(gl_parent_win);
        if (device)
            device->setAttribute(Qt::WA_PaintOnScreen, false);
    }
#endif

    if (gl_created_painter)
        delete gl_painter;
    else if (gl_painter)
        gl_painter->SetSwapControl(true);

    gl_painter = NULL;
    gl_created_painter = false;

    if (gl_context)
        gl_context->doneCurrent();

    gl_context_lock.unlock();
}
Example #16
0
void EditorClientQt::setInputMethodState(bool active)
{
    QWidget *view = m_page->view();
    if (view) {
        view->setAttribute(Qt::WA_InputMethodEnabled, active);
        emit m_page->microFocusChanged();
    }
}
Example #17
0
AddCategory::AddCategory( QWidget *parent )
    : KDialog( parent )
{
    QWidget *dialog = new QWidget( this );
    ui.setupUi( dialog );
    dialog->setAttribute( Qt::WA_DeleteOnClose );
    this->setMainWidget( dialog );
}
Example #18
0
void Books::openBook()
{
    BookLabel* label = dynamic_cast<BookLabel*>(sender());
    if (!label) return;
    QString bookName = label->text();
    QWidget * w = new QWidget;
    w->setAttribute(Qt::WA_DeleteOnClose);
    w->show();

}
Example #19
0
viewer_widget::viewer_widget(QWidget* parent,
                             const viewer::viewer_attributes&     view_attrib,
                             const wm::context::attribute_desc&   ctx_attrib,
                             const wm::surface::format_desc&      win_fmt)
  : QWidget(parent, Qt::MSWindowsOwnDC)
  , _auto_update(true)
{
    setMouseTracking(true);
    setFocusPolicy(Qt::StrongFocus);

    //parent->setAttribute(Qt::WA_NativeWindow, true);

    setAttribute(Qt::WA_NativeWindow, true);
    //setAttribute(Qt::WA_DontCreateNativeAncestors, false);
    setAttribute(Qt::WA_PaintOnScreen, true); // disables qt double buffering (seems X11 only since qt4.5, ...)
    //setAttribute(Qt::WA_OpaquePaintEvent, true);
    setAttribute(Qt::WA_NoSystemBackground, true);
    //setAttribute(Qt::WA_ForceUpdatesDisabled, true);
    //setAttribute(Qt::WA_PaintUnclipped, true);
    setAutoFillBackground(false);

    try {
        //HWND par_hndl = (HWND)parent->winId();
        //HWND this_hndl = (HWND)winId();
        //out() << std::hex << par_hndl << " " << this_hndl;
        _viewer = make_shared<viewer>(math::vec2ui(100, 100), wm::window::handle(this->winId()), view_attrib, ctx_attrib, win_fmt);
        //HWND vwr_hndl = _viewer->window()->window_handle();
        //out() << std::hex << par_hndl << " " << this_hndl << " " << vwr_hndl;
        //_viewer->window()->show();

        QWindow* nwnd = QWindow::fromWinId((WId)_viewer->window()->window_handle());
        QWidget* vw   = QWidget::createWindowContainer(nwnd, this, Qt::WindowTransparentForInput);

        vw->setAttribute(Qt::WA_TransparentForMouseEvents, true);

        QHBoxLayout* lo        = new QHBoxLayout(this);
        lo->setContentsMargins(0, 0, 0, 0);
        lo->addWidget(vw);


        // ok set the native window as this widgets window...and hold thumbs
        //this->destroy();
        //this->create((WId)vwr_hndl, true, true);
        _viewer->window_context()->make_current(_viewer->window());
    }
    catch(std::exception& e) {
        std::stringstream msg;
        msg << "viewer_widget::viewer_widget(): "
            << "unable to create viewer (evoking error: " << e.what() << ").";
        err() << msg.str();
        throw (std::runtime_error(msg.str()));
    }
}
Example #20
0
CheckPage::CheckPage(QWidget *parent) :
    QWidget(parent),
    ui(new Ui::CheckPage)
{
    double dXfactor = (double)g_pResManModule->m_pProjectParm->m_nWidth / 800;//因为在UI文件中布局时候是假设面板大小为800*600;
    ui->setupUi(this);
    ui->tableWidget->setRowCount(8);
    ui->tableWidget->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
    ui->tableWidget->verticalScrollBar()->setStyleSheet("QScrollBar:vertical{background:transparent;width:30px; border: 2px solid transparent;}");
    ui->tableWidget->setColumnWidth(0, 27*dXfactor);
    ui->tableWidget->setColumnWidth(1, 213*dXfactor);


    //表格第一列;
    for(int i = 0; i < 8; i++)
    {
        QCheckBox *pBox = new QCheckBox();
        pBox->setStyleSheet( "QCheckBox::indicator:unchecked {image: url(:/res/uncheck.png);}"
                             "QCheckBox::indicator:checked {image: url(:/res/checkbox.png);}");
        ui->tableWidget->setCellWidget(i,0, pBox);
#ifdef MYANDROID
        ui->tableWidget->setRowHeight(i, 50);
#endif
    }

    //表格第二列;
    QStringList list;
    for(int i = 0; i < 4; i++)
    {
        list.append(tr("Fixture%1").arg(i+1));
    }
    for(int i = 0; i < 2; i++)
    {
        list.append(tr("Sucker%1").arg(i+1));
    }
    list.append("X037");
    list.append("X023");

    for(int i = 0; i < 8; i++)
    {
        QCheckBox *pBox = new QCheckBox(list.at(i));
        pBox->setStyleSheet( "QCheckBox::indicator:unchecked {image: url(:/res/signalflag0.png);}"
                             "QCheckBox::indicator:checked {image: url(:/res/signalflag1.png);}");
        ui->tableWidget->setCellWidget(i, 1, pBox);
    }

    setAttribute(Qt::WA_TranslucentBackground);
    QObjectList childList = children();
    foreach (QObject *obj, childList) {
        QWidget *w = qobject_cast<QWidget *>(obj);
        if(w)
            w->setAttribute(Qt::WA_TranslucentBackground);
    }
MainWindow::MainWindow()
{

    setWindowTitle(QString::fromUtf8("Project Calendar"));
    QWidget *centralWidget = new QWidget(this);
    centralWidget->setAttribute(Qt::WA_DeleteOnClose);
    QTabWidget *tabs = new QTabWidget(centralWidget);
    QHBoxLayout *mainlayout = new QHBoxLayout(centralWidget);
    mainlayout->addWidget(tabs);
    tabs->addTab(new CalendarWindow(centralWidget),"Calendar");
    tabs->addTab(new Projectwindow(centralWidget),"Project");
    setCentralWidget(centralWidget);
}
Example #22
0
void toPieChart::openCopy(void)
{
    QWidget *newWin = new toPieChart(this,
                                     toMainWidget()->workspace(),
                                     NULL,
                                     0);

    newWin->setAttribute(Qt::WA_DeleteOnClose);
    newWin->show();
    newWin->raise();
    newWin->setFocus();
    toMainWidget()->updateWindowsMenu();
}
Example #23
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 #24
0
int ExtendedTabWidget::addSubWindow(EditorInterface* window)
{
    QWidget *widget = window->widget();
    Q_ASSERT(widget != 0);

    int curr = currentIndex();
    int index = QTabWidget::insertTab(curr + 1, widget, window->icon(), tabTextFor(widget));
    widget->installEventFilter(this);
    widget->setAttribute(Qt::WA_DeleteOnClose, true);
    setCurrentWidget(widget);
    tabsUpdate();
    return index;
}
Example #25
0
ReplayViewer::ReplayViewer(const QString &file) : finished(false), paused(false), speeding(false), timerDiff(0), nextRead(quint32(-1))
{
    in = new QFile(file);

    if (!in->open(QFile::ReadOnly)) {
        QMessageBox::critical(nullptr, tr("Error when opening replay file"), tr("The replay file couldn't be opened: %1").arg(file));
        deleteLater();
        return;
    }

    QByteArray version = in->readLine().trimmed();

    if (version != "battle_logs_v2" && version != "battle_logs_v3") {
        QMessageBox::critical(nullptr, tr("Log format not supported"), tr("The replay version of the file isn't supported by this client."));
        deleteLater();
        return;
    }

    this->version = version.right(1).toInt();

    DataStream stream(in, this->version);

    stream >> conf;

    window = new SpectatorWindow(conf);

    QWidget *widget = new QWidget();
    QGridLayout *gl = new QGridLayout(widget);
    gl->addWidget(window->getSceneWidget(), 0, 0);
    gl->addWidget(window->getLogWidget(), 0, 1);

    bar.init();
    gl->addLayout(bar.getLayout(), 1, 0, 1, 2);
    connect(&bar, SIGNAL(paused()), SLOT(pause()));
    connect(&bar, SIGNAL(speedChange(bool)), SLOT(changeSpeed(bool)));
    connect(&bar, SIGNAL(play()), SLOT(play()));
    connect(&bar, SIGNAL(seekNext()), SLOT(seekNext()));

    widget->setWindowTitle(tr("Pok\303\251mon Online Replay"));

    widget->setObjectName("ReplayViewer");
    widget->show();
    //widget->setWindowFlags(Qt::Window);
    widget->setAttribute(Qt::WA_DeleteOnClose);

    connect(widget, SIGNAL(destroyed()), SLOT(deleteLater()));

    t.start();
    read();
}
QGesture *FingerSwipeGestureRecognizer::create(QObject *target)
{
	if (target && target->isWidgetType()) {
		QWidget *widget = static_cast<QWidget *>(target);
		widget->setAttribute(Qt::WA_AcceptTouchEvents);

	} else if (target) {
		QGraphicsObject *go = qobject_cast<QGraphicsObject*>(target);
		if (go) {
			go->setAcceptTouchEvents(true);
		}
	}
	return new FingerSwipeGesture();
}
Example #27
0
MapView::MapView(QWidget *parent, Mode mode)
    : QGraphicsView(parent)
    , mHandScrolling(false)
    , mMode(mode)
    , mZoomable(new Zoomable(this))
{
    setTransformationAnchor(QGraphicsView::AnchorViewCenter);
#ifdef Q_OS_MAC
    setFrameStyle(QFrame::NoFrame);
#endif

#ifndef QT_NO_OPENGL
    Preferences *prefs = Preferences::instance();
    setUseOpenGL(prefs->useOpenGL());
    connect(prefs, SIGNAL(useOpenGLChanged(bool)), SLOT(setUseOpenGL(bool)));
#endif

    QWidget *v = viewport();

    /* Since Qt 4.5, setting this attribute yields significant repaint
     * reduction when the view is being resized. */
    if (mMode == StaticContents)
        v->setAttribute(Qt::WA_StaticContents);

    /* Since Qt 4.6, mouse tracking is disabled when no graphics item uses
     * hover events. We need to set it since our scene wants the events. */
    v->setMouseTracking(true);

    // Adjustment for antialiasing is done by the items that need it
    setOptimizationFlags(QGraphicsView::DontAdjustForAntialiasing);

    grabGesture(Qt::PinchGesture);

    setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOn);
    setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOn);

    connect(mZoomable, SIGNAL(scaleChanged(qreal)), SLOT(adjustScale(qreal)));

    // RTB: create layer name label
    mLayerLabel = new QLabel(this);

    QFont font = mLayerLabel->font();
    font.setPointSize(24);
    font.setBold(true);
    mLayerLabel->setFont(font);
    mLayerLabel->setAlignment(Qt::AlignRight);

    updateLayerLabelText(0);
}
void CanvasProcessorWidgetQt::initialize() {
    CanvasProcessorWidget::initialize();

    ivec2 dim = CanvasProcessorWidget::getDimensions();
    ivec2 pos = CanvasProcessorWidget::getPosition();

    setWindowTitle(QString::fromStdString(processor_->getIdentifier()));
    CanvasQt* sharedCanvas = CanvasQt::getSharedCanvas();
    if (!sharedCanvas->getProcessorWidgetOwner()) {
        canvas_ = sharedCanvas;
        hasSharedCanvas_ = true;
    } else {
        canvas_ = new CanvasQt(nullptr, uvec2(dim.x, dim.y));
    }

    canvas_->setEventPropagator(nullptr);

    if (!canvas_->isInitialized()) canvas_->initialize();

    canvas_->setProcessorWidgetOwner(this);
    QGridLayout* gridLayout = new QGridLayout;
    gridLayout->setContentsMargins(0, 0, 0, 0);
#ifdef USE_QWINDOW
    QWidget* container = QWidget::createWindowContainer(canvas_);
#else
    canvas_->setMouseTracking(true);
    QWidget* container = static_cast<QWidget*>(canvas_);
#endif
    container->setAttribute(Qt::WA_OpaquePaintEvent);
    gridLayout->addWidget(container, 0, 0);
    setLayout(gridLayout);
    
    setWindowFlags(Qt::Tool);
    setDimensions(dim);

    InviwoApplicationQt* app = dynamic_cast<InviwoApplicationQt*>(InviwoApplication::getPtr());
    if (app) {
        QPoint newPos = app->movePointOntoDesktop(QPoint(pos.x, pos.y), QSize(dim.x, dim.y), true);

        if (!(newPos.x() == 0 && newPos.y() == 0)) {
            QWidget::move(newPos);
        } else { // We guess that this is a new widget and give a new position
            newPos = app->getMainWindow()->pos();
            newPos += app->offsetWidget();
            QWidget::move(newPos);
        }
    }
}
Example #29
0
void InputManager::createAndShow(QWidget* parent, InputMap* inputMap)
{
    QWidget* window = NULL;

    /* Must not create more than one instance */
    if (s_instance == NULL)
    {
#ifdef __APPLE__
        /* Create a separate window for OSX */
        s_instance = new InputManager(parent, inputMap, Qt::Window);
        window = s_instance;
#else
        /* Create an MDI window for X11 & Win32 */
        QMdiArea* area = qobject_cast<QMdiArea*> (parent);
        Q_ASSERT(area != NULL);
        QMdiSubWindow* sub = new QMdiSubWindow;
        s_instance = new InputManager(sub, inputMap);
        sub->setWidget(s_instance);
        window = area->addSubWindow(sub);
#endif

        /* Set some common properties for the window and show it */
        window->setAttribute(Qt::WA_DeleteOnClose);
        window->setWindowIcon(QIcon(":/input.png"));
        window->setWindowTitle(tr("Input Manager"));
        window->setContextMenuPolicy(Qt::CustomContextMenu);
        window->show();

        QSettings settings;
        QVariant var = settings.value(SETTINGS_GEOMETRY);
        if (var.isValid() == true)
        {
            window->restoreGeometry(var.toByteArray());
            AppUtil::ensureWidgetIsVisible(window);
        }
    }
    else
    {
#ifdef __APPLE__
        window = s_instance;
#else
        window = s_instance->parentWidget();
#endif
    }

    window->show();
    window->raise();
}
Example #30
0
int main(int argc, char *argv[])
{
	QApplication app(argc, argv);

	QWidget *window = new QWidget;
	window->setAttribute(Qt::WA_DeleteOnClose, true); // when close, auto delete

	// create a button with *parent*, in the case,
	// when parent deleted, the button deleted
	MyButton *button = new MyButton("Demo21", window);

	// show window
	window->show();

	return app.exec();
}