int TabWidget::addTab(Tab *widget, const QString &name, quint32 tabId) { if(!widget->isHometab()) emit closeHomeTab(); int idx = QTabWidget::addTab(widget, name); installEventFilterToChildren(widget); std::vector<quint32>::iterator itr = m_tab_ids.begin() + idx; m_tab_ids.insert(itr, tabId); setCurrentIndex(idx); changeMenu(idx); if(count() >= 2) m_tab_bar->enableSplit(true); if(widget->isWorkTab()) { connect(widget, SIGNAL(statusBarMsg(QString,int)), SIGNAL(statusBarMsg(QString,int))); connect(widget, SIGNAL(setConnId(QString,bool)), SLOT(setConnString(QString,bool))); } else if(widget->isChild()) connect((ChildTab*)widget, SIGNAL(tabText(QString)), SLOT(setTabNameAndTooltip(QString))); connect(widget, SIGNAL(activateMe()), SLOT(activateTab())); connect(widget, SIGNAL(destroyed()), SLOT(checkEmpty()), Qt::QueuedConnection); setTabNameAndTooltip(idx, name); setTabsClosable(true); return idx; }
bool TabWidget::closeTab(int index) { if(index < 0 || m_tab_ids.size() <= (uint)index) { Q_ASSERT(false); return false; } quint32 id = m_tab_ids[index]; Tab *tab = dynamic_cast<Tab*>(widget(index)); if(!tab) { Q_ASSERT(false); return false; } if(!tab->onTabClose()) return false; if(id & IDMASK_CHILD) { sWorkTabMgr.removeChildTab((ChildTab*)tab); } else { disconnect((WorkTab*)tab, SIGNAL(statusBarMsg(QString,int)), this, SIGNAL(statusBarMsg(QString,int))); sWorkTabMgr.removeTab((WorkTab*)tab); } changeMenu(currentIndex()); checkEmpty(); return true; }
MenuState::MenuState(Controller& cntrl , sf::RenderWindow& window) : mView(window.getView()) , mViewCenter(mView.getCenter()) , mMenuTextPos(mViewCenter.x , mViewCenter.y + 64) , mController(cntrl) , mWindow(window) , mBackground(cntrl.getTexture(Controller::Textures::GameBackground) , mWindow.getViewport(mView)) , mTitleText("Flocky\n\t Sheep" , mController.getFont(Controller::Fonts::Smoke) , 128) , mCurrentMenu(MenuState::MenuType::Main) , mNewMenu(mCurrentMenu) , mPreviousMenu(mCurrentMenu) , mCurrentMenuSelection(0) , mEnterName(false) { mTitleText.setColor(mSelectedTextColour); sf::FloatRect bounds = mTitleText.getLocalBounds(); mTitleText.setOrigin(bounds.width / 2.f, bounds.height / 2.f); mTitleText.setPosition(mViewCenter.x, mViewCenter.y - 128); for(size_t i = 0; i < mMaxTextNum; i++) { mMenuText.push_back(sf::Text("" , mController.getFont(Controller::Fonts::Sansation) , 64)); mMenuText.at(i).setColor(mOtherTextColour); } changeMenu(mCurrentMenu); }
void MenuState::update(sf::Time dt) { if(mCurrentMenu != mNewMenu) changeMenu(mNewMenu); for(sf::Text& txt : mMenuText) txt.setColor(mOtherTextColour); mMenuText.at(mCurrentMenuSelection).setColor(mSelectedTextColour); }
void TabWidget::removeChildTab(ChildTab *widget) { int idx = indexOf(widget); if(idx == -1) return; removeTab(idx); changeMenu(currentIndex()); checkEmpty(); }
ClockfaceMenu::ClockfaceMenu() : Menu(MENU_CLOCK) , faceType(FACE_PONG) , face(NULL) { faceType = state.current_face; if (faceType >= FACE_MAX) faceType = 0; changeMenu(); uint8_t hour = state.now.hour(); if (!state.mode24h && hour > 12) { hour = hour - 12; } face->begin(hour, state.now.minute()); }
void TabWidget::currentIndexChanged(int idx) { changeMenu(idx); if(idx == -1) return; emit changeWindowTitle(tabToolTip(idx)); if((size_t)idx < m_tab_ids.size()) { m_tabHistory.removeOne(m_tab_ids[idx]); m_tabHistory.push_back(m_tab_ids[idx]); } }
QWidget *TabWidget::unregisterTab(int index) { Tab *tab = (Tab*)widget(index); Q_ASSERT(tab); removeTab(index); removeEventFilterFromChildren(tab); tab->disconnect(this); this->disconnect(tab); changeMenu(currentIndex()); return tab; }
Window::Window(){ client = new Client(this); sdlWindow = SDL_CreateWindow("Strong", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, windowRect.w, windowRect.h, SDL_WINDOW_SHOWN | SDL_WINDOW_RESIZABLE); if(!sdlWindow){ errorf("SDL_CreateWindow: %s", SDL_GetError()); running = false; } sdlRenderer = SDL_CreateRenderer(sdlWindow, -1, SDL_RENDERER_ACCELERATED); if(!sdlRenderer){ errorf("SDL_CreateRenderer: %s", SDL_GetError()); running = false; } Graphics::loadImages(this); changeMenu(new MenuMain(this), true); }
void ClockfaceMenu::button1() { do { faceType = (faceType + 1) % FACE_MAX; } while (!(state.enabled_faces & _BV(faceType))); changeMenu(); }