FavoritesView::FavoritesView(QWidget *parent) : QTreeWidget(parent) { setAcceptDrops(true); setDragEnabled(true); setDropIndicatorShown(true); setSelectionMode(QAbstractItemView::SingleSelection); dataStore.clear(); targetStore.clear(); this->setFont(global.getGuiFont(font())); filterPosition = -1; maxCount = 0; // Highest count of any notebook. Used in calculating column width // setup options this->setEditTriggers(QAbstractItemView::NoEditTriggers); this->setSelectionBehavior(QAbstractItemView::SelectRows); this->setSelectionMode(QAbstractItemView::SingleSelection); this->setDragDropMode(QAbstractItemView::InternalMove); this->setRootIsDecorated(true); this->setSortingEnabled(true); this->header()->setVisible(false); this->setStyleSheet("QTreeView {border-image:none; image:none;} "); root = new FavoritesViewItem(0); root->setData(NAME_POSITION, Qt::UserRole, "root"); root->setData(NAME_POSITION, Qt::DisplayRole, tr("Shortcuts")); QFont rootFont = root->font(NAME_POSITION); rootFont.setBold(true); root->setFont(NAME_POSITION, rootFont); root->setIcon(NAME_POSITION, global.getIconResource(":favoritesIcon")); root->setRootColor(false); expandedImage = new QImage(":expandedIcon"); collapsedImage = new QImage(":collapsedIcon"); this->setAcceptDrops(true); this->setItemDelegate(new FavoritesViewDelegate()); this->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Preferred); this->setFrameShape(QFrame::NoFrame); setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff); setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); this->setMinimumHeight(1); this->addTopLevelItem(root); this->rebuildFavoritesTreeNeeded = true; this->loadData(); context.addSeparator(); deleteAction = context.addAction(tr("Remove from shortcuts")); deleteAction->setShortcut(QKeySequence(Qt::Key_Delete)); deleteShortcut = new QShortcut(this); deleteShortcut->setKey(QKeySequence(Qt::Key_Delete)); deleteShortcut->setContext(Qt::WidgetShortcut); connect(deleteAction, SIGNAL(triggered()), this, SLOT(deleteRequested())); connect(this, SIGNAL(itemExpanded(QTreeWidgetItem*)), this, SLOT(calculateHeight())); connect(this, SIGNAL(itemCollapsed(QTreeWidgetItem*)), this, SLOT(calculateHeight())); connect(this, SIGNAL(itemSelectionChanged()), this, SLOT(buildSelection())); connect(deleteShortcut, SIGNAL(activated()), this, SLOT(deleteRequested())); root->setExpanded(true); resetSize(); }
/* ***************************************** * C O N S T R U C T O R * * Sets up program environment. * ******************************************/ Puzzle::Puzzle() { scene = new QGraphicsScene; scene->setSceneRect(0,0,WIDTH,LENGTH); setScene(scene); setFixedSize(WIDTH,LENGTH); setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff); setWindowTitle(tr("8 Puzzle Solver")); solveButton = new UIButton; solveButton->setObjectName(QStringLiteral("solveButton")); solveButton->setDefault(true); solveButton->setText(QApplication::translate("Dialog", "&Solve", 0)); solveButton->setGeometry(WIDTH - 200,LENGTH/2 - 50, 100, 50); solver = new Solve(); playButton = new UIButton; playButton->setObjectName(QStringLiteral("playButton")); playButton->setDefault(true); playButton->setText(QApplication::translate("Dialog", "&Play", 0)); playButton->setGeometry(WIDTH - 200,LENGTH/2 - 100, 100, 50); randomizer = new Randomize; randButton = new UIButton; randButton->setObjectName(QStringLiteral("randButton")); randButton->setDefault(true); randButton->setText(QApplication::translate("Dialog", "&Random", 0)); randButton->setGeometry(WIDTH - 200,LENGTH/2 - 150, 100, 50); exitButton = new UIButton; exitButton->setObjectName(QStringLiteral("exitButton")); exitButton->setDefault(true); exitButton->setText(QApplication::translate("Dialog", "E&xit", 0)); exitButton->setGeometry(WIDTH - 200,LENGTH/2, 100, 50); scene->addWidget(solveButton); scene->addWidget(playButton); scene->addWidget(randButton); scene->addWidget(exitButton); matrix = new Matrix(); matrix->setPos(150, 150); scene->addItem(matrix); for (int i = 0; i < matrix->size(); ++i) { Cell *cell = (*matrix)[i]; cell->setPos(cell->x() + 150, cell->y() + 150); cell->setFlag(QGraphicsItem::ItemIsFocusable); cell->setFocus(); scene->addItem(cell); QObject::connect(cell, SIGNAL(moved()), solveButton, SLOT(enable())); QObject::connect(cell, SIGNAL(moved()), playButton, SLOT(disable())); } msg = new Message; msg->setPos(10, 10); scene->addItem(msg); playButton->setEnabled(false); QObject::connect(randButton, SIGNAL(clicked()), randomizer, SLOT(accept())); QObject::connect(solveButton, SIGNAL(clicked()), solver, SLOT(accept())); QObject::connect(playButton, SIGNAL(clicked()), solver, SLOT(play())); QObject::connect(exitButton, SIGNAL(clicked()), solver, SLOT(reject())); QObject::connect(solveButton, SIGNAL(clicked()), randButton, SLOT(disable())); QObject::connect(solveButton, SIGNAL(released()), playButton, SLOT(enable())); QObject::connect(randButton, SIGNAL(clicked()), playButton, SLOT(disable())); QObject::connect(randButton, SIGNAL(clicked()), solveButton, SLOT(enable())); QObject::connect(playButton, SIGNAL(clicked()), playButton, SLOT(disable())); QObject::connect(playButton, SIGNAL(clicked()), solveButton, SLOT(disable())); QObject::connect(solver, SIGNAL(timedout()), randButton, SLOT(enable())); QObject::connect(solver, SIGNAL(timedout()), solveButton, SLOT(enable())); show(); }
OSItemList::OSItemList(OSVectorController* vectorController, bool addScrollArea, QWidget * parent) : OSItemSelector(parent), m_vectorController(vectorController), m_vLayout(nullptr), m_selectedItem(nullptr), m_itemsDraggable(false), m_itemsRemoveable(false), m_type(OSItemType::ListItem), m_dirty(false) { // for now we will allow this item list to manage memory of OS_ASSERT(!m_vectorController->parent()); m_vectorController->setParent(this); this->setObjectName("GrayWidget"); QString style; style.append("QWidget#GrayWidget {"); style.append(" background: #E6E6E6;"); style.append(" border-bottom: 1px solid black;"); style.append("}"); setStyleSheet(style); auto outerVLayout = new QVBoxLayout(); outerVLayout->setContentsMargins(0,0,0,0); this->setLayout(outerVLayout); auto outerWidget = new QWidget(); if (addScrollArea){ auto scrollArea = new QScrollArea(); scrollArea->setFrameStyle(QFrame::NoFrame); scrollArea->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOn); scrollArea->setHorizontalScrollBarPolicy(Qt::ScrollBarAsNeeded); outerVLayout->addWidget(scrollArea); scrollArea->setWidget(outerWidget); scrollArea->setWidgetResizable(true); }else{ outerVLayout->addWidget(outerWidget); } m_vLayout = new QVBoxLayout(); outerWidget->setLayout(m_vLayout); m_vLayout->setContentsMargins(0,0,0,0); m_vLayout->setSpacing(0); m_vLayout->addStretch(); connect(this, &OSItemList::itemsRequested, vectorController, &OSVectorController::reportItems); /* Vector controller does not handle removing items in list from model * connect(this, &OSItemList::itemRemoveClicked, vectorController, &OSVectorController::removeItem); */ connect(vectorController, &OSVectorController::itemIds, this, &OSItemList::setItemIds); connect(vectorController, &OSVectorController::selectedItemId, this, &OSItemList::selectItemId); // allow time for OSDocument to finish constructing QTimer::singleShot(0, vectorController, SLOT(reportItems())); }
// Note: the QDesktopViewWidget Class will become it's own widget // so others can easly create there own desktopsor file managers with // only a few lines of code QDesktopViewWidget::QDesktopViewWidget(QWidget *parent) : QListWidget(parent) { // This sets the QDesktopViewWidget(QListWidget) to transparent so that the // desktop wallpaper below it can be seen. Note: the color: white propertiy // needs to be moved to the desktop config file setStyleSheet("QListView {background-color: transparent; color: white;}"); // Note: Need to check if config files exist, if it doesnt we need to // create it. // In the future the below QDesktopViewWidget settings will be wrapped // in this block of code so every aspect of how the desktop looks and feels // can be configured. // Note: Needs to be moved to a class function of it's own //desktopSettings = new QSettings("chipara", "desktop"); //desktopSettings->beginGroup("desktop"); //desktopSettings->endGroup(); // Variouse settings for the QDesktopViewWidget(QListWidget) class setSelectionMode(QAbstractItemView::ExtendedSelection); setViewMode(QListView::IconMode); setSpacing(20); setFlow(QListView::TopToBottom); setLayoutMode(QListView::Batched); setBatchSize(100); setMovement(QListView::Free); setIconSize(QSize(48, 48)); setUniformItemSizes(true); setWrapping(true); setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff); setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); //setSortingEnabled(true); setLayoutDirection(Qt::LeftToRight); setSelectionRectVisible(true); //setTextElideMode(Qt::ElideMiddle); setDragEnabled(true); setFrameStyle(0); setFrameShape(QFrame::NoFrame); setAutoScroll(true); setResizeMode(QListView::Adjust); // Right Click Desktop Menu menu = new QMenu(this); // Create Folder QAction *createFolder = new QAction(tr("New Folder"), this); menu->addAction(createFolder); connect(createFolder, SIGNAL(triggered()), this, SLOT(createFolder())); // Create submenu for Create Document QMenu *viewMenu = menu->addMenu(tr("&View")); QActionGroup *viewGroup = new QActionGroup(this); // Large Icons extraLargeIcons = new QAction(QIcon::fromTheme("folder"), "X-Large Icons", this); extraLargeIcons->setCheckable(true); viewGroup->addAction(extraLargeIcons); viewMenu->addAction(extraLargeIcons); connect(extraLargeIcons, SIGNAL(triggered()), this, SLOT(resizeIcons())); // Large Icons largeIcons = new QAction(QIcon::fromTheme("folder"), "Large Icons", this); largeIcons->setCheckable(true); viewGroup->addAction(largeIcons); viewMenu->addAction(largeIcons); connect(largeIcons, SIGNAL(triggered()), this, SLOT(resizeIcons())); // Medium Icons mediumIcons = new QAction(QIcon::fromTheme("folder"), "Medium Icons", this); mediumIcons->setCheckable(true); mediumIcons->setChecked(true); viewGroup->addAction(mediumIcons); viewMenu->addAction(mediumIcons); connect(mediumIcons, SIGNAL(triggered()), this, SLOT(resizeIcons())); // Medium Icons smallIcons = new QAction(QIcon::fromTheme("folder"), "Small Icons", this); smallIcons->setCheckable(true); viewGroup->addAction(smallIcons); viewMenu->addAction(smallIcons); connect(smallIcons, SIGNAL(triggered()), this, SLOT(resizeIcons())); // Add a separator to the menu viewMenu->addSeparator(); QActionGroup *layoutGroup = new QActionGroup(this); // Medium Icons leftToRight = new QAction(QIcon::fromTheme("folder"), "Left To Right", this); leftToRight->setCheckable(true); layoutGroup->addAction(leftToRight); viewMenu->addAction(leftToRight); connect(leftToRight, SIGNAL(triggered()), this, SLOT(layoutDirection())); // Medium Icons rightToLeft = new QAction(QIcon::fromTheme("folder"), "Right To Left", this); rightToLeft->setCheckable(true); layoutGroup->addAction(rightToLeft); viewMenu->addAction(rightToLeft); connect(rightToLeft, SIGNAL(triggered()), this, SLOT(layoutDirection())); // Add a separator to the menu viewMenu->addSeparator(); // Sort By Size showIcons = new QAction(QIcon::fromTheme("folder"), "Show Desktop Icons", this); showIcons->setCheckable(true); showIcons->setChecked(true); viewMenu->addAction(showIcons); connect(showIcons, SIGNAL(triggered()), this, SLOT(showDesktopIcons())); // Create submenu for Create Document QMenu *sortMenu = menu->addMenu(tr("&Sort By")); QActionGroup *sortGroup = new QActionGroup(this); // Sort By Name QAction *nameSort = new QAction(QIcon::fromTheme("folder"), "Name", this); nameSort->setCheckable(true); nameSort->setChecked(true); sortGroup->addAction(nameSort); sortMenu->addAction(nameSort); // Sort By Size QAction *sizeSort = new QAction(QIcon::fromTheme("folder"), "Size", this); sizeSort->setCheckable(true); sizeSort->setDisabled(true); sortGroup->addAction(sizeSort); sortMenu->addAction(sizeSort); // Sort By Size QAction *typeSort = new QAction(QIcon::fromTheme("folder"), "Item Type", this); typeSort->setCheckable(true); typeSort->setDisabled(true); sortGroup->addAction(typeSort); sortMenu->addAction(typeSort); // Sort By Size QAction *dateSort = new QAction(QIcon::fromTheme("folder"), "Date Modified", this); dateSort->setCheckable(true); dateSort->setDisabled(true); sortGroup->addAction(dateSort); sortMenu->addAction(dateSort); // Refresh QAction *refresh = new QAction(QIcon::fromTheme("folder"), "Refresh", this); menu->addAction(refresh); // Add a separator to the menu menu->addSeparator(); // Paste QAction *paste = new QAction(QIcon::fromTheme("folder"), "Paste", this); paste->setEnabled(false); menu->addAction(paste); // Paste Shortcut QAction *pasteShortCut = new QAction(QIcon::fromTheme("folder"), "Paste Shortcut", this); pasteShortCut->setEnabled(false); menu->addAction(pasteShortCut); // Add a separator to the menu menu->addSeparator(); // New Menu QMenu *create = menu->addMenu(tr("&New")); // Create Launcher QAction *createLauncher = new QAction(QIcon::fromTheme("application-x-desktop"), tr("&Launcher"), this); create->addAction(createLauncher); createLauncher->setIconVisibleInMenu(true); connect(createLauncher, SIGNAL(triggered()), this, SLOT(createLauncher())); // Create Empty File QAction *createEmptyFile = new QAction(QIcon::fromTheme("text-plain"), tr("&Empty File"), this); create->addAction(createEmptyFile); createEmptyFile->setIconVisibleInMenu(true); connect(createEmptyFile, SIGNAL(triggered()), this, SLOT(createEmptyFile())); // Add a separator to the menu menu->addSeparator(); // Paste QAction *desktopSettings = new QAction(QIcon::fromTheme("preferences-desktop"), "Desktop Settings", this); desktopSettings->setIconVisibleInMenu(true); menu->addAction(desktopSettings); connect(desktopSettings, SIGNAL(triggered()), this, SLOT(execDesktopSettings())); // Right Click Desktop Icon Menu iconMenu = new QIconMenu(this); // desktopDir = new QFileSystemWatcher; desktopDir->addPath(QDesktopServices::storageLocation(QDesktopServices::DesktopLocation)); // dSettings = new QSettings("chipara", "desktop"); dSettings->beginGroup("window"); if (dSettings->value("showIcons") == 1) { showIcons->setChecked(true); } else { showIcons->setChecked(false); } // if (dSettings->value("layoutDirection") == 1) { setLayoutDirection(Qt::LeftToRight); leftToRight->setChecked(true); } else { setLayoutDirection(Qt::RightToLeft); rightToLeft->setChecked(true); } // if (dSettings->value("iconSize") == 1) { this->setIconSize(QSize(128, 128)); extraLargeIcons->setChecked(true); } else if (dSettings->value("iconSize") == 2) { this->setIconSize(QSize(64, 64)); largeIcons->setChecked(true); } else if (dSettings->value("iconSize") == 3) { this->setIconSize(QSize(48, 48)); mediumIcons->setChecked(true); } else if (dSettings->value("iconSize") == 4) { this->setIconSize(QSize(36, 36)); smallIcons->setChecked(true); } populatedDesktop(); dSettings->endGroup(); // Desktop Icon Double Click EventexecDesktopSettings connect(this, SIGNAL(itemDoubleClicked(QListWidgetItem*)), this, SLOT(iconDoubleClicked(QListWidgetItem*))); connect(this, SIGNAL(itemClicked(QListWidgetItem*)), this, SLOT(iconClicked(QListWidgetItem*))); connect(desktopDir, SIGNAL(directoryChanged(QString)), this, SLOT(populatedDesktop())); }
MapGraphicsView::MapGraphicsView() : QGraphicsView() { #ifndef Q_OS_WIN srand ( time(NULL) ); #endif m_scaleFactor = 1.; #ifndef QT_NO_OPENGL //setViewport(new QGLWidget(QGLFormat(QGL::SampleBuffers))); #endif setCacheMode(CacheBackground); //setViewportUpdateMode(BoundingRectViewportUpdate); //setRenderHint(QPainter::Antialiasing); //setTransformationAnchor(AnchorUnderMouse); #ifdef Q_OS_ANDROID setTransformationAnchor(QGraphicsView::AnchorViewCenter); #endif setResizeAnchor(AnchorViewCenter); setDragMode(QGraphicsView::ScrollHandDrag); setRenderHints(QPainter::Antialiasing | QPainter::TextAntialiasing | QPainter::SmoothPixmapTransform ); // if there are ever graphic glitches to be found, remove this again setOptimizationFlags(QGraphicsView::DontAdjustForAntialiasing | QGraphicsView::DontClipPainter | QGraphicsView::DontSavePainterState); //setCacheMode(QGraphicsView::CacheBackground); //setViewportUpdateMode(QGraphicsView::BoundingRectViewportUpdate); setViewportUpdateMode(QGraphicsView::SmartViewportUpdate); setOptimizationFlags(QGraphicsView::DontSavePainterState); setFrameStyle(QFrame::NoFrame); #ifdef Q_OS_ANDROID setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff); setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); #endif QWidget *viewport = new QWidget(); QVBoxLayout *vbox = new QVBoxLayout(viewport); QHBoxLayout *hbox; hbox = new QHBoxLayout(); { hbox->setSpacing(0); hbox->addStretch(1); m_hudLabel = new QLabel(); hbox->addWidget(m_hudLabel); vbox->addLayout(hbox); } vbox->addStretch(1); hbox = new QHBoxLayout(); { hbox->setSpacing(0); hbox->addStretch(1); m_statusLabel = new QLabel(); hbox->addWidget(m_statusLabel); m_statusLabel->hide(); hbox->addStretch(1); } vbox->addLayout(hbox); hbox = new QHBoxLayout(); { hbox->setSpacing(0); hbox->addStretch(1); QPushButton *btn; { btn = new QPushButton("-"); btn->setStyleSheet("QPushButton {" #ifdef Q_OS_ANDROID "background: url(':/data/images/android-zoom-minus-button.png'); width: 117px; height: 47px; " #else "background: url(':/data/images/zoom-minus-button.png'); width: 58px; height: 24px; " #endif "padding:0; margin:0; border:none; color: transparent; outline: none; }"); btn->setSizePolicy(QSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed)); btn->setAutoRepeat(true); btn->setMaximumSize(117,48); connect(btn, SIGNAL(clicked()), this, SLOT(zoomOut())); hbox->addWidget(btn); } { btn = new QPushButton("+"); btn->setStyleSheet("QPushButton {" #ifdef Q_OS_ANDROID "background: url(':/data/images/android-zoom-plus-button.png'); width: 117px; height: 47px; " #else "background: url(':/data/images/zoom-plus-button.png'); width: 58px; height: 24px; " #endif "padding:0; margin:0; border:none; color: transparent; outline: none; }"); btn->setSizePolicy(QSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed)); btn->setAttribute(Qt::WA_TranslucentBackground, true); btn->setAutoRepeat(true); btn->setMaximumSize(117,48); connect(btn, SIGNAL(clicked()), this, SLOT(zoomIn())); hbox->addWidget(btn); } hbox->addStretch(1); } vbox->addLayout(hbox); m_viewportLayout = vbox; setViewport(viewport); // Set a timer to update layout because it doesn't give buttons correct position right at the start QTimer::singleShot(500, this, SLOT(updateViewportLayout())); // Disable here because it interferes with the 'longpress' functionality in MapGraphicsScene // FlickCharm *flickCharm = new FlickCharm(this); // flickCharm->activateOn(this); }
//! [0] PadNavigator::PadNavigator(const QSize &size, QWidget *parent) : QGraphicsView(parent) { //! [0] //! [1] // Splash item SplashItem *splash = new SplashItem; splash->setZValue(1); //! [1] //! [2] // Pad item FlippablePad *pad = new FlippablePad(size); QGraphicsRotation *flipRotation = new QGraphicsRotation(pad); QGraphicsRotation *xRotation = new QGraphicsRotation(pad); QGraphicsRotation *yRotation = new QGraphicsRotation(pad); flipRotation->setAxis(Qt::YAxis); xRotation->setAxis(Qt::YAxis); yRotation->setAxis(Qt::XAxis); pad->setTransformations(QList<QGraphicsTransform *>() << flipRotation << xRotation << yRotation); //! [2] //! [3] // Back (proxy widget) item QGraphicsProxyWidget *backItem = new QGraphicsProxyWidget(pad); QWidget *widget = new QWidget; form.setupUi(widget); form.hostName->setFocus(); backItem->setWidget(widget); backItem->setVisible(false); backItem->setFocus(); backItem->setCacheMode(QGraphicsItem::ItemCoordinateCache); const QRectF r = backItem->rect(); backItem->setTransform(QTransform() .rotate(180, Qt::YAxis) .translate(-r.width()/2, -r.height()/2)); //! [3] //! [4] // Selection item RoundRectItem *selectionItem = new RoundRectItem(QRectF(-60, -60, 120, 120), Qt::gray, pad); selectionItem->setZValue(0.5); //! [4] //! [5] // Splash animations QPropertyAnimation *smoothSplashMove = new QPropertyAnimation(splash, "y"); QPropertyAnimation *smoothSplashOpacity = new QPropertyAnimation(splash, "opacity"); smoothSplashMove->setEasingCurve(QEasingCurve::InQuad); smoothSplashMove->setDuration(250); smoothSplashOpacity->setDuration(250); //! [5] //! [6] // Selection animation QPropertyAnimation *smoothXSelection = new QPropertyAnimation(selectionItem, "x"); QPropertyAnimation *smoothYSelection = new QPropertyAnimation(selectionItem, "y"); QPropertyAnimation *smoothXRotation = new QPropertyAnimation(xRotation, "angle"); QPropertyAnimation *smoothYRotation = new QPropertyAnimation(yRotation, "angle"); smoothXSelection->setDuration(125); smoothYSelection->setDuration(125); smoothXRotation->setDuration(125); smoothYRotation->setDuration(125); smoothXSelection->setEasingCurve(QEasingCurve::InOutQuad); smoothYSelection->setEasingCurve(QEasingCurve::InOutQuad); smoothXRotation->setEasingCurve(QEasingCurve::InOutQuad); smoothYRotation->setEasingCurve(QEasingCurve::InOutQuad); //! [6] //! [7] // Flip animation setup QPropertyAnimation *smoothFlipRotation = new QPropertyAnimation(flipRotation, "angle"); QPropertyAnimation *smoothFlipScale = new QPropertyAnimation(pad, "scale"); QPropertyAnimation *smoothFlipXRotation = new QPropertyAnimation(xRotation, "angle"); QPropertyAnimation *smoothFlipYRotation = new QPropertyAnimation(yRotation, "angle"); QParallelAnimationGroup *flipAnimation = new QParallelAnimationGroup(this); smoothFlipScale->setDuration(500); smoothFlipRotation->setDuration(500); smoothFlipXRotation->setDuration(500); smoothFlipYRotation->setDuration(500); smoothFlipScale->setEasingCurve(QEasingCurve::InOutQuad); smoothFlipRotation->setEasingCurve(QEasingCurve::InOutQuad); smoothFlipXRotation->setEasingCurve(QEasingCurve::InOutQuad); smoothFlipYRotation->setEasingCurve(QEasingCurve::InOutQuad); smoothFlipScale->setKeyValueAt(0, qvariant_cast<qreal>(1.0)); smoothFlipScale->setKeyValueAt(0.5, qvariant_cast<qreal>(0.7)); smoothFlipScale->setKeyValueAt(1, qvariant_cast<qreal>(1.0)); flipAnimation->addAnimation(smoothFlipRotation); flipAnimation->addAnimation(smoothFlipScale); flipAnimation->addAnimation(smoothFlipXRotation); flipAnimation->addAnimation(smoothFlipYRotation); //! [7] //! [8] // Flip animation delayed property assignment QSequentialAnimationGroup *setVariablesSequence = new QSequentialAnimationGroup; QPropertyAnimation *setFillAnimation = new QPropertyAnimation(pad, "fill"); QPropertyAnimation *setBackItemVisibleAnimation = new QPropertyAnimation(backItem, "visible"); QPropertyAnimation *setSelectionItemVisibleAnimation = new QPropertyAnimation(selectionItem, "visible"); setFillAnimation->setDuration(0); setBackItemVisibleAnimation->setDuration(0); setSelectionItemVisibleAnimation->setDuration(0); setVariablesSequence->addPause(250); setVariablesSequence->addAnimation(setBackItemVisibleAnimation); setVariablesSequence->addAnimation(setSelectionItemVisibleAnimation); setVariablesSequence->addAnimation(setFillAnimation); flipAnimation->addAnimation(setVariablesSequence); //! [8] //! [9] // Build the state machine QStateMachine *stateMachine = new QStateMachine(this); QState *splashState = new QState(stateMachine); QState *frontState = new QState(stateMachine); QHistoryState *historyState = new QHistoryState(frontState); QState *backState = new QState(stateMachine); //! [9] //! [10] frontState->assignProperty(pad, "fill", false); frontState->assignProperty(splash, "opacity", 0.0); frontState->assignProperty(backItem, "visible", false); frontState->assignProperty(flipRotation, "angle", qvariant_cast<qreal>(0.0)); frontState->assignProperty(selectionItem, "visible", true); backState->assignProperty(pad, "fill", true); backState->assignProperty(backItem, "visible", true); backState->assignProperty(xRotation, "angle", qvariant_cast<qreal>(0.0)); backState->assignProperty(yRotation, "angle", qvariant_cast<qreal>(0.0)); backState->assignProperty(flipRotation, "angle", qvariant_cast<qreal>(180.0)); backState->assignProperty(selectionItem, "visible", false); stateMachine->addDefaultAnimation(smoothXRotation); stateMachine->addDefaultAnimation(smoothYRotation); stateMachine->addDefaultAnimation(smoothXSelection); stateMachine->addDefaultAnimation(smoothYSelection); stateMachine->setInitialState(splashState); //! [10] //! [11] // Transitions QEventTransition *anyKeyTransition = new QEventTransition(this, QEvent::KeyPress, splashState); anyKeyTransition->setTargetState(frontState); anyKeyTransition->addAnimation(smoothSplashMove); anyKeyTransition->addAnimation(smoothSplashOpacity); //! [11] //! [12] QKeyEventTransition *enterTransition = new QKeyEventTransition(this, QEvent::KeyPress, Qt::Key_Enter, backState); QKeyEventTransition *returnTransition = new QKeyEventTransition(this, QEvent::KeyPress, Qt::Key_Return, backState); QKeyEventTransition *backEnterTransition = new QKeyEventTransition(this, QEvent::KeyPress, Qt::Key_Enter, frontState); QKeyEventTransition *backReturnTransition = new QKeyEventTransition(this, QEvent::KeyPress, Qt::Key_Return, frontState); enterTransition->setTargetState(historyState); returnTransition->setTargetState(historyState); backEnterTransition->setTargetState(backState); backReturnTransition->setTargetState(backState); enterTransition->addAnimation(flipAnimation); returnTransition->addAnimation(flipAnimation); backEnterTransition->addAnimation(flipAnimation); backReturnTransition->addAnimation(flipAnimation); //! [12] //! [13] // Create substates for each icon; store in temporary grid. int columns = size.width(); int rows = size.height(); QVector< QVector< QState * > > stateGrid; stateGrid.resize(rows); for (int y = 0; y < rows; ++y) { stateGrid[y].resize(columns); for (int x = 0; x < columns; ++x) stateGrid[y][x] = new QState(frontState); } frontState->setInitialState(stateGrid[0][0]); selectionItem->setPos(pad->iconAt(0, 0)->pos()); //! [13] //! [14] // Enable key navigation using state transitions for (int y = 0; y < rows; ++y) { for (int x = 0; x < columns; ++x) { QState *state = stateGrid[y][x]; QKeyEventTransition *rightTransition = new QKeyEventTransition(this, QEvent::KeyPress, Qt::Key_Right, state); QKeyEventTransition *leftTransition = new QKeyEventTransition(this, QEvent::KeyPress, Qt::Key_Left, state); QKeyEventTransition *downTransition = new QKeyEventTransition(this, QEvent::KeyPress, Qt::Key_Down, state); QKeyEventTransition *upTransition = new QKeyEventTransition(this, QEvent::KeyPress, Qt::Key_Up, state); rightTransition->setTargetState(stateGrid[y][(x + 1) % columns]); leftTransition->setTargetState(stateGrid[y][((x - 1) + columns) % columns]); downTransition->setTargetState(stateGrid[(y + 1) % rows][x]); upTransition->setTargetState(stateGrid[((y - 1) + rows) % rows][x]); //! [14] //! [15] RoundRectItem *icon = pad->iconAt(x, y); state->assignProperty(xRotation, "angle", -icon->x() / 6.0); state->assignProperty(yRotation, "angle", icon->y() / 6.0); state->assignProperty(selectionItem, "x", icon->x()); state->assignProperty(selectionItem, "y", icon->y()); frontState->assignProperty(icon, "visible", true); backState->assignProperty(icon, "visible", false); QPropertyAnimation *setIconVisibleAnimation = new QPropertyAnimation(icon, "visible"); setIconVisibleAnimation->setDuration(0); setVariablesSequence->addAnimation(setIconVisibleAnimation); } } //! [15] //! [16] // Scene QGraphicsScene *scene = new QGraphicsScene(this); scene->setBackgroundBrush(QPixmap(":/images/blue_angle_swirl.jpg")); scene->setItemIndexMethod(QGraphicsScene::NoIndex); scene->addItem(pad); scene->setSceneRect(scene->itemsBoundingRect()); setScene(scene); //! [16] //! [17] // Adjust splash item to scene contents const QRectF sbr = splash->boundingRect(); splash->setPos(-sbr.width() / 2, scene->sceneRect().top() - 2); frontState->assignProperty(splash, "y", splash->y() - 100.0); scene->addItem(splash); //! [17] //! [18] // View setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff); setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); setMinimumSize(50, 50); setViewportUpdateMode(FullViewportUpdate); setCacheMode(CacheBackground); setRenderHints(QPainter::Antialiasing | QPainter::SmoothPixmapTransform | QPainter::TextAntialiasing); #ifndef QT_NO_OPENGL setViewport(new QGLWidget(QGLFormat(QGL::SampleBuffers))); #endif stateMachine->start(); //! [18] }
// Constructor NTagView::NTagView(QWidget *parent) : QTreeWidget(parent) { accountFilter = 0; this->setFont(global.getGuiFont(font())); filterPosition = 0; maxCount = 0; // setup options this->setEditTriggers(QAbstractItemView::NoEditTriggers); this->setSelectionBehavior(QAbstractItemView::SelectRows); this->setSelectionMode(QAbstractItemView::ExtendedSelection); this->setRootIsDecorated(true); this->setSortingEnabled(false); this->header()->setVisible(false); //this->setStyleSheet("QTreeWidget { background:transparent; border:none; margin:0px; padding: 0px; }"); // Build the root item root = new NTagViewItem(this); root->setIcon(NAME_POSITION,global.getIconResource(":tagIcon")); root->setData(NAME_POSITION, Qt::UserRole, "root"); root->setData(NAME_POSITION, Qt::DisplayRole, tr("Tags from Personal")); root->setExpanded(true); QFont rootFont = root->font(NAME_POSITION); rootFont.setBold(true); root->setFont(NAME_POSITION, rootFont); this->setMinimumHeight(1); this->addTopLevelItem(root); this->rebuildTagTreeNeeded = true; this->loadData(); setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff); setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); connect(this, SIGNAL(itemExpanded(QTreeWidgetItem*)), this, SLOT(calculateHeight())); connect(this, SIGNAL(itemCollapsed(QTreeWidgetItem*)), this, SLOT(calculateHeight())); connect(this, SIGNAL(itemSelectionChanged()), this, SLOT(buildSelection())); setAcceptDrops(true); setDragEnabled(true); global.settings->beginGroup("SaveState"); hideUnassigned = global.settings->value("hideUnassigned", false).toBool(); global.settings->endGroup(); addAction = context.addAction(tr("Create New Tag")); addAction->setShortcut(QKeySequence(Qt::Key_Insert)); addAction->setShortcutContext(Qt::WidgetShortcut); addShortcut = new QShortcut(this); addShortcut->setKey(QKeySequence(Qt::Key_Insert)); addShortcut->setContext(Qt::WidgetShortcut); context.addSeparator(); deleteAction = context.addAction(tr("Delete")); deleteAction->setShortcut(QKeySequence(Qt::Key_Delete)); deleteShortcut = new QShortcut(this); deleteShortcut->setKey(QKeySequence(Qt::Key_Delete)); deleteShortcut->setContext(Qt::WidgetShortcut); renameAction = context.addAction(tr("Rename")); renameAction->setShortcutContext(Qt::WidgetShortcut); mergeAction = context.addAction(tr("Merge")); context.addSeparator(); hideUnassignedAction = context.addAction(tr("Hide Unassigned")); hideUnassignedAction->setCheckable(true); hideUnassignedAction->setChecked(hideUnassigned); connect(hideUnassignedAction, SIGNAL(triggered()), this, SLOT(hideUnassignedTags())); context.addSeparator(); propertiesAction = context.addAction(tr("Properties")); connect(addAction, SIGNAL(triggered()), this, SLOT(addRequested())); connect(deleteAction, SIGNAL(triggered()), this, SLOT(deleteRequested())); connect(renameAction, SIGNAL(triggered()), this, SLOT(renameRequested())); connect(propertiesAction, SIGNAL(triggered()), this, SLOT(propertiesRequested())); connect(mergeAction, SIGNAL(triggered()), this, SLOT(mergeRequested())); connect(addShortcut, SIGNAL(activated()), this, SLOT(addRequested())); connect(deleteShortcut, SIGNAL(activated()), this, SLOT(deleteRequested())); this->setItemDelegate(new NTagViewDelegate()); this->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Preferred); this->setFrameShape(QFrame::NoFrame); expandedImage = new QImage(":expandedIcon"); collapsedImage = new QImage(":collapsedIcon"); }
PrintView::PrintView() { setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff); setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); }
KNMusicTreeViewBase::KNMusicTreeViewBase(QWidget *parent, KNMusicTab *tab) : QTreeView(parent), m_musicTab(tab), m_mouseAnime(new QTimeLine(200, this)), m_proxyModel(nullptr), m_hScrollBar(new QScrollBar(Qt::Horizontal, this)), m_vScrollBar(new QScrollBar(Qt::Vertical, this)), m_dragMoveRow(-1), m_dragIndicatorPos(QAbstractItemView::OnViewport), m_initialLoad(true), m_pressed(false), m_notAcceptDragMove(false) { //Set properties. setAllColumnsShowFocus(true); setAlternatingRowColors(false); //We will use our own alternating drawing. setContentsMargins(0, 0, 0, 0); setDragDropMode(QAbstractItemView::InternalMove); setDragEnabled(true); setDropIndicatorShown(true); setFrameShape(QFrame::NoFrame); setIndentation(0); setMouseTracking(true); setSizeAdjustPolicy(QAbstractScrollArea::AdjustToContents); setSelectionBehavior(QAbstractItemView::SelectRows); setSelectionMode(QAbstractItemView::ExtendedSelection); setUniformRowHeights(true); setVerticalScrollMode(QAbstractItemView::ScrollPerPixel); setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff); //Set scroll bar policies. horizontalScrollBar()->setSingleStep(5); horizontalScrollBar()->setPageStep(5); verticalScrollBar()->setSingleStep(4); verticalScrollBar()->setPageStep(4); //Configure the horizontal scroll bar. m_hScrollBar->setObjectName("MusicScrollBar"); m_hScrollBar->setStyle(KNSaoStyle::instance()); m_hScrollBar->hide(); m_hScrollBar->setFixedHeight(ScrollBarWidth); knTheme->registerWidget(m_hScrollBar); setHorizontalScrollBar(m_hScrollBar); //Configure the vertical scroll bar. m_vScrollBar->setObjectName("MusicScrollBar"); m_vScrollBar->setStyle(KNSaoStyle::instance()); m_vScrollBar->hide(); knTheme->registerWidget(m_vScrollBar); connect(verticalScrollBar(), &QScrollBar::rangeChanged, [=](int min, int max) { //Update the range first. m_vScrollBar->setRange(min, max); //Check whether the scroll bar is still valid. m_vScrollBar->setVisible(min!=max); //Update scrollbar state parameters. m_vScrollBar->setPageStep(verticalScrollBar()->pageStep()); m_vScrollBar->setSingleStep(verticalScrollBar()->singleStep()); //Update the geometry. updateVerticalScrollBarGeometry(); }); connect(verticalScrollBar(), &QScrollBar::valueChanged, [=](int value) { //Block the signal. m_vScrollBar->blockSignals(true); //Reset the value. m_vScrollBar->setValue(value); //Release the block m_vScrollBar->blockSignals(false); }); connect(m_vScrollBar, &QScrollBar::valueChanged, verticalScrollBar(), &QScrollBar::setValue); //Configure the time line. m_mouseAnime->setEasingCurve(QEasingCurve::OutCubic); m_mouseAnime->setUpdateInterval(10); //Link the time line. connect(m_mouseAnime, &QTimeLine::frameChanged, this, &KNMusicTreeViewBase::onActionMouseInOut); //Generate the music tree view animation header. KNMusicTreeViewHeader *header=new KNMusicTreeViewHeader(this); //Link the reqirement. connect(header, &KNMusicTreeViewHeader::requireResizeColumnToContents, this, &KNMusicTreeViewBase::resizeColumnToContents); //Set the header view. setHeader(header); //Set the rating delegate for Rating and AlbumRating row. setItemDelegateForColumn(Rating, new KNMusicRatingDelegate(this)); setItemDelegateForColumn(AlbumRating, new KNMusicRatingDelegate(this)); //Set the search shortcut. QAction *searchAction=new QAction(this); searchAction->setShortcut(QKeySequence(Qt::CTRL+Qt::Key_F)); searchAction->setShortcutContext(Qt::WidgetWithChildrenShortcut); connect(searchAction, &QAction::triggered, [=] { //Check whether the search plugin is loaded. if(knMusicGlobal->search()) { knMusicGlobal->search()->onActionSearchShortcut(this); } }); addAction(searchAction); //Link the tree view signal and slot. connect(this, &KNMusicTreeViewBase::activated, this, &KNMusicTreeViewBase::onActionActivate); //Link with theme manager. connect(knTheme, &KNThemeManager::themeChange, this, &KNMusicTreeViewBase::onActionThemeUpdate); }
Game::Game(): QGraphicsView(){ move_timer = new QTimer(this); move_timer->start(20); //create a scene scene = new QGraphicsScene(this); scene->setSceneRect(0,0,920,720); //set the scene setScene(scene); //set cursor cursor = nullptr; building = nullptr; setMouseTracking(true); //alter window setFixedSize(920,720); setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff); //split screen into playfield and menu field_menu << QPointF(720,0) << QPointF(720,720); for(size_t i=0, n = field_menu.size()-1; i < n; i++){ //create a line QLineF line(field_menu[i],field_menu[i+1]); QGraphicsLineItem * lineItem = new QGraphicsLineItem(line); QPen pen; pen.setWidth(5); pen.setColor(Qt::black); lineItem->setPen(pen); scene->addItem(lineItem); } //create gridpoints for(gPoint_x=0; gPoint_x<20; gPoint_x++){ for(gPoint_y=0; gPoint_y<20; gPoint_y++){ Gridpoint *gPoint = new Gridpoint; gPoint->setPos(x()+12+(36*gPoint_x),y()+12+(36*gPoint_y)); scene->addItem(gPoint); } } //creat enemy spawnTimer = new QTimer(this); enemiesSpawned = 0; maxNumberOfEnemies = 0; pointsToFollow << QPointF(18,18) << QPointF(18,414) << QPointF(198,414)<< QPointF(594,414) << QPointF(594,54) << QPointF(800,54)<< QPointF(594,54); for(int i=0;i<=(pointsToFollow.length()-2);i++){ QPointF temp; double test; temp=((pointsToFollow[i+1])-(pointsToFollow[i])); temp=temp; direction[i][0]=temp.x()/(sqrt(pow(temp.x(),2)+pow(temp.y(),2))); direction[i][1]=temp.y()/(sqrt(pow(temp.x(),2)+pow(temp.y(),2))); } createEnemies(20); //create Road createRoad(); //create Tower-Icon BuildRedTowerIcon * rt = new BuildRedTowerIcon(); BuildGreenTowerIcon * gt = new BuildGreenTowerIcon(); BuildBlueTowerIcon * bt = new BuildBlueTowerIcon(); BuildBlackTowerIcon * bkt = new BuildBlackTowerIcon(); BuildWhiteTowerIcon * wt = new BuildWhiteTowerIcon(); BuildYellowTowerIcon * yt = new BuildYellowTowerIcon(); //move tower icons rt->setPos(x()+850,y()); gt->setPos(x()+850,y()+50); bt->setPos(x()+850,y()+100); bkt->setPos(x()+850,y()+150); yt->setPos(x()+850,y()+200); wt->setPos(x()+850,y()+250); scene->addItem(rt); scene->addItem(gt); scene->addItem(bt); scene->addItem(bkt); scene->addItem(yt); scene->addItem(wt); }
QgsMapCanvas::QgsMapCanvas( QWidget * parent, const char *name ) : QGraphicsView( parent ) , mCanvasProperties( new CanvasProperties ) , mJob( 0 ) , mJobCancelled( false ) , mLabelingResults( 0 ) , mUseParallelRendering( false ) , mDrawRenderingStats( false ) , mCache( 0 ) , mPreviewEffect( 0 ) , mSnappingUtils( 0 ) { setObjectName( name ); mScene = new QGraphicsScene(); setScene( mScene ); setHorizontalScrollBarPolicy( Qt::ScrollBarAlwaysOff ); setVerticalScrollBarPolicy( Qt::ScrollBarAlwaysOff ); mLastExtentIndex = -1; mCurrentLayer = NULL; mMapOverview = NULL; mMapTool = NULL; mLastNonZoomMapTool = NULL; mFrozen = false; mRefreshScheduled = false; setWheelAction( WheelZoom ); // by default, the canvas is rendered mRenderFlag = true; setMouseTracking( true ); setFocusPolicy( Qt::StrongFocus ); mMapRenderer = new QgsMapRenderer; mResizeTimer = new QTimer( this ); mResizeTimer->setSingleShot( true ); connect( mResizeTimer, SIGNAL( timeout() ), this, SLOT( refresh() ) ); // create map canvas item which will show the map mMap = new QgsMapCanvasMap( this ); // project handling connect( QgsProject::instance(), SIGNAL( readProject( const QDomDocument & ) ), this, SLOT( readProject( const QDomDocument & ) ) ); connect( QgsProject::instance(), SIGNAL( writeProject( QDomDocument & ) ), this, SLOT( writeProject( QDomDocument & ) ) ); mSettings.setFlag( QgsMapSettings::DrawEditingInfo ); mSettings.setFlag( QgsMapSettings::UseRenderingOptimization ); // class that will sync most of the changes between canvas and (legacy) map renderer // it is parented to map canvas, will be deleted automatically new QgsMapCanvasRendererSync( this, mMapRenderer ); QSize s = viewport()->size(); mSettings.setOutputSize( s ); mMapRenderer->setOutputSize( s, mSettings.outputDpi() ); setSceneRect( 0, 0, s.width(), s.height() ); mScene->setSceneRect( QRectF( 0, 0, s.width(), s.height() ) ); moveCanvasContents( true ); connect( &mMapUpdateTimer, SIGNAL( timeout() ), SLOT( mapUpdateTimeout() ) ); mMapUpdateTimer.setInterval( 250 ); #ifdef Q_OS_WIN // Enable touch event on Windows. // Qt on Windows needs to be told it can take touch events or else it ignores them. grabGesture( Qt::PinchGesture ); viewport()->setAttribute( Qt::WA_AcceptTouchEvents ); #endif mPreviewEffect = new QgsPreviewEffect( this ); viewport()->setGraphicsEffect( mPreviewEffect ); setInteractive( false ); refresh(); } // QgsMapCanvas ctor
GameView::GameView(QWidget *parent){ // Сглаживание this -> setRenderHint(QPainter::Antialiasing); // Количество игроков count_players = 2; // Количество действий // X A W S D Tab Q E Space count_actions = 9; // Забиваем вектор из действий if ( count_players > 0 ){ QVector<int> temp = { Qt::Key_X, Qt::Key_A, Qt::Key_W, Qt::Key_S, Qt::Key_D, Qt::Key_Tab, Qt::Key_Q, Qt::Key_E, Qt::Key_Space }; controls.push_back(temp); } if ( count_players > 1 ){ QVector<int> temp = { Qt::Key_2, Qt::Key_4, Qt::Key_8, Qt::Key_5, Qt::Key_6, Qt::Key_Plus, Qt::Key_7, Qt::Key_9, Qt::Key_0 }; controls.push_back(temp); } // Инициализируем переменную fps fps = 120; // Создаем графическую сцену scene = new QGraphicsScene(this); scene -> setSceneRect(-1, -1, screen_size.x()+1, screen_size.y()+1); // Ставим фон сцены QImage * img = new QImage(":/images/bg_1_1.png"); resizeImage(img, QSize(1920.0*resize_factor, 1080.0*resize_factor)); QBrush bg_brush(*img); scene -> setBackgroundBrush(bg_brush); // Добавляем границы сцены addBorder(); // Ставим нашу сцену setScene(scene); // Отключение полос прокрутки setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff); // Ставим заголовок окна setWindowTitle("Space Wars"); // Добавление игрока 1 player1 = new Ship(1, 1, 3, 1); placeShip(player1, scene -> width() / 2.0 - player1 -> boundingRect().width(), scene -> height() / 2.0 - player1 -> boundingRect().height() / 2.0 ); // Добавление игрока 2 player2 = new Ship(1, 2, 4, 1); placeShip(player2, scene -> width() / 2.0, scene -> height() / 2.0 - player1 -> boundingRect().height() / 2.0 ); // Добавление мобов /* for (int j = 2; j <= 2; ++j) for (int i = 1; i <= 4; ++i){ Ship * ship = new Ship(1, j, i, qrand()%4+1); npcs.insert(ship); placeShip(ship, qrand()%qRound(scene -> width()- ship -> boundingRect().width() ), qrand()%qRound(scene -> height()- ship -> boundingRect().height() ) ); } */ // Главный таймер QTimer * timer = new QTimer(); connect(timer, SIGNAL(timeout()), this, SLOT(mainTimer())); timer -> start(1000.0 / fps); }
// Constructor NNotebookView::NNotebookView(QWidget *parent) : QTreeWidget(parent) { stackStore.clear(); dataStore.clear(); this->setFont(global.getGuiFont(font())); filterPosition = -1; maxCount = 0; // Highest count of any notebook. Used in calculating column width // setup options this->setEditTriggers(QAbstractItemView::NoEditTriggers); this->setSelectionBehavior(QAbstractItemView::SelectRows); this->setSelectionMode(QAbstractItemView::SingleSelection); this->setRootIsDecorated(true); this->setSortingEnabled(false); this->header()->setVisible(false); this->setStyleSheet("QTreeView {border-image:none; image:none;} "); root = new NNotebookViewItem(0); root->setType(NNotebookViewItem::Stack); root->setData(NAME_POSITION, Qt::UserRole, "rootsynchronized"); root->setData(NAME_POSITION, Qt::DisplayRole, tr("Notebooks")); QFont rootFont = root->font(NAME_POSITION); rootFont.setBold(true); root->setFont(NAME_POSITION, rootFont); root->setRootColor(false); this->setMinimumHeight(1); this->addTopLevelItem(root); this->rebuildNotebookTreeNeeded = true; this->loadData(); setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff); setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); connect(this, SIGNAL(itemExpanded(QTreeWidgetItem*)), this, SLOT(calculateHeight())); connect(this, SIGNAL(itemCollapsed(QTreeWidgetItem*)), this, SLOT(calculateHeight())); connect(this, SIGNAL(itemSelectionChanged()), this, SLOT(buildSelection())); addAction = context.addAction(tr("Create New Notebook")); addAction->setShortcut(QKeySequence(Qt::Key_Insert)); addAction->setShortcutContext(Qt::WidgetShortcut); addShortcut = new QShortcut(this); addShortcut->setKey(QKeySequence(Qt::Key_Insert)); addShortcut->setContext(Qt::WidgetShortcut); context.addSeparator(); deleteAction = context.addAction(tr("Delete")); deleteAction->setShortcut(QKeySequence(Qt::Key_Delete)); deleteShortcut = new QShortcut(this); deleteShortcut->setKey(QKeySequence(Qt::Key_Delete)); deleteShortcut->setContext(Qt::WidgetShortcut); // Start building the stack menu stackMenu = context.addMenu(tr("Add to stack")); QAction *newAction; NotebookTable table(global.db); QStringList stacks; table.getStacks(stacks); for (int i=0; i<stacks.size(); i++) { newAction = stackMenu->addAction(stacks[i]); connect(newAction, SIGNAL(triggered()), this, SLOT(moveToStackRequested())); } sortStackMenu(); if (stacks.size() > 0) { stackMenu->addSeparator(); } newStackAction = stackMenu->addAction(tr("New stack")); connect(newStackAction, SIGNAL(triggered()), this, SLOT(moveToNewStackRequested())); removeFromStackAction = context.addAction(tr("Remove from stack")); removeFromStackAction->setShortcutContext(Qt::WidgetShortcut); removeFromStackAction->setVisible(false); renameAction = context.addAction(tr("Rename")); renameAction->setShortcutContext(Qt::WidgetShortcut); //renameShortcut = new QShortcut(this); //renameShortcut->setKey(QKeySequence(Qt::Key_F2)); //renameShortcut->setContext(Qt::WidgetShortcut); context.addSeparator(); propertiesAction = context.addAction(tr("Properties")); connect(addAction, SIGNAL(triggered()), this, SLOT(addRequested())); connect(deleteAction, SIGNAL(triggered()), this, SLOT(deleteRequested())); connect(renameAction, SIGNAL(triggered()), this, SLOT(renameRequested())); connect(propertiesAction, SIGNAL(triggered()), this, SLOT(propertiesRequested())); connect(addShortcut, SIGNAL(activated()), this, SLOT(addRequested())); connect(deleteShortcut, SIGNAL(activated()), this, SLOT(deleteRequested())); //connect(renameShortcut, SIGNAL(activated()), this, SLOT(renameRequested())); connect(removeFromStackAction, SIGNAL(triggered()), this, SLOT(removeFromStackRequested())); this->setAcceptDrops(true); this->setItemDelegate(new NNotebookViewDelegate()); root->setExpanded(true); this->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Preferred); this->setFrameShape(QFrame::NoFrame); //setStyle(new MyStyle("QTreeView")); // setStyle(new QCleanlooksStyle); //setStyleSheet("::branches {image: url(:right-arrow.png);}"); // setStyleSheet("QTreeView::branch { image: url(:right-arrow.png); }"); expandedImage = new QImage(":expandedIcon"); collapsedImage = new QImage(":collapsedIcon"); }
CSearchAnalysisView::CSearchAnalysisView(CSearchAnalysisScene* scene, QWidget* parent) : QGraphicsView(scene, parent) { setFocusPolicy(Qt::WheelFocus); setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff); resize(sizeHint()); }
WbWidget::WbWidget(SxeSession* session, QWidget *parent) : QGraphicsView(parent) { newWbItem_ = 0; adding_ = 0; addVertex_ = false; strokeColor_ = Qt::black; fillColor_ = Qt::transparent; strokeWidth_ = 1; session_ = session; // setCacheMode(CacheBackground); setRenderHint(QPainter::Antialiasing); setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); // Make the scroll bars always stay on because otherwise the resize event can cause // an infinite loop as the effective size of the widget changes when scroll bars are // added/removed setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOn); setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOn); // create the scene scene_ = new WbScene(session_, this); scene_->setItemIndexMethod(QGraphicsScene::NoIndex); setRenderHint(QPainter::Antialiasing); setTransformationAnchor(AnchorUnderMouse); setResizeAnchor(AnchorViewCenter); setScene(scene_); // render the initial document rerender(); // rerender on update connect(session_, SIGNAL(documentUpdated(bool)), SLOT(handleDocumentUpdated(bool))); // add the initial items const QDomNodeList children = session_->document().documentElement().childNodes(); for(int i = 0; i < (int)children.length(); i++) { const QDomNode node = children.at(i); if(node.isElement()) { queueNodeInspection(node.toElement()); } } inspectNodes(); // add new items as nodes are added // remove/add items if corresponding nodes are moved connect(session_, SIGNAL(nodeAdded(QDomNode, bool)), SLOT(queueNodeInspection(QDomNode))); connect(session_, SIGNAL(nodeMoved(QDomNode, bool)), SLOT(queueNodeInspection(QDomNode))); // remove items if corresponding nodes are deleted connect(session_, SIGNAL(nodeToBeRemoved(QDomNode, bool)), SLOT(removeWbItem(QDomNode))); connect(session_, SIGNAL(nodeToBeRemoved(QDomNode, bool)), SLOT(checkForRemovalOfId(QDomNode))); // adjust the viewBox as necessary connect(session_, SIGNAL(nodeAdded(QDomNode, bool)), SLOT(checkForViewBoxChange(QDomNode))); connect(session_, SIGNAL(nodeMoved(QDomNode, bool)), SLOT(checkForViewBoxChange(QDomNode))); connect(session_, SIGNAL(chdataChanged(QDomNode, bool)), SLOT(checkForViewBoxChange(QDomNode))); // set the default mode to select setMode(Select); // set the initial size if(session_->document().documentElement().hasAttribute("viewBox")) checkForViewBoxChange(session_->document().documentElement().attributeNode("viewBox")); else { QSize size; QRectF rect = scene_->sceneRect(); size.setWidth(rect.x() + rect.width()); size.setHeight(rect.y() + rect.height()); if(size.width() > 0 && size.height() > 0) setSize(size); else setSize(QSize(400, 600)); } }
YigNetworkChannelView::YigNetworkChannelView(QWidget *parent) : QGraphicsView(parent) { QGLFormat glFormat( QGL::SampleBuffers ); //glFormat.setSwapInterval( 1 ); // set VSync QGLWidget* viewportGL = new QGLWidget( glFormat ); setViewportUpdateMode( QGraphicsView::FullViewportUpdate ); setViewport(viewportGL); setRenderHints(QPainter::Antialiasing); setOptimizationFlag(QGraphicsView::DontAdjustForAntialiasing, true); YigGraphicsScene* yigScene = new YigGraphicsScene; yigScene->setSceneRect(0, 0, 1920, 1200); setScene(yigScene); scaleFactor = 1.0; selectionRect = new QGraphicsRectItem( QRect( 0, 0, 0, 0 ) ); selectionRect->setPen( QColor( 0, 0, 0, 200 ) ); selectionRect->setFlag(QGraphicsItem::ItemIgnoresTransformations); //selectionRect->setBrush( QColor( 69, 139, 19, 40 ) ); QColor rectColor = YigColorKit::accent; rectColor.setAlpha(130); selectionRect->setBrush(rectColor); selectionRect->setZValue( 10000 ); scene()->addItem( selectionRect ); selectionRect->hide(); //glWidget->startRendering(); mActiveBool = false; setActiveView(mActiveBool); currentCableBool = false; mouseDownBool = false; cableCounter = 0; srand((unsigned) time(0)); /* #ifdef __APPLE__ verticalScrollBar()->setStyle(new QMacStyle); horizontalScrollBar()->setStyle(new QMacStyle); #else verticalScrollBar()->setStyle(new QGtkStyle); horizontalScrollBar()->setStyle(new QGtkStyle); #endif */ QPalette scrollPalette = verticalScrollBar()->palette(); scrollPalette.setColor(QPalette::Button, YigColorKit::focus2); verticalScrollBar()->setPalette(scrollPalette); scrollPalette = horizontalScrollBar()->palette(); scrollPalette.setColor(QPalette::Button, YigColorKit::focus2); horizontalScrollBar()->setPalette(scrollPalette); setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOn); setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOn); /* QLinearGradient gradient(0, 0, 0, parent->geometry().height()); gradient.setColorAt(0, YigColorKit::background2); gradient.setColorAt(0.005, QColor(255, 255, 255)); gradient.setColorAt(1, QColor(190, 190, 190)); gradient.setInterpolationMode(QGradient::ColorInterpolation); QBrush backgroundBrush(gradient); backgroundBrush.setStyle(Qt::LinearGradientPattern);*/ //QBrush backgroundBrush(QPixmap(":/images/gui/YigAttractorBackground.png")); //scene()->setBackgroundBrush(YigColorKit::background); //backgroundPixmap = scene()->addPixmap(YigAttractor::renderAttractor(width(), height())); modCableParent = new QGraphicsLineItem(); modCableParent->setZValue(-20); modCableParent->setFlag(QGraphicsItem::ItemHasNoContents, true); //modCableParent->setVisible(false); scene()->addItem(modCableParent); audioCableParent = new QGraphicsLineItem(); audioCableParent->setZValue(-5); //audioCableParent->setVisible(false); audioCableParent->setFlag(QGraphicsItem::ItemHasNoContents, true); scene()->addItem(audioCableParent); /* QObject::connect(this, SIGNAL(synthForGLAdded(int,QPointF)), glWidget->getGLThread(), SLOT(addSynth(int,QPointF)), Qt::QueuedConnection); QObject::connect(this, SIGNAL(synthForGLRemoved(int)), glWidget->getGLThread(), SLOT(removeSynth(int)), Qt::QueuedConnection); QObject::connect(this, SIGNAL(synthForGLMoved(int,QPointF)), glWidget->getGLThread(), SLOT(setSynthPos(int,QPointF)), Qt::QueuedConnection); */ //glWidget.lower(); //setupViewport(&glWidget); //scene()->setBackgroundBrush(Qt::transparent); //setAttribute(Qt::WA_TranslucentBackground); //setWindowFlags(Qt::FramelessWindowHint | Qt::WindowSystemMenuHint); //QPalette p = viewport()->palette(); //p.setColor(QPalette::Base, Qt::transparent); //viewport()->setPalette(p); //viewport()->setAutoFillBackground(false); //parent->setAttribute(Qt::WA_TranslucentBackground); //parent->setAutoFillBackground(false); //setStyleSheet("background-color: transparent;"); //lower(); //glWidget.raise(); //glWidget.lower(); //glWidget.setStyleSheet("background-color: transparent;"); //glParent = new QWidget(parent); //glWidget.setParent(glParent); //glParent->lower(); //glWidget.show(); setActiveView(true); setMouseTracking(true); setFrameStyle(0); mouseCounter = 0; centerOn(0, 0); show(); }
CWizDocumentListView::CWizDocumentListView(CWizExplorerApp& app, QWidget *parent /*= 0*/) : QListWidget(parent) , m_app(app) , m_dbMgr(app.databaseManager()) , m_tagList(NULL) { setFrameStyle(QFrame::NoFrame); setAttribute(Qt::WA_MacShowFocusRect, false); connect(this, SIGNAL(itemSelectionChanged()), SLOT(on_itemSelectionChanged())); // use custom scrollbar setVerticalScrollMode(QAbstractItemView::ScrollPerPixel); setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff); setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); m_vScroll = new CWizScrollBar(this); m_vScroll->syncWith(verticalScrollBar()); //QScrollAreaKineticScroller *newScroller = new QScrollAreaKineticScroller(); //newScroller->setWidget(this); //m_kinecticScroll = new QsKineticScroller(this); //m_kinecticScroll->enableKineticScrollFor(this); //#ifndef Q_OS_MAC // smoothly scroll m_vscrollCurrent = 0; m_vscrollOldPos = 0; connect(verticalScrollBar(), SIGNAL(valueChanged(int)), SLOT(on_vscroll_valueChanged(int))); connect(verticalScrollBar(), SIGNAL(actionTriggered(int)), SLOT(on_vscroll_actionTriggered(int))); connect(&m_vscrollTimer, SIGNAL(timeout()), SLOT(on_vscroll_update())); //#endif //Q_OS_MAC setItemDelegate(new CWizDocumentListViewDelegate(this)); // setup background QPalette pal = palette(); pal.setColor(QPalette::Base, QColor(247,247,247)); setPalette(pal); setStyle(::WizGetStyle(m_app.userSettings().skin())); connect(&m_dbMgr, SIGNAL(tagCreated(const WIZTAGDATA&)), \ SLOT(on_tag_created(const WIZTAGDATA&))); connect(&m_dbMgr, SIGNAL(tagModified(const WIZTAGDATA&, const WIZTAGDATA&)), \ SLOT(on_tag_modified(const WIZTAGDATA&, const WIZTAGDATA&))); connect(&m_dbMgr, SIGNAL(documentCreated(const WIZDOCUMENTDATA&)), \ SLOT(on_document_created(const WIZDOCUMENTDATA&))); connect(&m_dbMgr, SIGNAL(documentModified(const WIZDOCUMENTDATA&, const WIZDOCUMENTDATA&)), \ SLOT(on_document_modified(const WIZDOCUMENTDATA&, const WIZDOCUMENTDATA&))); connect(&m_dbMgr, SIGNAL(documentDeleted(const WIZDOCUMENTDATA&)), SLOT(on_document_deleted(const WIZDOCUMENTDATA&))); // message connect(&m_dbMgr.db(), SIGNAL(messageModified(const WIZMESSAGEDATA&, const WIZMESSAGEDATA&)), SLOT(on_message_modified(const WIZMESSAGEDATA&, const WIZMESSAGEDATA&))); connect(&m_dbMgr.db(), SIGNAL(messageDeleted(const WIZMESSAGEDATA&)), SLOT(on_message_deleted(const WIZMESSAGEDATA&))); // thumb cache m_thumbCache = new CWizThumbIndexCache(app); connect(m_thumbCache, SIGNAL(loaded(const WIZABSTRACT&)), SLOT(on_document_abstractLoaded(const WIZABSTRACT&))); QThread *thread = new QThread(); m_thumbCache->moveToThread(thread); thread->start(); // avatar downloader m_avatarDownloader = new CWizUserAvatarDownloaderHost(m_dbMgr.db().GetAvatarPath(), this); connect(m_avatarDownloader, SIGNAL(downloaded(const QString&)), SLOT(on_userAvatar_downloaded(const QString&))); setDragDropMode(QAbstractItemView::DragDrop); setDragEnabled(true); viewport()->setAcceptDrops(true); setSelectionMode(QAbstractItemView::ExtendedSelection); // message context menu m_menuMessage = new QMenu(this); m_menuMessage->addAction(WIZACTION_LIST_MESSAGE_MARK_READ, this, SLOT(on_action_message_mark_read())); m_menuMessage->addAction(WIZACTION_LIST_MESSAGE_DELETE, this, SLOT(on_action_message_delete())); // document context menu m_menuDocument = new QMenu(this); m_menuDocument->addAction(WIZACTION_LIST_TAGS, this, SLOT(on_action_selectTags())); m_menuDocument->addSeparator(); QAction* actionDeleteDoc = m_menuDocument->addAction(WIZACTION_LIST_DELETE, this, SLOT(on_action_deleteDocument()), QKeySequence::Delete); QAction* actionMoveDoc = m_menuDocument->addAction(WIZACTION_LIST_MOVE_DOCUMENT, this, SLOT(on_action_moveDocument()), QKeySequence("Ctrl+Shift+M")); QAction* actionCopyDoc = m_menuDocument->addAction(WIZACTION_LIST_COPY_DOCUMENT, this, SLOT(on_action_copyDocument()), QKeySequence("Ctrl+Shift+C")); // not implement, hide currently. actionCopyDoc->setVisible(false); // Add to widget's actions list addAction(actionDeleteDoc); addAction(actionMoveDoc); addAction(actionCopyDoc); actionDeleteDoc->setShortcutContext(Qt::WidgetWithChildrenShortcut); actionMoveDoc->setShortcutContext(Qt::WidgetWithChildrenShortcut); //actionCopyDoc->setShortcutContext(Qt::WidgetWithChildrenShortcut); //m_actionEncryptDocument = new QAction(tr("Encrypt Document"), m_menu); //connect(m_actionEncryptDocument, SIGNAL(triggered()), SLOT(on_action_encryptDocument())); //m_menu->addAction(m_actionEncryptDocument); }
StelMainView::StelMainView(QWidget* parent) : QGraphicsView(parent), guiItem(NULL), gui(NULL), flagInvertScreenShotColors(false), flagOverwriteScreenshots(false), screenShotPrefix("stellarium-"), screenShotDir(""), cursorTimeout(-1.f), flagCursorTimeout(false), minFpsTimer(NULL), maxfps(10000.f) { StelApp::initStatic(); // Can't create 2 StelMainView instances Q_ASSERT(!singleton); singleton = this; setWindowIcon(QIcon(":/mainWindow/icon.bmp")); initTitleI18n(); setObjectName("Mainview"); // Allows for precise FPS control setViewportUpdateMode(QGraphicsView::NoViewportUpdate); setFrameShape(QFrame::NoFrame); setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff); setFocusPolicy(Qt::StrongFocus); connect(this, SIGNAL(screenshotRequested()), this, SLOT(doScreenshot())); lastEventTimeSec = 0; #if STEL_USE_NEW_OPENGL_WIDGETS // Primary test for OpenGL existence if (QSurfaceFormat::defaultFormat().majorVersion() < 2) { qWarning() << "No OpenGL 2 support on this system. Aborting."; QMessageBox::critical(0, "Stellarium", q_("No OpenGL 2 found on this system. Please upgrade hardware or use MESA or an older version."), QMessageBox::Abort, QMessageBox::Abort); exit(0); } //QSurfaceFormat format(); //// TBD: What options shall be default? //QSurfaceFormat::setDefaultFormat(format); ////QOpenGLContext* context=new QOpenGLContext::create(); glWidget = new StelQOpenGLWidget(this); //glWidget->setFormat(format); #else // Primary test for OpenGL existence if (QGLFormat::openGLVersionFlags() < QGLFormat::OpenGL_Version_2_1) { qWarning() << "No OpenGL 2.1 support on this system. Aborting."; QMessageBox::critical(0, "Stellarium", q_("No OpenGL 2 found on this system. Please upgrade hardware or use MESA or an older version."), QMessageBox::Abort, QMessageBox::Abort); exit(1); } // Create an openGL viewport QGLFormat glFormat(QGL::StencilBuffer | QGL::DepthBuffer | QGL::DoubleBuffer); // Even if setting a version here, it is ignored in StelQGLWidget()! // TBD: Maybe this must make a differentiation between OpenGL and OpenGL ES! // glFormat.setVersion(2, 1); QGLContext* context=new QGLContext(glFormat); if (context->format() != glFormat) { qWarning() << "Cannot provide OpenGL context. Apparently insufficient OpenGL resources on this system."; QMessageBox::critical(0, "Stellarium", q_("Cannot acquire necessary OpenGL resources."), QMessageBox::Abort, QMessageBox::Abort); exit(1); } glWidget = new StelQGLWidget(context, this); // This does not return the version number set previously! // qDebug() << "glWidget.context.format.version, result:" << glWidget->context()->format().majorVersion() << "." << glWidget->context()->format().minorVersion(); #endif setViewport(glWidget); setScene(new QGraphicsScene(this)); scene()->setItemIndexMethod(QGraphicsScene::NoIndex); rootItem = new QGraphicsWidget(); rootItem->setFocusPolicy(Qt::NoFocus); // Workaround (see Bug #940638) Although we have already explicitly set // LC_NUMERIC to "C" in main.cpp there seems to be a bug in OpenGL where // it will silently reset LC_NUMERIC to the value of LC_ALL during OpenGL // initialization. This has been observed on Ubuntu 11.10 under certain // circumstances, so here we set it again just to be on the safe side. setlocale(LC_NUMERIC, "C"); // End workaround }
PostWindow::PostWindow(QWidget* parent): QPlainTextEdit(parent) { setReadOnly(true); setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOn); QRect availableScreenRect = qApp->desktop()->availableGeometry(this); mSizeHint = QSize( availableScreenRect.width() / 2.7, 300 ); QAction * action; QAction *copyAction = new QAction(tr("Copy"), this); connect(copyAction, SIGNAL(triggered()), this, SLOT(copy())); copyAction->setShortcut( Main::settings()->shortcut("IDE/shortcuts/copy") ); copyAction->setShortcutContext( Qt::WidgetShortcut ); addAction(copyAction); mClearAction = new QAction(tr("Clear"), this); connect(mClearAction, SIGNAL(triggered()), this, SLOT(clear())); addAction(mClearAction); action = new QAction(this); action->setSeparator(true); addAction(action); action = new QAction(tr("Enlarge Post Font"), this); action->setIconText("+"); action->setShortcut(tr("Ctrl++", "Enlarge Font")); action->setShortcutContext( Qt::WidgetShortcut ); action->setToolTip(tr("Enlarge font")); connect(action, SIGNAL(triggered()), this, SLOT(zoomIn())); addAction(action); action = new QAction(tr("Shrink Post Font"), this); action->setIconText("-"); action->setShortcut(tr("Ctrl+-", "Shrink Font")); action->setShortcutContext( Qt::WidgetShortcut ); action->setToolTip(tr("Shrink font")); connect(action, SIGNAL(triggered()), this, SLOT(zoomOut())); addAction(action); action = new QAction(this); action->setSeparator(true); addAction(action); mLineWrapAction = action = new QAction(tr("Wrap Text"), this); action->setCheckable(true); addAction(action); connect( action, SIGNAL(triggered(bool)), this, SLOT(setLineWrap(bool)) ); mAutoScrollAction = new QAction(tr("Auto Scroll"), this); mAutoScrollAction->setToolTip(tr("Scroll to bottom on new posts")); mAutoScrollAction->setCheckable(true); mAutoScrollAction->setChecked(true); addAction(mAutoScrollAction); setContextMenuPolicy(Qt::ActionsContextMenu); connect(this, SIGNAL(scrollToBottomRequest()), this, SLOT(scrollToBottom()), Qt::QueuedConnection); connect(mAutoScrollAction, SIGNAL(triggered(bool)), this, SLOT(onAutoScrollTriggered(bool))); applySettings( Main::settings() ); }
QgsMapCanvas::QgsMapCanvas( QWidget * parent ) : QGraphicsView( parent ) , mCanvasProperties( new CanvasProperties ) , mMap( nullptr ) , mFrozen( false ) , mRefreshScheduled( false ) , mRenderFlag( true ) // by default, the canvas is rendered , mCurrentLayer( nullptr ) , mScene( nullptr ) , mMapTool( nullptr ) , mLastNonZoomMapTool( nullptr ) , mLastExtentIndex( -1 ) , mWheelZoomFactor( 2.0 ) , mJob( nullptr ) , mJobCancelled( false ) , mLabelingResults( nullptr ) , mUseParallelRendering( false ) , mDrawRenderingStats( false ) , mCache( nullptr ) , mResizeTimer( nullptr ) , mPreviewEffect( nullptr ) , mSnappingUtils( nullptr ) , mScaleLocked( false ) , mExpressionContextScope( tr( "Map Canvas" ) ) , mZoomDragging( false ) { mScene = new QGraphicsScene(); setScene( mScene ); setHorizontalScrollBarPolicy( Qt::ScrollBarAlwaysOff ); setVerticalScrollBarPolicy( Qt::ScrollBarAlwaysOff ); setMouseTracking( true ); setFocusPolicy( Qt::StrongFocus ); mResizeTimer = new QTimer( this ); mResizeTimer->setSingleShot( true ); connect( mResizeTimer, SIGNAL( timeout() ), this, SLOT( refresh() ) ); // create map canvas item which will show the map mMap = new QgsMapCanvasMap( this ); // project handling connect( QgsProject::instance(), SIGNAL( readProject( const QDomDocument & ) ), this, SLOT( readProject( const QDomDocument & ) ) ); connect( QgsProject::instance(), SIGNAL( writeProject( QDomDocument & ) ), this, SLOT( writeProject( QDomDocument & ) ) ); mSettings.setFlag( QgsMapSettings::DrawEditingInfo ); mSettings.setFlag( QgsMapSettings::UseRenderingOptimization ); mSettings.setFlag( QgsMapSettings::RenderPartialOutput ); //segmentation parameters QSettings settings; double segmentationTolerance = settings.value( QStringLiteral( "/qgis/segmentationTolerance" ), "0.01745" ).toDouble(); QgsAbstractGeometry::SegmentationToleranceType toleranceType = QgsAbstractGeometry::SegmentationToleranceType( settings.value( QStringLiteral( "/qgis/segmentationToleranceType" ), 0 ).toInt() ); mSettings.setSegmentationTolerance( segmentationTolerance ); mSettings.setSegmentationToleranceType( toleranceType ); mWheelZoomFactor = settings.value( QStringLiteral( "/qgis/zoom_factor" ), 2 ).toDouble(); QSize s = viewport()->size(); mSettings.setOutputSize( s ); setSceneRect( 0, 0, s.width(), s.height() ); mScene->setSceneRect( QRectF( 0, 0, s.width(), s.height() ) ); moveCanvasContents( true ); connect( &mMapUpdateTimer, SIGNAL( timeout() ), SLOT( mapUpdateTimeout() ) ); mMapUpdateTimer.setInterval( 250 ); #ifdef Q_OS_WIN // Enable touch event on Windows. // Qt on Windows needs to be told it can take touch events or else it ignores them. grabGesture( Qt::PinchGesture ); viewport()->setAttribute( Qt::WA_AcceptTouchEvents ); #endif mPreviewEffect = new QgsPreviewEffect( this ); viewport()->setGraphicsEffect( mPreviewEffect ); QPixmap zoomPixmap = QPixmap(( const char ** )( zoom_in ) ); mZoomCursor = QCursor( zoomPixmap, 7, 7 ); setInteractive( false ); refresh(); } // QgsMapCanvas ctor
PadNavigator::PadNavigator( QWidget *parent) : QGraphicsView(parent) { QSize size(6,2); // Pad item this->pad = new FlippablePad(size); // Selection item RoundRectItem *selectionItem = new RoundRectItem(QRectF(-110, -110, 220, 220), Qt::gray, pad); selectionItem->setZValue(0.5); // Selection animation QPropertyAnimation *smoothXSelection = new QPropertyAnimation(selectionItem, "x"); QPropertyAnimation *smoothYSelection = new QPropertyAnimation(selectionItem, "y"); smoothXSelection->setDuration(100); smoothYSelection->setDuration(100); smoothXSelection->setEasingCurve(QEasingCurve::InCurve); smoothYSelection->setEasingCurve(QEasingCurve::InCurve); // Build the state machine QStateMachine *stateMachine = new QStateMachine(this); QState *frontState = new QState(stateMachine); frontState->assignProperty(pad, "fill", false); frontState->assignProperty(selectionItem, "visible", true); stateMachine->addDefaultAnimation(smoothXSelection); stateMachine->addDefaultAnimation(smoothYSelection); stateMachine->setInitialState(frontState); // Create substates for each icon; store in temporary grid. int columns = size.width(); int rows = size.height(); QVector< QVector< QState * > > stateGrid; stateGrid.resize(rows); for (int y = 0; y < rows; ++y) { stateGrid[y].resize(columns); for (int x = 0; x < columns; ++x) stateGrid[y][x] = new QState(frontState); } frontState->setInitialState(stateGrid[0][0]); selectionItem->setPos(pad->iconAt(0, 0)->pos()); // Enable key navigation using state transitions for (int y = 0; y < rows; ++y) { for (int x = 0; x < columns; ++x) { QState *state = stateGrid[y][x]; QKeyEventTransition *rightTransition = new QKeyEventTransition(this, QEvent::KeyPress, Qt::Key_Right, state); QKeyEventTransition *leftTransition = new QKeyEventTransition(this, QEvent::KeyPress, Qt::Key_Left, state); QKeyEventTransition *downTransition = new QKeyEventTransition(this, QEvent::KeyPress, Qt::Key_Down, state); QKeyEventTransition *upTransition = new QKeyEventTransition(this, QEvent::KeyPress, Qt::Key_Up, state); rightTransition->setTargetState(stateGrid[y][(x + 1) % columns]); leftTransition->setTargetState(stateGrid[y][((x - 1) + columns) % columns]); downTransition->setTargetState(stateGrid[(y + 1) % rows][x]); upTransition->setTargetState(stateGrid[((y - 1) + rows) % rows][x]); RoundRectItem *icon = pad->iconAt(x, y); state->assignProperty(selectionItem, "x", icon->x()); state->assignProperty(selectionItem, "y", icon->y()); } } // Scene QGraphicsScene *scene = new QGraphicsScene(this); scene->setItemIndexMethod(QGraphicsScene::NoIndex); scene->addItem(pad); scene->setSceneRect(scene->itemsBoundingRect()); setScene(scene); // View setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff); setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); setMinimumSize(50, 50); setCacheMode(CacheBackground); setRenderHints(QPainter::Antialiasing | QPainter::SmoothPixmapTransform | QPainter::TextAntialiasing); stateMachine->start(); }
SmallPokeTextEdit::SmallPokeTextEdit() { setMinimumSize(QSize(0, 0)); setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff); }
void MainView::construct() { m_scene = new QGraphicsScene; #ifndef QT_NO_OPENGL if (m_enableOpenGL) { qDebug() << "OpenGL enabled"; setViewport(new QGLWidget); // Qt doc says: This is the preferred update mode for // viewports that do not support partial updates, such as QGLWidget... setViewportUpdateMode(QGraphicsView::FullViewportUpdate); } else #endif setViewportUpdateMode(QGraphicsView::BoundingRectViewportUpdate); setScene(m_scene); m_scene->setItemIndexMethod(QGraphicsScene::NoIndex); //setCacheMode(QGraphicsView::CacheBackground); setAlignment(Qt::AlignLeft | Qt::AlignTop); // Turn off automatic background setAttribute(Qt::WA_OpaquePaintEvent); setAttribute(Qt::WA_NoBackground); setAttribute(Qt::WA_NoSystemBackground); setAutoFillBackground(false); //Background m_backGround = new BackgroundItem("background.svg"); m_scene->addItem(m_backGround); m_backGround->setZValue(0); //Menu m_menu = new Menu(this); m_scene->addItem(m_menu); //Add menu to the scene directly m_menu->setZValue(10); //Bring to front m_mainLayout = new QGraphicsLinearLayout(Qt::Vertical); m_mainLayout->setContentsMargins(0,0,0,0); m_mainLayout->setSpacing(0); m_mainWidget = new QGraphicsWidget; m_mainWidget->setLayout(m_mainLayout); m_mainWidget->setZValue(1); m_scene->addItem(m_mainWidget); //Topbar m_topBar = new TopBar(this, 0); m_mainLayout->addItem(m_topBar); m_topBar->setZValue(1); connect(m_topBar, SIGNAL(clicked(bool)), m_menu, SLOT(menuShowHide())); setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff); setContentsMargins(0,0,0,0); setViewportMargins(0,0,0,0); setFrameShape(QFrame::NoFrame); fpsReset(); m_fpsUpdated.start(); }
NAttributeTree::NAttributeTree(QWidget *parent) : QTreeWidget(parent) { this->setFont(global.getGuiFont(font())); filterPosition = -1; // setup options this->setEditTriggers(QAbstractItemView::NoEditTriggers); this->setSelectionBehavior(QAbstractItemView::SelectRows); this->setSelectionMode(QAbstractItemView::SingleSelection); this->setRootIsDecorated(true); this->setSortingEnabled(false); this->header()->setVisible(false); //this->setStyleSheet("QTreeWidget { border: none; background-color:transparent; }"); // Build the root item root = new QTreeWidgetItem(this); QIcon icon(":attributes.png"); root->setIcon(0,icon); root->setData(0, Qt::UserRole, "root"); root->setData(0, Qt::DisplayRole, tr("Attributes")); QFont font = root->font(0); font.setBold(true); root->setFont(0,font); this->setMinimumHeight(1); this->addTopLevelItem(root); setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff); setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); connect(this, SIGNAL(itemExpanded(QTreeWidgetItem*)), this, SLOT(calculateHeight())); connect(this, SIGNAL(itemCollapsed(QTreeWidgetItem*)), this, SLOT(calculateHeight())); connect(this, SIGNAL(itemSelectionChanged()), this, SLOT(buildSelection())); // Allocate memory for everything needed createdRoot = new QTreeWidgetItem(root); lastUpdatedRoot = new QTreeWidgetItem(root); containsRoot = new QTreeWidgetItem(root); sourceRoot = new QTreeWidgetItem(root); createdSinceRoot = new QTreeWidgetItem(createdRoot); createdSinceToday = new QTreeWidgetItem(createdSinceRoot); createdSinceYesterday = new QTreeWidgetItem(createdSinceRoot); createdSinceThisWeek = new QTreeWidgetItem(createdSinceRoot); createdSinceLastWeek = new QTreeWidgetItem(createdSinceRoot); createdSinceThisMonth = new QTreeWidgetItem(createdSinceRoot); createdSinceLastMonth = new QTreeWidgetItem(createdSinceRoot); createdSinceThisYear = new QTreeWidgetItem(createdSinceRoot); createdSinceLastYear = new QTreeWidgetItem(createdSinceRoot); createdBeforeRoot = new QTreeWidgetItem(createdRoot); createdBeforeToday = new QTreeWidgetItem(createdBeforeRoot); createdBeforeYesterday = new QTreeWidgetItem(createdBeforeRoot); createdBeforeThisWeek = new QTreeWidgetItem(createdBeforeRoot); createdBeforeLastWeek = new QTreeWidgetItem(createdBeforeRoot); createdBeforeThisMonth = new QTreeWidgetItem(createdBeforeRoot); createdBeforeLastMonth = new QTreeWidgetItem(createdBeforeRoot); createdBeforeThisYear = new QTreeWidgetItem(createdBeforeRoot); createdBeforeLastYear = new QTreeWidgetItem(createdBeforeRoot); lastUpdatedSinceRoot = new QTreeWidgetItem(lastUpdatedRoot); lastUpdatedSinceToday = new QTreeWidgetItem(lastUpdatedSinceRoot); lastUpdatedSinceYesterday = new QTreeWidgetItem(lastUpdatedSinceRoot); lastUpdatedSinceThisWeek = new QTreeWidgetItem(lastUpdatedSinceRoot); lastUpdatedSinceLastWeek = new QTreeWidgetItem(lastUpdatedSinceRoot); lastUpdatedSinceThisMonth = new QTreeWidgetItem(lastUpdatedSinceRoot); lastUpdatedSinceLastMonth = new QTreeWidgetItem(lastUpdatedSinceRoot); lastUpdatedSinceThisYear = new QTreeWidgetItem(lastUpdatedSinceRoot); lastUpdatedSinceLastYear = new QTreeWidgetItem(lastUpdatedSinceRoot); lastUpdatedBeforeRoot = new QTreeWidgetItem(lastUpdatedRoot); lastUpdatedBeforeToday = new QTreeWidgetItem(lastUpdatedBeforeRoot); lastUpdatedBeforeYesterday = new QTreeWidgetItem(lastUpdatedBeforeRoot); lastUpdatedBeforeThisWeek = new QTreeWidgetItem(lastUpdatedBeforeRoot); lastUpdatedBeforeLastWeek = new QTreeWidgetItem(lastUpdatedBeforeRoot); lastUpdatedBeforeThisMonth = new QTreeWidgetItem(lastUpdatedBeforeRoot); lastUpdatedBeforeLastMonth = new QTreeWidgetItem(lastUpdatedBeforeRoot); lastUpdatedBeforeThisYear = new QTreeWidgetItem(lastUpdatedBeforeRoot); lastUpdatedBeforeLastYear = new QTreeWidgetItem(lastUpdatedBeforeRoot); containsImages = new QTreeWidgetItem(containsRoot); containsAudio = new QTreeWidgetItem(containsRoot); containsInk = new QTreeWidgetItem(containsRoot); containsEncryptedText = new QTreeWidgetItem(containsRoot); containsToDoItems = new QTreeWidgetItem(containsRoot); containsUnfinishedToDoItems = new QTreeWidgetItem(containsRoot); containsFinishedToDoItems = new QTreeWidgetItem(containsRoot); containsPDFDocument = new QTreeWidgetItem(containsRoot); containsAttachment = new QTreeWidgetItem(containsRoot); sourceEmailedToEvernote = new QTreeWidgetItem(sourceRoot); sourceEmail = new QTreeWidgetItem(sourceRoot); sourceWebPage = new QTreeWidgetItem(sourceRoot); sourceMobile = new QTreeWidgetItem(sourceRoot); sourceAnotherApplication = new QTreeWidgetItem(sourceRoot); // Start building selection criteria createdRoot->setText(0, tr("Created")); createdRoot->setData(0, Qt::UserRole, 0); createdSinceRoot->setText(0, tr("Since")); createdSinceRoot->setData(0, Qt::UserRole, 0); createdRoot->addChild(createdSinceRoot); createdSinceToday->setText(0, tr("Today")); createdSinceToday->setData(0, Qt::UserRole, CREATED_SINCE_TODAY); createdSinceRoot->addChild(createdSinceToday); createdSinceYesterday->setText(0, tr("Yesterday")); createdSinceYesterday->setData(0, Qt::UserRole, CREATED_SINCE_YESTERDAY); createdSinceRoot->addChild(createdSinceYesterday); createdSinceThisWeek->setText(0, tr("This week")); createdSinceThisWeek->setData(0, Qt::UserRole, CREATED_SINCE_THIS_WEEK); createdSinceRoot->addChild(createdSinceThisWeek); createdSinceLastWeek->setText(0, tr("Last week")); createdSinceLastWeek->setData(0, Qt::UserRole, CREATED_SINCE_LAST_WEEK); createdSinceRoot->addChild(createdSinceLastWeek); createdSinceThisMonth->setText(0, tr("This Month")); createdSinceThisMonth->setData(0, Qt::UserRole, CREATED_SINCE_THIS_MONTH); createdSinceRoot->addChild(createdSinceThisMonth); createdSinceLastMonth->setText(0, tr("Last Month")); createdSinceLastMonth->setData(0, Qt::UserRole, CREATED_SINCE_LAST_MONTH); createdSinceRoot->addChild(createdSinceLastMonth); createdSinceThisYear->setText(0, tr("This Year")); createdSinceThisYear->setData(0, Qt::UserRole, CREATED_SINCE_THIS_YEAR); createdSinceRoot->addChild(createdSinceThisYear); createdSinceLastYear->setText(0, tr("Last Year")); createdSinceLastYear->setData(0, Qt::UserRole, CREATED_SINCE_LAST_YEAR); createdSinceRoot->addChild(createdSinceLastYear); createdBeforeRoot->setText(0, tr("Before")); createdBeforeRoot->setData(0, Qt::UserRole, 0); createdRoot->addChild(createdBeforeRoot); createdBeforeToday->setText(0, tr("Today")); createdBeforeToday->setData(0, Qt::UserRole, CREATED_BEFORE_TODAY); createdBeforeRoot->addChild(createdBeforeToday); createdBeforeYesterday->setText(0, tr("Yesterday")); createdBeforeYesterday->setData(0, Qt::UserRole, CREATED_BEFORE_YESTERDAY); createdBeforeRoot->addChild(createdBeforeYesterday); createdBeforeThisWeek->setText(0, tr("This week")); createdBeforeThisWeek->setData(0, Qt::UserRole, CREATED_BEFORE_THIS_WEEK); createdBeforeRoot->addChild(createdBeforeThisWeek); createdBeforeLastWeek->setText(0, tr("Last week")); createdBeforeLastWeek->setData(0, Qt::UserRole, CREATED_BEFORE_LAST_WEEK); createdBeforeRoot->addChild(createdBeforeLastWeek); createdBeforeThisMonth->setText(0, tr("This Month")); createdBeforeThisMonth->setData(0, Qt::UserRole, CREATED_BEFORE_THIS_MONTH); createdBeforeRoot->addChild(createdSinceThisMonth); createdBeforeLastMonth->setText(0, tr("Last Month")); createdBeforeLastMonth->setData(0, Qt::UserRole, CREATED_BEFORE_LAST_MONTH); createdBeforeRoot->addChild(createdBeforeLastMonth); createdBeforeThisYear->setText(0, tr("This Year")); createdBeforeThisYear->setData(0, Qt::UserRole, CREATED_BEFORE_THIS_YEAR); createdBeforeRoot->addChild(createdBeforeThisYear); createdBeforeLastYear->setText(0, tr("Last Year")); createdBeforeLastYear->setData(0, Qt::UserRole, CREATED_BEFORE_LAST_YEAR); createdBeforeRoot->addChild(createdBeforeLastYear); //** Start doing the "Last Modified" selection criteria lastUpdatedRoot->setText(0, tr("Last Modified")); lastUpdatedRoot->setData(0, Qt::UserRole, 0); lastUpdatedSinceRoot->setText(0, tr("Since")); lastUpdatedSinceRoot->setData(0, Qt::UserRole, 0); lastUpdatedRoot->addChild(lastUpdatedSinceRoot); lastUpdatedSinceToday->setText(0, tr("Today")); lastUpdatedSinceToday->setData(0, Qt::UserRole, MODIFIED_SINCE_TODAY); lastUpdatedSinceRoot->addChild(lastUpdatedSinceToday); lastUpdatedSinceYesterday->setText(0, tr("Yesterday")); lastUpdatedSinceYesterday->setData(0, Qt::UserRole, MODIFIED_SINCE_YESTERDAY); lastUpdatedSinceRoot->addChild(lastUpdatedSinceYesterday); lastUpdatedSinceThisWeek->setText(0, tr("This week")); lastUpdatedSinceThisWeek->setData(0, Qt::UserRole, MODIFIED_SINCE_THIS_WEEK); lastUpdatedSinceRoot->addChild(lastUpdatedSinceThisWeek); lastUpdatedSinceLastWeek->setText(0, tr("Last week")); lastUpdatedSinceLastWeek->setData(0, Qt::UserRole, MODIFIED_SINCE_LAST_WEEK); lastUpdatedSinceRoot->addChild(lastUpdatedSinceLastWeek); lastUpdatedSinceThisMonth->setText(0, tr("This Month")); lastUpdatedSinceThisMonth->setData(0, Qt::UserRole, MODIFIED_SINCE_THIS_MONTH); lastUpdatedSinceRoot->addChild(lastUpdatedSinceThisMonth); lastUpdatedSinceLastMonth->setText(0, tr("Last Month")); lastUpdatedSinceLastMonth->setData(0, Qt::UserRole, MODIFIED_SINCE_LAST_MONTH); lastUpdatedSinceRoot->addChild(lastUpdatedSinceLastMonth); lastUpdatedSinceThisYear->setText(0, tr("This Year")); lastUpdatedSinceThisYear->setData(0, Qt::UserRole, MODIFIED_SINCE_THIS_YEAR); lastUpdatedSinceRoot->addChild(lastUpdatedSinceThisYear); lastUpdatedSinceLastYear->setText(0, tr("Last Year")); lastUpdatedSinceLastYear->setData(0, Qt::UserRole, MODIFIED_SINCE_LAST_YEAR); lastUpdatedSinceRoot->addChild(lastUpdatedSinceLastYear); lastUpdatedBeforeRoot->setText(0, tr("Before")); lastUpdatedBeforeRoot->setData(0, Qt::UserRole, 0); lastUpdatedRoot->addChild(lastUpdatedBeforeRoot); lastUpdatedBeforeToday->setText(0, tr("Today")); lastUpdatedBeforeToday->setData(0, Qt::UserRole, MODIFIED_BEFORE_TODAY); lastUpdatedBeforeRoot->addChild(lastUpdatedBeforeToday); lastUpdatedBeforeYesterday->setText(0, tr("Yesterday")); lastUpdatedBeforeYesterday->setData(0, Qt::UserRole, MODIFIED_BEFORE_YESTERDAY); lastUpdatedBeforeRoot->addChild(lastUpdatedBeforeYesterday); lastUpdatedBeforeThisWeek->setText(0, tr("This week")); lastUpdatedBeforeThisWeek->setData(0, Qt::UserRole, MODIFIED_BEFORE_THIS_WEEK); lastUpdatedBeforeRoot->addChild(lastUpdatedBeforeThisWeek); lastUpdatedBeforeLastWeek->setText(0, tr("Last week")); lastUpdatedBeforeLastWeek->setData(0, Qt::UserRole, MODIFIED_BEFORE_LAST_WEEK); lastUpdatedBeforeRoot->addChild(lastUpdatedBeforeLastWeek); lastUpdatedBeforeThisMonth->setText(0, tr("This Month")); lastUpdatedBeforeThisMonth->setData(0, Qt::UserRole, MODIFIED_BEFORE_THIS_MONTH); lastUpdatedBeforeRoot->addChild(lastUpdatedBeforeThisMonth); lastUpdatedBeforeLastMonth->setText(0, tr("Last Month")); lastUpdatedBeforeLastMonth->setData(0, Qt::UserRole, MODIFIED_BEFORE_LAST_MONTH); lastUpdatedBeforeRoot->addChild(lastUpdatedBeforeLastMonth); lastUpdatedBeforeThisYear->setText(0, tr("This Year")); lastUpdatedBeforeThisYear->setData(0, Qt::UserRole, MODIFIED_BEFORE_THIS_YEAR); lastUpdatedBeforeRoot->addChild(lastUpdatedBeforeThisYear); lastUpdatedBeforeLastYear->setText(0, tr("Last Year")); lastUpdatedBeforeLastYear->setData(0, Qt::UserRole, MODIFIED_BEFORE_LAST_YEAR); lastUpdatedBeforeRoot->addChild(lastUpdatedBeforeLastYear); //*** Contains selection criteria this->containsRoot->setText(0, tr("Contains")); this->containsRoot->setData(0,Qt::UserRole, 0); this->containsImages->setText(0, tr("Images")); this->containsImages->setData(0, Qt::UserRole, CONTAINS_IMAGES); this->containsRoot->addChild(containsImages); this->containsAudio->setText(0, tr("Audio")); this->containsAudio->setData(0, Qt::UserRole, CONTAINS_AUDIO); this->containsRoot->addChild(containsAudio); this->containsInk->setText(0, tr("Ink")); this->containsInk->setData(0, Qt::UserRole, CONTAINS_INK); this->containsRoot->addChild(containsInk); this->containsEncryptedText->setText(0, tr("Encrypted Text")); this->containsEncryptedText->setData(0, Qt::UserRole, CONTAINS_ENCRYPTED_TEXT); this->containsRoot->addChild(containsEncryptedText); this->containsToDoItems->setText(0, tr("To-do items")); this->containsToDoItems->setData(0, Qt::UserRole, CONTAINS_TODO_ITEMS); this->containsRoot->addChild(containsUnfinishedToDoItems); this->containsUnfinishedToDoItems->setText(0, tr("Unfinished to-do items")); this->containsUnfinishedToDoItems->setData(0, Qt::UserRole, CONTAINS_UNFINISHED_TODO_ITEMS); this->containsRoot->addChild(containsUnfinishedToDoItems); this->containsFinishedToDoItems->setText(0, tr("Finished to-do items")); this->containsFinishedToDoItems->setData(0, Qt::UserRole, CONTAINS_FINISHED_TODO_ITEMS); this->containsRoot->addChild(containsFinishedToDoItems); this->containsPDFDocument->setText(0, tr("PDF document")); this->containsPDFDocument->setData(0, Qt::UserRole, CONTAINS_PDF_DOCUMENT); this->containsRoot->addChild(containsPDFDocument); this->containsAttachment->setText(0, tr("Attachment")); this->containsAttachment->setData(0, Qt::UserRole, CONTAINS_ATTACHMENT); this->containsRoot->addChild(containsAttachment); //*** Source selection criteria this->sourceRoot->setText(0, tr("Source")); this->sourceRoot->setData(0,Qt::UserRole, 0); this->sourceEmailedToEvernote->setText(0, tr("Emailed to Evernote")); this->sourceEmailedToEvernote->setData(0, Qt::UserRole, SOURCE_EMAILED_TO_EVERNOTE); this->sourceRoot->addChild(sourceEmailedToEvernote); this->sourceEmail->setText(0, tr("Email")); this->sourceEmail->setData(0, Qt::UserRole, SOURCE_EMAIL); this->sourceRoot->addChild(sourceEmail); this->sourceWebPage->setText(0, tr("Web page")); this->sourceWebPage->setData(0, Qt::UserRole, SOURCE_WEB_PAGE); this->sourceRoot->addChild(sourceWebPage); this->sourceMobile->setText(0, tr("Mobile")); this->sourceMobile->setData(0, Qt::UserRole, SOURCE_MOBILE); this->sourceRoot->addChild(sourceMobile); this->sourceAnotherApplication->setText(0, tr("Another application")); this->sourceAnotherApplication->setData(0, Qt::UserRole, SOURCE_ANOTHER_APPLICATION); this->sourceRoot->addChild(sourceAnotherApplication); // Add the options to the root root->addChild(createdRoot); root->addChild(lastUpdatedRoot); root->addChild(containsRoot); root->addChild(sourceRoot); root->setExpanded(true); this->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Preferred); this->setFrameShape(QFrame::NoFrame); expandedImage = new QImage(":expandedIcon"); collapsedImage = new QImage(":collapsedIcon"); }
/**Constructor*/ Game::Game(QTimer *t, QString n) { setFixedSize(500, 500); setFocus(); //removes scroll bars setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff); //creates a new scene and sets it in a fixed location gScene = new QGraphicsScene(); gScene->setSceneRect(0, 0, 500, 500); setScene(gScene); //creates the Pixmaps of all the "things" for their constructors yPix = new QPixmap("img/yoshiw2.png"); bPix = new QPixmap("img/bg.png"); hPix = new QPixmap("img/heart.png"); coinPix = new QPixmap("img/coin.png"); goombaPix = new QPixmap("img/goombaw1.png"); koopaPix = new QPixmap("img/koopaw1r.png"); kamekLPix = new QPixmap("img/kamek1.png"); kamekRPix = new QPixmap("img/kamek21.png"); billLPix = new QPixmap("img/lbill.png"); billRPix = new QPixmap("img/rbill.png"); magicPix = new QPixmap("img/magic.png"); boltPix = new QPixmap("img/bolt.png"); windPix = new QPixmap("img/wind.png"); /*creates "things"*/ //background background = new Bg(bPix, 0, 0, 0, 0); //adds Yoshi (playable character) to list yoshi = new Yoshi(yPix, 225, 405, 1, 1); things.push_back(yoshi); yoshi->setZValue(3); //coin on stats panel (lava) sCoin = new Coin(coinPix, 170, 460, 0, 0); sCoin->setZValue(2); //heart heart = new Heart(hPix, 20, 465, 0, 0); heart->setZValue(2); /*create text*/ //font size font.setPixelSize(30); fontT.setPixelSize(14); //word "Score" sLabel = new QGraphicsSimpleTextItem("Score: "); sLabel->setPos(300, 450); sLabel->setFont(fontT); sLabel->setZValue(3); nameLabel = new QGraphicsSimpleTextItem("Name: "); nameLabel->setPos(300, 465); nameLabel->setFont(fontT); nameLabel->setZValue(3); levelLabel = new QGraphicsSimpleTextItem("Level: "); levelLabel->setPos(300, 480); levelLabel->setFont(fontT); levelLabel->setZValue(3); //actual score value score = 0; QString temp = QString::number(score); sAmount = new QGraphicsSimpleTextItem(temp); sAmount->setPos(400, 450); sAmount->setFont(fontT); sAmount->setZValue(3); //lives lives = 3; temp = QString::number(lives); lAmount = new QGraphicsSimpleTextItem(temp); lAmount->setPos(70, 460); lAmount->setFont(font); lAmount->setZValue(3); //number of coins collected nCoins = 0; temp = QString::number(nCoins); cAmount = new QGraphicsSimpleTextItem(temp); cAmount->setPos(210, 460); cAmount->setFont(font); cAmount->setZValue(2); //level levelCnt = 1; temp = QString::number(levelCnt); levelAmount = new QGraphicsSimpleTextItem(temp); levelAmount->setPos(400, 480); levelAmount->setFont(fontT); levelAmount->setZValue(2); gScene->addItem(levelAmount); //name nLabel = new QGraphicsSimpleTextItem(n); nLabel->setPos(400, 465); nLabel->setFont(fontT); nLabel->setZValue(2); //now barrage the scene with the items! gScene->addItem(background); gScene->addItem(heart); gScene->addItem(sCoin); gScene->addItem(sLabel); gScene->addItem(nLabel); gScene->addItem(sAmount); gScene->addItem(lAmount); gScene->addItem(cAmount); gScene->addItem(nameLabel); gScene->addItem(levelLabel); for(int k=1; k<things.size(); k++) gScene->addItem(things[k]); gScene->addItem(yoshi); //timers timer = t; //counters goombaCnt = 0; koopaCnt = 0; kamekCnt = 0; billCnt = 0; coinCnt = 0; heartCnt = 0; goombaMax = 150; koopaMax = 200; kamekMax = 300; billMax = 400; coinMax = 200; heartMax = 450; yoshiJCnt = 0; spawnCnt = 100; timeCnt = 0; interval = timer->interval(); velx = 1; vely = 1; boolMagic = false; overG = false; //connect to slot functions connect(timer, SIGNAL(timeout()), this, SLOT(animate())); connect(timer, SIGNAL(timeout()), this, SLOT(newCoin())); connect(timer, SIGNAL(timeout()), this, SLOT(newGoomba())); connect(timer, SIGNAL(timeout()), this, SLOT(newKoopa())); connect(timer, SIGNAL(timeout()), this, SLOT(newKamek())); connect(timer, SIGNAL(timeout()), this, SLOT(newBill())); connect(timer, SIGNAL(timeout()), this, SLOT(newHeart())); connect(timer, SIGNAL(timeout()), this, SLOT(offScreen())); }
PhotoView::PhotoView( PhotoDir * photoDir ) : QGraphicsView() , _photoDir( photoDir ) , _lastPhoto( 0 ) , _zoomMode( ZoomFitImage ) , _zoomFactor( 1.0 ) , _zoomIncrement( 1.2 ) , _idleTimeout( DefaultIdleTimeout ) , _actions( this ) { Q_CHECK_PTR( photoDir ); setScene( new QGraphicsScene ); _canvas = new Canvas( this ); createBorders(); QSize pannerMaxSize( qApp->desktop()->screenGeometry().size() / 6 ); _panner = new Panner( pannerMaxSize, this ); createPanels(); // // Visual tweaks // QPalette pal = palette(); pal.setColor( QPalette::Base, Qt::black ); setPalette( pal ); setFrameStyle( QFrame::NoFrame ); setVerticalScrollBarPolicy ( Qt::ScrollBarAlwaysOff ); setHorizontalScrollBarPolicy( Qt::ScrollBarAlwaysOff ); #if 0 // Some styles (e.g. Plastique) have an undesired two pixel wide focus rect // around QGraphicsView widgets. This is not what we want here, so let's // select a style that does not do this. This does not have an effect on // existing or future child widgets. And since scroll bars are turned off, // there is no other visual effect anyway. // FIXME // FIXME // FIXME setStyle( new QWindowsStyle() ); // FIXME // FIXME // FIXME #endif // Enable mouse tracking so a mouse cursor that was set invisible by an // item (e.g., Canvas) can be made visible again upon mouse movement. setMouseTracking( true ); connect( &_idleTimer, SIGNAL( timeout() ), this, SLOT ( hideCursor() ) ); _idleTimer.setSingleShot( true ); _idleTimer.start( _idleTimeout ); _cursor = viewport()->cursor(); // // Load images // _photoDir->prefetch(); if ( ! _photoDir->isEmpty() ) loadImage(); }
void ChatEdit::updateScrollBar(){ setVerticalScrollBarPolicy(sizeHint().height() > height() ? Qt::ScrollBarAlwaysOn : Qt::ScrollBarAlwaysOff); ensureCursorVisible(); }