/*------------------------------------------------------------------------------*\
	MessageReceived( msg)
		-	
\*------------------------------------------------------------------------------*/
void BmPrefsIdentityView::MessageReceived( BMessage* msg) {
	try {
		switch( msg->what) {
			case BM_SELECTION_CHANGED: {
				int32 index = mIdentListView->CurrentSelection( 0);
				ShowIdentity( index);
				break;
			}
			case BM_TEXTFIELD_MODIFIED: {
				if (mCurrIdent) {
					BView* srcView = NULL;
					msg->FindPointer( "source", (void**)&srcView);
					BmTextControl* source = dynamic_cast<BmTextControl*>( srcView);
					if ( source == mIdentityControl)
						TheIdentityList->RenameItem( mCurrIdent->Name(), 
															  mIdentityControl->Text());
					else if ( source == mMailAddrControl)
						mCurrIdent->MailAddr( mMailAddrControl->Text());
					else if ( source == mAliasesControl)
						mCurrIdent->MailAliases( mAliasesControl->Text());
					else if ( source == mRealNameControl)
						mCurrIdent->RealName( mRealNameControl->Text());
					else if ( source == mReplyToControl)
						mCurrIdent->ReplyTo( mReplyToControl->Text());
					NoticeChange();
				}
				break;
			}
			case BM_IS_BUCKET_CHANGED: {
				if (mCurrIdent)
					mCurrIdent->MarkedAsBitBucket( mIsBucketControl->Value());
				NoticeChange();
				break;
			}
			case BM_SMTP_SELECTED: {
				BMenuItem* item = mSmtpControl->Menu()->FindMarked();
				if (item && BM_NoItemLabel != item->Label())
					mCurrIdent->SMTPAccount( item->Label());
				else
					mCurrIdent->SMTPAccount( "");
				NoticeChange();
				break;
			}
			case BM_RECV_SELECTED: {
				BMenuItem* item = mRecvControl->Menu()->FindMarked();
				if (item && BM_NoItemLabel != item->Label())
					mCurrIdent->RecvAccount( item->Label());
				else
					mCurrIdent->RecvAccount( "");
				NoticeChange();
				break;
			}
			case BM_SIGNATURE_SELECTED: {
				BMenuItem* item = mSignatureControl->Menu()->FindMarked();
				if (item && BM_NoItemLabel != item->Label())
					mCurrIdent->SignatureName( item->Label());
				else
					mCurrIdent->SignatureName( "");
				NoticeChange();
				break;
			}
			case BM_SET_SPECIAL_HEADERS: {
				if (!mCurrIdent)
					break;
				BmString specialHeaders = mCurrIdent->SpecialHeaders();
				BScreen scr;
				BRect screen( scr.Frame());
				float w=600, h=400;
				BRect alertFrame( (screen.Width()-w)/2,
										(screen.Height()-h)/2,
										(screen.Width()+w)/2,
										(screen.Height()+h)/2);
				TextEntryAlert* alert = 
					new TextEntryAlert( 
						"Edit Special Headers", 
						"Please enter any special headers below, "
						"just as they would appear in a mail.\n\n"
						"Here's an example: \n"
						"    Bcc: maileater <*****@*****.**>\n"
						"    Cc: Jim-Bob <*****@*****.**>\n"
						"        John-Boy <*****@*****.**>\n"
						"    X-Company-Special: grok.dis",
						specialHeaders.String(),
						"Cancel",
						"OK",
						false, 80, 20, B_WIDTH_FROM_LABEL, true,
						&alertFrame
					);
				alert->SetShortcut( 0, B_ESCAPE);
				alert->TextEntryView()->DisallowChar( 27);
				alert->TextEntryView()->SetFontAndColor( be_fixed_font);
				alert->SetShortcut( 0, B_ESCAPE);
				int32 choice = alert->Go( specialHeaders);
				if (choice == 1) {
					if (specialHeaders.Length()
					&& specialHeaders[specialHeaders.Length()-1] != '\n')
						specialHeaders << '\n';
					mCurrIdent->SpecialHeaders( specialHeaders);
				}
				break;
			}
			case BM_ADD_IDENTITY: {
				BmString key( "new identity");
				for( int32 i=1; TheIdentityList->FindItemByKey( key); ++i) {
					key = BmString("new identity_")<<i;
				}
				TheIdentityList->AddItemToList( 
					new BmIdentity( key.String(), 
										 TheIdentityList.Get())
				);
				mIdentityControl->MakeFocus( true);
				mIdentityControl->TextView()->SelectAll();
				NoticeChange();
				break;
			}
			case BM_REMOVE_IDENTITY: {
				int32 buttonPressed;
				if (msg->FindInt32( "which", &buttonPressed) != B_OK) {
					// first step, ask user about it:
					BAlert* alert 
						= new BAlert( "Remove Mail-Identity", 
										  (BmString(
										  		"Are you sure about removing the "
										  		"identity <") << mCurrIdent->Name() 
											   << ">?"
										  ).String(),
										  "Remove", "Cancel", NULL, B_WIDTH_AS_USUAL,
										  B_WARNING_ALERT);
					alert->SetShortcut( 1, B_ESCAPE);
					alert->Go( new BInvoker( new BMessage(BM_REMOVE_IDENTITY), 
													 BMessenger( this)));
				} else {
					// second step, do it if user said ok:
					if (buttonPressed == 0) {
						TheIdentityList->RemoveItemFromList( mCurrIdent.Get());
						mCurrIdent = NULL;
						NoticeChange();
					}
				}
				break;
			}
			case BM_COMPLAIN_ABOUT_FIELD: {
				int32 buttonPressed;
				if (msg->FindInt32( "which", &buttonPressed) != B_OK) {
					BmString complaint;
					complaint = msg->FindString( MSG_COMPLAINT);
					// first step, tell user about complaint:
					BAlert* alert = new BAlert( "Sanity Check Failed", 
														 complaint.String(),
													 	 "OK", NULL, NULL, B_WIDTH_AS_USUAL,
													 	 B_WARNING_ALERT);
					alert->SetShortcut( 0, B_ESCAPE);
					alert->Go( new BInvoker( new BMessage(*msg), BMessenger( this)));
					BmIdentity* ident=NULL;
					msg->FindPointer( MSG_ITEM, (void**)&ident);
					BmListViewItem* accItem 
						= mIdentListView->FindViewItemFor( ident);
					if (accItem)
						mIdentListView->Select( mIdentListView->IndexOf( accItem));
				} else {
					// second step, set corresponding focus:
					BmString fieldName;
					fieldName = msg->FindString( MSG_FIELD_NAME);
					if (fieldName.ICompare( "smtpaccount")==0)
						mSmtpControl->MakeFocus( true);
					else if (fieldName.ICompare( "recvaccount")==0)
						mRecvControl->MakeFocus( true);
				}
				break;
			}
			default:
				inherited::MessageReceived( msg);
		}
	}
	catch( BM_error &err) {
		// a problem occurred, we tell the user:
		BM_SHOWERR( BmString("PrefsView_") << Name() << ":\n\t" << err.what());
	}
}
Exemple #2
0
dlpy_main::dlpy_main(int state,string filename,QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::dlpy_main)
{

    ui->setupUi(this);
    setGeometry(697, 50, 220, 480);

    wid = new widget();
    wid->setWindowFlags(Qt::FramelessWindowHint);
    wid->show();

    frame = new dlpy_frames(state,filename);
    frame->setWindowFlags(Qt::FramelessWindowHint);     //隐藏标题栏
    frame->show();
    connect(this,SIGNAL(setparasignal(int,int,int,int,int)),frame,SLOT(setparaslot(int,int,int,int,int)));
    connect(frame,SIGNAL(setalertsignal(int)),this,SLOT(setalertslot(int)));    //每一帧图像信号槽初始化警报参数
    connect(this,SIGNAL(setlinesignal(int)),frame,SLOT(setlineslot(int)));


/////////////////////////////////////////////////////////////////////////////////////////////
    //img_alert: 显示所有
    //img_alert_1: 红色警报
    //img_alert_3: 无警报
    //img_temp:所有
    //img:所有
////////////////////////////////////////////////////////////////////////////////////////////

    img_alert = cv::imread("/home/hugo/code/bin/alert.bmp");
    img_alert_1 = cv::imread("/home/hugo/code/bin/alert_2.bmp");
    img_alert_2 = cv::imread("/home/hugo/code/bin/alert_3.bmp");
    img_temp = cv::imread("/home/hugo/code/bin/alert.bmp");
    roi_l=Rect(0, 0, (img_alert.cols-1)/2, img_alert.rows-1);
    roi_r=Rect((img_alert.cols-1)/2, 0, (img_alert.cols-1)/2, img_alert.rows-1);
    QGraphicsScene *scene = new QGraphicsScene;
    QImage img;
    img.load("/home/hugo/code/bin/alert.bmp");
    QPixmap mp;
    mp=mp.fromImage(img);

    times_alert=0;
    last_alert=0;
    w0=weatherobj(10,20,30,40,50);
    w1=weatherobj(60,70,80,90,100);
    w2=weatherobj(100,110,120,130,140);
    w3=weatherobj(10,60,0,42,100);
    w4=weatherobj(150,160,170,180,190);
    w5=weatherobj(200,210,220,230,240);
    w6=weatherobj(10,25,10,32,90);
    w7=weatherobj(200,240,220,250,123);

    QImage *qimg=new QImage;
    *qimg=mat2qimage(img_temp);
    /*cvtColor(img_temp, img_temp, CV_BGR2RGB);
    qimg = new QImage((unsigned char*)img_temp.data, // uchar* data
            img_temp.cols, img_temp.rows, // width height
            img_temp.step, //bytesPerLine
            QImage::Format_RGB888); //format*/
    scene->addPixmap(QPixmap::fromImage(*qimg));
    ui->graphicsView->setScene(scene);
    ui->graphicsView->resize(qimg->width() + 10, qimg->height() + 10);
    ui->graphicsView->show();
     timer = new QTimer(this);
     timer->setInterval(30);
     connect(timer,SIGNAL(timeout()),this,SLOT(alertFrame()));      //每隔30s读取一次报警图片
     timer->start();

}