MainMenu::MainMenu(
	QWidget *parent,
	not_null<Controller*> controller)
: TWidget(parent)
, _controller(controller)
, _menu(this, st::mainMenu)
, _telegram(this, st::mainMenuTelegramLabel)
, _version(this, st::mainMenuVersionLabel) {
	setAttribute(Qt::WA_OpaquePaintEvent);

	subscribe(Global::RefSelfChanged(), [this] {
		checkSelf();
	});
	checkSelf();

	_nightThemeSwitch.setCallback([this] {
		if (const auto action = *_nightThemeAction) {
			const auto nightMode = Window::Theme::IsNightMode();
			if (action->isChecked() != nightMode) {
				Window::Theme::ToggleNightMode();
			}
		}
	});

	resize(st::mainMenuWidth, parentWidget()->height());
	_menu->setTriggeredCallback([](QAction *action, int actionTop, Ui::Menu::TriggeredSource source) {
		emit action->triggered();
	});
	refreshMenu();

	_telegram->setRichText(textcmdLink(1, qsl("Telegram Desktop")));
	_telegram->setLink(1, std::make_shared<UrlClickHandler>(qsl("https://desktop.telegram.org")));
	_version->setRichText(textcmdLink(1, lng_settings_current_version(lt_version, currentVersionText())) + QChar(' ') + QChar(8211) + QChar(' ') + textcmdLink(2, lang(lng_menu_about)));
	_version->setLink(1, std::make_shared<UrlClickHandler>(qsl("https://desktop.telegram.org/changelog")));
	_version->setLink(2, std::make_shared<LambdaClickHandler>([] { Ui::show(Box<AboutBox>()); }));

	subscribe(Auth().downloaderTaskFinished(), [this] { update(); });
	subscribe(Auth().downloaderTaskFinished(), [this] { update(); });
	subscribe(Notify::PeerUpdated(), Notify::PeerUpdatedHandler(Notify::PeerUpdate::Flag::UserPhoneChanged, [this](const Notify::PeerUpdate &update) {
		if (update.peer->isSelf()) {
			updatePhone();
		}
	}));
	subscribe(Global::RefPhoneCallsEnabledChanged(), [this] { refreshMenu(); });
	subscribe(Window::Theme::Background(), [this](const Window::Theme::BackgroundUpdate &update) {
		if (update.type == Window::Theme::BackgroundUpdate::Type::ApplyingTheme) {
			refreshMenu();
		}
	});
	updatePhone();
}
Пример #2
0
void GameLayer::floatLeftStarMsg(int leftNum){
	Size visibleSize = Director::getInstance()->getVisibleSize();
	FloatWord* leftStarMsg1 = FloatWord::create("剩余" + String::createWithFormat("%d",leftNum)->_string +"个",
		50,Point(visibleSize.width,visibleSize.height/2));
	this->addChild(leftStarMsg1);
    int jiangLiScore = GAMEDATA::getInstance()->getJiangli(leftNum);
	FloatWord* leftStarMsg2 = FloatWord::create("奖励" + String::createWithFormat("%d",jiangLiScore)->_string + "分",
		50,Point(visibleSize.width,visibleSize.height/2 - 50));
	this->addChild(leftStarMsg2);

	leftStarMsg1->floatInOut(0.5f,1.0f,
				[=](){
					hideLinkNum();
					matrix->setNeedClear(true);
					GAMEDATA* data = GAMEDATA::getInstance();
					data->setCurScore(data->getCurScore() + jiangLiScore);
					if(data->getCurScore() > data->getHistoryScore()){
						data->setHistoryScore(data->getCurScore());
					}
					refreshMenu();
				});
	leftStarMsg2->floatInOut(0.5f,1.0f,nullptr);
}
Пример #3
0
void GameLayer::gotoNextLevel(){
	refreshMenu();
	floatLevelWord();
}
Пример #4
0
std::optional<Menu> &State::getCurrentMenu() {
    refreshMenu();
    return menu;
}
Пример #5
0
void MainWindow::globalStateChanged(CAbstractUpdateController::EUpdateControllerState new_state)
{
    refreshMenu();    

    bool isUpdatesAvail= (mSysController.currentState() == CAbstractUpdateController::eUPDATES_AVAIL)
                       ||(mPkgController.currentState() == CAbstractUpdateController::eUPDATES_AVAIL)
                       ||(mPBIController.currentState() == CAbstractUpdateController::eUPDATES_AVAIL);

    ui->updateAllButton->setEnabled(isUpdatesAvail);

    bool isFullyUpdate= (mSysController.currentState() == CAbstractUpdateController::eFULLY_UPDATED)
            &&(mPkgController.currentState() == CAbstractUpdateController::eFULLY_UPDATED)
            &&(mPBIController.currentState() == CAbstractUpdateController::eFULLY_UPDATED);

    ui->mainStatesStack->setCurrentIndex((isFullyUpdate)?MAIN_FULLY_UPDATED_IDX:MAIN_INDICATORS_IDX);

    switch(mSysController.currentState())
    {
        case CAbstractUpdateController::eUPDATES_AVAIL:
        case CAbstractUpdateController::eUPDATING:
            ui->mainTab->setTabEnabled(TOOLBOX_SYS_INDEX, true);
            break;
        case CAbstractUpdateController::eUPDATING_ERROR:
            break;
        default:
            if (ui->mainTab->currentIndex() == TOOLBOX_SYS_INDEX)
                ui->mainTab->setCurrentIndex(TOOLBOX_MAIN_INDEX);
            ui->mainTab->setTabEnabled(TOOLBOX_SYS_INDEX, false);
            break;
    }

    switch(mPkgController.currentState())
    {
        case CAbstractUpdateController::eUPDATES_AVAIL:
        case CAbstractUpdateController::eUPDATING:
            ui->mainTab->setTabEnabled(TOOLBOX_PKG_INDEX, true);
            break;
        case CAbstractUpdateController::eUPDATING_ERROR:
            break;
        default:
            if (ui->mainTab->currentIndex() == TOOLBOX_PKG_INDEX)
                ui->mainTab->setCurrentIndex(TOOLBOX_MAIN_INDEX);
            ui->mainTab->setTabEnabled(TOOLBOX_PKG_INDEX, false);
            break;
    }

    switch(mPBIController.currentState())
    {
        case CAbstractUpdateController::eUPDATES_AVAIL:
        case CAbstractUpdateController::eUPDATING:
            ui->mainTab->setTabEnabled(TOOLBOX_PBI_INDEX, true);
            break;
        case CAbstractUpdateController::eUPDATING_ERROR:
            break;
        default:
            if (ui->mainTab->currentIndex() == TOOLBOX_PBI_INDEX)
                ui->mainTab->setCurrentIndex(TOOLBOX_MAIN_INDEX);
            ui->mainTab->setTabEnabled(TOOLBOX_PBI_INDEX, false);
            break;
    }
    Q_UNUSED(new_state)
}