START_NS ProposalTreeWidget::ProposalTreeWidget(QWidget * p) : QTreeWidget(p), mOverlay(new Overlay(this)), mAddRemoveEnabled(false), mSolutionSelectionMultiple(true) //mSolutionDelegate(new SolutionCheckDelegate(this) ) { setDragEnabled(true); setDragDropMode(InternalMove); viewport()->setAcceptDrops(true); setDropIndicatorShown(true); setSelectionMode(SingleSelection); setEditTriggers(AllEditTriggers); // maintain order accordingly to ColumnId, ColumnProposalText, etc. setHeaderLabels( QStringList() << tr("Id") << tr("Text") << tr("Solution") ); setRootIsDecorated(false); setWordWrap(true); overlay()->setText( tr("Right click to add new proposal") ); connect(this, SIGNAL(itemSelectionChanged()),this, SLOT(onSelectionChange())); connect(this, SIGNAL(itemChanged(QTreeWidgetItem*,int)), this, SLOT(onItemChange(QTreeWidgetItem*,int))); connect(this,SIGNAL(itemClicked(QTreeWidgetItem*,int)), this, SLOT(onClicked(QTreeWidgetItem*,int))); }
void CatActionList::initialList() { CatPluginManager* mgr = CatPluginManager::GetInstance(); foreach(const QUuid& uid,mgr->plugins()) { ui.actionList->addItem(mgr->pluginTitle(uid),uid.toString()); myDescriptions.insert(uid,mgr->pluginDescription(uid)); } connect(ui.actionList,SIGNAL(currentIndexChanged(int)),this,SLOT(onSelectionChange(int))); if(ui.actionList->count()) { ui.actionList->setCurrentIndex(0); onSelectionChange(0); } }
void LLPanelOutfitsInventory::onTabSelectionChange(LLInventoryPanel* tab_panel, const std::deque<LLFolderViewItem*> &items, BOOL user_action) { if (user_action && items.size() > 0) { for (tabpanels_vec_t::iterator iter = mTabPanels.begin(); iter != mTabPanels.end(); ++iter) { LLInventoryPanel *panel = (*iter); if (panel == tab_panel) { mActivePanel = panel; } else { panel->getRootFolder()->clearSelection(); } } } onSelectionChange(items, user_action); }
void OsuPauseMenu::updateLayout() { const float height = (m_osu->getScreenHeight()/(float)m_buttons.size()); const float half = (m_buttons.size()-1)/2.0f; float maxWidth = 0.0f; float maxHeight = 0.0f; for (int i=0; i<m_buttons.size(); i++) { Image *img = m_buttons[i]->getImage(); if (img == NULL) img = m_osu->getSkin()->getMissingTexture(); const float scale = m_osu->getUIScale(m_osu, 256) / (411.0f * (m_osu->getSkin()->isPauseContinue2x() ? 2.0f : 1.0f)); m_buttons[i]->setBaseScale(scale, scale); m_buttons[i]->setSize(img->getWidth()*scale, img->getHeight()*scale); if (m_buttons[i]->getSize().x > maxWidth) maxWidth = m_buttons[i]->getSize().x; if (m_buttons[i]->getSize().y > maxHeight) maxHeight = m_buttons[i]->getSize().y; } for (int i=0; i<m_buttons.size(); i++) { Vector2 newPos = Vector2(m_osu->getScreenWidth()/2.0f - maxWidth/2, (i+1)*height - height/2.0f - maxHeight/2.0f); const float pinch = std::max(0.0f, (height/2.0f - maxHeight/2.0f)); if ((float)i < half) newPos.y += pinch; else if ((float)i > half) newPos.y -= pinch; m_buttons[i]->setPos(newPos); m_buttons[i]->setSize(maxWidth, maxHeight); } onSelectionChange(); }
MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow), _isUsingCapture(false) #ifdef Q_OS_WIN ,proxySetting("\\HKEY_CURRENT_USER\\Software\\Microsoft\\Windows\\CurrentVersion\\Internet Settings\\",QSettings::NativeFormat) #endif { ui->setupUi(this); pipeTableModel = new RyTableModel(this); sortFilterProxyModel = new RyTableSortFilterProxyModel(this); ui->tableView->setSortingEnabled(true); ui->tableView->setModel(sortFilterProxyModel); sortFilterProxyModel->setDynamicSortFilter(true); sortFilterProxyModel->setSourceModel(pipeTableModel); ui->tableView->setSelectionBehavior(QAbstractItemView::SelectRows); ui->tableView->setColumnWidth(0,30); ui->tableView->setColumnWidth(1,30); ui->tableView->setColumnWidth(2,50); ui->tableView->setColumnWidth(3,50); ui->tableView->setColumnWidth(7,50); ui->tableView->verticalHeader()->setDefaultSectionSize(20); ui->tableView->verticalHeader()->hide(); _jsBridge = new RyJsBridge(); QWebSettings::globalSettings()->setAttribute(QWebSettings::DeveloperExtrasEnabled, true); addJsObject(); connect(ui->webView->page()->mainFrame(),SIGNAL(javaScriptWindowObjectCleared()),SLOT(addJsObject())); ui->webView->load(QUrl("http://127.0.0.1:8889/manager/RythemManagerUI/rules.html")); // should use slot to do this //ui->composer->setupProxy(RyProxyServer::instance()->serverAddress().toString(), // RyProxyServer::instance()->serverPort()); ui->composer->setupProxy("127.0.0.1", 8889); _itemSelectModel = ui->tableView->selectionModel(); connect(ui->tableView,SIGNAL(doubleClicked(QModelIndex)),SLOT(onItemDoubleClicked(QModelIndex))); //connect(_itemSelectModel,SIGNAL(currentChanged(QModelIndex,QModelIndex)),SLOT(onSelectionChange(QModelIndex))); connect(_itemSelectModel,SIGNAL(selectionChanged(QItemSelection,QItemSelection)),SLOT(onSelectionChange(QItemSelection,QItemSelection))); //ui->tableView->setItemDelegate(); createMenus(); //toggleCapture(); connect(ui->ActionCapture,SIGNAL(triggered()),SLOT(toggleCapture())); connect(ui->actionRemoveAll,SIGNAL(triggered()),this,SLOT(onActionRemoveAll())); connect(ui->actionWaterfall, SIGNAL(triggered()), this, SLOT(onWaterfallActionTriggered())); #ifdef Q_WS_MAC // TODO: mac下需手动设置代理 ui->ActionCapture->setEnabled(false); ui->ActionCapture->setText(tr("SetupProxyManually")); ui->ActionCapture->setToolTip(tr("non-windows OS need to set proxy to:127.0.0.1:8889 manually")); #endif }
void OsuPauseMenu::onKeyDown(KeyboardEvent &e) { OsuScreen::onKeyDown(e); // only used for options menu if (!m_bVisible || e.isConsumed()) return; if (e == (KEYCODE)OsuKeyBindings::LEFT_CLICK.getInt() || e == (KEYCODE)OsuKeyBindings::RIGHT_CLICK.getInt()) { bool fireButtonClick = false; if (e == (KEYCODE)OsuKeyBindings::LEFT_CLICK.getInt() && !m_bClick1Down) { m_bClick1Down = true; fireButtonClick = true; } if (e == (KEYCODE)OsuKeyBindings::RIGHT_CLICK.getInt() && !m_bClick2Down) { m_bClick2Down = true; fireButtonClick = true; } if (fireButtonClick) { for (int i=0; i<m_buttons.size(); i++) { if (m_buttons[i]->isMouseInside()) { m_buttons[i]->click(); break; } } } } // handle arrow keys selection if (m_buttons.size() > 0) { if (!engine->getKeyboard()->isAltDown() && e == KEY_DOWN) { OsuUIPauseMenuButton *nextSelectedButton = m_buttons[0]; // get first visible button for (int i=0; i<m_buttons.size(); i++) { if (!m_buttons[i]->isVisible()) continue; nextSelectedButton = m_buttons[i]; break; } // next selection logic bool next = false; for (int i=0; i<m_buttons.size(); i++) { if (!m_buttons[i]->isVisible()) continue; if (next) { nextSelectedButton = m_buttons[i]; break; } if (m_selectedButton == m_buttons[i]) next = true; } m_selectedButton = nextSelectedButton; onSelectionChange(); } if (!engine->getKeyboard()->isAltDown() && e == KEY_UP) { OsuUIPauseMenuButton *nextSelectedButton = m_buttons[m_buttons.size()-1]; // get first visible button for (int i=m_buttons.size()-1; i>=0; i--) { if (!m_buttons[i]->isVisible()) continue; nextSelectedButton = m_buttons[i]; break; } // next selection logic bool next = false; for (int i=m_buttons.size()-1; i>=0; i--) { if (!m_buttons[i]->isVisible()) continue; if (next) { nextSelectedButton = m_buttons[i]; break; } if (m_selectedButton == m_buttons[i]) next = true; } m_selectedButton = nextSelectedButton; onSelectionChange(); } if (m_selectedButton != NULL && e == KEY_ENTER) m_selectedButton->click(); } // consume ALL events, except for a few special binds which are allowed through (e.g. for unpause or changing the local offset in Osu.cpp) if (e != KEY_ESCAPE && e != (KEYCODE)OsuKeyBindings::GAME_PAUSE.getInt() && e != (KEYCODE)OsuKeyBindings::INCREASE_LOCAL_OFFSET.getInt() && e != (KEYCODE)OsuKeyBindings::DECREASE_LOCAL_OFFSET.getInt()) e.consume(); }
void OsuPauseMenu::onKeyDown(KeyboardEvent &e) { if (!m_bVisible) return; if (e == KEY_1) onContinueClicked(); else if (e == KEY_2) onRetryClicked(); else if (e == KEY_3) onBackClicked(); else if (e == (KEYCODE)OsuKeyBindings::LEFT_CLICK.getInt() || e == (KEYCODE)OsuKeyBindings::RIGHT_CLICK.getInt()) { for (int i=0; i<m_buttons.size(); i++) { if (m_buttons[i]->isMouseInside()) { m_buttons[i]->click(); break; } } } // handle arrow keys selection if (m_buttons.size() > 0) { if (!engine->getKeyboard()->isAltDown() && e == KEY_DOWN) { OsuPauseMenuButton *nextSelectedButton = m_buttons[0]; bool next = false; for (int i=0; i<m_buttons.size(); i++) { if (next) { nextSelectedButton = m_buttons[i]; break; } if (m_selectedButton == m_buttons[i]) next = true; } m_selectedButton = nextSelectedButton; onSelectionChange(); } if (!engine->getKeyboard()->isAltDown() && e == KEY_UP) { OsuPauseMenuButton *nextSelectedButton = m_buttons[m_buttons.size()-1]; bool next = false; for (int i=m_buttons.size()-1; i>=0; i--) { if (next) { nextSelectedButton = m_buttons[i]; break; } if (m_selectedButton == m_buttons[i]) next = true; } m_selectedButton = nextSelectedButton; onSelectionChange(); } if (m_selectedButton != NULL && e == KEY_ENTER) m_selectedButton->click(); } if (e != KEY_ESCAPE && e != (KEYCODE)OsuKeyBindings::GAME_PAUSE.getInt()) // needed for unpause in Osu.cpp e.consume(); }