QMenus::QMenus(QWidget *parent) : QMainWindow(parent, 0) // QMainWindow's default flag is WType_TopLevel { QAction *action; QMenu *file = new QMenu(this); action = new QAction(QPixmap((const char**)fileopen), "&Open", this); action->setShortcut(tr("CTRL+O")); connect(action, SIGNAL(triggered()), this, SLOT(fileOpen())); file->addAction(action); action = new QAction(QPixmap((const char**)filesave),"&Save", this); action->setShortcut(tr("CTRL+S")); connect(action, SIGNAL(triggered()), this, SLOT(fileSave())); file->addAction(action); QMenu *edit = new QMenu(this); action = new QAction("&Normal", this); action->setShortcut(tr("CTRL+N")); action->setToolTip("Normal"); action->setStatusTip("Toggles Normal"); action->setCheckable(true); connect(action, SIGNAL(triggered()), this, SLOT(editNormal())); edit->addAction(action); action = new QAction("&Bold", this); action->setShortcut(tr("CTRL+B")); action->setCheckable(true); connect(action, SIGNAL(triggered()), this, SLOT(editBold())); edit->addAction(action); action = new QAction("&Underline", this); action->setShortcut(tr("CTRL+U")); action->setCheckable(true); connect(action, SIGNAL(triggered()), this, SLOT(editUnderline())); edit->addAction(action); QMenu *advanced = new QMenu(this); action = new QAction("&Font...", this); connect(action, SIGNAL(triggered()), this, SLOT(editAdvancedFont())); advanced->addAction(action); action = new QAction("&Style...", this); connect(action, SIGNAL(triggered()), this, SLOT(editAdvancedStyle())); advanced->addAction(action); edit->addMenu(advanced)->setText("&Advanced"); edit->addSeparator(); action = new QAction("Una&vailable", this); action->setShortcut(tr("CTRL+V")); action->setCheckable(true); action->setEnabled(false); connect(action, SIGNAL(triggered()), this, SLOT(editUnderline())); edit->addAction(action); QMenu *help = new QMenu(this); action = new QAction("&About...", this); action->setShortcut(tr("F1")); connect(action, SIGNAL(triggered()), this, SLOT(helpAbout())); help->addAction(action); action = new QAction("&About Qt...", this); connect(action, SIGNAL(triggered()), this, SLOT(helpAboutQt())); help->addAction(action); if (!QAxFactory::isServer()) menuBar()->addMenu(file)->setText("&File"); menuBar()->addMenu(edit)->setText("&Edit"); menuBar()->addMenu(help)->setText("&Help"); editor = new QTextEdit(this); setCentralWidget(editor); statusBar(); }
PostWindow::PostWindow(QWidget* parent): QPlainTextEdit(parent) { setReadOnly(true); setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOn); QRect availableScreenRect = qApp->desktop()->availableGeometry(this); mSizeHint = QSize( availableScreenRect.width() / 2.7, 300 ); QAction * action; QAction *copyAction = new QAction(tr("Copy"), this); connect(copyAction, SIGNAL(triggered()), this, SLOT(copy())); copyAction->setShortcut( Main::settings()->shortcut("IDE/shortcuts/copy") ); copyAction->setShortcutContext( Qt::WidgetShortcut ); addAction(copyAction); mClearAction = new QAction(tr("Clear"), this); connect(mClearAction, SIGNAL(triggered()), this, SLOT(clear())); addAction(mClearAction); action = new QAction(this); action->setSeparator(true); addAction(action); action = new QAction(tr("Enlarge Post Font"), this); action->setIconText("+"); action->setShortcut(tr("Ctrl++", "Enlarge Font")); action->setShortcutContext( Qt::WidgetShortcut ); action->setToolTip(tr("Enlarge font")); connect(action, SIGNAL(triggered()), this, SLOT(zoomIn())); addAction(action); action = new QAction(tr("Shrink Post Font"), this); action->setIconText("-"); action->setShortcut(tr("Ctrl+-", "Shrink Font")); action->setShortcutContext( Qt::WidgetShortcut ); action->setToolTip(tr("Shrink font")); connect(action, SIGNAL(triggered()), this, SLOT(zoomOut())); addAction(action); action = new QAction(this); action->setSeparator(true); addAction(action); mLineWrapAction = action = new QAction(tr("Wrap Text"), this); action->setCheckable(true); addAction(action); connect( action, SIGNAL(triggered(bool)), this, SLOT(setLineWrap(bool)) ); mAutoScrollAction = new QAction(tr("Auto Scroll"), this); mAutoScrollAction->setToolTip(tr("Scroll to bottom on new posts")); mAutoScrollAction->setCheckable(true); mAutoScrollAction->setChecked(true); addAction(mAutoScrollAction); setContextMenuPolicy(Qt::ActionsContextMenu); connect(this, SIGNAL(scrollToBottomRequest()), this, SLOT(scrollToBottom()), Qt::QueuedConnection); connect(mAutoScrollAction, SIGNAL(triggered(bool)), this, SLOT(onAutoScrollTriggered(bool))); applySettings( Main::settings() ); }
void QCSXCAD::BuildToolBar() { QToolBar *mainTB = addToolBar(tr("General")); mainTB->setObjectName("General_ToolBar"); QSize TBIconSize(16,16); mainTB->setIconSize(TBIconSize); if (QCSX_Settings.GetEdit()) mainTB->addAction(QIcon(":/images/filenew.png"),tr("New"),this,SLOT(New())); if (QCSX_Settings.GetEdit()) mainTB->addAction(QIcon(":/images/down.png"),tr("Import"),this,SLOT(ImportGeometry())); mainTB->addAction(QIcon(":/images/up.png"),tr("Export"),this,SLOT(ExportGeometry())); QToolBar *ItemTB = addToolBar(tr("Item View")); ItemTB->setIconSize(TBIconSize); ItemTB->setObjectName("Item_View_ToolBar"); ItemTB->addAction(tr("CollapseAll"),CSTree,SLOT(collapseAll())); ItemTB->addAction(tr("ExpandAll"),CSTree,SLOT(expandAll())); ItemTB->addAction(QIcon(":/images/bulb.png"),tr("ShowAll"),this,SLOT(ShowAll())); ItemTB->addAction(QIcon(":/images/bulb_off.png"),tr("HideAll"),this,SLOT(HideAll())); QToolBar *newObjct = NULL; QAction* newAct = NULL; if (QCSX_Settings.GetEdit()) { newObjct = addToolBar(tr("add new Primitive")); newObjct->setObjectName("New_Primitive_ToolBar"); newAct = newObjct->addAction(tr("Box"),this,SLOT(NewBox())); newAct->setToolTip(tr("add new Box")); newAct = newObjct->addAction(tr("MultiBox"),this,SLOT(NewMultiBox())); newAct->setToolTip(tr("add new Multi-Box")); newAct = newObjct->addAction(tr("Sphere"),this,SLOT(NewSphere())); newAct->setToolTip(tr("add new Sphere")); newAct = newObjct->addAction(tr("Cylinder"),this,SLOT(NewCylinder())); newAct->setToolTip(tr("add new Cylinder")); newAct = newObjct->addAction(tr("Polygon"),this,SLOT(NewPolygon())); newAct->setToolTip(tr("add new Polygon")); newAct = newObjct->addAction(tr("User Defined"),this,SLOT(NewUserDefined())); newAct->setToolTip(tr("add new User Definied Primitive")); newObjct = addToolBar(tr("add new Property")); newObjct->setObjectName("New_Property_ToolBar"); newAct = newObjct->addAction(tr("Material"),this,SLOT(NewMaterial())); newAct->setToolTip(tr("add new Material-Property")); newAct = newObjct->addAction(tr("Metal"),this,SLOT(NewMetal())); newAct->setToolTip(tr("add new Metal-Property")); newAct = newObjct->addAction(tr("Excitation"),this,SLOT(NewExcitation())); newAct->setToolTip(tr("add new Excitation-Property")); newAct = newObjct->addAction(tr("ProbeBox"),this,SLOT(NewChargeBox())); newAct->setToolTip(tr("add new Probe-Box-Property")); newAct = newObjct->addAction(tr("ResBox"),this,SLOT(NewResBox())); newAct->setToolTip(tr("add new Res-Box-Property")); newAct = newObjct->addAction(tr("DumpBox"),this,SLOT(NewDumpBox())); newAct->setToolTip(tr("add new Dump-Box-Property")); } newObjct = addToolBar(tr("Zoom")); newObjct->setIconSize(TBIconSize); newObjct->setObjectName("Zoom_ToolBar"); newAct = newObjct->addAction(QIcon(":/images/viewmagfit.png"),tr("Zoom fit"),this,SLOT(BestView())); newAct->setToolTip("Zoom to best fit all objects"); viewPlane[0] = newObjct->addAction(GridEditor->GetNormName(0),this,SLOT(setYZ())); viewPlane[0]->setToolTip(tr("Switch to y-z-plane view (x-normal)")); viewPlane[1] = newObjct->addAction(GridEditor->GetNormName(1),this,SLOT(setZX())); viewPlane[1]->setToolTip(tr("Switch to z-x-plane view (y-normal)")); viewPlane[2] = newObjct->addAction(GridEditor->GetNormName(2),this,SLOT(setXY())); viewPlane[2]->setToolTip(tr("Switch to x-y-plane view (z-normal)")); addToolBarBreak(); QActionGroup* ActViewGrp = new QActionGroup(this); newAct = newObjct->addAction(tr("2D"),this,SLOT(View2D())); newAct->setToolTip(tr("Switch to 2D view mode")); ActViewGrp->addAction(newAct); newAct->setCheckable(true); newAct = newObjct->addAction(tr("3D"),this,SLOT(View3D())); newAct->setToolTip(tr("Switch to 3D view mode")); ActViewGrp->addAction(newAct); newAct->setCheckable(true); m_PPview = newObjct->addAction(tr("PP")); m_PPview->setToolTip(tr("Toggle parallel projection view mode")); QObject::connect(m_PPview,SIGNAL(toggled(bool)),this,SLOT(SetParallelProjection(bool))); m_PPview->setCheckable(true); if (QCSX_Settings.GetEdit()) addToolBar(GridEditor->BuildToolbar()); }
void Monitor::initToolBar() { QActionGroup* group; QAction* action; QToolBar* toolBar = new QToolBar(this); /* Menu bar */ Q_ASSERT(layout() != NULL); layout()->setMenuBar(toolBar); /* Font */ toolBar->addAction(QIcon(":/fonts.png"), tr("Font"), this, SLOT(slotChooseFont())); toolBar->addSeparator(); /* Channel style */ group = new QActionGroup(this); group->setExclusive(true); action = toolBar->addAction(tr("DMX Channels")); action->setToolTip(tr("Show absolute DMX channel numbers")); action->setCheckable(true); action->setData(DMXChannels); connect(action, SIGNAL(triggered(bool)), this, SLOT(slotChannelStyleTriggered())); toolBar->addAction(action); group->addAction(action); if (channelStyle() == DMXChannels) action->setChecked(true); action = toolBar->addAction(tr("Relative Channels")); action->setToolTip(tr("Show channel numbers relative to fixture")); action->setCheckable(true); action->setData(RelativeChannels); connect(action, SIGNAL(triggered(bool)), this, SLOT(slotChannelStyleTriggered())); toolBar->addAction(action); group->addAction(action); if (channelStyle() == RelativeChannels) action->setChecked(true); toolBar->addSeparator(); /* Value display style */ group = new QActionGroup(this); group->setExclusive(true); action = toolBar->addAction(tr("DMX Values")); action->setToolTip(tr("Show DMX values 0-255")); action->setCheckable(true); action->setData(DMXValues); connect(action, SIGNAL(triggered(bool)), this, SLOT(slotValueStyleTriggered())); toolBar->addAction(action); group->addAction(action); action->setChecked(true); if (valueStyle() == DMXValues) action->setChecked(true); action = toolBar->addAction(tr("Percent Values")); action->setToolTip(tr("Show percentage values 0-100%")); action->setCheckable(true); action->setData(PercentageValues); connect(action, SIGNAL(triggered(bool)), this, SLOT(slotValueStyleTriggered())); toolBar->addAction(action); group->addAction(action); if (valueStyle() == PercentageValues) action->setChecked(true); }
void DkCropToolBar::createLayout() { QList<QKeySequence> enterSc; enterSc.append(QKeySequence(Qt::Key_Enter)); enterSc.append(QKeySequence(Qt::Key_Return)); QAction* cropAction = new QAction(icons[crop_icon], tr("Crop (ENTER)"), this); cropAction->setShortcuts(enterSc); cropAction->setObjectName("cropAction"); QAction* cancelAction = new QAction(icons[cancel_icon], tr("Cancel (ESC)"), this); cancelAction->setShortcut(QKeySequence(Qt::Key_Escape)); cancelAction->setObjectName("cancelAction"); panAction = new QAction(icons[pan_icon], tr("Pan"), this); panAction->setShortcut(QKeySequence(Qt::Key_P)); panAction->setObjectName("panAction"); panAction->setCheckable(true); panAction->setChecked(false); QStringList ratios; ratios << "1:1" << "4:3" << "5:4" << "14:10" << "14:11" << "16:9" << "16:10"; ratios.prepend(tr("User Defined")); ratios.prepend(tr("No Aspect Ratio")); ratioBox = new QComboBox(this); ratioBox->addItems(ratios); ratioBox->setObjectName("ratioBox"); horValBox = new QDoubleSpinBox(this); horValBox->setObjectName("horValBox"); horValBox->setSpecialValueText(" "); horValBox->setToolTip(tr("Horizontal Constraint")); horValBox->setStatusTip(horValBox->toolTip()); QAction* swapAction = new QAction(QIcon(":/nomacs/img/swap.png"), tr("Swap"), this); swapAction->setObjectName("swapAction"); swapAction->setToolTip(tr("Swap Dimensions")); swapAction->setStatusTip(swapAction->toolTip()); verValBox = new QDoubleSpinBox(this); verValBox->setObjectName("verValBox"); verValBox->setSpecialValueText(" "); horValBox->setToolTip(tr("Vertical Constraint")); horValBox->setStatusTip(horValBox->toolTip()); angleBox = new QDoubleSpinBox(this); angleBox->setObjectName("angleBox"); angleBox->setSuffix("°"); angleBox->setMinimum(-180); angleBox->setMaximum(180); // background color bgCol = QColor(0,0,0,0); bgColButton = new QPushButton(this); bgColButton->setObjectName("bgColButton"); bgColButton->setStyleSheet("QPushButton {background-color: " + DkUtils::colorToString(bgCol) + "; border: 1px solid #888;}"); bgColButton->setToolTip(tr("Background Color")); bgColButton->setStatusTip(bgColButton->toolTip()); colorDialog = new QColorDialog(this); colorDialog->setObjectName("colorDialog"); colorDialog->setOption(QColorDialog::ShowAlphaChannel, true); // crop customization QStringList guides; guides << tr("Guides") << tr("Rule of Thirds") << tr("Grid"); guideBox = new QComboBox(this); guideBox->addItems(guides); guideBox->setObjectName("guideBox"); guideBox->setToolTip(tr("Show Guides in the Preview")); guideBox->setStatusTip(guideBox->toolTip()); invertAction = new QAction(icons[invert_icon], tr("Invert Crop Tool Color"), this); invertAction->setObjectName("invertAction"); invertAction->setCheckable(true); invertAction->setChecked(false); infoAction = new QAction(icons[info_icon], tr("Show Info"), this); infoAction->setObjectName("infoAction"); infoAction->setCheckable(true); infoAction->setChecked(false); addAction(cropAction); addAction(panAction); addAction(cancelAction); addSeparator(); addWidget(ratioBox); addWidget(horValBox); addAction(swapAction); addWidget(verValBox); addWidget(angleBox); addSeparator(); addWidget(bgColButton); addSeparator(); addWidget(guideBox); addAction(invertAction); addAction(infoAction); }
QMenu * CanvasAppliance::createBackgroundMenu() { QMenu * menu = new QMenu(m_dummyWidget); m_gBackModeGroup = new QActionGroup(menu); connect(m_gBackModeGroup, SIGNAL(triggered(QAction*)), this, SLOT(slotSetBackMode(QAction*))); QAction * aNone = new QAction(tr("None"), menu); aNone->setToolTip(tr("Transparency can be saved to PNG images only.")); aNone->setShortcut(QKeySequence("CTRL+1")); aNone->setProperty("modeId", (int)Canvas::BackNone); aNone->setCheckable(true); aNone->setActionGroup(m_gBackModeGroup); menu->addAction(aNone); QAction * aBlack = new QAction(tr("Black"), menu); aBlack->setShortcut(QKeySequence("CTRL+2")); aBlack->setProperty("modeId", (int)Canvas::BackBlack); aBlack->setCheckable(true); aBlack->setActionGroup(m_gBackModeGroup); menu->addAction(aBlack); QAction * aWhite = new QAction(tr("White"), menu); aWhite->setShortcut(QKeySequence("CTRL+3")); aWhite->setProperty("modeId", (int)Canvas::BackWhite); aWhite->setCheckable(true); aWhite->setActionGroup(m_gBackModeGroup); menu->addAction(aWhite); QAction * aGradient = new QAction(tr("Gradient"), menu); aGradient->setShortcut(QKeySequence("CTRL+4")); aGradient->setProperty("modeId", (int)Canvas::BackGradient); aGradient->setCheckable(true); aGradient->setActionGroup(m_gBackModeGroup); menu->addAction(aGradient); menu->addSeparator(); m_gBackContentAction = new QAction(tr("Content"), menu); connect(m_gBackContentAction, SIGNAL(toggled(bool)), this, SLOT(slotBackContentRemove(bool))); m_gBackContentAction->setToolTip(tr("Double click on any content to put it on background.")); m_gBackContentAction->setEnabled(false); m_gBackContentAction->setCheckable(true); menu->addAction(m_gBackContentAction); QMenu * mScaling = new QMenu(tr("Content Aspect Ratio"), menu); m_gBackRatioGroup = new QActionGroup(menu); connect(m_gBackRatioGroup, SIGNAL(triggered(QAction*)), this, SLOT(slotSetBackRatio(QAction*))); menu->addMenu(mScaling); QAction * aRatioKeepEx = new QAction(tr("Keep proportions by expanding"), mScaling); aRatioKeepEx->setShortcut(QKeySequence("CTRL+5")); aRatioKeepEx->setProperty("ratioId", (int)Qt::KeepAspectRatioByExpanding); aRatioKeepEx->setCheckable(true); aRatioKeepEx->setActionGroup(m_gBackRatioGroup); mScaling->addAction(aRatioKeepEx); QAction * aRatioKeep = new QAction(tr("Keep proportions"), mScaling); aRatioKeep->setShortcut(QKeySequence("CTRL+6")); aRatioKeep->setProperty("ratioId", (int)Qt::KeepAspectRatio); aRatioKeep->setCheckable(true); aRatioKeep->setActionGroup(m_gBackRatioGroup); mScaling->addAction(aRatioKeep); QAction * aRatioIgnore = new QAction(tr("Ignore proportions"), mScaling); aRatioIgnore->setShortcut(QKeySequence("CTRL+7")); aRatioIgnore->setProperty("ratioId", (int)Qt::IgnoreAspectRatio); aRatioIgnore->setCheckable(true); aRatioIgnore->setActionGroup(m_gBackRatioGroup); mScaling->addAction(aRatioIgnore); menu->addSeparator(); QMenu * mPerspective = new QMenu(tr("View Perspective"), menu); menu->addMenu(mPerspective); QWidgetAction * aPerspective = new QWidgetAction(mPerspective); PaneWidget * perspWidget = new PaneWidget; perspWidget->setFixedSize(71, 71); perspWidget->setRange(QRectF(-30.0, -30.0, 60.0, 60.0)); new PE_PaneWidget(perspWidget, m_extCanvas, "perspective", perspWidget); aPerspective->setDefaultWidget(perspWidget); mPerspective->addAction(aPerspective); QMenu * mRotation = new QMenu(tr("View Rotation"), menu); menu->addMenu(mRotation); QWidgetAction * aRotation = new QWidgetAction(mRotation); QSlider * rotWidget = new QSlider(Qt::Horizontal); rotWidget->setMinimum(-40); rotWidget->setValue(0); rotWidget->setMaximum(40); rotWidget->setMinimumWidth(81 * 2); rotWidget->setProperty("noremap", true); new PE_AbstractSlider(rotWidget, m_extCanvas, "rotation", rotWidget); aRotation->setDefaultWidget(rotWidget); mRotation->addAction(aRotation); // initially check the action slotBackConfigChanged(); return menu; }
void CustomWebView::contextMenuEvent (QGraphicsSceneContextMenuEvent *e) { QPointer<QMenu> menu (new QMenu ()); QWebHitTestResult r = page ()-> mainFrame ()->hitTestContent (e->pos ().toPoint ()); IHookProxy_ptr proxy (new Util::DefaultHookProxy ()); emit hookWebViewContextMenu (proxy, this, e, r, menu, WVSStart); if (!r.linkUrl ().isEmpty ()) { QUrl url = r.linkUrl (); QString text = r.linkText (); if (XmlSettingsManager::Instance ()-> property ("TryToDetectRSSLinks").toBool ()) { bool hasAtom = text.contains ("Atom"); bool hasRSS = text.contains ("RSS"); if (hasAtom || hasRSS) { LeechCraft::Entity e; if (hasAtom) { e.Additional_ ["UserVisibleName"] = "Atom"; e.Mime_ = "application/atom+xml"; } else { e.Additional_ ["UserVisibleName"] = "RSS"; e.Mime_ = "application/rss+xml"; } e.Entity_ = url; e.Parameters_ = LeechCraft::FromUserInitiated | LeechCraft::OnlyHandle; bool ch = false; emit couldHandle (e, &ch); if (ch) { QList<QVariant> datalist; datalist << url << e.Mime_; menu->addAction (tr ("Subscribe"), this, SLOT (subscribeToLink ()))->setData (datalist); menu->addSeparator (); } } } menu->addAction (tr ("Open &here"), this, SLOT (openLinkHere ()))->setData (url); menu->addAction (tr ("Open in new &tab"), this, SLOT (openLinkInNewTab ()))->setData (url); menu->addSeparator (); menu->addAction (tr ("&Save link..."), this, SLOT (saveLink ())); QList<QVariant> datalist; datalist << url << text; menu->addAction (tr ("&Bookmark link..."), this, SLOT (bookmarkLink ()))->setData (datalist); menu->addSeparator (); if (!page ()->selectedText ().isEmpty ()) menu->addAction (pageAction (QWebPage::Copy)); menu->addAction (tr ("&Copy link"), this, SLOT (copyLink ())); if (page ()->settings ()->testAttribute (QWebSettings::DeveloperExtrasEnabled)) menu->addAction (pageAction (QWebPage::InspectElement)); } else if (page ()->selectedText ().contains (UrlInText)) { menu->addAction (tr ("Open as link"), this, SLOT (openLinkInNewTab ()))-> setData (page ()->selectedText ()); } emit hookWebViewContextMenu (proxy, this, e, r, menu, WVSAfterLink); if (!r.imageUrl ().isEmpty ()) { if (!menu->isEmpty ()) menu->addSeparator (); menu->addAction (tr ("Open image here"), this, SLOT (openImageHere ()))->setData (r.imageUrl ()); menu->addAction (tr ("Open image in new tab"), this, SLOT (openImageInNewTab ())); menu->addSeparator (); menu->addAction (tr ("Save image..."), this, SLOT (saveImage ())); QAction *spx = menu->addAction (tr ("Save pixmap..."), this, SLOT (savePixmap ())); spx->setToolTip (tr ("Saves the rendered pixmap without redownloading.")); spx->setProperty ("Poshuku/OrigPX", r.pixmap ()); spx->setProperty ("Poshuku/OrigURL", r.imageUrl ()); menu->addAction (tr ("Copy image"), this, SLOT (copyImage ())); menu->addAction (tr ("Copy image location"), this, SLOT (copyImageLocation ()))->setData (r.imageUrl ()); } emit hookWebViewContextMenu (proxy, this, e, r, menu, WVSAfterImage); bool hasSelected = !page ()->selectedText ().isEmpty (); if (hasSelected) { if (!menu->isEmpty ()) menu->addSeparator (); menu->addAction (pageAction (QWebPage::Copy)); } if (r.isContentEditable ()) menu->addAction (pageAction (QWebPage::Paste)); if (hasSelected) { Browser_->Find_->setData (page ()->selectedText ()); menu->addAction (Browser_->Find_); menu->addAction (tr ("Search..."), this, SLOT (searchSelectedText ())); } emit hookWebViewContextMenu (proxy, this, e, r, menu, WVSAfterSelectedText); if (menu->isEmpty ()) menu = page ()->createStandardContextMenu (); if (!menu->isEmpty ()) menu->addSeparator (); menu->addAction (Browser_->Add2Favorites_); menu->addSeparator (); menu->addAction (Browser_->Print_); menu->addAction (Browser_->PrintPreview_); menu->addSeparator (); menu->addAction (Browser_->ViewSources_); menu->addAction (Browser_->SavePage_); menu->addSeparator (); menu->addAction (pageAction (QWebPage::ReloadAndBypassCache)); menu->addAction (Browser_->ReloadPeriodically_); menu->addAction (Browser_->NotifyWhenFinished_); menu->addSeparator (); menu->addAction (Browser_->ChangeEncoding_->menuAction ()); menu->addSeparator (); menu->addAction (Browser_->RecentlyClosedAction_); emit hookWebViewContextMenu (proxy, this, e, r, menu, WVSAfterFinish); if (!menu->isEmpty ()) menu->exec (Browser_->GetGraphicsView ()->viewport ()-> mapToGlobal (e->pos ().toPoint ())); else QGraphicsWebView::contextMenuEvent (e); if (menu) delete menu; }
void MainWindow::loadComPorts() { ui->menuFile->clear(); m_comPorts = new QActionGroup(this); m_comPorts->setExclusive(true); QList<QextPortInfo> ports = QextSerialEnumerator::getPorts(); for (int i = 0; i < ports.size(); i++) { QString fullName; QString friendName = ports.at(i).friendName; QString name = ports.at(i).portName; if (name.contains("LPT")) { continue; } #ifdef Q_OS_WIN name.remove("\\\\.\\"); fullName = QString("%1").arg(friendName); #else #ifdef Q_OS_LINUX name.prepend("/dev/"); #endif if (friendName.size() > 0) { fullName = QString("%1 (%2)").arg(friendName) .arg(name); } else { QChar num = name.at(name.size() - 1); if (name.contains("ttyS")) { fullName = QString("Serial Port %1 (%2)").arg(num).arg(name); } else if (name.contains("ttyACM")) { fullName = QString("Serial ACM %1 (%2)").arg(num).arg(name); } else if (name.contains("ttyUSB")) { fullName = QString("Serial USB %1 (%2)").arg(num).arg(name); } } #endif QAction * com = new QAction(fullName, this); com->setToolTip(name); com->setCheckable(true); if (com->toolTip() == m_tty) { com->setChecked(true); } m_comPorts->addAction(com); } connect(m_comPorts, SIGNAL(triggered(QAction*)), this, SLOT(comAction_triggered(QAction*))); ui->menuFile->addActions(m_comPorts->actions()); ui->menuFile->addSeparator(); ui->menuFile->addAction(ui->actionRefresh); ui->menuFile->addSeparator(); ui->menuFile->addAction(ui->actionQuit); }
//BEGIN KateViewSpace KateViewSpace::KateViewSpace(KateViewManager *viewManager, QWidget *parent, const char *name) : QWidget(parent) , m_viewManager(viewManager) , m_isActiveSpace(false) { setObjectName(QString::fromLatin1(name)); QVBoxLayout *layout = new QVBoxLayout(this); layout->setSpacing(0); layout->setMargin(0); //BEGIN tab bar QHBoxLayout *hLayout = new QHBoxLayout(); hLayout->setSpacing(0); hLayout->setMargin(0); // add tab bar m_tabBar = new KateTabBar(this); connect(m_tabBar, &KateTabBar::currentChanged, this, &KateViewSpace::changeView); connect(m_tabBar, &KateTabBar::moreTabsRequested, this, &KateViewSpace::addTabs); connect(m_tabBar, &KateTabBar::lessTabsRequested, this, &KateViewSpace::removeTabs); connect(m_tabBar, &KateTabBar::closeTabRequested, this, &KateViewSpace::closeTabRequest, Qt::QueuedConnection); connect(m_tabBar, &KateTabBar::contextMenuRequest, this, &KateViewSpace::showContextMenu, Qt::QueuedConnection); connect(m_tabBar, &KateTabBar::newTabRequested, this, &KateViewSpace::createNewDocument); connect(m_tabBar, SIGNAL(activateViewSpaceRequested()), this, SLOT(makeActive())); hLayout->addWidget(m_tabBar); // add quick open m_quickOpen = new QToolButton(this); m_quickOpen->setAutoRaise(true); KAcceleratorManager::setNoAccel(m_quickOpen); m_quickOpen->installEventFilter(this); // on click, active this view space hLayout->addWidget(m_quickOpen); // forward tab bar quick open action to globa quick open action QAction * bridge = new QAction(QIcon::fromTheme(QStringLiteral("tab-duplicate")), i18nc("indicator for more documents", "+%1", 100), this); m_quickOpen->setDefaultAction(bridge); QAction * quickOpen = m_viewManager->mainWindow()->actionCollection()->action(QStringLiteral("view_quick_open")); Q_ASSERT(quickOpen); bridge->setToolTip(quickOpen->toolTip()); bridge->setWhatsThis(i18n("Click here to switch to the Quick Open view.")); connect(bridge, SIGNAL(triggered()), quickOpen, SLOT(trigger())); // add vertical split view space m_split = new QToolButton(this); m_split->setAutoRaise(true); m_split->setPopupMode(QToolButton::InstantPopup); m_split->setIcon(QIcon::fromTheme(QStringLiteral("view-split-left-right"))); m_split->addAction(m_viewManager->mainWindow()->actionCollection()->action(QStringLiteral("view_split_vert"))); m_split->addAction(m_viewManager->mainWindow()->actionCollection()->action(QStringLiteral("view_split_horiz"))); m_split->addAction(m_viewManager->mainWindow()->actionCollection()->action(QStringLiteral("view_close_current_space"))); m_split->addAction(m_viewManager->mainWindow()->actionCollection()->action(QStringLiteral("view_close_others"))); m_split->addAction(m_viewManager->mainWindow()->actionCollection()->action(QStringLiteral("view_hide_others"))); m_split->setWhatsThis(i18n("Control view space splitting")); m_split->installEventFilter(this); // on click, active this view space hLayout->addWidget(m_split); layout->addLayout(hLayout); //END tab bar stack = new QStackedWidget(this); stack->setFocus(); stack->setSizePolicy(QSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Expanding)); layout->addWidget(stack); m_group.clear(); // connect signal to hide/show statusbar connect(m_viewManager->mainWindow(), SIGNAL(statusBarToggled()), this, SLOT(statusBarToggled())); connect(m_viewManager->mainWindow(), SIGNAL(tabBarToggled()), this, SLOT(tabBarToggled())); // init the bars... statusBarToggled(); tabBarToggled(); // make sure we show correct number of hidden documents updateQuickOpen(); connect(KateApp::self()->documentManager(), SIGNAL(documentCreated(KTextEditor::Document*)), this, SLOT(updateQuickOpen())); connect(KateApp::self()->documentManager(), SIGNAL(documentsDeleted(const QList<KTextEditor::Document*>&)), this, SLOT(updateQuickOpen())); }
MainMenubar::MainMenubar (QMainWindow *mw) : QMenuBar (mw, "mainMenubar") { actions.setAutoDelete(FALSE); RcFile rcfile; QPixmap icon(finished); QAction *action = new QAction(this, "actionExit"); action->setMenuText(tr("E&xit")); action->setIconSet(icon); action->setAccel(CTRL+Key_Q); action->setStatusTip(tr("Quit Qtstalker (Ctrl+Q)")); action->setToolTip(tr("Quit Qtstalker (Ctrl+Q)")); connect(action, SIGNAL(activated()), this, SIGNAL(signalExit())); actions.replace(Exit, action); icon = indicator; action = new QAction(this, "actionNewIndicator"); action->setMenuText(tr("New &Indicator")); action->setIconSet(icon); action->setStatusTip(tr("Add a new indicator to chart (Ctrl+2)")); action->setToolTip(tr("Add a new indicator to chart (Ctrl+2)")); connect(action, SIGNAL(activated()), this, SIGNAL(signalNewIndicator())); actions.replace(NewIndicator, action); icon = configure; action = new QAction(this, "actionOptions"); action->setMenuText(tr("Edit &Preferences")); action->setIconSet(icon); action->setStatusTip(tr("Modify user preferences (Ctrl+3)")); action->setToolTip(tr("Modify user preferences (Ctrl+3)")); connect(action, SIGNAL(activated()), mw, SLOT(slotOptions())); actions.replace(Options, action); icon = gridicon; bool b; rcfile.loadData(RcFile::Grid, b); action = new QAction(this, "actionGrid"); action->setMenuText(tr("Chart &Grid")); action->setIconSet(icon); action->setStatusTip(tr("Toggle the chart grid (Ctrl+4)")); action->setToolTip(tr("Toggle the chart grid (Ctrl+4)")); action->setToggleAction(TRUE); action->setOn(b); connect(action, SIGNAL(toggled(bool)), this, SIGNAL(signalGrid(bool))); actions.replace(Grid, action); icon = quotes; action = new QAction(this, "actionQuote"); action->setMenuText(tr("Load Quotes")); action->setIconSet(icon); action->setStatusTip(tr("Load Quotes (Ctrl+Y)")); action->setToolTip(tr("Load Quotes (Ctrl+Y)")); connect(action, SIGNAL(activated()), mw, SLOT(slotQuotes())); actions.replace(Quotes, action); icon = datawindow; action = new QAction(this, "actionDataWindow"); action->setMenuText(tr("&Data Window")); action->setIconSet(icon); action->setAccel(ALT+Key_1); action->setStatusTip(tr("Show the data window (Alt+1)")); action->setToolTip(tr("Show the data window (Alt+1)")); connect(action, SIGNAL(activated()), mw, SLOT(slotDataWindow())); actions.replace(DataWindow, action); icon = qtstalker; action = new QAction(this, "actionAbout"); action->setMenuText(tr("&About")); action->setIconSet(icon); action->setStatusTip(tr("About Qtstalker.")); action->setToolTip(tr("About Qtstalker.")); connect(action, SIGNAL(activated()), mw, SLOT(slotAbout())); actions.replace(About, action); icon = scaletoscreen; rcfile.loadData(RcFile::ScaleToScreen, b); action = new QAction(this, "actionScale"); action->setMenuText(tr("&Scale To Screen")); action->setIconSet(icon); action->setStatusTip(tr("Scale chart to current screen data (Ctrl+5)")); action->setToolTip(tr("Scale chart to current screen data (Ctrl+5)")); action->setToggleAction(TRUE); action->setOn(b); connect(action, SIGNAL(toggled(bool)), this, SIGNAL(signalScale(bool))); actions.replace(ScaleToScreen, action); icon = nav; rcfile.loadData(RcFile::ShowSidePanel, b); action = new QAction(this, "actionPanel"); action->setMenuText(tr("Side Pa&nel")); action->setIconSet(icon); action->setStatusTip(tr("Toggle the side panel area from view (Ctrl+7)")); action->setToolTip(tr("Toggle the side panel area from view (Ctrl+7)")); action->setToggleAction(TRUE); action->setOn(b); connect(action, SIGNAL(toggled(bool)), mw, SLOT(slotHideNav(bool))); actions.replace(SidePanel, action); icon = co; rcfile.loadData(RcFile::DrawMode, b); action = new QAction(this, "actionDraw"); action->setMenuText(tr("Toggle Dra&w Mode")); action->setIconSet(icon); action->setStatusTip(tr("Toggle drawing mode (Ctrl+0)")); action->setToolTip(tr("Toggle drawing mode (Ctrl+0)")); action->setToggleAction(TRUE); action->setOn(b); connect(action, SIGNAL(toggled(bool)), this, SIGNAL(signalDraw(bool))); actions.replace(DrawMode, action); icon = crosshair; rcfile.loadData(RcFile::Crosshairs, b); action = new QAction(this, "actionCrosshairs"); action->setMenuText(tr("Toggle Cross&hairs")); action->setIconSet(icon); action->setStatusTip(tr("Toggle crosshairs (Ctrl+6)")); action->setToolTip(tr("Toggle crosshairs (Ctrl+6)")); action->setToggleAction(TRUE); action->setOn(b); connect(action, SIGNAL(toggled(bool)), this, SIGNAL(signalCrosshairs(bool))); actions.replace(Crosshairs, action); icon = papertrade; rcfile.loadData(RcFile::PaperTradeMode, b); action = new QAction(this, "actionPaperTrade"); action->setMenuText(tr("Paper Trade Mode")); action->setIconSet(icon); action->setStatusTip(tr("Toggle the paper trade mode")); action->setToolTip(tr("Toggle the paper trade mode")); action->setToggleAction(TRUE); action->setOn(b); connect(action, SIGNAL(toggled(bool)), this, SIGNAL(signalPaperTrade(bool))); actions.replace(PaperTrade, action); icon = help; action = new QAction(this, "actionHelp"); action->setMenuText(tr("&Help")); action->setIconSet(icon); action->setAccel(ALT+Key_3); action->setStatusTip(tr("Display Help Dialog (Alt+3)")); action->setToolTip(tr("Display Help Dialog (Alt+3)")); connect(action, SIGNAL(activated()), mw, SLOT(slotHelp())); actions.replace(Help, action); action = new QAction(this, "actionAdvancePaperTrade"); action->setAccel(CTRL+Key_Right); connect(action, SIGNAL(activated()), this, SIGNAL(signalAdvancePaperTrade())); actions.replace(AdvancePaperTrade, action); action = new QAction(this, "actionIndicatorSummary"); action->setMenuText(tr("Indicator Summary")); action->setStatusTip(tr("Indicator Summary")); action->setToolTip(tr("Indicator Summary")); connect(action, SIGNAL(activated()), mw, SLOT(slotIndicatorSummary())); actions.replace(IndicatorSummary, action); QAccel *a = new QAccel(mw); connect(a, SIGNAL(activated(int)), this, SLOT(slotAccel(int))); a->insertItem(CTRL+Key_2, NewIndicator); a->insertItem(CTRL+Key_3, Options); a->insertItem(CTRL+Key_4, Grid); a->insertItem(CTRL+Key_5, ScaleToScreen); a->insertItem(CTRL+Key_6, Crosshairs); a->insertItem(CTRL+Key_7, SidePanel); a->insertItem(CTRL+Key_0, DrawMode); a->insertItem(CTRL+Key_Y, Quotes); a->insertItem(CTRL+Key_Right, AdvancePaperTrade); a->insertItem(CTRL+Key_Escape, 8); createMenus(); rcfile.loadData(RcFile::ShowMenuBar, b); if (!b) hide(); }
void ReferencesTool::createActions() { QWidgetAction *wAction = 0; QAction *action = new QAction(i18n("Insert"), this); addAction("insert_tableofcontents", action); action->setToolTip(i18n("Insert a Table of Contents into the document.")); action = new QAction(i18n("Insert Custom..."), this); addAction("insert_configure_tableofcontents", action); action->setToolTip(i18n("Insert a custom Table of Contents into the document.")); action = new QAction(koIcon("configure"), i18n("Configure..."), this); addAction("format_tableofcontents", action); action->setToolTip(i18n("Configure the Table of Contents")); connect(action, SIGNAL(triggered()), this, SLOT(formatTableOfContents())); action = new QAction(i18n("Insert footnote with auto number"),this); addAction("insert_autofootnote",action); connect(action, SIGNAL(triggered()), this, SLOT(insertAutoFootNote())); wAction = new QWidgetAction(this); wAction->setText(i18n("Insert Labeled Footnote")); QWidget *w = new LabeledWidget(wAction, i18n("Insert with label:"), LabeledWidget::INLINE, false); wAction->setDefaultWidget(w); addAction("insert_labeledfootnote", wAction); connect(w, SIGNAL(triggered(QString)), this, SLOT(insertLabeledFootNote(QString))); action = new QAction(i18n("Insert endnote with auto number"),this); addAction("insert_autoendnote",action); connect(action, SIGNAL(triggered()), this, SLOT(insertAutoEndNote())); wAction = new QWidgetAction(this); wAction->setText(i18n("Insert Labeled Endnote")); w = new LabeledWidget(wAction, i18n("Insert with label:"), LabeledWidget::INLINE, false); wAction->setDefaultWidget(w); addAction("insert_labeledendnote", wAction); connect(w, SIGNAL(triggered(QString)), this, SLOT(insertLabeledEndNote(QString))); action = new QAction(koIcon("configure"), i18n("Settings..."), this); addAction("format_footnotes",action); connect(action, SIGNAL(triggered()), this, SLOT(showFootnotesConfigureDialog())); action = new QAction(koIcon("configure"), i18n("Settings..."), this); addAction("format_endnotes",action); connect(action, SIGNAL(triggered()), this, SLOT(showEndnotesConfigureDialog())); action = new QAction(i18n("Insert Citation"), this); addAction("insert_citation",action); action->setToolTip(i18n("Insert a citation into the document.")); connect(action, SIGNAL(triggered()), this, SLOT(insertCitation())); action = new QAction(i18n("Insert Bibliography"), this); addAction("insert_bibliography",action); action->setToolTip(i18n("Insert a bibliography into the document.")); action = new QAction(i18n("Insert Custom Bibliography"), this); addAction("insert_custom_bibliography", action); action->setToolTip(i18n("Insert a custom Bibliography into the document.")); action = new QAction(i18n("Configure"),this); addAction("configure_bibliography",action); action->setToolTip(i18n("Configure the bibliography")); connect(action, SIGNAL(triggered()), this, SLOT(configureBibliography())); action = new QAction(i18n("Insert Link"), this); addAction("insert_link", action); action->setToolTip(i18n("Insert a weblink or link to a bookmark.")); connect(action, SIGNAL(triggered()), this, SLOT(insertLink())); wAction = new QWidgetAction(this); wAction->setText(i18n("Add Bookmark")); m_bmark = new LabeledWidget(wAction, i18n("Add Bookmark :"), LabeledWidget::ABOVE, true); connect(m_bmark, SIGNAL(lineEditChanged(QString)), this, SLOT(validateBookmark(QString))); wAction->setDefaultWidget(m_bmark); addAction("insert_bookmark", wAction); connect(m_bmark, SIGNAL(triggered(QString)), this, SLOT(insertBookmark(QString))); wAction->setToolTip(i18n("Insert a Bookmark. This is useful to create links that point to areas within the document")); action = new QAction(i18n("Bookmarks"), this); addAction("invoke_bookmark_handler", action); action->setToolTip(i18n("Display a pop up that hosts the options to add new Bookmark or handle existing Bookmarks")); action = new QAction(i18n("Manage Bookmarks"), this); addAction("manage_bookmarks", action); action->setToolTip(i18n("Manage your Bookmarks. Check where are they pointing to, Delete or Rename.")); }
void MainWindow::createMenuFile() { QIcon iconLogo; iconLogo.addPixmap(QPixmap(":/shared/res/qtitan.png")); iconLogo.addPixmap(QPixmap(":/shared/res/qtitanlogo32x32.png")); if (QAction* actionFile = ribbonBar()->addSystemButton(iconLogo, tr("&File"))) { actionFile->setToolTip(tr("Click here to see everything<br />you can do with your<br />document")); if (Qtitan::RibbonSystemPopupBar* popupBar = qobject_cast<Qtitan::RibbonSystemPopupBar*>(actionFile->menu())) { QAction* newFile = popupBar->addAction(QIcon(":/res/new.png"), tr("&New")); newFile->setShortcut(tr("Ctrl+N")); newFile->setStatusTip(tr("Create a new document")); newFile->setToolTip(tr("New")); newFile->setEnabled(false); QAction* openFile = popupBar->addAction(QIcon(":/res/open.png"), tr("&Open...")); openFile->setShortcut(tr("Ctrl+O")); openFile->setToolTip(tr("Open")); openFile->setStatusTip(tr("Open an existing document")); connect(openFile, SIGNAL(triggered()), this, SLOT(open())); QAction* saveFile = popupBar->addAction(QIcon(":/res/save.png"), tr("&Save")); saveFile->setShortcut(tr("Ctrl+S")); saveFile->setToolTip(tr("Save")); saveFile->setStatusTip(tr("Save the active document")); connect(saveFile, SIGNAL(triggered()), this, SLOT(save())); QAction* saveAsFile = popupBar->addAction(tr("Save &As...")); saveAsFile->setToolTip(tr("Save As")); saveAsFile->setStatusTip(tr("Save the active document with a new name")); connect(saveAsFile, SIGNAL(triggered()), this, SLOT(save())); #ifndef QT_NO_PRINTER popupBar->addSeparator(); QAction* printFile = popupBar->addAction(QIcon(":/res/print.png"), tr("&Print")); printFile->setShortcut(tr("Ctrl+P")); printFile->setToolTip(tr("Print")); printFile->setStatusTip(tr("Print the active document")); connect(printFile, SIGNAL(triggered()), this, SLOT(print())); QAction* printPreviewFile = popupBar->addAction(QIcon(":/res/printPreview.png"), tr("Print Pre&view")); printPreviewFile->setToolTip(tr("Print Preview")); printPreviewFile->setStatusTip(tr("Display full pages")); QAction* printSetupFile = popupBar->addAction(tr("P&rint Setup...")); printSetupFile->setToolTip(tr("Print Setup")); printSetupFile->setStatusTip(tr("Change the printer and printing options")); connect(printSetupFile, SIGNAL(triggered()), this, SLOT(printSetup())); popupBar->addSeparator(); #endif // QT_NO_PRINTER QAction* actClose = popupBar->addAction(QIcon(":/res/close.png"), tr("&Close")); actClose->setShortcut(tr("Ctrl+C")); actClose->setStatusTip(tr("Exit")); connect(actClose, SIGNAL(triggered()), this, SLOT(close())); popupBar->addPopupBarAction(actClose); QAction* option = popupBar->addPopupBarAction(tr("Option")); option->setEnabled(false); } } }
void MainWindow::createRibbon() { if (Qtitan::RibbonPage* pageGallery = ribbonBar()->addPage( tr("&Galleries 1"))) { if (Qtitan::RibbonGroup* groupPopup = pageGallery->addGroup(tr("Popup Galleries"))) { groupPopup->setOptionButtonVisible(); QAction* act = groupPopup->optionButtonAction(); act->setToolTip(tr("Popup Galleries")); connect(act, SIGNAL(triggered()), this, SLOT(pressButton())); groupPopup->setControlsCentering(true); OfficePopupMenu* popup = OfficePopupMenu::createPopupMenu(this); Qtitan::RibbonGallery* popupGallery = new Qtitan::RibbonGallery; popupGallery->setBaseSize(QSize(307, 168)); popupGallery->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); popupGallery->setGalleryGroup(m_itemsStyles); popup->addWidget(popupGallery); popup->addSeparator(); popup->addAction(tr("Save Style")); popup->addAction(tr("Apply Style")); groupPopup->addAction(QIcon(":/res/largeStyleButton.png"), tr("Styles"), Qt::ToolButtonTextUnderIcon, popup, QToolButton::InstantPopup); popup = OfficePopupMenu::createPopupMenu(this); m_popupTableGallery = new Qtitan::RibbonGallery; m_popupTableGallery->setBaseSize(QSize(193, 175)); m_popupTableGallery->setLabelsVisible(true); m_popupTableGallery->setScrollBarPolicy(Qt::ScrollBarAlwaysOff); m_popupTableGallery->setGalleryGroup(m_itemsTable); popup->addWidget(m_popupTableGallery); groupPopup->addAction(QIcon(":/res/largeTable.png"), tr("Table"), Qt::ToolButtonTextUnderIcon, popup, QToolButton::InstantPopup); connect(m_popupTableGallery, SIGNAL(itemPressed(RibbonGalleryItem*)), this, SLOT(itemTablePressed(RibbonGalleryItem*))); popup = OfficePopupMenu::createPopupMenu(this); popupGallery = new Qtitan::RibbonGallery(); popupGallery->setBaseSize(QSize(173, 145)); popupGallery->setLabelsVisible(true); popupGallery->setScrollBarPolicy(Qt::ScrollBarAlwaysOff); popupGallery->setGalleryGroup(m_itemsFontTextColor); popup->addWidget(popupGallery); groupPopup->addAction(QIcon(":/res/largeColorButton.png"), tr("Color"), Qt::ToolButtonTextUnderIcon, popup, QToolButton::InstantPopup); popup = OfficePopupMenu::createPopupMenu(this); popup->setGripVisible(false); m_popupUndoGallery = new WidgetGalleryUndo(); m_popupUndoGallery->setGalleryGroup(m_itemsUndo); m_popupUndoGallery->setBaseSize(QSize(120, m_itemsUndo->getSize().height() * m_itemsUndo->getItemCount() + 2)); m_popupUndoGallery->setScrollBarPolicy(Qt::ScrollBarAlwaysOff); popup->addWidget(m_popupUndoGallery); QLabel* label = new QLabel(); label->setAlignment(Qt::AlignCenter); label->setMinimumWidth(118); popup->addWidget(label); m_popupUndoGallery->selectedItemChanged(); m_actionUndo = groupPopup->addAction(QIcon(":/res/largeUndo.png"), tr("Undo"), Qt::ToolButtonTextUnderIcon, popup); connect(popup, SIGNAL(aboutToHide()), this, SLOT(aboutToHideUndo())); connect(m_popupUndoGallery, SIGNAL(itemPressed(RibbonGalleryItem*)), this, SLOT(itemUndoPressed(RibbonGalleryItem*))); } if (Qtitan::RibbonGroup* groupInline = pageGallery->addGroup(tr("Inline Galleries"))) { groupInline->setOptionButtonVisible(); QAction* act = groupInline->optionButtonAction(); act->setToolTip(tr("Inline Galleries")); connect(act, SIGNAL(triggered()), this, SLOT(pressButton())); groupInline->setControlsCentering(true); m_widgetFontTextColor = new Qtitan::RibbonGallery; m_widgetFontTextColor->setBaseSize(QSize(190, 60)); m_widgetFontTextColor->setLabelsVisible(false); m_widgetFontTextColor->setScrollBarPolicy(Qt::ScrollBarAlwaysOn); m_widgetFontTextColor->setBorderVisible(true); m_widgetFontTextColor->setGalleryGroup(m_itemsFontTextColor); m_widgetFontTextColor->setCheckedIndex(1); act = groupInline->addWidget(m_widgetFontTextColor); act->setText(tr("&Color")); connect(m_widgetFontTextColor, SIGNAL(itemPressed(RibbonGalleryItem*)), this, SLOT(itemColorPressed(RibbonGalleryItem*))); groupInline->addSeparator(); m_widgetStyleFont = new Qtitan::RibbonGallery; m_widgetStyleFont->setBaseSize(QSize(632, 60)); m_widgetStyleFont->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); m_widgetStyleFont->setLabelsVisible(false); m_widgetStyleFont->setContentsMargins(0, 1, 0, 1); m_widgetStyleFont->setBorderVisible(true); m_widgetStyleFont->setGalleryGroup(m_itemsStyles); m_widgetStyleFont->setCheckedIndex(0); connect(m_widgetStyleFont, SIGNAL(itemPressed(RibbonGalleryItem*)), this, SLOT(itemStyleFontPressed(RibbonGalleryItem*))); OfficePopupMenu* popup = OfficePopupMenu::createPopupMenu(this); m_widgetStyleFont->setPopupMenu(popup); m_popupStyleFont = new Qtitan::RibbonGallery; m_popupStyleFont->setBaseSize(QSize(307, 168)); m_popupStyleFont->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); m_popupStyleFont->setGalleryGroup(m_itemsStyles); m_popupStyleFont->setCheckedIndex(0); connect(m_popupStyleFont, SIGNAL(itemPressed(RibbonGalleryItem*)), this, SLOT(itemStyleFontPressed(RibbonGalleryItem*))); popup->addWidget(m_popupStyleFont); popup->addSeparator(); // hide page, if enabled minimization signal - released() QAction* actSaveStyle = popup->addAction(tr("&Save Style")); QObject::connect(actSaveStyle, SIGNAL(triggered()), groupInline, SIGNAL(released())); QAction* actApplyStyle = popup->addAction(tr("&Apply Style")); QObject::connect(actApplyStyle, SIGNAL(triggered()), groupInline, SIGNAL(released())); act = groupInline->addWidget(m_widgetStyleFont); act->setText(tr("&Style")); }
MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow) { // Setup this MainWindow with the parameters mainwindow.ui: // Definition of size, creation of widgets inside etc.. ui->setupUi(this); // Retrieve pointers of widgets already created by the up operation // Those who will be used again outside the creator are saved at class variables QMenuBar * menuBar = ui->menuBar; QSlider *slider_color = ui->verticalSlider; QSlider *slider_style = ui->verticalSlider_2; QToolBar * toolbar = ui->toolBar; mydrawzone = ui->widget; // Declaration of menus and adition inside menubar QMenu * openMenu = menuBar->addMenu( tr("&Open")); QMenu * saveMenu = menuBar->addMenu( tr("&Save")); QMenu * quitMenu = menuBar->addMenu( tr("&Quit")); QMenu * penMenu = menuBar->addMenu( tr("&Pen Settings")); QMenu * colorMenu = menuBar->addMenu( tr("&Color Settings")); QMenu * styleMenu = menuBar->addMenu( tr("&Style Settings")); QMenu * formMenu = menuBar->addMenu( tr("&Form Settings")); // Declaration of principal actions // Those that will be shown at the toolbar QAction * openAction = new QAction( QIcon(":/icons/open.png"), tr("&Open"), this); QAction * saveAction = new QAction( QIcon(":/icons/save.png"), tr("&Save"), this); QAction * quitAction = new QAction( QIcon(":/icons/quit.png"), tr("&Quit"), this); QAction * paintAction = new QAction( QIcon(":/icons/paint.png"), tr("&Paint"), this); QAction * editAction = new QAction( QIcon(":/icons/edit.png"), tr("&Edit"), this); QAction * moveAction = new QAction( QIcon(":/icons/move.png"), tr("&Edit"), this); // Declaration of some other actions // Those that will have shortcuts as well but wont be shown in the toolbar QAction *set_pen_color =new QAction(tr("Alternate Color Pen"), this); QAction *set_pen_width_larger =new QAction(tr("&Pen Width +"), this); QAction *set_pen_width_shorter =new QAction(tr("&Pen Width -"), this); QAction *set_pen_style =new QAction(tr("&Alternate Style Pen"), this); QAction *set_figure_form =new QAction(tr("&Alternate Figure Form"), this); QAction *undo =new QAction(tr("&Undo"), this); // Declaration of action groups // The pointers for the actions are saved inside class variables // to be used outside the class creator QActionGroup *action_group_color = new QActionGroup(this); color0 = action_group_color->addAction(tr("Black Pen")); color1 = action_group_color->addAction(tr("White Pen")); color2 = action_group_color->addAction(tr("Dark Gray Pen")); color3 = action_group_color->addAction(tr("Gray Pen")); color4 = action_group_color->addAction(tr("Light Gray Pen")); color5 = action_group_color->addAction(tr("Red Pen")); color6 = action_group_color->addAction(tr("Green Pen")); color7 = action_group_color->addAction(tr("Blue Pen")); color8 = action_group_color->addAction(tr("Cyan Pen")); color9 = action_group_color->addAction(tr("Magenta Pen")); color10 = action_group_color->addAction(tr("Yellow Pen")); color11 = action_group_color->addAction(tr("Dark Red Pen")); color12 = action_group_color->addAction(tr("Dark Green Pen")); color13 = action_group_color->addAction(tr("Dark Blue Pen")); color14 = action_group_color->addAction(tr("Dark Cyan Pen")); color15 = action_group_color->addAction(tr("Dark Magenta Pen")); color16 = action_group_color->addAction(tr("Dark Yellow Pen")); color17 = action_group_color->addAction(tr("Transparent")); QActionGroup *action_group_style = new QActionGroup(this); style0 = action_group_style->addAction(tr("Solid Pen")); style1 = action_group_style->addAction(tr("Dash Line Pen")); style2 = action_group_style->addAction(tr("Dot Line Pen")); style3 = action_group_style->addAction(tr("Dash dot Line Pen")); style4 = action_group_style->addAction(tr("Dash Dot Dot Line Pen")); style5 = action_group_style->addAction(tr("Custom Dash Line Pen")); QActionGroup *action_group_form = new QActionGroup(this); form0 = action_group_form->addAction(tr("Line Form")); form1 = action_group_form->addAction(tr("Rectangle Form")); form2 = action_group_form->addAction(tr("Elipse Form")); // Adition of shortcuts for principal actions openAction->setShortcut( tr("Ctrl+O")); saveAction->setShortcut( tr("Ctrl+S")); quitAction->setShortcut( tr("Ctrl+Q")); paintAction->setShortcut( tr("Ctrl+P")); editAction->setShortcut( tr("Ctrl+E")); moveAction->setShortcut( tr("Ctrl+M")); // Adition of shortcuts for those other actions set_pen_color->setShortcut( tr("Ctrl+C")); set_pen_style->setShortcut( tr("Ctrl+Space")); set_pen_width_larger->setShortcut( tr("Ctrl++")); set_pen_width_shorter->setShortcut( tr("Ctrl+-")); set_figure_form->setShortcut( tr("Ctrl+F")); undo->setShortcut(tr ("Ctrl+Z")); // Adition of tool tips for principal actions openAction->setToolTip( tr("Open file")); saveAction->setToolTip( tr("Save file")); quitAction->setToolTip( tr("Quit file")); // Adition of status tips for principal actions openAction->setStatusTip( tr("Open file")); saveAction->setStatusTip( tr("Save file")); quitAction->setStatusTip( tr("Quit file")); // Adition of actions to menus openMenu->addAction(openAction); saveMenu->addAction(saveAction); quitMenu->addAction(quitAction); penMenu->addAction(set_pen_width_larger); penMenu->addAction(set_pen_width_shorter); penMenu->addAction(undo); colorMenu->addAction(set_pen_color); colorMenu->addActions(action_group_color->actions()); styleMenu->addAction(set_pen_style); styleMenu->addActions(action_group_style->actions()); formMenu->addAction(set_figure_form); formMenu->addActions(action_group_form->actions()); // Adition of principal actions to toolbar toolbar->addAction(openAction); toolbar->addAction(saveAction); toolbar->addAction(quitAction); toolbar->addAction(paintAction); toolbar->addAction(editAction); toolbar->addAction(moveAction); // Set some parameters to the sliders slider_color->setTickPosition(QSlider::TicksBothSides); slider_color->setMinimum(0); slider_color->setMaximum(17); slider_color->setSingleStep(1); slider_style->setTickPosition(QSlider::TicksBothSides); slider_style->setMinimum(0); slider_style->setMaximum(5); slider_style->setSingleStep(1); // Link actions and signals to slots connect(openAction, SIGNAL(triggered( )), this, SLOT(openFile())); connect(saveAction, SIGNAL(triggered( )), this, SLOT(saveFile())); connect(quitAction, SIGNAL(triggered( )), this, SLOT(quitApp())); connect(paintAction, SIGNAL(triggered( )), mydrawzone, SLOT(set_draw_mode_paint())); connect(editAction, SIGNAL(triggered( )), mydrawzone, SLOT(set_draw_mode_edit())); connect(moveAction, SIGNAL(triggered( )), mydrawzone, SLOT(set_draw_mode_move())); connect(set_pen_width_larger, SIGNAL(triggered( )), mydrawzone, SLOT(set_pen_width_larger())); connect(set_pen_width_shorter, SIGNAL(triggered( )), mydrawzone, SLOT(set_pen_width_shorter())); connect(undo, SIGNAL(triggered( )), mydrawzone, SLOT(undo())); connect(set_pen_color, SIGNAL(triggered( )), mydrawzone, SLOT(set_pen_color())); connect(action_group_color, SIGNAL(triggered(QAction *)), this, SLOT(doIt(QAction *))); connect(this, SIGNAL(color_pen_changed(int)), mydrawzone, SLOT(set_pen_color(int))); connect(set_pen_style, SIGNAL(triggered( )), mydrawzone, SLOT(set_pen_style())); connect(action_group_style, SIGNAL(triggered(QAction *)), this, SLOT(doIt2(QAction *))); connect(this, SIGNAL(style_pen_changed(int)), mydrawzone, SLOT(set_pen_style(int))); connect(set_figure_form, SIGNAL(triggered( )), mydrawzone, SLOT(set_figure_form())); connect(action_group_form, SIGNAL(triggered(QAction *)), this, SLOT(doIt3(QAction *))); connect(this, SIGNAL(form_painter_changed(int)), mydrawzone, SLOT(set_figure_form(int))); connect(slider_color, SIGNAL(valueChanged(int)), this, SLOT(slide_color_pen_changed(int))); connect(slider_style, SIGNAL(valueChanged(int)), this, SLOT(slide_style_pen_changed(int))); }
void WebView::contextMenuEvent(QContextMenuEvent *event) { // do not display the context menu if gesture was previously invoked if (m_gestureTime.isValid() && !m_gestureTime.isNull()) { int secs = m_gestureTime.secsTo(QDateTime::currentDateTime()); if (secs >= 0 && secs <=1) return; } QMenu menu(this); QWebHitTestResult r = page()->mainFrame()->hitTestContent(event->pos()); m_hitResult = r; if (!r.linkUrl().isEmpty()) { MenuCommands cmds; QAction* newwin = new QAction(pageAction(QWebPage::OpenLinkInNewWindow)->text(), this); connect(newwin, SIGNAL(triggered()), this, SLOT(openLinkInNewWin())); menu.addAction(newwin); QAction* newtab = new QAction(cmds.OpenNewTabTitle(), this); newtab->setShortcuts(cmds.OpenNewTabShortcuts()); connect(newtab, SIGNAL(triggered()), this, SLOT(openLinkInNewTab())); menu.addAction(newtab); menu.addSeparator(); menu.addAction(pageAction(QWebPage::DownloadLinkToDisk)); menu.addSeparator(); menu.addAction(pageAction(QWebPage::CopyLinkToClipboard)); { QAction* copyadr = new QAction(cmds.CopyAddrTitle(), this); connect(copyadr, SIGNAL(triggered()), this, SLOT(copyMailtoAddress())); menu.addAction( copyadr ); } if (page()->settings()->testAttribute(QWebSettings::DeveloperExtrasEnabled)) { QAction* inspect = new QAction(cmds.InspectTitle(), this); //inspect->setShortcuts(cmds.InspectShortcuts()); connect(inspect, SIGNAL(triggered()), this, SLOT(slotInspectElement())); menu.addAction(inspect); } } if (!r.imageUrl().isEmpty()) { if (!menu.isEmpty()) menu.addSeparator(); menu.addAction( pageAction(QWebPage::DownloadImageToDisk)); menu.addAction( pageAction(QWebPage::CopyImageToClipboard)); QAction* newwin = new QAction(pageAction(QWebPage::OpenImageInNewWindow)->text(), this); connect(newwin, SIGNAL(triggered()), this, SLOT(openImageInNewWin())); menu.addAction(newwin); MenuCommands cmds; QAction* newtab = new QAction(cmds.OpenNewTabTitle(), this); newtab->setShortcuts(cmds.OpenNewTabShortcuts()); connect(newtab, SIGNAL(triggered()), this, SLOT(openImageInNewTab())); menu.addAction( newtab ); menu.addSeparator(); QAction* adblock = new QAction(cmds.OpenAdBlockTitle(), this); adblock->setShortcuts(cmds.OpenAdBlockShortcuts()); connect(adblock, SIGNAL(triggered()), this, SLOT(adBlock())); adblock->setToolTip(r.imageUrl().toString()); menu.addAction( adblock ); } if (!menu.isEmpty()) { menu.exec(mapToGlobal(event->pos())); return; } QWebView::contextMenuEvent(event); }
Dialog_Mail::Dialog_Mail(QWidget *parent, QString iTitle, int *iIdx, DialogMailType iMode) : QDialog(parent) { Mode = iMode; Idx = iIdx; setWindowTitle(iTitle); QAction *ActSend = new QAction(tr("Отправить"),this); ActSend->setIcon(QPixmap(":img/SendMail.png")); ActSend->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_S)); ActSend->setText(tr("&Отправить Сообщения")); ActSend->setToolTip(tr("Отправить Сообщения")); ActSend->setStatusTip(tr("Отправить Сообщения")); connect(ActSend, SIGNAL(triggered()), this, SLOT(SlotSend())); QAction *ActSave = new QAction(tr("Сохранить"),this); ActSave->setIcon(QPixmap(":img/Save.png")); ActSave->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_R)); ActSave->setText(tr("&Сохранить Сообщение")); ActSave->setToolTip(tr("Сохранить Сообщение")); ActSave->setStatusTip(tr("Сохранить Сообщение")); connect(ActSave, SIGNAL(triggered()), this, SLOT(SlotSave())); QAction *ActCancel = new QAction(tr("Отменить"),this); ActCancel->setIcon(QPixmap(":img/Cancel.png")); ActCancel->setShortcut(QKeySequence("ESC")); ActCancel->setText(tr("&Отменить Сообщение")); ActCancel->setToolTip(tr("Отменить Сообщение")); ActCancel->setStatusTip(tr("Отменить Сообщение")); connect(ActCancel, SIGNAL(triggered()), this, SLOT(SlotCancel())); QHBoxLayout *ToolLayout = new QHBoxLayout(); ToolLayout->setMargin(0); QToolBar *ToolBar = new QToolBar(); ToolBar->setOrientation(Qt::Horizontal); ToolBar->setToolButtonStyle(Qt::ToolButtonIconOnly); ToolLayout->addWidget(ToolBar); ToolBar->addAction(ActSend); ToolBar->addSeparator(); ToolBar->addAction(ActSave); ToolBar->addSeparator(); ToolBar->addAction(ActCancel); QFrame *ToolFrame = new QFrame(); ToolFrame->setStyleSheet(QString("background-color: %1").arg(Global.Palette.color(QPalette::Window).name())); ToolFrame->setFrameStyle(QFrame::StyledPanel | QFrame::Plain); ToolFrame->setLayout(ToolLayout); QVBoxLayout *TBox = new QVBoxLayout(); TBox->setMargin(0); Receiver = new QComboBox(); Subj = new QLineEdit(); Message = new QTextEdit(); QFormLayout *Form = new QFormLayout(); Form->addRow(tr("Получатель: "), Receiver); Form->addRow(tr("Тема: "), Subj); Form->setLabelAlignment(Qt::AlignRight); TBox->addLayout(Form,0); TBox->addWidget(Message,1); QFrame *Center = new QFrame(); Center->setLayout(TBox); QVBoxLayout *Out = new QVBoxLayout(); Out->addWidget(ToolFrame,0); Out->addSpacing(4); Out->addWidget(Center,1); setLayout(Out); setMinimumSize(480,320); Init(); }