void PsiToolBar::initialize( QString base, bool createUniqueActions )
{
	d->base = base;
	d->uniqueActions.clear();

// PsiOptions::instance()->getOption(base + ".").toString()	
	
//	setHorizontallyStretchable(PsiOptions::instance()->getOption(base + ".stretchable").toBool());
//	setVerticallyStretchable(PsiOptions::instance()->getOption(base + ".stretchable").toBool());
  
	setMovable (!PsiOptions::instance()->getOption(base + ".locked").toBool());

	if ( d->psi ) {
		ActionList actions = d->psi->actionList()->suitableActions( d->type );
		QStringList keys = PsiOptions::instance()->getOption(base + ".actions").toStringList();
		for (int j = 0; j < keys.size(); j++) {
			IconAction *action = actions.action( keys[j] );

			if ( action && action->isSeparator() ) {
				addSeparator();
			}
			else if ( action ) {
				if ( createUniqueActions ) {
					action = action->copy();
					d->uniqueActions.append( action );
				}

				action->addTo( this );
				emit registerAction( action );
			}
			else {
				qWarning("PsiToolBar::initialize(): action %s not found!", keys[j].latin1());
			}
		}
	}
	else {
		qWarning("PsiToolBar::initialize(): psi is NULL!");
	}

	if (PsiOptions::instance()->getOption(base + ".visible").toBool()) {
		show();
	} else {
		hide();
	}
}
Пример #2
0
void PsiToolBar::initialize( Options::ToolbarPrefs &tbPref, bool createUniqueActions )
{
	d->uniqueActions.clear();

	setHorizontallyStretchable( tbPref.stretchable );
	setVerticallyStretchable( tbPref.stretchable );

	setMovingEnabled ( !tbPref.locked );

	if ( d->psi ) {
		ActionList actions = d->psi->actionList()->suitableActions( d->type );
		QStringList keys = tbPref.keys;
		for (int j = 0; j < keys.size(); j++) {
			IconAction *action = actions.action( keys[j] );

			if ( action && action->isSeparator() ) {
				addSeparator();
			}
			else if ( action ) {
				if ( createUniqueActions ) {
					action = action->copy();
					d->uniqueActions.append( action );
				}

				action->addTo( this );
				emit registerAction( action );
			}
			else
				qWarning("PsiToolBar::initialize(): action %s not found!", keys[j].latin1());
		}
	}
	else
		qWarning("PsiToolBar::initialize(): psi is NULL!");

	if ( tbPref.on )
		show();
	else
		hide();

	tbPref.dirty = false;
}
Пример #3
0
WbDlg::WbDlg(SxeSession* session, PsiAccount* pa) {
	groupChat_ = session->groupChat();
	pending_ = 0;
	keepOpen_ = false;
	allowEdits_ = true;

	selfDestruct_ = 0;
	setAttribute(Qt::WA_DeleteOnClose, false); // we want deferred endSession call and delete from manager

	setWindowTitle(CAP(tr("Whiteboard (%1)").arg(pa->jid().bare())));
	QVBoxLayout *vb1 = new QVBoxLayout(this);

	// first row
	le_jid_ = new QLineEdit(this);
	le_jid_->setReadOnly(true);
	le_jid_->setFocusPolicy(Qt::NoFocus);
	le_jid_->setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Minimum));
	lb_ident_ = new AccountLabel(this);
	lb_ident_->setAccount(pa);
	lb_ident_->setShowJid(false);
	lb_ident_->setSizePolicy(QSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum));
	QHBoxLayout *hb1 = new QHBoxLayout();
	hb1->addWidget(le_jid_);
	hb1->addWidget(lb_ident_);
	vb1->addLayout(hb1);

	// mid area
	wbWidget_ = new WbWidget(session, this);
	wbWidget_->setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding));
	vb1->addWidget(wbWidget_);

	// Bottom (tool) area
	act_save_ = new IconAction(tr("Save session"), "psi/saveBoard", tr("Save the contents of the whiteboard"), 0, this );
	act_geometry_ = new IconAction(tr("Change the geometry"), "psi/whiteboard", tr("Change the geometry"), 0, this );
	act_clear_ = new IconAction(tr("End session"), "psi/clearChat", tr("Clear the whiteboard"), 0, this );
	act_end_ = new IconAction(tr("End session"), "psi/closetab", tr("End session"), 0, this );

	// Black is the default color
	QPixmap pixmap(16, 16);
	pixmap.fill(QColor(Qt::black));
	act_color_ = new QAction(QIcon(pixmap), tr("Stroke color"), this);
	pixmap.fill(QColor(Qt::lightGray));
	act_fill_ = new IconAction(tr("Fill color"), "psi/select", tr("Fill color"),0, this, 0, true);
	act_fill_->setIcon(QIcon(pixmap));
	act_fill_->setChecked(false);

	act_widths_ = new IconAction(tr("Stroke width" ), "psi/drawPaths", tr("Stroke width"), 0, this );
	act_modes_ = new IconAction(tr("Edit mode" ), "psi/select", tr("Edit mode"), 0, this );
	group_widths_ = new QActionGroup(this);
	group_modes_ = new QActionGroup(this);

	connect(act_color_, SIGNAL(triggered()), SLOT(setStrokeColor()));
	connect(act_fill_, SIGNAL(triggered(bool)), SLOT(setFillColor(bool)));
	connect(group_widths_, SIGNAL(triggered(QAction *)), SLOT(setStrokeWidth(QAction *)));
	connect(group_modes_, SIGNAL(triggered(QAction *)), SLOT(setMode(QAction *)));
	connect(act_save_, SIGNAL(triggered()), SLOT(save()));
	connect(act_geometry_, SIGNAL(triggered()), SLOT(setGeometry()));
	connect(act_clear_, SIGNAL(triggered()), wbWidget_, SLOT(clear()));
	connect(act_end_, SIGNAL(triggered()), SLOT(endSession()));

	pixmap = QPixmap(2, 2);
	pixmap.fill(QColor(Qt::black));
	QAction* widthaction = new QAction(QIcon(pixmap), tr("Thin stroke"), group_widths_);
	widthaction->setData(QVariant(1));
	widthaction->setCheckable(true);
	widthaction->trigger();
	pixmap = QPixmap(6, 6);
	pixmap.fill(QColor(Qt::black));
	widthaction = new QAction(QIcon(pixmap), tr("Medium stroke"), group_widths_);
	widthaction->setData(QVariant(3));
	widthaction->setCheckable(true);
	pixmap = QPixmap(12, 12);
	pixmap.fill(QColor(Qt::black));
	widthaction = new QAction(QIcon(pixmap), tr("Thick stroke"), group_widths_);
	widthaction->setData(QVariant(6));
	widthaction->setCheckable(true);

	IconAction* action;
	action = new IconAction(tr("Select"), "psi/select", tr("Select"), 0, group_modes_ );
	action->setData(QVariant(WbWidget::Select));
	action->setCheckable(true);
	action = new IconAction(tr( "Translate"), "psi/translate", tr("Translate"), 0, group_modes_ );
	action->setData(QVariant(WbWidget::Translate));
	action->setCheckable(true);
	action = new IconAction(tr( "Rotate"), "psi/rotate", tr("Rotate"), 0, group_modes_ );
	action->setData(QVariant(WbWidget::Rotate));
	action->setCheckable(true);
	action = new IconAction(tr( "Scale"), "psi/scale", tr("Scale"), 0, group_modes_ );
	action->setData(QVariant(WbWidget::Scale));
	action->setCheckable(true);
	action = new IconAction(tr( "Erase"), "psi/erase", tr("Erase"), 0, group_modes_ );
	action->setData(QVariant(WbWidget::Erase));
	action->setCheckable(true);
	QAction *separator = new QAction(group_modes_);
	separator->setSeparator(true);
	action = new IconAction(tr( "Scroll view"), "psi/scroll", tr("Scroll"), 0, group_modes_ );
	action->setData(QVariant(WbWidget::Scroll));
	action->setCheckable(true);
	separator = new QAction(group_modes_);
	separator->setSeparator(true);
	action = new IconAction(tr( "Draw paths"), "psi/drawPaths", tr("Draw paths"), 0, group_modes_ );
	action->setData(QVariant(WbWidget::DrawPath));
	action->setCheckable(true);
	action->trigger();
	// action = new IconAction(tr( "Draw lines"), "psi/drawLines", tr("Draw lines"), 0, group_modes_ );
	// action->setData(QVariant(WbWidget::DrawLine));
	// action->setCheckable(true);
	// action = new IconAction(tr( "Draw ellipses"), "psi/drawEllipses", tr("Draw ellipses"), 0, group_modes_ );
	// action->setData(QVariant(WbWidget::DrawEllipse));
	// action->setCheckable(true);
	// action = new IconAction(tr( "Draw circles"), "psi/drawCircles", tr("Draw circles"), 0, group_modes_ );
	// action->setData(QVariant(WbWidget::DrawCircle));
	// action->setCheckable(true);
	// action = new IconAction(tr( "Draw rectangles"), "psi/drawRectangles", tr("Draw rectangles"), 0, group_modes_ );
	// action->setData(QVariant(WbWidget::DrawRectangle));
	// action->setCheckable(true);
	// 	action = new IconAction(tr( "Add text"), "psi/addText", tr("Add text"), 0, group_modes_ );
	// 	action->setData(QVariant(WbWidget::DrawText));
	// 	action->setCheckable(true);
	action = new IconAction(tr( "Add images"), "psi/addImage", tr("Add images"), 0, group_modes_ );
	action->setData(QVariant(WbWidget::DrawImage));
	action->setCheckable(true);

	menu_widths_ = new QMenu(this);
	menu_widths_->addActions(group_widths_->actions());
	act_widths_->setMenu(menu_widths_);

	menu_modes_ = new QMenu(this);
	menu_modes_->addActions(group_modes_->actions());
	act_modes_->setMenu(menu_modes_);

	toolbar_ = new QToolBar(tr("Whiteboard toolbar"), this);
	toolbar_->setIconSize(QSize(16,16));
	toolbar_->setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Minimum));
	toolbar_->addAction(act_end_);
	toolbar_->addAction(act_clear_);
	toolbar_->addAction(act_save_);
	toolbar_->addAction(act_geometry_);
	toolbar_->addWidget(new StretchWidget(this));
	toolbar_->addAction(act_fill_);
	toolbar_->addAction(act_color_);
	QToolButton *bw = new QToolButton;
	bw->setIcon(IconsetFactory::icon("psi/drawPaths").icon());
	bw->setMenu(menu_widths_);
	bw->setPopupMode(QToolButton::InstantPopup);
	toolbar_->addWidget(bw);
	QToolButton *bm = new QToolButton;
	bm->setIcon(IconsetFactory::icon("psi/select").icon());
	bm->setMenu(menu_modes_);
	bm->setPopupMode(QToolButton::InstantPopup);
	toolbar_->addWidget(bm);
	vb1->addWidget(toolbar_);

	// Context menu
	pm_settings_ = new QMenu(this);
	connect(pm_settings_, SIGNAL(aboutToShow()), SLOT(buildMenu()));

	X11WM_CLASS("whiteboard");

	// set the Jid -> le_jid.
	le_jid_->setText(QString("%1 (session: %2)").arg(session->target().full()).arg(session->session()));
	le_jid_->setCursorPosition(0);
	le_jid_->setToolTip(session->target().full());

	// update the widget icon
#ifndef Q_OS_MAC
	setWindowIcon(IconsetFactory::icon("psi/whiteboard").icon());
#endif
	
	setWindowOpacity(double(qMax(MINIMUM_OPACITY, PsiOptions::instance()->getOption("options.ui.chat.opacity").toInt())) / 100);

	setGeometryOptionPath(geometryOption);
}
Пример #4
0
AHCommand RCSetOptionsServer::execute(const AHCommand& c, const Jid&)
{
	if (!c.hasData()) {
		// Initial set options form
		XData form;
		form.setTitle(QObject::tr("Set Options"));
		form.setInstructions(QObject::tr("Set the desired options"));
		form.setType(XData::Data_Form);
		XData::FieldList fields;

		XData::Field type_field;
		type_field.setType(XData::Field::Field_Hidden);
		type_field.setVar("FORM_TYPE");
		type_field.setValue(QStringList("http://jabber.org/protocol/rc"));
		type_field.setRequired(false);
		fields += type_field;
		
		XData::Field sounds_field;
		sounds_field.setType(XData::Field::Field_Boolean);
		sounds_field.setLabel(QObject::tr("Play sounds"));
		sounds_field.setVar("sounds");
		sounds_field.setValue(QStringList((PsiOptions::instance()->getOption("options.ui.notifications.sounds.enable").toBool() ? "1" : "0")));
		sounds_field.setRequired(false);
		fields += sounds_field;
		
		XData::Field auto_offline_field;
		auto_offline_field.setType(XData::Field::Field_Boolean);
		auto_offline_field.setLabel(QObject::tr("Automatically go offline when idle"));
		auto_offline_field.setVar("auto-offline");
		auto_offline_field.setValue(QStringList((PsiOptions::instance()->getOption("options.status.auto-away.use-offline").toBool() ? "1" : "0")));
		auto_offline_field.setRequired(false);
		fields += auto_offline_field;
		
		XData::Field auto_auth_field;
		auto_auth_field.setType(XData::Field::Field_Boolean);
		auto_auth_field.setLabel(QObject::tr("Auto-authorize contacts"));
		auto_auth_field.setVar("auto-auth");
		auto_auth_field.setValue(QStringList((PsiOptions::instance()->getOption("options.subscriptions.automatically-allow-authorization").toBool() ? "1" : "0")));
		auto_auth_field.setRequired(false);
		fields += auto_auth_field;
		
		XData::Field auto_open_field;
		auto_open_field.setType(XData::Field::Field_Boolean);
		auto_open_field.setLabel(QObject::tr("Auto-open new messages"));
		auto_open_field.setVar("auto-open");
		auto_open_field.setValue(QStringList((PsiOptions::instance()->getOption("options.ui.message.auto-popup").toBool() ? "1" : "0")));
		auto_open_field.setRequired(false);
		fields += auto_open_field;
		
		form.setFields(fields);
		
		return AHCommand::formReply(c, form);
	}
	else {
		// Set the options
		XData::FieldList fl = c.data().fields();
		for (int i=0; i < fl.count(); i++) {
			if (fl[i].var() == "sounds") {
				QString v =  fl[i].value().first();
				IconAction* soundact = psiCon_->actionList()->suitableActions(PsiActionList::ActionsType( PsiActionList::Actions_MainWin | PsiActionList::Actions_Common)).action("menu_play_sounds");
				if (v == "1") 
					soundact->setOn(true);
				else if (v == "0") 
					soundact->setOn(false);
			}
			else if (fl[i].var() == "auto-offline") {
				QString v =  fl[i].value().first();
				if (v == "1") 
					PsiOptions::instance()->setOption("options.status.auto-away.use-offline", (bool) true);
				else if (v == "0") 
					PsiOptions::instance()->setOption("options.status.auto-away.use-offline", (bool) false);
			}
			else if (fl[i].var() == "auto-auth") {
				QString v =  fl[i].value().first();
				if (v == "1") 
					PsiOptions::instance()->setOption("options.subscriptions.automatically-allow-authorization", (bool) true);
				else if (v == "0") 
					PsiOptions::instance()->setOption("options.subscriptions.automatically-allow-authorization", (bool) false);
			}
			else if (fl[i].var() == "auto-open") {
				QString v =  fl[i].value().first();
				if (v == "1") 
					PsiOptions::instance()->setOption("options.ui.message.auto-popup", (bool) true);
				else if (v == "0") 
					PsiOptions::instance()->setOption("options.ui.message.auto-popup", (bool) false);
			}
		}
		return AHCommand::completedReply(c);
	}
}