MyListWidget::MyListWidget(QWidget* parent) : QListWidget(parent) { m_hoveredIndex =QPersistentModelIndex(); m_showHotkey=false; m_arrowHover= false; setAttribute(Qt::WA_AlwaysShowToolTips); setAlternatingRowColors(true); setAutoScroll(true); QRect r = geometry(); setAutoScrollMargin(r.height()/3); connect(this, SIGNAL(listItemAction(QString , CatItem )), (QObject*)gMainWidget, // SLOT(operateOnItem(QString , CatItem ))); connect(this, SIGNAL(showOptionsMenu(QString, QPoint)), (QObject*)gMainWidget, SLOT(listMenuEvent(QString, QPoint)), Qt::QueuedConnection); setMouseTracking(true); m_hoveStart = QTime::currentTime(); m_hovered= false; }
void MyListWidget::sendMenuEvent(QContextMenuEvent* event){ QPoint pos = event->pos(); QPersistentModelIndex index = indexAt(pos); QString path = index.data(ROLE_ITEM_PATH).toString(); // QPoint globalPos = QWidget::mapToGlobal(pos); // emit showOptionsMenu(path, globalPos); // QPoint mainWidgetPos = mapTo((QWidget*)gMarginWidget,pos); QPoint mainWidgetPos = this->mapToGlobal(pos); emit showOptionsMenu(path, mainWidgetPos); }
void FullScreenContent::createOptionsAction() { // We do not use a KActionMenu because: // // - It causes the button to show a small down arrow on its right, // which makes it wider // // - We can't control where the menu shows: in no-thumbnail-mode, the // menu should not be aligned to the right edge of the screen because // if the mode is changed to thumbnail-mode, we want the option button // to remain visible mOptionsAction = new QAction(this); mOptionsAction->setPriority(QAction::LowPriority); mOptionsAction->setIcon(QIcon::fromTheme("configure")); mOptionsAction->setToolTip(i18nc("@info:tooltip", "Configure full screen mode")); QObject::connect(mOptionsAction, SIGNAL(triggered()), this, SLOT(showOptionsMenu())); }
//============================================================================== CabbagePluginListComponent::CabbagePluginListComponent (AudioPluginFormatManager& manager, KnownPluginList& listToEdit, const File& deadMansPedal, PropertiesFile* const props, bool allowPluginsWhichRequireAsynchronousInstantiation) : formatManager (manager), list (listToEdit), deadMansPedalFile (deadMansPedal), optionsButton ("Options..."), propertiesToUse (props), allowAsync (allowPluginsWhichRequireAsynchronousInstantiation), numThreads (allowAsync ? 1 : 0) { tableModel.reset (new TableModel (*this, listToEdit)); TableHeaderComponent& header = table.getHeader(); header.addColumn (TRANS("Name"), TableModel::nameCol, 200, 100, 700, TableHeaderComponent::defaultFlags | TableHeaderComponent::sortedForwards); header.addColumn (TRANS("Format"), TableModel::typeCol, 80, 80, 80, TableHeaderComponent::notResizable); header.addColumn (TRANS("Category"), TableModel::categoryCol, 100, 100, 200); header.addColumn (TRANS("Manufacturer"), TableModel::manufacturerCol, 200, 100, 300); header.addColumn (TRANS("Description"), TableModel::descCol, 300, 100, 500, TableHeaderComponent::notSortable); table.setHeaderHeight (22); table.setRowHeight (20); table.setModel (tableModel.get()); table.setMultipleSelectionEnabled (true); addAndMakeVisible (table); addAndMakeVisible (optionsButton); optionsButton.onClick = [this] { showOptionsMenu(); }; optionsButton.setTriggeredOnMouseDown (true); setSize (400, 600); list.addChangeListener (this); updateList(); table.getHeader().reSortTable(); PluginDirectoryScanner::applyBlacklistingsFromDeadMansPedal (list, deadMansPedalFile); deadMansPedalFile.deleteFile(); }
SearchBar::SearchBar(QWidget* parent) : SearchBarBase(parent) { m_searchFoward = false; m_matchCase = false; m_wholeWords = false; m_fromCursor = false; setFocusProxy(m_searchEdit); KIconLoader* iconLoader = kapp->iconLoader(); m_closeButton->setIconSet(iconLoader->loadIconSet("fileclose", KIcon::Toolbar, 16)); m_findNextButton->setIconSet(iconLoader->loadIconSet("up", KIcon::Toolbar, 16)); m_findPreviousButton->setIconSet(iconLoader->loadIconSet("down", KIcon::Toolbar, 16)); m_statusPixLabel->hide(); m_statusTextLabel->hide(); m_timer = new QTimer(this); QAccel* accel = new QAccel(this); accel->connectItem( accel->insertItem(Qt::Key_Escape), this, SLOT(hide())); connect(m_timer, SIGNAL(timeout()), SLOT(slotFind())); connect(m_searchEdit, SIGNAL(textChanged(const QString&)), SLOT(slotTextChanged())); connect(m_searchEdit, SIGNAL(returnPressed()), SLOT(slotFindNext())); connect(m_findNextButton, SIGNAL(clicked()), SLOT(slotFindNext())); connect(m_findPreviousButton, SIGNAL(clicked()), SLOT(slotFindPrevious())); connect(m_closeButton, SIGNAL(clicked()), SLOT(hide())); connect(m_optionsButton, SIGNAL(clicked()), this, SLOT(showOptionsMenu())); m_optionsMenu = new QPopupMenu(m_optionsButton, "options_menu"); m_optionsMenu->setCheckable(true); m_optionsMenu->insertItem(i18n("Find Forward"), this, SLOT(toggleSearchFoward()), 0, SEARCH_FORWARD_MENU); m_optionsMenu->insertItem(i18n("Case Sensitive"), this, SLOT(toggleMatchCase()), 0, MATCH_CASE_MENU); m_optionsMenu->insertItem(i18n("Whole Words Only"), this, SLOT(toggleWholeWords()), 0, WHOLE_WORDS_ONLY_MENU); m_optionsMenu->insertItem(i18n("From Cursor"), this, SLOT(toggleFromCursor()), 0, FROM_CURSOR_MENU); m_optionsButton->setPopup(m_optionsMenu); }
void MyListWidget::mousePressEvent( QMouseEvent * event ) { QPoint pos = event->pos(); QPersistentModelIndex index = indexAt(pos); QString path = index.data(ROLE_ITEM_PATH).toString(); if(event->button() != Qt::LeftButton){ QPoint globalPos = QWidget::mapToGlobal(pos); emit showOptionsMenu(path,globalPos); //emit pressed(index); return; } //Later... //if(event->button() == Qt::RightButton){ } QRect containingRect = this->geometry(); containingRect.setHeight(UI_DEFAULT_ITEM_HEIGHT); containingRect.moveTop(0); QRect pinRect = IconDelegate::getPinItemRect(containingRect); QListWidgetItem* listWidgetItem = item(index.row()); QPoint localPos = pos; localPos.setY(pos.y() % UI_DEFAULT_ITEM_HEIGHT); if(pinRect.contains(localPos)){ CatItem pinItem(addPrefix(OPERATION_PREFIX,PIN_OPERATION_NAME)); if(!(listWidgetItem->data((ROLE_ITEM_PINNED)).toBool())){ listWidgetItem->setData((ROLE_ITEM_PINNED),true); } else {listWidgetItem->setData((ROLE_ITEM_PINNED),false);} //emit listItemAction(path, pinItem); //frickin signal not going through gMainWidget->operateOnItem(path,pinItem); return; } QRect childRect = IconDelegate::getChildArrowRect(containingRect); if(childRect.contains(pos)){ listWidgetItem->setSelected(true); setCurrentRow(index.row()); CatItem clickItem(addPrefix(OPERATION_PREFIX,GOTO_CHILD_OPERATION)); gMainWidget->operateOnItem(path,clickItem); return; } QRect depRect = IconDelegate::getDepricateItemRect(containingRect); if(depRect.contains(localPos)){ CatItem depricateItem(addPrefix(OPERATION_PREFIX,DEPRICATE_OPERATION_NAME)); //emit listItemAction(path, depricateItem); //fickin signals not going through... gMainWidget->operateOnItem(path,depricateItem); return; } if(listWidgetItem){ listWidgetItem->setSelected(true); setCurrentRow(index.row()); CatItem clickItem(addPrefix(OPERATION_PREFIX,SELECTION_OPERATION_NAME)); gMainWidget->operateOnItem(path,clickItem); } }
RenderWidget::RenderWidget() { /// DEBUG DRAW m_draw_debug_button = new QPushButton("Debug Gizmos"); m_draw_debug_menu = new QMenu(); m_draw_debug = m_draw_debug_menu->addAction("draw gizmos"); m_draw_debug->setCheckable(true); m_draw_debug->setChecked(RENDER_MANAGER.getDrawDebug()); m_draw_debug_menu->addSeparator(); RenderManager::DebugGizmosFilter filter = RENDER_MANAGER.getDrawDebugFilter(); m_draw_transforms = m_draw_debug_menu->addAction("transforms"); m_draw_transforms->setCheckable(true); m_draw_transforms->setChecked(filter.draw_transforms); m_draw_lights = m_draw_debug_menu->addAction("lights"); m_draw_lights->setCheckable(true); m_draw_lights->setChecked(filter.draw_lights); m_draw_cameras = m_draw_debug_menu->addAction("cameras"); m_draw_cameras->setCheckable(true); m_draw_cameras->setChecked(filter.draw_cameras); m_draw_skeletons = m_draw_debug_menu->addAction("skeletons"); m_draw_skeletons->setCheckable(true); m_draw_skeletons->setChecked(filter.draw_skeletons); m_draw_colliders = m_draw_debug_menu->addAction("colliders"); m_draw_colliders->setCheckable(true); m_draw_colliders->setChecked(filter.draw_colliders); /// OPTIONS m_options_button = new QPushButton("Options"); m_options_menu = new QMenu(); m_options_shadows = m_options_menu->addAction("shadows"); m_options_shadows->setCheckable(true); m_options_shadows->setChecked(RENDER_MANAGER.getShadowsEnabled()); m_options_bloom = m_options_menu->addAction("bloom"); m_options_bloom->setCheckable(true); m_options_bloom->setChecked(RENDER_MANAGER.getBloomEnabled()); m_options_sss = m_options_menu->addAction("SSS"); m_options_sss->setCheckable(true); m_options_sss->setChecked(RENDER_MANAGER.getSSSEnabled()); m_options_lightscattering = m_options_menu->addAction("LightScattering"); m_options_lightscattering->setCheckable(true); m_options_lightscattering->setChecked(RENDER_MANAGER.getLightScatteringEnabled()); m_options_normalmapping = m_options_menu->addAction("Normal mapping"); m_options_normalmapping->setCheckable(true); m_options_normalmapping->setChecked(RENDER_MANAGER.getNormalMappingEnabled()); m_options_specularmapping = m_options_menu->addAction("Specular mapping"); m_options_specularmapping->setCheckable(true); m_options_specularmapping->setChecked(RENDER_MANAGER.getSpecularMappingEnabled()); m_options_forward_pipeline = m_options_menu->addAction("Forward pipeline"); m_options_forward_pipeline->setCheckable(true); m_options_deferred_pipeline = m_options_menu->addAction("Deferred pipeline"); m_options_deferred_pipeline->setCheckable(true); QActionGroup* pipelinesGroup = new QActionGroup(m_options_menu); pipelinesGroup->addAction(m_options_forward_pipeline); pipelinesGroup->addAction(m_options_deferred_pipeline); if(RENDER_MANAGER.getRenderPipeline() == RenderManager::FORWARD_PIPELINE) m_options_forward_pipeline->setChecked(true); else m_options_deferred_pipeline->setChecked(true); /// CAMERAS m_cameras_combo = new QComboBox(); m_cameras_combo->setModel(CAMERA_MANAGER.getDebugModel()); m_cameras_combo->setView(CAMERA_MANAGER.getDebugView()); QHBoxLayout* layout = new QHBoxLayout; layout->addWidget(m_draw_debug_button); layout->addWidget(m_options_button); layout->addWidget(m_cameras_combo); //layout->addStretch(1); setLayout(layout); setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Maximum); connect(m_draw_debug_button, SIGNAL(clicked()), this, SLOT(showDebugMenu())); connect(m_draw_debug, SIGNAL(triggered()), this, SLOT(drawDebugChanged())); connect(m_draw_colliders, SIGNAL(triggered()), this, SLOT(drawDebugFilterChanged())); connect(m_draw_cameras, SIGNAL(triggered()), this, SLOT(drawDebugFilterChanged())); connect(m_draw_transforms, SIGNAL(triggered()), this, SLOT(drawDebugFilterChanged())); connect(m_draw_lights, SIGNAL(triggered()), this, SLOT(drawDebugFilterChanged())); connect(m_draw_skeletons, SIGNAL(triggered()), this, SLOT(drawDebugFilterChanged())); connect(m_options_button, SIGNAL(clicked()), this, SLOT(showOptionsMenu())); connect(m_options_shadows, SIGNAL(triggered()), this, SLOT(optionShadowsChanged())); connect(m_options_bloom, SIGNAL(triggered()), this, SLOT(optionBloomChanged())); connect(m_options_sss, SIGNAL(triggered()), this, SLOT(optionSSSChanged())); connect(m_options_lightscattering, SIGNAL(triggered()), this, SLOT(optionLightScatteringChanged())); connect(m_options_normalmapping, SIGNAL(triggered()), this, SLOT(optionNormalMappingChanged())); connect(m_options_specularmapping, SIGNAL(triggered()), this, SLOT(optionSpecularMappingChanged())); connect(m_options_forward_pipeline, SIGNAL(triggered()), this, SLOT(optionPipelineToForward())); connect(m_options_deferred_pipeline, SIGNAL(triggered()), this, SLOT(optionPipelineToDeferred())); }