Ejemplo n.º 1
0
//reputation
void ActionsAction::appendReputationPoint(CatchChallenger::Api_protocol *api,const std::string &type,const int32_t &point)
{
    if(point==0)
        return;
    if(DatapackClientLoader::datapackLoader.reputationNameToId.find(type)==DatapackClientLoader::datapackLoader.reputationNameToId.cend())
    {
        //emit error(QStringLiteral("Unknow reputation: %1").arg(type));
        abort();
        return;
    }
    const uint16_t &reputatioId=DatapackClientLoader::datapackLoader.reputationNameToId.at(type);
    CatchChallenger::PlayerReputation playerReputation;
    if(api->player_informations.reputation.find(reputatioId)!=api->player_informations.reputation.cend())
        playerReputation=api->player_informations.reputation.at(reputatioId);
    else
    {
        playerReputation.point=0;
        playerReputation.level=0;
    }
    #ifdef DEBUG_MESSAGE_CLIENT_REPUTATION
    emit message(QStringLiteral("Reputation %1 at level: %2 with point: %3").arg(type).arg(playerReputation.level).arg(playerReputation.point));
    #endif
    CatchChallenger::PlayerReputation oldPlayerReputation=playerReputation;
    int32_t old_level=playerReputation.level;
    CatchChallenger::FacilityLib::appendReputationPoint(&playerReputation,point,CatchChallenger::CommonDatapack::commonDatapack.reputation.at(reputatioId));
    if(oldPlayerReputation.level==playerReputation.level && oldPlayerReputation.point==playerReputation.point)
        return;
    if(api->player_informations.reputation.find(reputatioId)!=api->player_informations.reputation.cend())
        api->player_informations.reputation[reputatioId]=playerReputation;
    else
        api->player_informations.reputation[reputatioId]=playerReputation;
    const std::string &reputationCodeName=CatchChallenger::CommonDatapack::commonDatapack.reputation.at(reputatioId).name;
    if(old_level<playerReputation.level)
    {
        if(DatapackClientLoader::datapackLoader.reputationExtra.find(reputationCodeName)!=DatapackClientLoader::datapackLoader.reputationExtra.cend())
            showTip(tr("You have better reputation into %1")
                    .arg(QString::fromStdString(DatapackClientLoader::datapackLoader.reputationExtra.at(reputationCodeName).name)));
        else
            showTip(tr("You have better reputation into %1")
                    .arg(QStringLiteral("???")));
    }
    else if(old_level>playerReputation.level)
    {
        if(DatapackClientLoader::datapackLoader.reputationExtra.find(reputationCodeName)!=DatapackClientLoader::datapackLoader.reputationExtra.cend())
            showTip(tr("You have worse reputation into %1")
                    .arg(QString::fromStdString(DatapackClientLoader::datapackLoader.reputationExtra.at(reputationCodeName).name)));
        else
            showTip(tr("You have worse reputation into %1")
                    .arg(QStringLiteral("???")));
    }
    #ifdef DEBUG_MESSAGE_CLIENT_REPUTATION
    emit message(QStringLiteral("New reputation %1 at level: %2 with point: %3").arg(type).arg(playerReputation.level).arg(playerReputation.point));
    #endif
}
Ejemplo n.º 2
0
QgsTipGui::QgsTipGui( QWidget *parent )
    : QDialog( parent, Qt::WindowSystemMenuHint )  // Dialog with close button only
#else
QgsTipGui::QgsTipGui( QWidget *parent )
    : QDialog( parent )  // Normal dialog in non Mac-OS
#endif
{
  setupUi( this );
  init();
}

QgsTipGui::~QgsTipGui()
{
}

void QgsTipGui::init()
{

  QgsTipFactory myFactory;
  QgsTip myTip = myFactory.getTip();
  mTipPosition = myFactory.position( myTip );

  showTip( myTip );

  QPushButton *pb;
  pb = new QPushButton( tr( "&Previous" ) );
  connect( pb, SIGNAL( clicked() ), this, SLOT( prevClicked() ) );
  buttonBox->addButton( pb, QDialogButtonBox::ActionRole );

  pb = new QPushButton( tr( "&Next" ) );
  connect( pb, SIGNAL( clicked() ), this, SLOT( nextClicked() ) );
  buttonBox->addButton( pb, QDialogButtonBox::ActionRole );
}
Ejemplo n.º 3
0
void ShowTip::showTipCenter(const char *str, float fontSize, float delayTime)
{
    CCSize visiSize = CCDirector::sharedDirector()->getVisibleSize();
    CCPoint origin  = CCDirector::sharedDirector()->getVisibleOrigin();
    CCPoint centerPoint = CCPoint(visiSize.width * 0.5 + origin.x, visiSize.height * 0.5 + origin.y);
    showTip(str, centerPoint, fontSize, delayTime);
}
Ejemplo n.º 4
0
MainWindow::MainWindow(QWidget *parent)
    :QMainWindow(parent)
    ,ui(new Ui::MainWindow)
{
    ui->setupUi(this);
    connect(ui->actionRestart_game, SIGNAL(triggered()), this, SLOT(restartGame()));
    connect(ui->actionShow_tip, SIGNAL(triggered()), this, SLOT(showTip()));
    connect(ui->actionStart_new_game, SIGNAL(triggered()), this, SLOT(startNewGame()));
    connect(ui->openGLWidget, SIGNAL(resizeParent(QSize)), this, SLOT(customResize(QSize)));
}
Ejemplo n.º 5
0
void CCharTip::setItem(const CFcEngine::TChar &ch)
{
    hideTip();

    itsItem=ch;
    itsTimer->disconnect(this);
    connect(itsTimer, SIGNAL(timeout()), this, SLOT(showTip()));
    itsTimer->setSingleShot(true);
    itsTimer->start(300);
}
Ejemplo n.º 6
0
void QgsTipGui::nextClicked()
{
  mTipPosition += 1;
  QgsTipFactory myFactory;
  if ( mTipPosition >= myFactory.count() )
  {
    mTipPosition = 0;
  }
  QgsTip myTip = myFactory.getTip( mTipPosition );
  showTip( myTip );
}
Ejemplo n.º 7
0
void TipsDialog::showRandomTip()
{
  int i = m_currentTip;
  srand(time(NULL));
  while(i == m_currentTip)
  {
    i = rand() % m_tips.size();
  }
  m_currentTip = i;
  showTip(m_currentTip);
}
Ejemplo n.º 8
0
void QgsTipGui::prevClicked()
{
  mTipPosition -= 1;
  QgsTipFactory myFactory;
  if ( mTipPosition < 0 )
  {
    mTipPosition = myFactory.count() - 1;
  }
  QgsTip myTip = myFactory.getTip( mTipPosition );
  showTip( myTip );
}
Ejemplo n.º 9
0
void QTipDlg::on_pushbutton_ok_clicked()
{
    this->hide();

    QTime nowTime = QTime::currentTime();
    int nowHour = nowTime.hour();
    QTime targetTime = QTime(nowHour,59,59);//到下一个 整点时钟
    int seconds = nowTime.secsTo(targetTime)+1;
    qDebug()<<seconds;

    QTimer::singleShot(seconds*10, this, SLOT(showTip()));

}
Ejemplo n.º 10
0
void Pana::ToolTip::maybeTip( const QPoint &pos )
{
    s_pos = QToolTip::parentWidget()->mapToGlobal( pos );
    QString prev = s_text;
    QPair<QString, QRect> p = m_client->toolTipText( QToolTip::parentWidget(), pos );
    s_text = p.first;
    s_rect = p.second;
    if( QToolTip::parentWidget() && !s_text.isEmpty() )
    {
        if( s_text != prev )
            hideTips();
        showTip();
    }
    else
        hideTips();
}
Ejemplo n.º 11
0
TipsDialog::TipsDialog(ICaptureContext &Ctx, QWidget *parent)
    : m_Ctx(Ctx), QDialog(parent), ui(new Ui::TipsDialog), m_currentTip(0)
{
  ui->setupUi(this);
  setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint);
  initialize();

  if(m_Ctx.Config().Tips_HasSeenFirst)
  {
    showRandomTip();
  }
  else
  {
    showTip(m_currentTip);
  }

  m_Ctx.Config().Tips_HasSeenFirst = true;
}
Ejemplo n.º 12
0
FloatyWnd::FloatyWnd(FloatyPlugin *plugin, unsigned id)
        : QWidget(NULL, "floaty",
                  WType_TopLevel | WStyle_Customize | WStyle_NoBorder | WStyle_Tool | WStyle_StaysOnTop )
{
    m_plugin = plugin;
    m_id = id;
    init();
#ifdef USE_KDE
    KWin::setState(winId(), NET::SkipTaskbar | NET::SkipPager);
    KWin::setOnAllDesktops(winId(), true);
#endif
    m_tip = NULL;
    tipTimer = new QTimer(this);
    connect(tipTimer, SIGNAL(timeout()), this, SLOT(showTip()));
    moveTimer = new QTimer(this);
    connect(moveTimer, SIGNAL(timeout()), this, SLOT(startMove()));
    setMouseTracking(true);
}
Ejemplo n.º 13
0
void ProgView::mouseReleaseEvent(QMouseEvent * event) {
	for (int i = 0; i < programmes.size(); i++) {
		Programme *prog = programmes.at(i);
		QDateTime start = getRelTime(prog->getStart());
		QDateTime stop = getRelTime(prog->getStop());
		QString channel = prog->getChannel();
		int s = getY(start);
		int min = getKey(CHANNELBAR_HEIGHT).toInt();
		s = s < min ? min : s;
		int index = channelIds.indexOf(channel);
		if (index < 0) {
			continue;
		}
		int c = getX(index);
		QRect full(c, s, getKey(CHANNEL_WIDTH).toInt(), getY(stop) - s);
		if (full.contains(event->pos())) {
			qDebug() << "clicked on" << prog->getTitleList().at(0)->getValue();
			showTip(event, prog);
		}
	}
}
Ejemplo n.º 14
0
FloatyWnd::FloatyWnd(FloatyPlugin *plugin, unsigned id)
        : QWidget(NULL, "floaty", Qt::Window | Qt::FramelessWindowHint | Qt::Tool | Qt::WindowStaysOnTopHint)
{
    m_plugin = plugin;
    m_id = id;
    m_blink = 0;
    init();
    setAcceptDrops(true);
    setBackgroundMode(Qt::NoBackground);
#ifdef USE_KDE
    KWin::setState(winId(), NET::SkipTaskbar | NET::SkipPager);
    KWin::setOnAllDesktops(winId(), true);
#endif
    m_tip = NULL;
    tipTimer = new QTimer(this);
    connect(tipTimer, SIGNAL(timeout()), this, SLOT(showTip()));
    moveTimer = new QTimer(this);
    connect(moveTimer, SIGNAL(timeout()), this, SLOT(startMove()));
    blinkTimer = new QTimer(this);
    connect(blinkTimer, SIGNAL(timeout()), this, SLOT(blink()));
    setMouseTracking(true);
}
Ejemplo n.º 15
0
 void showText(const QPoint& pos, const QString& text)
 {
     QLabel* label = new QLabel(text);
     label->setForegroundRole(QPalette::ToolTipText);
     showTip(pos, label);
 }
Ejemplo n.º 16
0
bool ActionsAction::tryValidateQuestStep(CatchChallenger::Api_protocol *api, const uint16_t &questId, const uint16_t &botId, bool silent)
{
    CatchChallenger::Player_private_and_public_informations &player=api->get_player_informations();
    const std::unordered_map<uint16_t, CatchChallenger::PlayerQuest> &quests=player.quests;
    if(CatchChallenger::CommonDatapackServerSpec::commonDatapackServerSpec.quests.find(questId)==CatchChallenger::CommonDatapackServerSpec::commonDatapackServerSpec.quests.cend())
    {
        if(!silent)
            showTip(tr("Quest not found"));
        return
                false;
    }
    const CatchChallenger::Quest &quest=CatchChallenger::CommonDatapackServerSpec::commonDatapackServerSpec.quests.at(questId);

    if(quests.find(questId)==quests.cend())
    {
        //start for the first time the quest
        if(vectorcontainsAtLeastOne(quest.steps.at(0).bots,botId)
                && haveStartQuestRequirement(api,quest))
        {
            api->startQuest(questId);
            startQuest(api,quest);
            //updateDisplayedQuests();
            return true;
        }
        else
        {
            if(!silent)
                showTip(tr("You don't have the requirement to start this quest"));
            return false;
        }
    }
    else if(quests.at(questId).step==0)
    {
        //start again the quest if can be repeated
        if(quest.repeatable &&
                vectorcontainsAtLeastOne(quest.steps.at(0).bots,botId)
                && haveStartQuestRequirement(api,quest))
        {
            api->startQuest(questId);
            startQuest(api,quest);
            //updateDisplayedQuests();
            return true;
        }
        else
        {
            if(!silent)
                showTip(tr("You don't have the requirement to start this quest"));
            return false;
        }
    }
    if(!haveNextStepQuestRequirements(api,quest))
    {
        if(!silent)
            showTip(tr("You don't have the requirement to continue this quest"));
        return false;
    }
    if(quests.at(questId).step>=(quest.steps.size()))
    {
        if(!silent)
            showTip(tr("You have finish the quest <b>%1</b>").arg(QString::fromStdString(DatapackClientLoader::datapackLoader.questsExtra.at(questId).name)));
        api->finishQuest(questId);
        nextStepQuest(api,quest);
        //updateDisplayedQuests();
        return true;
    }
    if(vectorcontainsAtLeastOne(quest.steps.at(quests.at(questId).step).bots,botId))
    {
        if(!silent)
            showTip(tr("You need talk to another bot"));
        return false;
    }
    api->nextQuestStep(questId);
    nextStepQuest(api,quest);
    //updateDisplayedQuests();
    return true;
}
AssemblyMainWindow::AssemblyMainWindow(QWidget *parent) :
	QMainWindow( parent )
,	mpTrack( 0 )
,	mCurrentTerrainBrush( 0 )
,	ui( new Ui::AssemblyMainWindow )
,	trackView( new TrackView() )
{	
	trackView->setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Expanding );
	trackView->setMinimumSize( 100, 100 );

	ui->setupUi(this);
	QGridLayout* container_layout = new QGridLayout( ui->viewContainer );
	//((QGridLayout*) ui->CentralFrame->layout())->addWidget( trackView, 1, 1 );

	container_layout->setContentsMargins( 0, 0, 0, 0 );
	container_layout->setSpacing( 0 );

	container_layout->addWidget( trackView, 0, 0 );

	// konfiguruje suwaki:
	ui->horizontalScrollBar->setSingleStep( 5 );
	ui->horizontalScrollBar->setPageStep( 20 );
	ui->horizontalScrollBar->setMinimum( 0 );


	ui->verticalScrollBar->setSingleStep( 5 );
	ui->verticalScrollBar->setPageStep( 20 );
	ui->verticalScrollBar->setMinimum( 0 );

	// status bar:
	connect( trackView, SIGNAL(showTip(QString)), ui->statusBar, SLOT(showMessage(QString)) );
	connect( trackView, SIGNAL(removeTip()), ui->statusBar, SLOT(clearMessage()) );

	// zakresy:
	connect( trackView, SIGNAL(horizontalSliderRangeChanged(int)), this, SLOT(setHorizontalSliderMaximum(int)) );
	connect( trackView, SIGNAL(verticalSliderRangeChanged(int)), this, SLOT(setVerticalSliderMaximum(int)) );

	// wlaczanie i wylaczanie scrollbarow:
	connect( trackView, SIGNAL(horizontalSliderEnabled(bool)), ui->horizontalScrollBar, SLOT(setEnabled(bool)));
	connect( trackView, SIGNAL(verticalSliderEnabled(bool)), ui->verticalScrollBar, SLOT(setEnabled(bool)));

	// sprzezenie zwrotne scrollbarow do TrackView:
	connect( ui->horizontalScrollBar, SIGNAL(valueChanged(int)), trackView, SLOT(setHorizontalPosition(int)) );
	connect( ui->verticalScrollBar, SIGNAL(valueChanged(int)), trackView, SLOT(setVerticalPosition(int)) );

	// guzik wczytywania obrazkow:
	connect( ui->loadImageButton, SIGNAL(clicked()), this, SLOT(loadImage()) );

	// taby:
	connect( ui->tabWidget, SIGNAL(currentChanged(int)), trackView, SLOT(setMode(int)) );
	connect( ui->tabWidget, SIGNAL(currentChanged(int)), this, SLOT(prepareTab(int)) );

	// siatka:
	connect( ui->gridSlider, SIGNAL(valueChanged(int)), this, SLOT(setGridDensity(int)) );

	// menu:
	connect( ui->actionNewTrack, SIGNAL(triggered()), this, SLOT(newTrack()) );
	connect( ui->actionOpen, SIGNAL(triggered()), this, SLOT(openTrack()) );
	connect( ui->actionSave, SIGNAL(triggered()), this, SLOT(saveTrack()) );
	connect( ui->actionSaveAs, SIGNAL(triggered()), this, SLOT(saveTrackAs()) );
	connect( ui->actionClose, SIGNAL(triggered()), this, SLOT(close()) );
	connect( ui->actionDrawGrid, SIGNAL(toggled(bool)), trackView, SLOT(drawGrid(bool)) );

	// zakladka terenu:
	connect( ui->comboTerrainBrushType, SIGNAL(currentIndexChanged(int)), this, SLOT(terrainChangeBrush(int)) );
	connect( ui->comboTerrainBrushType, SIGNAL(currentIndexChanged(int)), trackView, SLOT(setBrushId(int)) );
	connect( ui->sliderTerrainBrushSize, SIGNAL(valueChanged(int)), trackView, SLOT(setBrushSize(int)) );
	connect( ui->sliderTerrainIntensity, SIGNAL(valueChanged(int)), trackView, SLOT(setBrushIntensity(int)) );
	connect( ui->sliderTerrainBrushSize, SIGNAL(valueChanged(int)),ui->lineTerrainBrushSize,SLOT(setValue(int)) );
	connect( ui->sliderTerrainIntensity, SIGNAL(valueChanged(int)),ui->lineTerrainIntensity,SLOT(setValue(int)) );

	// koncowa inicjalizacja...
	disableMenus();
}
Ejemplo n.º 18
0
void TaskJuggler::setupActions()
{
    // "File" menu
    KStdAction::openNew(this, SLOT(fileNew()), actionCollection());
    new KAction(i18n("New &Include File" ), "file_temporary", KShortcut(),
                this, SLOT(fileNewInclude()),
                actionCollection(), "new_include");
    KStdAction::open(this, SLOT(fileOpen()), actionCollection());
    KStdAction::close(this, SLOT(fileClose()), actionCollection());
    KStdAction::print(this, SLOT(filePrint()), actionCollection());
    KStdAction::quit(kapp, SLOT(closeAllWindows()), actionCollection());

    // Setup "Open Recent" menu and load old recent files.
    m_recentAction = KStdAction::openRecent(this, SLOT(load(const KURL&)),
                                            actionCollection());


    // "Goto" menu
    new KAction(i18n("Tas&ks"), "tj_task_group", KShortcut(KKey("ALT+k")),
                m_view, SLOT(setFocusToTaskList()),
                actionCollection(), "tasks");
    new KAction(i18n("&Resources"), "tj_resource_group",
                KShortcut(KKey("ALT+r")),
                m_view, SLOT(setFocusToResourceList()),
                actionCollection(), "resources");
    new KAction(i18n("&Accounts"), "tj_account_group",
                KShortcut(KKey("ALT+a")),
                m_view, SLOT(setFocusToAccountList()),
                actionCollection(), "accounts");
    new KAction(i18n("Re&ports"), "tj_report_list", KShortcut(KKey("ALT+p")),
                m_view, SLOT(setFocusToReportList()),
                actionCollection(), "reports");
    new KAction(i18n("F&iles"), "tj_file_list", KShortcut(KKey("ALT+i")),
                m_view, SLOT(setFocusToFileList()),
                actionCollection(), "files");
    new KAction(i18n("E&ditor"), "tj_editor", KShortcut("ALT+d"),
                m_view, SLOT(setFocusToEditor()),
                actionCollection(), "editor");
    new KAction(i18n("Rep&ort"), "tj_report", KShortcut("ALT+o"),
                m_view, SLOT(setFocusToReport()),
                actionCollection(), "report");

    // "Tools" menu
    new KAction(i18n("&Schedule"), "tj_schedule", KShortcut(KKey("F9")),
                m_view, SLOT(schedule()),
                actionCollection(), "schedule");
    new KAction(i18n("Stop scheduling"), "stop", 0,
                m_view, SLOT(stop()),
                actionCollection(), "stop");
    new KAction(i18n("&Generate all Reports"), 0, 0,
                m_view, SLOT(generate()),
                actionCollection(), "generate");
    new KAction(i18n("Goto &previous Problem"), "tj_previous_problem",
                KShortcut(KKey("F10")),
                m_view, SLOT(previousProblem()),
                actionCollection(), "previous_problem");
    new KAction(i18n("Goto &next Problem"), "tj_next_problem",
                KShortcut(KKey("F11")),
                m_view, SLOT(nextProblem()),
                actionCollection(), "next_problem");

    new KAction(i18n("Zoom &In"), "viewmag+", KShortcut(KKey("F7")),
                m_view, SLOT(zoomIn()),
                actionCollection(), "zoom_in");
    new KAction(i18n("Zoom &Out"), "viewmag-", KShortcut(KKey("F8")),
                m_view, SLOT(zoomOut()),
                actionCollection(), "zoom_out");

    // "Help" menu
    new KAction(i18n("Tip of the day"), "idea", 0, this,
                SLOT(showTip()), actionCollection(), "tip");
    new KAction(i18n("Explain Keyword"), "tj_keyword_help",
                KShortcut(KKey("F2")),
                m_view, SLOT(keywordHelp()),
                actionCollection(), "keyword_help");
    new KAction(i18n("Tutorial"), "tj_tutorial", 0,
                m_view, SLOT(tutorial()),
                actionCollection(), "tutorial");

    setupGUI(ToolBar | Keys | StatusBar | Save | Create);
}
Ejemplo n.º 19
0
void TipsDialog::on_nextButton_clicked()
{
  m_currentTip++;
  m_currentTip %= m_tips.size();
  showTip(m_currentTip);
}
Ejemplo n.º 20
0
// Draws the interface to the screen
void drawInterface()
{
	Sprite *temp;
	int i = -1;
	int x, y;
	TTF_Font *font;
	SDL_Surface *button;
	SDL_Rect dest;
	SDL_Surface icon;

	// fade HUD in/out
	if(HUD.menu != 0 && aSlide == false)
	{
		if(alpha > 4)
			alpha -= 5;
		else
			alpha = SDL_ALPHA_TRANSPARENT;
	}
	else if(alpha < (255*aLevel))
		alpha += 5;
	else
	{
		alpha = 255*aLevel;
	}

	if(HUD.menu > 0)
		SDL_FillRect(screen,&screen->clip_rect,SDL_MapRGB(screen->format, 0,0,0));
	else
	{
		if(players[0].placing > -1)
			placeStruct2();
	}

	// load font for text
	font = TTF_OpenFont("fonts/font1.ttf",30);
	if(font == NULL)
	{
		fprintf(stderr,"Font failed to load.\n");
	}

	// unless alpha > 0, don't bother drawing the interface
	if(alpha > 0)
	{
		// minimap
		temp = LoadSprite("hud/minimap.png",HUD.mapw,HUD.maph);
		SDL_SetAlpha( temp->image, SDL_SRCALPHA|SDL_RLEACCEL, alpha );
		DrawSprite(temp,screen,HUD.mapx,HUD.mapy,0);

		// info bar
		temp = LoadSprite("hud/infobar.png",HUD.infow,HUD.infoh);
		SDL_SetAlpha( temp->image, SDL_SRCALPHA|SDL_RLEACCEL, alpha );
		DrawSprite(temp,screen,HUD.infox,HUD.infoy,0);

		// Draw structure icons
		while(++i<MAX_STRUCT_TYPES)
		{
			if( HUD.aStructs[i].draw == false ) continue;

			// Draw background
			temp = LoadSprite("hud/qbutton.png",58,58);
			SDL_SetAlpha( temp->image, SDL_SRCALPHA|SDL_RLEACCEL, alpha );
			DrawSprite(temp, screen, HUD.aStructs[i].x, HUD.aStructs[i].y, 0);

			// Draw structure icon
			SDL_SetColorKey(HUD.aStructs[i].img->image, SDL_SRCCOLORKEY , SDL_MapRGB(HUD.aStructs[i].img->image->format, 255,255,255));
			SDL_SetAlpha(HUD.aStructs[i].img->image, SDL_SRCALPHA|SDL_RLEACCEL, alpha );
			DrawSprite(HUD.aStructs[i].img, screen, HUD.aStructs[i].x+((58-HUD.aStructs[i].img->w)*.5), HUD.aStructs[i].y+((58-HUD.aStructs[i].img->h)*.5), 0);
		}

		// Draw unit icons
		i = -1;
		while(++i<MAX_UNIT_TYPES)
		{
			if( HUD.aUnits[i].draw == false ) continue;

			// Draw background
			temp = LoadSprite("hud/qbutton.png",58,58);
			SDL_SetAlpha(temp->image, SDL_SRCALPHA|SDL_RLEACCEL, alpha );
			DrawSprite(temp,screen,HUD.aUnits[i].x,HUD.aUnits[i].y,0);

			// Draw unit icon
			SDL_SetColorKey(HUD.aUnits[i].img->image, SDL_SRCCOLORKEY , SDL_MapRGB(HUD.aUnits[i].img->image->format, 255,255,255));
			SDL_SetAlpha(HUD.aUnits[i].img->image, SDL_SRCALPHA|SDL_RLEACCEL, alpha );
			DrawSprite(HUD.aUnits[i].img, screen, HUD.aUnits[i].x+((58-HUD.aUnits[i].img->w)*.5), HUD.aUnits[i].y+((58-HUD.aUnits[i].img->h)*.5), 0);
		}

		// media player bar
		temp = LoadSprite("hud/mplayerbar.png",HUD.playerw,HUD.playerh);
		SDL_SetAlpha( temp->image, SDL_SRCALPHA|SDL_RLEACCEL, alpha );
		DrawSprite(temp,screen,HUD.playerx,HUD.playery,0);
		updatePlayer();

		// tool tips
		if(HUD.ttips)
			showTip();
	}

	// Draw menu
	if( (HUD.menu > 0) && (HUD.menu != 5) )
	{
		temp = LoadSprite("hud/menu.png",640,480);

		// center and draw the menu panel and buttons
		if(screen->w > 640)
			x = screen->w * .5 - 320;
		else
			x = 0;
		if(screen->h > 480)
			y = screen->h * .5 - 240;
		else
			y = 0;

		DrawSprite(temp,screen,x,y,0);
	}

	// Draw the button text
	// Main menu
	if(HUD.menu == 1)
	{
		// New Game
		dest.x = MENU_X+250;
		dest.y = MENU_Y+55;
		dest.w = 100;
		dest.h = 50;
		if(mouseOver == 1)
			button = TTF_RenderText_Blended(font,"New Game",oColor);
		else
			button = TTF_RenderText_Blended(font,"New Game",color);
		if(button != NULL)
			SDL_BlitSurface(button,NULL,screen,&dest);
		SDL_FreeSurface(button);

		// Resume
		dest.x = MENU_X+260;
		dest.y = MENU_Y+138;
		dest.w = 100;
		dest.h = 50;

		if(players[0].inGame)
		{
			if(mouseOver == 2)
				button = TTF_RenderText_Blended(font,"Resume",oColor);
			else
				button = TTF_RenderText_Blended(font,"Resume",color);
		}
		else
			button = TTF_RenderText_Blended(font,"Resume",bColor);

		if(button != NULL)
			SDL_BlitSurface(button,NULL,screen,&dest);
		SDL_FreeSurface(button);

		// Save/Load
		dest.x = MENU_X+245;
		dest.y = MENU_Y+223;
		dest.w = 100;
		dest.h = 50;
		if(mouseOver == 3)
			button = TTF_RenderText_Blended(font,"Save/Load",oColor);
		else
			button = TTF_RenderText_Blended(font,"Save/Load",color);
		if(button != NULL)
			SDL_BlitSurface(button,NULL,screen,&dest);
		SDL_FreeSurface(button);

		// Options
		dest.x = MENU_X+260;
		dest.y = MENU_Y+302;
		dest.w = 100;
		dest.h = 50;
		if(mouseOver == 4)
			button = TTF_RenderText_Blended(font,"Options",oColor);
		else
			button = TTF_RenderText_Blended(font,"Options",color);
		if(button != NULL)
			SDL_BlitSurface(button,NULL,screen,&dest);
		SDL_FreeSurface(button);

		// Quit
		dest.x = MENU_X+285;
		dest.y = MENU_Y+385;
		dest.w = 100;
		dest.h = 50;
		if(mouseOver == 5)
			button = TTF_RenderText_Blended(font,"Quit",oColor);
		else
			button = TTF_RenderText_Blended(font,"Quit",color);
		if(button != NULL)
			SDL_BlitSurface(button,NULL,screen,&dest);
		SDL_FreeSurface(button);
	}

	// Save/Load submenu
	else if(HUD.menu == 2)
	{
		// Save
		dest.x = MENU_X+275;
		dest.y = MENU_Y+55;
		dest.w = 100;
		dest.h = 50;
		if(mouseOver == 1)
			button = TTF_RenderText_Blended(font,"Save",oColor);
		else
			button = TTF_RenderText_Blended(font,"Save",color);
		if(button != NULL)
			SDL_BlitSurface(button,NULL,screen,&dest);
		SDL_FreeSurface(button);

		// Load
		dest.x = MENU_X+275;
		dest.y = MENU_Y+138;
		dest.w = 100;
		dest.h = 50;
		if(mouseOver == 2)
			button = TTF_RenderText_Blended(font,"Load",oColor);
		else
			button = TTF_RenderText_Blended(font,"Load",color);
		if(button != NULL)
			SDL_BlitSurface(button,NULL,screen,&dest);
		SDL_FreeSurface(button);

		// Main Menu
		dest.x = MENU_X+245;
		dest.y = MENU_Y+385;
		dest.w = 100;
		dest.h = 50;
		if(mouseOver == 5)
			button = TTF_RenderText_Blended(font,"Main Menu",oColor);
		else
			button = TTF_RenderText_Blended(font,"Main Menu",color);
		if(button != NULL)
			SDL_BlitSurface(button,NULL,screen,&dest);
		SDL_FreeSurface(button);
	}

	// Options submenu
	else if(HUD.menu == 3)
	{
		// Sound
		dest.x = MENU_X+275;
		dest.y = MENU_Y+55;
		dest.w = 100;
		dest.h = 50;
		if(mouseOver == 1)
			button = TTF_RenderText_Blended(font,"Sound",oColor);
		else
			button = TTF_RenderText_Blended(font,"Sound",color);
		if(button != NULL)
			SDL_BlitSurface(button,NULL,screen,&dest);
		SDL_FreeSurface(button);

		// Controls
		dest.x = MENU_X+260;
		dest.y = MENU_Y+138;
		dest.w = 100;
		dest.h = 50;
		if(mouseOver == 2)
			button = TTF_RenderText_Blended(font,"Controls",oColor);
		else
			button = TTF_RenderText_Blended(font,"Controls",color);
		if(button != NULL)
			SDL_BlitSurface(button,NULL,screen,&dest);
		SDL_FreeSurface(button);

		// HUD
		dest.x = MENU_X+285;
		dest.y = MENU_Y+223;
		dest.w = 100;
		dest.h = 50;
		if(mouseOver == 3)
			button = TTF_RenderText_Blended(font,"HUD",oColor);
		else
			button = TTF_RenderText_Blended(font,"HUD",color);
		if(button != NULL)
			SDL_BlitSurface(button,NULL,screen,&dest);
		SDL_FreeSurface(button);

		// Game
		dest.x = MENU_X+270;
		dest.y = MENU_Y+302;
		dest.w = 100;
		dest.h = 50;
		if(mouseOver == 4)
			button = TTF_RenderText_Blended(font,"Game",oColor);
		else
			button = TTF_RenderText_Blended(font,"Game",color);
		if(button != NULL)
			SDL_BlitSurface(button,NULL,screen,&dest);
		SDL_FreeSurface(button);

		// Main Menu
		dest.x = MENU_X+245;
		dest.y = MENU_Y+385;
		dest.w = 100;
		dest.h = 50;
		if(mouseOver == 5)
			button = TTF_RenderText_Blended(font,"Main Menu",oColor);
		else
			button = TTF_RenderText_Blended(font,"Main Menu",color);
		if(button != NULL)
			SDL_BlitSurface(button,NULL,screen,&dest);
		SDL_FreeSurface(button);
	}

	// Sound submenu
	else if(HUD.menu == 4)
	{
		// Sound effects volume
		dest.x = MENU_X+140;
		dest.y = MENU_Y+55;
		dest.w = 100;
		dest.h = 50;
		if(mouseOver == 1)
			button = TTF_RenderText_Blended(font,"Effects Volume",oColor);
		else
			button = TTF_RenderText_Blended(font,"Effects Volume",color);
		if(button != NULL)
			SDL_BlitSurface(button,NULL,screen,&dest);
		SDL_FreeSurface(button);

		// Draw slots for volume sliders
		dest.x += 235;
		dest.y += 15;
		temp = LoadSprite("hud/menuslots.png",126,13);
		DrawSprite(temp,screen,dest.x,dest.y,0);

		dest.y += 85;
		temp = LoadSprite("hud/menuslots.png",126,13);
		DrawSprite(temp,screen,dest.x,dest.y,0);

		// Update info based on slider position
		dest.x += 10;
		dest.w = 100;
		if( (audio.slide == 1) )
		{
			if(SDL_GetMouseState(NULL,NULL)&SDL_BUTTON_LMASK)
			{
				audio.eVol = moveSlider(&audio.evSlider,&dest);
			}
			else
				audio.slide = 0;
		}

		else if( (audio.slide == 2) )
		{
			if(SDL_GetMouseState(NULL,NULL)&SDL_BUTTON_LMASK)
			{
				audio.mVol = moveSlider(&audio.mvSlider,&dest);
			}
			else
				audio.slide = 0;
		}
		else
		{
			audio.evSlider.x = dest.x + (dest.w*audio.eVol);
			audio.mvSlider.x = dest.x + (dest.w*audio.mVol);
		}

		// Draw sliders
		temp = LoadSprite("hud/slider.png",50,24);
		button = IMG_Load("hud/slider.png");
		SDL_SetColorKey(button, 0, 0);
		temp->image = SDL_DisplayFormatAlpha(button);
		SDL_FreeSurface(button);

		temp = LoadSprite("hud/slider.png",50,24);
		DrawSprite(temp,screen,audio.evSlider.x-(audio.evSlider.w*.5),audio.evSlider.y,0);

		temp = LoadSprite("hud/slider.png",50,24);
		DrawSprite(temp,screen,audio.mvSlider.x-(audio.mvSlider.w*.5),audio.mvSlider.y,0);

		// Music volume
		dest.x = MENU_X+140;
		dest.y = MENU_Y+138;
		dest.w = 100;
		dest.h = 50;
		if(mouseOver == 2)
			button = TTF_RenderText_Blended(font,"Music Volume",oColor);
		else
			button = TTF_RenderText_Blended(font,"Music Volume",color);
		if(button != NULL)
			SDL_BlitSurface(button,NULL,screen,&dest);
		SDL_FreeSurface(button);

		// Mute
		dest.x = MENU_X+275;
		dest.y = MENU_Y+223;
		dest.w = 100;
		dest.h = 50;
		if(mouseOver == 3)
			button = TTF_RenderText_Blended(font,"Mute",oColor);
		else
			button = TTF_RenderText_Blended(font,"Mute",color);
		if(button != NULL)
			SDL_BlitSurface(button,NULL,screen,&dest);
		SDL_FreeSurface(button);

		// Back
		dest.x = MENU_X+285;
		dest.y = MENU_Y+385;
		dest.w = 100;
		dest.h = 50;
		if(mouseOver == 5)
			button = TTF_RenderText_Blended(font,"Back",oColor);
		else
			button = TTF_RenderText_Blended(font,"Back",color);
		if(button != NULL)
			SDL_BlitSurface(button,NULL,screen,&dest);
		SDL_FreeSurface(button);
	}

	// HUD submenu
	else if(HUD.menu == 6)
	{
		// Alpha level
		dest.x = MENU_X+175;
		dest.y = MENU_Y+55;
		dest.w = 100;
		dest.h = 50;
		if(mouseOver == 1)
			button = TTF_RenderText_Blended(font,"Alpha Level",oColor);
		else
			button = TTF_RenderText_Blended(font,"Alpha Level",color);
		if(button != NULL)
			SDL_BlitSurface(button,NULL,screen,&dest);
		SDL_FreeSurface(button);

		// Draw slot for alpha slider
		dest.x += 200;
		dest.y += 15;
		temp = LoadSprite("hud/menuslots.png",126,13);
		DrawSprite(temp,screen,dest.x,dest.y,0);

		// Update info based on slider position
		dest.x += 10;
		dest.w = 100;
		if( (aSlide == true) )
		{
			if(SDL_GetMouseState(NULL,NULL)&SDL_BUTTON_LMASK)
			{
				aLevel = moveSlider(&aSlider,&dest);
			}
			else
				aSlide = false;
		}

		else
		{
			aSlider.x = dest.x + (dest.w*aLevel);
		}

		// Draw sliders
		temp = LoadSprite("hud/slider.png",50,24);
		DrawSprite(temp,screen,aSlider.x-(aSlider.w*.5),aSlider.y,0);

		// Save
		dest.x = MENU_X+285;
		dest.y = MENU_Y+138;
		dest.w = 100;
		dest.h = 50;
		if(mouseOver == 2)
			button = TTF_RenderText_Blended(font,"Save",oColor);
		else
			button = TTF_RenderText_Blended(font,"Save",color);
		if(button != NULL)
			SDL_BlitSurface(button,NULL,screen,&dest);
		SDL_FreeSurface(button);

		// Load
		dest.x = MENU_X+285;
		dest.y = MENU_Y+223;
		dest.w = 100;
		dest.h = 50;
		if(mouseOver == 3)
			button = TTF_RenderText_Blended(font,"Load",oColor);
		else
			button = TTF_RenderText_Blended(font,"Load",color);
		if(button != NULL)
			SDL_BlitSurface(button,NULL,screen,&dest);
		SDL_FreeSurface(button);

		// Back
		dest.x = MENU_X+285;
		dest.y = MENU_Y+385;
		dest.w = 100;
		dest.h = 50;
		if(mouseOver == 5)
			button = TTF_RenderText_Blended(font,"Back",oColor);
		else
			button = TTF_RenderText_Blended(font,"Back",color);
		if(button != NULL)
			SDL_BlitSurface(button,NULL,screen,&dest);
		SDL_FreeSurface(button);
	}

	// Game submenu
	else if(HUD.menu == 7)
	{
		// Scroll speed
		dest.x = MENU_X+175;
		dest.y = MENU_Y+55;
		dest.w = 100;
		dest.h = 50;
		if(mouseOver == 1)
			button = TTF_RenderText_Blended(font,"Scroll Speed",oColor);
		else
			button = TTF_RenderText_Blended(font,"Scroll Speed",color);
		if(button != NULL)
			SDL_BlitSurface(button,NULL,screen,&dest);
		SDL_FreeSurface(button);

		// Draw slot for scroll speed slider
		dest.x += 200;
		dest.y += 15;
		temp = LoadSprite("hud/menuslots.png",126,13);
		DrawSprite(temp,screen,dest.x,dest.y,0);

		dest.x += 10;
		dest.w = 100;

		if( (HUD.sSlide == true) )
		{
			if(SDL_GetMouseState(NULL,NULL)&SDL_BUTTON_LMASK)
			{
				sSpeed = moveSlider(&sSlider,&dest);
			}
			else
				HUD.sSlide = false;
		}

		else
		{
			sSlider.x = dest.x + (dest.w*sSpeed);
		}

		// Draw slider
		temp = LoadSprite("hud/slider.png",50,24);
		DrawSprite(temp,screen,sSlider.x-(sSlider.w*.5),sSlider.y,0);

		// Tool tips on/off
		dest.x = MENU_X+215;
		dest.y = MENU_Y+138;
		dest.w = 100;
		dest.h = 50;

		if(mouseOver == 2)
			button = TTF_RenderText_Blended(font,"Tool Tips",oColor);
		else
			button = TTF_RenderText_Blended(font,"Tool Tips",color);
		if(button != NULL)
		{
			SDL_BlitSurface(button,NULL,screen,&dest);
			SDL_FreeSurface(button);
		}

		dest.x += 150;
		if(HUD.ttips)
			button = TTF_RenderText_Blended(font,"On",color);
		else
			button = TTF_RenderText_Blended(font,"Off",color);
		if(button != NULL)
		{
			SDL_BlitSurface(button,NULL,screen,&dest);
			SDL_FreeSurface(button);
		}

		// Back
		dest.x = MENU_X+285;
		dest.y = MENU_Y+385;
		dest.w = 100;
		dest.h = 50;
		if(mouseOver == 5)
			button = TTF_RenderText_Blended(font,"Back",oColor);
		else
			button = TTF_RenderText_Blended(font,"Back",color);
		if(button != NULL)
			SDL_BlitSurface(button,NULL,screen,&dest);
		SDL_FreeSurface(button);
	}

	if(font != NULL)
		TTF_CloseFont(font);
}
Ejemplo n.º 21
0
void ExprShortTextEdit::keyPressEvent(QKeyEvent* e) {

    // If the completer is active pass keys it needs down
    if (completer && completer->popup()->isVisible()) {
        switch (e->key()) {
            case Qt::Key_Enter:
            case Qt::Key_Return:
            case Qt::Key_Escape:
            case Qt::Key_Tab:
            case Qt::Key_Backtab:
                e->ignore();
                return;
            default:
                break;
        }
    }

    // Accept expression
    if (e->key() == Qt::Key_Return || e->key() == Qt::Key_Enter) {
        selectAll();
        finishEdit();
        return;
    } else if (e->key() == Qt::Key_Escape) {
        setText(savedText);
        selectAll();
        finishEdit();
        return;
    } else if (e->key() == Qt::Key_Tab) {
        QWidget::keyPressEvent(e);
        return;
    } else if (!editing) {
        editing = true;
        setColor(true);
        savedText = toPlainText();
    }

    // use the values here as long as we are not using the shortcut to bring up the editor
    bool isShortcut = ((e->modifiers() & Qt::ControlModifier) && e->key() == Qt::Key_E);  // CTRL+E
    if (!isShortcut)  // dont process the shortcut when we have a completer
        QTextEdit::keyPressEvent(e);

    const bool ctrlOrShift = e->modifiers() & (Qt::ControlModifier | Qt::ShiftModifier);
    if (!completer || (ctrlOrShift && e->text().isEmpty())) return;

    bool hasModifier = (e->modifiers() != Qt::NoModifier) && !ctrlOrShift;

    // grab the line we're on
    QTextCursor tc = textCursor();
    tc.movePosition(QTextCursor::StartOfLine, QTextCursor::KeepAnchor);
    QString line = tc.selectedText();

    // matches the last prefix of a completable variable or function and extract as completionPrefix
    static QRegExp completion("^(?:.*[^A-Za-z0-9_$])?((?:\\$[A-Za-z0-9_]*)|[A-Za-z]+[A-Za-z0-9_]*)$");
    int index = completion.indexIn(line);
    QString completionPrefix;
    if (index != -1 && !line.contains('#')) {
        completionPrefix = completion.cap(1);
        // std::cout<<"we have completer prefix '"<<completionPrefix.toStdString()<<"'"<<std::endl;
    }

    // hide the completer if we have too few characters, we are at end of word
    if (!isShortcut && (hasModifier || e->text().isEmpty() || completionPrefix.length() < 1 || index == -1)) {
        completer->popup()->hide();
    } else {

        // copy the completion prefix in if we don't already have it in the completer
        if (completionPrefix != completer->completionPrefix()) {
            completer->setCompletionPrefix(completionPrefix);
            completer->popup()->setCurrentIndex(completer->completionModel()->index(0, 0));
        }

        // display the completer
        QRect cr = cursorRect();
        cr.setWidth(2 * (completer->popup()->sizeHintForColumn(0) + completer->popup()->sizeHintForColumn(1) +
                         completer->popup()->verticalScrollBar()->sizeHint().width()));
        completer->complete(cr);
        hideTip();
        return;
    }

    // documentation completion
    static QRegExp inFunction("^(?:.*[^A-Za-z0-9_$])?([A-Za-z0-9_]+)\\([^()]*$");
    int index2 = inFunction.indexIn(line);
    if (index2 != -1) {
        QString functionName = inFunction.cap(1);
        QStringList tips = completionModel->getDocString(functionName).split("\n");
        QString tip = "<b>" + tips[0] + "</b>";
        for (int i = 1; i < tips.size(); i++) {
            tip += "<br>" + tips[i];
        }
        showTip(tip);
    } else {
        hideTip();
    }
}
Ejemplo n.º 22
0
void keyInput(void)
{
	// 传入NULL参数将返回所有已按的按键的一个指针数组、迩可以
	// 遍历这个数组然后检测迩想检测的按键是否已经按下去了
	keys = SDL_GetKeyState(NULL);

	if(Gamepad->Button_Start)
	{	
		showMenu();
	}

	/*
	if(keys[SDLK_f])
	{
		delete [] cheatcode;
		cheatcode = new char[10];

		strcpy(cheatcode,"f");		
		keys[SDLK_f] = 0;
	}
	if(keys[SDLK_i])
	{
		if(strlen(cheatcode)<10)
			strcat(cheatcode,"i");	
		keys[SDLK_i] = 0;
	}
	if(keys[SDLK_r])
	{
		if(strlen(cheatcode)<10)
			strcat(cheatcode,"r");
		keys[SDLK_r] = 0;
	}

	*/
	// 1、 假如输入fir再输入e、那么会掉一个花出来奖励给玩家、如果再按
	// 会再出现、最多只能出现5朵花
   // 2、假如输入了di再输入e、那么会自杀
	// e就是执行的意思
	if(keys[SDLK_8])
	{
		if(cheats_enabled)
		//if(!strcmp(cheatcode,"fir"))
		{
			keys[SDLK_8] = 0;
		
			for(int i=0;i<5;i++)
				// 同一时刻只准在屏幕中出现最多5个奖励物品
				if(!BONUS_DYNAMIC[i]->online)
				{
					cheater = 1;
					BONUS_DYNAMIC[i]->init(PLAYER->x/40,(PLAYER->y-80)/40,1);
					break;
				}
		}
		//if(!strcmp(cheatcode,"di"))
			//PLAYER->die();
	}

	if(keys[SDLK_0])
	{
		if(cheats_enabled)
		//if(!strcmp(cheatcode,"fir"))
		{
			keys[SDLK_0] = 0;
		
			for(int i=0;i<5;i++)
				// 同一时刻只准在屏幕中出现最多5个奖励物品
				if(!BONUS_DYNAMIC[i]->online)
				{
					cheater = 1;
					BONUS_DYNAMIC[i]->init(PLAYER->x/40,(PLAYER->y-80)/40,2);
					break;
				}
		}
		//if(!strcmp(cheatcode,"di"))
			//PLAYER->die();
	}
	/*
	else
	if(keys[SDLK_b])
	{
		delete [] cheatcode;
		cheatcode = new char[10];

		strcpy(cheatcode,"b");		
		keys[SDLK_b] = 0;
	}
	*/

	// 如果输入了bi再输入g、就长出蘑菇、和前面长出花是一样道理的
	if(keys[SDLK_9])
	{
	if(cheats_enabled)
		//if(!strcmp(cheatcode,"bi"))
		{	keys[SDLK_9] = 0;
			for(int i=0;i<5;i++)
				if(!BONUS_DYNAMIC[i]->online)
				{
					cheater = 1;
					BONUS_DYNAMIC[i]->init(PLAYER->x/40,(PLAYER->y-80)/40,0);
					break;
				}
		}
	}
	/*
	else
	if(keys[SDLK_d])
	{
		delete [] cheatcode;
		cheatcode = new char[10];

		strcpy(cheatcode,"d");		
		keys[SDLK_d] = 0;
	}
		else
	if(keys[SDLK_s])
	{
		delete [] cheatcode;
		cheatcode = new char[10];

		strcpy(cheatcode,"s");		
		keys[SDLK_s] = 0;
	}

	*/
	// 先输入s再输入l可以实现超级跳
	if(keys[SDLK_l])
	{
	if(cheats_enabled)
		//if(!strcmp(cheatcode,"s"))
			PLAYER->changeStat(0);
	}
	if(keys[SDLK_p])
	{
		PLAYSOUND0(S_PAUSE);
		showTip("  Game Paused"," "," ","   The journey goes on"," "," "," ");
	}

	// 如果同时输入5和1、MARIO会飞
	if(cheats_enabled)
	if(keys[SDLK_i])
	{
		cheater = 1;
		PLAYER->y_speed = -5;
	}

	
}
Ejemplo n.º 23
0
UserView::UserView()
        : UserListBase(NULL)
{
    m_bBlink = false;
    m_bUnreadBlink = false;
    m_bShowOnline = CorePlugin::m_plugin->getShowOnLine();

    setBackgroundMode(NoBackground);
    viewport()->setBackgroundMode(NoBackground);

    mTipItem = NULL;
    m_tip = NULL;
    m_searchTip = NULL;
    m_current = NULL;

    setTreeStepSize(0);

    tipTimer = new QTimer(this);
    connect(tipTimer, SIGNAL(timeout()), this, SLOT(showTip()));
    blinkTimer = new QTimer(this);
    connect(blinkTimer, SIGNAL(timeout()), this, SLOT(blink()));
    unreadTimer = new QTimer(this);
    connect(unreadTimer, SIGNAL(timeout()), this, SLOT(unreadBlink()));

    topLevelWidget()->installEventFilter(this);
    viewport()->installEventFilter(this);

    m_dropContactId = 0;
    m_dropItem = NULL;
    m_searchItem = NULL;

    setFrameStyle(QFrame::Panel);
    setFrameShadow(QFrame::Sunken);
    WindowDef wnd;
    wnd.widget = this;
    wnd.bDown  = true;
    Event e(EventAddWindow, &wnd);
    e.process();
    clear();

    setGroupMode(CorePlugin::m_plugin->getGroupMode(), true);

    edtGroup = new IntLineEdit(viewport());
    edtContact = new IntLineEdit(viewport());
    edtGroup->hide();
    edtContact->hide();
    QFont font(font());
    int size = font.pixelSize();
    if (size <= 0){
        size = font.pointSize();
        font.setPointSize(size * 3 / 4);
    }else{
        font.setPixelSize(size * 3 / 4);
    }
    font.setBold(true);
    edtGroup->setFont(font);
    connect(edtGroup, SIGNAL(escape()), this, SLOT(editEscape()));
    connect(edtGroup, SIGNAL(returnPressed()), this, SLOT(editGroupEnter()));
    connect(edtGroup, SIGNAL(focusOut()), this, SLOT(editGroupEnter()));
    connect(edtContact, SIGNAL(escape()), this, SLOT(editEscape()));
    connect(edtContact, SIGNAL(returnPressed()), this, SLOT(editContactEnter()));
    connect(edtContact, SIGNAL(focusOut()), this, SLOT(editContactEnter()));
}