/** * Constructs a TabDlg * * \param tabManager The tabManager that will manage this TabDlg * \param delegate If non-zero, this is a pointer to a TabDlgDelegate that * will manage some aspects of the TabDlg behavior. Ownership is not * passed. */ TabDlg::TabDlg(TabManager* tabManager, const QString& geometryOption, TabDlgDelegate *delegate) : AdvancedWidget<QWidget>(0, delegate ? delegate->initWindowFlags() : (Qt::WindowFlags)0) , delegate_(delegate) , tabWidget_(0) , detachButton_(0) , closeButton_(0) , closeCross_(0) , tabMenu_(new QMenu(this)) , act_close_(0) , act_next_(0) , act_prev_(0) , tabManager_(tabManager) , userManagement_(true) , tabBarSingles_(true) , simplifiedCaption_(false) , activateTabMapper_(0) { if (delegate_) { delegate_->create(this); } // FIXME qRegisterMetaType<TabDlg*>("TabDlg*"); qRegisterMetaType<TabbableWidget*>("TabbableWidget*"); tabWidget_ = new PsiTabWidget(this); tabWidget_->setCloseIcon(IconsetFactory::icon("psi/closetab").icon()); connect(tabWidget_, SIGNAL(mouseDoubleClickTab(QWidget*)), SLOT(mouseDoubleClickTab(QWidget*))); connect(tabWidget_, SIGNAL(mouseMiddleClickTab(QWidget*)), SLOT(mouseMiddleClickTab(QWidget*))); connect(tabWidget_, SIGNAL(aboutToShowMenu(QMenu*)), SLOT(tab_aboutToShowMenu(QMenu*))); connect(tabWidget_, SIGNAL(tabContextMenu(int, QPoint, QContextMenuEvent*)), SLOT(showTabMenu(int, QPoint, QContextMenuEvent*))); connect(tabWidget_, SIGNAL(closeButtonClicked()), SLOT(closeCurrentTab())); connect(tabWidget_, SIGNAL(currentChanged(QWidget*)), SLOT(tabSelected(QWidget*))); if(delegate_) delegate_->tabWidgetCreated(this, tabWidget_); QVBoxLayout *vert1 = new QVBoxLayout(this); vert1->setMargin(1); vert1->addWidget(tabWidget_); setAcceptDrops(true); X11WM_CLASS("tabs"); setLooks(); act_close_ = new QAction(this); addAction(act_close_); connect(act_close_,SIGNAL(triggered()), SLOT(closeCurrentTab())); act_prev_ = new QAction(this); addAction(act_prev_); connect(act_prev_,SIGNAL(triggered()), SLOT(previousTab())); act_next_ = new QAction(this); addAction(act_next_); connect(act_next_,SIGNAL(triggered()), SLOT(nextTab())); setShortcuts(); setGeometryOptionPath(geometryOption); }
void ChatDlg::init() { initUi(); initActions(); setShortcuts(); // TODO: this have to be moved to chatEditCreated() chatView()->setDialog(this); chatEdit()->setDialog(this); chatEdit()->installEventFilter(this); connect(chatView(), SIGNAL(selectionChanged()), SLOT(logSelectionChanged())); // SyntaxHighlighters modify the QTextEdit in a QTimer::singleShot(0, ...) call // so we need to install our hooks after it fired for the first time QTimer::singleShot(10, this, SLOT(initComposing())); connect(this, SIGNAL(composing(bool)), SLOT(updateIsComposing(bool))); setAcceptDrops(TRUE); updateContact(jid(), true); X11WM_CLASS("chat"); setLooks(); updatePGP(); connect(account(), SIGNAL(pgpKeyChanged()), SLOT(updatePGP())); connect(account(), SIGNAL(encryptedMessageSent(int, bool, int, const QString &)), SLOT(encryptedMessageSent(int, bool, int, const QString &))); account()->dialogRegister(this, jid()); chatView()->setFocusPolicy(Qt::NoFocus); chatEdit()->setFocus(); // TODO: port to restoreSavedSize() (and adapt it from restoreSavedGeometry()) QSize size = PsiOptions::instance()->getOption("options.ui.chat.size").toSize(); if (!size.isEmpty()) { resize(size); } else { resize(defaultSize()); } }
HistoryDlg::HistoryDlg(const XMPP::Jid& j, PsiAccount* pa) : pa_(pa), jidFull_(j), from_(0), count_(30) { setupUi(this); setModal(false); setAttribute(Qt::WA_DeleteOnClose); pa_->dialogRegister(this, jidFull_); setWindowTitle(tr("History for ") + j.full()); #ifndef Q_WS_MAC setWindowIcon(IconsetFactory::icon("psi/history").icon()); #endif DateTree->setHeaderLabel(tr("Date")); DateTree->setSortingEnabled(true); DateTree->setColumnHidden(1,true); connect(DateTree, SIGNAL(customContextMenuRequested(const QPoint &)), SLOT(doDateContextMenu(const QPoint &))); EventsTree->setColumnCount(4); QStringList headers; headers << tr("Type") << tr("Time") << tr("Origin") << tr("Text"); EventsTree->setHeaderLabels(headers); EventsTree->sortItems(1,Qt::AscendingOrder); EventsTree->setSortingEnabled(true); EventsTree->setWordWrap(true); EventsTree->hideColumn(2); connect(EventsTree, SIGNAL(itemDoubleClicked(QTreeWidgetItem *, int)), SLOT(actionOpenEvent(QTreeWidgetItem *, int))); connect(EventsTree, SIGNAL(customContextMenuRequested(const QPoint &)), SLOT(doEventContextMenu(const QPoint &))); connect(tb_previousMonth, SIGNAL(clicked()), SLOT(doPrev())); connect(tb_latest, SIGNAL(clicked()), SLOT(doLatest())); connect(tb_nextMonth, SIGNAL(clicked()), SLOT(doNext())); connect(pb_find, SIGNAL(clicked()), SLOT(doFind())); connect(pb_export, SIGNAL(clicked()), SLOT(doExport())); connect(pb_close, SIGNAL(clicked()), SLOT(close())); jid_ = j.bare(); doLatest(); X11WM_CLASS("history"); }
/** * Constructs a TabDlg * * \param tabManager The tabManager that will manage this TabDlg * \param delegate If non-zero, this is a pointer to a TabDlgDelegate that * will manage some aspects of the TabDlg behavior. Ownership is not * passed. */ TabDlg::TabDlg(TabManager* tabManager, QSize size, TabDlgDelegate *delegate) : AdvancedWidget<QWidget>(0, delegate ? delegate->initWindowFlags() : (Qt::WindowFlags)0) , delegate_(delegate) , tabWidget_(0) , detachButton_(0) , closeButton_(0) , closeCross_(0) , tabMenu_(new QMenu(this)) , act_close_(0) , act_next_(0) , act_prev_(0) , tabManager_(tabManager) , userManagement_(true) , tabBarSingles_(true) , simplifiedCaption_(false) { if (delegate_) { delegate_->create(this); } // FIXME qRegisterMetaType<TabDlg*>("TabDlg*"); qRegisterMetaType<TabbableWidget*>("TabbableWidget*"); tabWidget_ = new PsiTabWidget(this); tabWidget_->setCloseIcon(IconsetFactory::icon("psi/closetab").icon()); connect(tabWidget_, SIGNAL(mouseDoubleClickTab(QWidget*)), SLOT(mouseDoubleClickTab(QWidget*))); connect(tabWidget_, SIGNAL(mouseMiddleClickTab(QWidget*)), SLOT(mouseMiddleClickTab(QWidget*))); connect(tabWidget_, SIGNAL(aboutToShowMenu(QMenu*)), SLOT(tab_aboutToShowMenu(QMenu*))); connect(tabWidget_, SIGNAL(tabContextMenu(int, QPoint, QContextMenuEvent*)), SLOT(showTabMenu(int, QPoint, QContextMenuEvent*))); connect(tabWidget_, SIGNAL(closeButtonClicked()), SLOT(closeCurrentTab())); connect(tabWidget_, SIGNAL(currentChanged(QWidget*)), SLOT(tabSelected(QWidget*))); if(delegate_) delegate_->tabWidgetCreated(this, tabWidget_); QVBoxLayout *vert1 = new QVBoxLayout(this); vert1->setMargin(1); vert1->addWidget(tabWidget_); setAcceptDrops(true); X11WM_CLASS("tabs"); setLooks(); act_close_ = new QAction(this); addAction(act_close_); connect(act_close_,SIGNAL(triggered()), SLOT(closeCurrentTab())); act_prev_ = new QAction(this); addAction(act_prev_); connect(act_prev_,SIGNAL(triggered()), SLOT(previousTab())); act_next_ = new QAction(this); addAction(act_next_); connect(act_next_,SIGNAL(triggered()), SLOT(nextTab())); setShortcuts(); QSignalMapper* activateTabMapper_ = new QSignalMapper(this); connect(activateTabMapper_, SIGNAL(mapped(int)), tabWidget_, SLOT(setCurrentPage(int))); for (int i = 0; i < 10; ++i) { QAction* action = new QAction(this); connect(action, SIGNAL(triggered()), activateTabMapper_, SLOT(map())); action->setShortcuts(QList<QKeySequence>() << QKeySequence(QString("Ctrl+%1").arg(i)) << QKeySequence(QString("Alt+%1").arg(i))); activateTabMapper_->setMapping(action, (i > 0 ? i : 10) - 1); addAction(action); } if (size.isValid()) { resize(size); } else { resize(ChatDlg::defaultSize()); //TODO: no! } }
/** * Constructs a TabDlg * * \param tabManager The tabManager that will manage this TabDlg * \param delegate If non-zero, this is a pointer to a TabDlgDelegate that * will manage some aspects of the TabDlg behavior. Ownership is not * passed. */ TabDlg::TabDlg(TabManager* tabManager, QSize size, TabDlgDelegate *delegate) : AdvancedWidget<QWidget>(0, delegate ? delegate->initWindowFlags() : (Qt::WindowFlags)0) , delegate_(delegate) , tabWidget_(0) , detachButton_(0) , closeButton_(0) , closeCross_(0) , tabMenu_(new QMenu(this)) , act_close_(0) , act_next_(0) , act_prev_(0) , tabManager_(tabManager) , userManagement_(true) , tabBarSingles_(true) , simplifiedCaption_(false) { if (delegate_) { delegate_->create(this); } if (PsiOptions::instance()->getOption("options.ui.mac.use-brushed-metal-windows").toBool()) { setAttribute(Qt::WA_MacMetalStyle); } // FIXME qRegisterMetaType<TabDlg*>("TabDlg*"); qRegisterMetaType<TabbableWidget*>("TabbableWidget*"); tabWidget_ = new PsiTabWidget(this); tabWidget_->setCloseIcon(IconsetFactory::icon("psi/closetab").icon()); connect(tabWidget_, SIGNAL(mouseDoubleClickTab(QWidget*)), SLOT(mouseDoubleClickTab(QWidget*))); connect(tabWidget_, SIGNAL(aboutToShowMenu(QMenu*)), SLOT(tab_aboutToShowMenu(QMenu*))); connect(tabWidget_, SIGNAL(tabContextMenu(int, QPoint, QContextMenuEvent*)), SLOT(showTabMenu(int, QPoint, QContextMenuEvent*))); connect(tabWidget_, SIGNAL(closeButtonClicked()), SLOT(closeCurrentTab())); connect(tabWidget_, SIGNAL(currentChanged(QWidget*)), SLOT(tabSelected(QWidget*))); if(delegate_) delegate_->tabWidgetCreated(this, tabWidget_); QVBoxLayout *vert1 = new QVBoxLayout( this, 1); vert1->addWidget(tabWidget_); setAcceptDrops(TRUE); X11WM_CLASS("tabs"); setLooks(); act_close_ = new QAction(this); addAction(act_close_); connect(act_close_,SIGNAL(activated()), SLOT(closeCurrentTab())); act_prev_ = new QAction(this); addAction(act_prev_); connect(act_prev_,SIGNAL(activated()), SLOT(previousTab())); act_next_ = new QAction(this); addAction(act_next_); connect(act_next_,SIGNAL(activated()), SLOT(nextTab())); setShortcuts(); if (size.isValid()) { resize(size); } else { resize(ChatDlg::defaultSize()); //TODO: no! } }
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); }
HistoryDlg::HistoryDlg(const Jid &jid, PsiAccount *pa) { setAttribute(Qt::WA_DeleteOnClose); d = new Private; d->pa = pa; d->jid = jid; d->pa->dialogRegister(this, d->jid); d->exp = 0; setWindowTitle(d->jid.full()); #ifndef Q_WS_MAC setWindowIcon(IconsetFactory::icon("psi/history").icon()); #endif d->h = new EDBHandle(d->pa->edb()); connect(d->h, SIGNAL(finished()), SLOT(edb_finished())); QVBoxLayout *vb1 = new QVBoxLayout(this); d->lv = new HistoryView(this); d->lv->setVScrollBarMode(Q3ScrollView::AlwaysOn); connect(d->lv, SIGNAL(aOpenEvent(PsiEvent *)), SLOT(actionOpenEvent(PsiEvent *))); QSizePolicy sp = d->lv->sizePolicy(); sp.setVerticalStretch(1); d->lv->setSizePolicy(sp); vb1->addWidget(d->lv); QHBoxLayout *hb1 = new QHBoxLayout; vb1->addLayout(hb1); QVBoxLayout *vb2 = new QVBoxLayout; hb1->addLayout(vb2); QHBoxLayout *hb2 = new QHBoxLayout; vb2->addLayout(hb2); //d->busy = new BusyWidget(this); //hb1->addWidget(d->busy); d->pb_refresh = new QPushButton(tr("&Latest"), this); d->pb_refresh->setMinimumWidth(80); connect(d->pb_refresh, SIGNAL(clicked()), SLOT(doLatest())); hb2->addWidget(d->pb_refresh); d->pb_prev = new QPushButton(tr("&Previous"), this); d->pb_prev->setMinimumWidth(80); connect(d->pb_prev, SIGNAL(clicked()), SLOT(doPrev())); hb2->addWidget(d->pb_prev); d->pb_next = new QPushButton(tr("&Next"), this); d->pb_next->setMinimumWidth(80); connect(d->pb_next, SIGNAL(clicked()), SLOT(doNext())); hb2->addWidget(d->pb_next); QHBoxLayout *hb3 = new QHBoxLayout; vb2->addLayout(hb3); d->le_find = new QLineEdit(this); connect(d->le_find, SIGNAL(textChanged(const QString &)), SLOT(le_textChanged(const QString &))); connect(d->le_find, SIGNAL(returnPressed()), SLOT(doFind())); hb3->addWidget(d->le_find); d->pb_find = new QPushButton(tr("Find"), this); connect(d->pb_find, SIGNAL(clicked()), SLOT(doFind())); d->pb_find->setEnabled(false); hb3->addWidget(d->pb_find); QFrame *sep; sep = new QFrame(this); sep->setFrameShape(QFrame::VLine); hb1->addWidget(sep); QVBoxLayout *vb3 = new QVBoxLayout; hb1->addLayout(vb3); QPushButton *pb_save = new QPushButton(tr("&Export..."), this); connect(pb_save, SIGNAL(clicked()), SLOT(doSave())); vb3->addWidget(pb_save); QPushButton *pb_erase = new QPushButton(tr("Er&ase All"), this); connect(pb_erase, SIGNAL(clicked()), SLOT(doErase())); vb3->addWidget(pb_erase); sep = new QFrame(this); sep->setFrameShape(QFrame::VLine); hb1->addWidget(sep); hb1->addStretch(1); QVBoxLayout *vb4 = new QVBoxLayout; hb1->addLayout(vb4); vb4->addStretch(1); QPushButton *pb_close = new QPushButton(tr("&Close"), this); pb_close->setMinimumWidth(80); connect(pb_close, SIGNAL(clicked()), SLOT(close())); vb4->addWidget(pb_close); resize(520,320); X11WM_CLASS("history"); d->le_find->setFocus(); setButtons(); doLatest(); }