コード例 #1
0
ファイル: ZFonts.cpp プロジェクト: OpenMagx/open-magx-src
void ZFonts::CreateWindow ( QWidget* parent )
{
	//Set title window
	setMainWidgetTitle ( "zFonts" );
	
	lbFonts = new ZListBox(this);
	
	QFont font ( qApp->font() ); 
	font.setPointSize ( 18 );
	lbFonts->setItemFont( ZListBox::LISTITEM_REGION_A, ZListBox::StStandard, font );	
	lbFonts->setItemFont( ZListBox::LISTITEM_REGION_A, ZListBox::StHighlighted, font );	
	
	connect ( lbFonts, SIGNAL( selected(int) ), this, SLOT( slot_fontSelect(int) ) );
	
	setContentWidget( lbFonts );

	fillFonts();

	//Create SoftKey and Menu
	ZSoftKey *softKey = new ZSoftKey ( NULL , this , this );
	
	QRect rect(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT);
	ZOptionsMenu* menu = new ZOptionsMenu ( rect, softKey, NULL, 0 );
	menu->setItemSpacing(12);
	
	QPixmap * pm = new QPixmap();

	pm->load(ProgDir+ "/view_font.png");
	menu->insertItem ( tr("TXT_RID_OPTION_PREVIEW", "Preview"), NULL, pm, true, 0, 0 );
	pm->load(ProgDir+ "/set_fonts.png");
	menu->insertItem ( tr("TXT_RID_SOFTKEY_INSTALL", "Install"), NULL, pm, true, 1, 1 );
	pm->load(ProgDir+ "/about.png");
	menu->insertSeparator(2, 2); 
	menu->insertItem ( tr("TXT_RID_SOFTKEY_ABOUT_JAVA", "About").replace("Java",""), NULL, pm, true, 3, 3 );
	pm->load(ProgDir+ "/exit.png");
	menu->insertItem ( tr("TXT_RID_OPTION_EXIT", "Exit"), NULL, pm, true, 4, 4 );
	
	menu->connectItem ( 0, this, SLOT ( slot_preview() ) );
	menu->connectItem ( 1, this, SLOT ( slot_install() ) );
	menu->connectItem ( 3, this, SLOT ( slot_about() ) );
	menu->connectItem ( 4, qApp, SLOT ( quit() ) );	
	
	softKey->setText ( ZSoftKey::LEFT, tr("TXT_RID_SOFTKEY_OPTIONS", "Options"), ( ZSoftKey::TEXT_PRIORITY ) 0 );
	softKey->setText ( ZSoftKey::RIGHT, tr("TXT_RID_OPTION_EXIT", "Exit"), ( ZSoftKey::TEXT_PRIORITY ) 0 );
	softKey->setOptMenu ( ZSoftKey::LEFT, menu );
	softKey->setClickedSlot ( ZSoftKey::RIGHT, qApp, SLOT ( quit() ) );
	
	setSoftKey ( softKey );
}
コード例 #2
0
bool IMPluginSwitcher::keyPressed(QKeyEvent *p_keyPressEvent,  ZInputField* field)
//bool IMPluginSwitcher::keyReleased(QKeyEvent *p_keyPressEvent,  ZInputField* field)
//bool IMPluginSwitcher::hack(QKeyEvent *p_keyPressEvent,  ZInputField* field)
{
	toLog( "##### Start my keyPressed! ");

	bool ret = keyPressedInternal( p_keyPressEvent, field );

    if ( field != NULL && p_keyPressEvent->key() == KEY_GREEN )
    {
		toLog( "##### Key code is GREEN !!! " );
		toLog( "##### Getting editor" );
		
		QWidget * editor = field->getEditorWidget();
		
		toLog( "##### Create action dlg" );
		EDIT_FILD_TYPE tupeEditor = TYPE_UDEFINE;
		
		{ //For not use more memory, to store class name
		QString s = QString(editor->className());

		toLog( "##### Editor class: "+s );

		if ( s.find("MultiLineEdit") != -1)
			tupeEditor = TYPE_MULTI_LINE_EDIT; 
		else if ( s.find("LineEdit") != -1 )
			tupeEditor = TYPE_LINE_EDIT; 
		else if ( (s.find("ZTextEdit") != -1) || (s.find("MMS_PageWidget") != -1) )
			tupeEditor = TYPE_TEXT_EDIT;
		else if  ( s.find("SVGCanvas") != -1 )
			return false; //Copy past don't work(
	
		}

		int selected=CANCEL_CODE;
		
		if ( onSelectText )
		{
			toLog( "##### Auto select" );
			selected = ACTION_SELECT_END;
		} else
		{			
			QRect rect(0,0,SCREEN_WIDTH,SCREEN_HEIGHT);
			ZOptionsMenu * menu = new ZOptionsMenu (rect, editor);//editor->topLevelWidget()
			
			toLog( "##### Insert item to list" );		
			
			INSERT_ITEM(ZWidget::tr("TXT_RID_OPTION_COPY", "Copy"),  ACTION_COPY);
			INSERT_ITEM(ZWidget::tr("TXT_RID_OPTION_INSERT", "Paste"), ACTION_PAST);
			
			int x1=0,x2=0,y1,y2;
			bool oldSel=false;
			
			if ( tupeEditor != TYPE_UDEFINE )
			{
				INSERT_ITEM(ZWidget::tr("TXT_RID_MENU_CUT", "Cut"), ACTION_CUT);
		        INSERT_SEP();
		        INSERT_ITEM(ZWidget::tr("TXT_RID_OPTION_SELECT_ALL", "onSelectText all"), ACTION_SELECT_ALL);
				INSERT_ITEM(ZWidget::tr("TXT_RID_HEADER_SELECT", "Select"), ACTION_SELECT_START);
				
				//save curren state of input fild and get cursor point
				QPoint pos(0,0);
				switch ( tupeEditor )
				{
					case TYPE_MULTI_LINE_EDIT:
						pos = ((ZMultiLineEdit*)editor)->mapToGlobal(((ZMultiLineEdit*)editor)->cursorPoint());
						oldSel = ((ZMultiLineEdit*)editor)->hasMarkedText();
						if ( oldSel )
							((ZMultiLineEdit*)editor)->getMarkedRegion( &x1, &y1, &x2, &y2 );
						else
							((ZMultiLineEdit*)editor)->getCursorPosition( &x1, &y1 );
						break;
					case TYPE_LINE_EDIT:
						pos = ((ZLineEdit*)editor)->mapToGlobal(((ZLineEdit*)editor)->cursorPoint());
						oldSel = ((ZLineEdit*)editor)->hasMarkedText();
						if ( !oldSel )
							x1=((ZLineEdit*)editor)->cursorPosition();
						break;
					case TYPE_TEXT_EDIT:
					default:
						pos = editor->mapToGlobal( field->getCursorPos() );
						break;
				}
				menu->setPosition(ZOptionsMenu::TopLeft, pos );
			}
			
			toLog(  "##### Show dlg" );
			
			menu->popup();	
			while ( !menu->isHidden() ) qApp->processEvents();
			selected = menu->getCurrentSelectedItemId();

			//load state of input fild
			if ( tupeEditor>0 )
			{
				switch ( tupeEditor )
				{
					case TYPE_MULTI_LINE_EDIT:
						if ( oldSel )
							((ZMultiLineEdit*)editor)->setSelection( x1, y1, x2, y2 );
						else
							((ZMultiLineEdit*)editor)->setCursorPosition( x1, y1, false );
						break;
					case TYPE_LINE_EDIT:
						if ( oldSel )
						{
							if ( GET_CURSOR_Y == -1 )
								((ZLineEdit*)editor)->selectAll();
							else
								((ZLineEdit*)editor)->setSelection( GET_CURSOR_X, GET_CURSOR_Y );
						}
						else
							((ZLineEdit*)editor)->setCursorPosition(x1);
						break;
					default:
						break;					
				}				
			}

			toLog(  "##### Delete dlg" );		
			    	
			delete menu;
			menu = NULL;
		}		
		
		if ( selected >= 0 )
		{
			toLog( "##### Operate code:" << selected << " edit type:" << tupeEditor );		
				
			switch (tupeEditor)
			{
				case TYPE_UDEFINE:
				{
					switch (selected)
					{
						case ACTION_COPY:
						{
							QString text = field->getText(QPoint(-1,-1),true);
							QApplication::clipboard()->setText( text=="text/plain"?"":text );
							toLog( "##### >Text:" + text  );
							break;
						}
						case ACTION_PAST:
						{
							field->insertString( field->getCursorPos(), QApplication::clipboard()->text());
							break;
						}
					}
					break;
				}	
				case TYPE_MULTI_LINE_EDIT:
				{							
					switch (selected)
					{
						case ACTION_COPY:
						{
							((ZMultiLineEdit*)editor)->copy();
							break;
						}
						case ACTION_PAST:
						{
							((ZMultiLineEdit*)editor)->paste();
							break;
						}
						case ACTION_CUT:
						{							
							((ZMultiLineEdit*)editor)->cut();
							break;
						}
						case ACTION_SELECT_ALL:
						{
							((ZMultiLineEdit*)editor)->selectAll();
							break;
						}
						case ACTION_SELECT_START:
						{
							int iSelX = 0;
							int iSelY = 0;
							((ZMultiLineEdit*)editor)->getCursorPosition( &iSelX, &iSelY );
							
							onSelectText = true;
		    				SET_CURSOR
							break;
						}	
						case ACTION_SELECT_END:
						{
							if ( !onSelectText )
								break;

							int iSelX = 0;
							int iSelY = 0;
							((ZMultiLineEdit*)editor)->getCursorPosition( &iSelX, &iSelY );

		    				((ZMultiLineEdit*)editor)->setCursorPosition( GET_CURSOR_X, GET_CURSOR_Y, false );
							((ZMultiLineEdit*)editor)->setCursorPosition( iSelX, iSelY, true );
							
		    				onSelectText = false;			
							break;
						}															
					}
					break;
				}
				case TYPE_TEXT_EDIT:
				{				
					switch (selected)
					{
						case ACTION_COPY:
						{
							if ( ((ZTextEdit*)editor)->hasSelectedText() )
								QApplication::clipboard()->setText( ((ZTextEdit*)editor)->selectedText() );
							else
								QApplication::clipboard()->setText( ((ZTextEdit*)editor)->text() );
							break;
						}
						case ACTION_PAST:
						{
							if ( ((ZTextEdit*)editor)->hasSelectedText() )	
								((ZTextEdit*)editor)->del();

							int iSelX = 0;
							int iSelY = 0;
							
		    				((ZTextEdit*)editor)->getCursorPosition( &iSelX, &iSelY );
		    				((ZTextEdit*)editor)->insertAt(QApplication::clipboard()->text(), iSelX, iSelY);							
							break;
						}
						case ACTION_CUT:
						{
							if ( ((ZTextEdit*)editor)->hasSelectedText() )
								QApplication::clipboard()->setText( ((ZTextEdit*)editor)->selectedText() );
							else
								QApplication::clipboard()->setText( ((ZTextEdit*)editor)->text() );	
							if ( ((ZTextEdit*)editor)->hasSelectedText() )	
								((ZTextEdit*)editor)->del();
							else
								((ZTextEdit*)editor)->clear();						
							break;
						}
						case ACTION_SELECT_ALL:
						{
							((ZTextEdit*)editor)->selectAll(true);
							break;
						}
						case ACTION_SELECT_START:
						{
							int iSelX = 0;
							int iSelY = 0;
							
		    				((ZTextEdit*)editor)->getCursorPosition( &iSelX, &iSelY );
							onSelectText = true;
		    				SET_CURSOR
							break;
						}	
						case ACTION_SELECT_END:
						{
							if ( !onSelectText )
								break;

							int iSelX = 0;
							int iSelY = 0;

		    				((ZTextEdit*)editor)->getCursorPosition( &iSelX, &iSelY );					
							((ZTextEdit*)editor)->setSelection( GET_CURSOR_X, GET_CURSOR_Y, iSelX, iSelY );
							
		    				onSelectText = false;			
							break;
						}															
					}
					break;					
				} 
				case TYPE_LINE_EDIT:
				{				
					switch (selected)
					{
						case ACTION_COPY:
						{
							if ( ((ZLineEdit*)editor)->hasMarkedText() )
								QApplication::clipboard()->setText( ((ZLineEdit*)editor)->markedText() );
							else
							{
								QString text = ((ZLineEdit*)editor)->text();
								QApplication::clipboard()->setText( text=="text/plain"?"":text );
							}
							break;
						}
						case ACTION_PAST:
						{
		    				((ZLineEdit*)editor)->insert(QApplication::clipboard()->text());							
							break;
						}
						case ACTION_CUT:
						{
							if ( ((ZLineEdit*)editor)->hasMarkedText() )
								QApplication::clipboard()->setText( ((ZLineEdit*)editor)->markedText() );
							else
								QApplication::clipboard()->setText( ((ZLineEdit*)editor)->text() );	
							if ( ((ZLineEdit*)editor)->hasMarkedText() )	
								((ZLineEdit*)editor)->del();
							else
								((ZLineEdit*)editor)->clear();						
							break;
						}
						case ACTION_SELECT_ALL:
						{
							((ZLineEdit*)editor)->selectAll();
		    				int iSelX=-1;
		    				int iSelY=0;
		    				SET_CURSOR							
							break;
						}
						case ACTION_SELECT_START:
						{
		    				onSelectText = true;
		    				int iSelX=(((ZLineEdit*)editor)->cursorPosition());
		    				int iSelY=0;
		    				
		    				SET_CURSOR		
							break;
						}	
						case ACTION_SELECT_END:
						{
							if ( !onSelectText )
								break;		
							
							int iSelY = ((ZLineEdit*)editor)->cursorPosition()-GET_CURSOR_X;
							int iSelX=GET_CURSOR_X;
							if ( iSelY > 0 )
								((ZLineEdit*)editor)->setSelection( GET_CURSOR_X, iSelY );
		    				
		    				SET_CURSOR	
		    				
		    				onSelectText = false;				
							break;
						}														
					}
					break;					
				}
			}
		}
コード例 #3
0
ファイル: zgui.cpp プロジェクト: BGCX262/zsoft-svn-to-git
void ZGui::CreateWindow ( QWidget* parent )
{
  setMainWidgetTitle ( "zCleaner" );
  ZWidget *myWidget = new ZWidget ( this, NULL, 0, ( ZSkinService::WidgetClsID ) 40 );
  QFont f ( qApp->font() );
  f.setPointSize ( 10 );
  myWidget->setFont ( f );

  QVBoxLayout *myVBoxLayout = new QVBoxLayout ( myWidget, 0 );
  //*****************************
  //*** add elements here
  QLabel *myLabel = new QLabel ( QString ( "<qt><font size=\"+1\">zCleaner</font><br>"
                                 "<font size=\"-1\">Simple antivirus for Z6</font></qt>" ), myWidget );
  myVBoxLayout->addWidget ( myLabel, 0 );
  myLabel->setIndent ( 5 );
  myLabel->setAutoResize ( true );


  scrollPanel = new ZScrollPanel ( myWidget, NULL, 0, ( ZSkinService::WidgetClsID ) 0 );
  scrollPanel->resize ( 240, 320 );
   //-----------------------------------------------------------------------------------
  modo=new ZComboBox(this,"ZComboBox",true);//declaro los combobox
  lugar=new ZComboBox(this,"ZComboBox",true);
  modo->insertItem("Clean", 0 );
  modo->insertItem("AV", 1 );	
  //modo->insertItem("Picture/Video", 2 );  
  scrollPanel->addChild(modo , 100 , 5);//agrego el combobox de las apps al escritorio

  lab1 = new ZLabel("Mode" , this, "ZLabel", 0, (ZSkinService::WidgetClsID)4);
  lab1->setPreferredWidth(240);
  lab1->setAutoResize(true );
  
  scrollPanel->addChild(lab1 , 10 , 8);//agrego el label al menu
  
  lugar->insertItem("SD",0);
  lugar->insertItem("Phone",1);
  lugar->insertItem("SD/Phone",2);

  scrollPanel->addChild(lugar , 100 , 55);//agrego el propiestario al escritorio
  lab2  = new ZLabel("Location" , this, "ZLabel", 0, (ZSkinService::WidgetClsID)4);
  lab2->setPreferredWidth(240);
  lab2->setAutoResize(true );
  
  scrollPanel->addChild(lab2 , 10 , 58);//agrego el label al menu
  myVBoxLayout->addWidget ( scrollPanel, 0 );


  //*****************************
  setContentWidget ( myWidget );
  //************** softkeys and menus **************************
  ZSoftKey *softKey = new ZSoftKey ( NULL , this , this );
  QPixmap* pm  = new QPixmap();
  
  QRect rect, rect2, rect3, rect4;

  ZOptionsMenu* agre = new ZOptionsMenu ( rect3, softKey, NULL, 0, ( ZSkinService::WidgetClsID ) 2 );
  //pm->load(getProgramDir() + "img/about.png");
  agre->insertItem ( QString ( " ASK" ), NULL, NULL, true, 0, 0 );
  agre->insertItem ( QString ( " DELETE" ), NULL, NULL, true, 1, 1 );
  agre->connectItem ( 0, this, SLOT ( agregarTipoASK() ) );
  agre->connectItem ( 1, this, SLOT ( agregarTipoDELETE() ) );

  ZOptionsMenu* borr = new ZOptionsMenu ( rect4, softKey, NULL, 0, ( ZSkinService::WidgetClsID ) 2 );
  borr->insertItem ( QString ( " ASK" ), NULL, NULL, true, 0, 0 );
  borr->insertItem ( QString ( " DELETE" ), NULL, NULL, true, 1, 1 );
  borr->connectItem ( 0, this, SLOT ( eliminarTipoASK() ) );

  ZOptionsMenu* data = new ZOptionsMenu ( rect2, softKey, NULL, 0, ( ZSkinService::WidgetClsID ) 2 );
  pm->load(getProgramDir() + "img/add.png");
  data->insertItem ( QString ( " Add type" ), agre, pm, true, 0, 0 );
  pm->load(getProgramDir() + "img/remove.png");
  data->insertItem ( QString ( " Remove type" ), borr, pm, true, 1, 1 );

  
  ZOptionsMenu* menu = new ZOptionsMenu ( rect, softKey, NULL, 0, ( ZSkinService::WidgetClsID ) 2 );
  pm->load(getProgramDir() + "img/about.png");
  menu->insertItem ( QString ( " About" ), NULL, pm, true, 0, 0 );
  menu->insertSeparator(1, 1); 
  pm->load(getProgramDir() + "img/white.png");
  menu->insertItem ( QString ( " Clean" ), NULL, pm, true, 2, 2 );
  pm->load(getProgramDir() + "img/properties.png");
  menu->insertItem ( QString ( " Database" ), data, pm, true, 3, 3 );
  pm->load(getProgramDir() + "img/edit.png");
  menu->insertItem ( QString ( " Save delete files list" ), NULL, pm, true, 4, 4 );
  menu->insertSeparator(5, 5); 
  pm->load(getProgramDir() + "img/exit.png");
  menu->insertItem ( QString ( " Exit" ), NULL, pm, true, 6, 6 );

  menu->connectItem ( 6, qApp, SLOT ( quit() ) );
  menu->connectItem ( 2, this, SLOT ( ejecutar() ) );
  menu->connectItem ( 0, this, SLOT ( about() ) );
  menu->connectItem ( 4, this, SLOT ( verEliminados() ) );

  softKey->setOptMenu ( ZSoftKey::LEFT, menu );
  softKey->setText ( ZSoftKey::LEFT, "Menu", ( ZSoftKey::TEXT_PRIORITY ) 0 );
  softKey->setText ( ZSoftKey::RIGHT, "Exit", ( ZSoftKey::TEXT_PRIORITY ) 0 );
  softKey->setClickedSlot ( ZSoftKey::RIGHT, qApp, SLOT ( quit() ) ); 
  setSoftKey ( softKey );


}