//----------------------------------------------------------------------------- void swftParaViewMenuBuilders::buildToolbars(QMainWindow& mainWindow) { QToolBar* mainToolBar = new swftMainControlsToolbar(&mainWindow) << pqSetName("MainControlsToolbar"); mainToolBar->layout()->setSpacing(0); mainWindow.addToolBar(Qt::TopToolBarArea, mainToolBar); QToolBar* colorToolbar = new pqColorToolbar(&mainWindow) << pqSetName("variableToolbar"); colorToolbar->layout()->setSpacing(0); mainWindow.addToolBar(Qt::TopToolBarArea, colorToolbar); mainWindow.insertToolBarBreak(colorToolbar); QToolBar* reprToolbar = new pqRepresentationToolbar(&mainWindow) << pqSetName("representationToolbar"); reprToolbar->layout()->setSpacing(0); mainWindow.addToolBar(Qt::TopToolBarArea, reprToolbar); QToolBar* vcrToolbar = new pqVCRToolbar(&mainWindow) << pqSetName("VCRToolbar"); vcrToolbar->layout()->setSpacing(0); mainWindow.addToolBar(Qt::TopToolBarArea, vcrToolbar); QToolBar* timeToolbar = new pqAnimationTimeToolbar(&mainWindow) << pqSetName("currentTimeToolbar"); timeToolbar->layout()->setSpacing(0); mainWindow.addToolBar(Qt::TopToolBarArea, timeToolbar); }
EditWidget::EditWidget(IMessageWidgets *AMessageWidgets, IMessageWindow *AWindow, QWidget *AParent) : QWidget(AParent) { ui.setupUi(this); ui.medEditor->setWordWrapMode(QTextOption::WrapAtWordBoundaryOrAnywhere); FWindow = AWindow; FMessageWidgets = AMessageWidgets; FBufferPos = -1; FSendEnabled = true; FEditEnabled = true; setRichTextEnabled(false); QToolBar *toolBar = new QToolBar; toolBar->setMovable(false); toolBar->setFloatable(false); toolBar->setIconSize(QSize(16,16)); toolBar->layout()->setMargin(0); toolBar->setStyleSheet("QToolBar { border: none; }"); toolBar->setSizePolicy(QSizePolicy::Preferred,QSizePolicy::Preferred); FEditToolBar = new ToolBarChanger(toolBar); FEditToolBar->setMinimizeWidth(true); FEditToolBar->setSeparatorsVisible(false); connect(FEditToolBar,SIGNAL(itemRemoved(QAction *)),SLOT(onUpdateEditToolBarVisibility())); connect(FEditToolBar,SIGNAL(itemInserted(QAction *, QAction *, Action *, QWidget *, int)),SLOT(onUpdateEditToolBarVisibility())); ui.wdtSendToolBar->setLayout(new QHBoxLayout); ui.wdtSendToolBar->layout()->setMargin(0); ui.wdtSendToolBar->layout()->addWidget(toolBar); FSendAction = new Action(toolBar); FSendAction->setToolTip(tr("Send")); FSendAction->setIcon(RSR_STORAGE_MENUICONS,MNI_MESSAGEWIDGETS_SEND); connect(FSendAction,SIGNAL(triggered(bool)),SLOT(onSendActionTriggered(bool))); FEditToolBar->insertAction(FSendAction,TBG_MWEWTB_SENDMESSAGE); ui.medEditor->installEventFilter(this); ui.medEditor->setContextMenuPolicy(Qt::CustomContextMenu); Shortcuts::insertWidgetShortcut(SCT_MESSAGEWINDOWS_EDITNEXTMESSAGE,ui.medEditor); Shortcuts::insertWidgetShortcut(SCT_MESSAGEWINDOWS_EDITPREVMESSAGE,ui.medEditor); connect(ui.medEditor,SIGNAL(createDataRequest(QMimeData *)),SLOT(onEditorCreateDataRequest(QMimeData *))); connect(ui.medEditor,SIGNAL(canInsertDataRequest(const QMimeData *, bool &)), SLOT(onEditorCanInsertDataRequest(const QMimeData *, bool &))); connect(ui.medEditor,SIGNAL(insertDataRequest(const QMimeData *, QTextDocument *)), SLOT(onEditorInsertDataRequest(const QMimeData *, QTextDocument *))); connect(ui.medEditor->document(),SIGNAL(contentsChange(int,int,int)),SLOT(onEditorContentsChanged(int,int,int))); connect(ui.medEditor,SIGNAL(customContextMenuRequested(const QPoint &)),SLOT(onEditorCustomContextMenuRequested(const QPoint &))); onOptionsChanged(Options::node(OPV_MESSAGES_EDITORAUTORESIZE)); onOptionsChanged(Options::node(OPV_MESSAGES_EDITORMINIMUMLINES)); connect(Options::instance(),SIGNAL(optionsChanged(const OptionsNode &)),SLOT(onOptionsChanged(const OptionsNode &))); connect(Shortcuts::instance(),SIGNAL(shortcutUpdated(const QString &)),SLOT(onShortcutUpdated(const QString &))); connect(Shortcuts::instance(),SIGNAL(shortcutActivated(const QString &, QWidget *)),SLOT(onShortcutActivated(const QString &, QWidget *))); onUpdateEditToolBarVisibility(); }
StringListEditor::StringListEditor(const QString& title, QWidget* parent) : QGroupBox(title, parent) { // create layout _hLayout = new QVBoxLayout( this ); _hLayout->setMargin(5); _hLayout->setSpacing(3); // create toolbar QToolBar* tb = new QToolBar; tb->layout()->setMargin(0); tb->layout()->setSpacing(0); tb->setIconSize(QSize(16, 16)); _hLayout->addWidget(tb); // create listwidget _list = new QListWidget; _list->setMinimumHeight(40); _list->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); _hLayout->addWidget(_list); // create actions QAction* addAction = new QAction( QIcon( ":/listeditor/add.png" ), tr("Add Item"), tb); QAction* removeAction = new QAction( QIcon( ":/listeditor/remove.png" ), tr("Remove Item"), tb); QAction* clearAction = new QAction( QIcon( ":/listeditor/clear.png" ), tr("Clear Items"), tb); QAction* upAction = new QAction( QIcon( ":/listeditor/up.png" ), tr("Move Item Up"), tb); QAction* downAction = new QAction( QIcon( ":/listeditor/down.png" ), tr("Move Item Down"), tb); QAction* editAction = new QAction( QIcon( ":/listeditor/edit.png" ), tr("Edit Item"), tb); // add actions to toolbar tb->addAction(addAction); tb->addAction(removeAction); tb->addAction(clearAction); tb->addAction(upAction); tb->addAction(downAction); tb->addAction(editAction); // connections connect(addAction, SIGNAL(triggered()), this, SLOT(onAddItem())); connect(removeAction, SIGNAL(triggered()), this, SLOT(onRemoveItem())); connect(clearAction, SIGNAL(triggered()), this, SLOT(onClearItem())); connect(upAction, SIGNAL(triggered()), this, SLOT(onMoveUpItem())); connect(downAction, SIGNAL(triggered()), this, SLOT(onMoveDownItem())); connect(editAction, SIGNAL(triggered()), this, SLOT(onEditItem())); connect(_list, SIGNAL(itemChanged(QListWidgetItem*)), this, SIGNAL(edited())); connect( this, SIGNAL(edited()), this, SLOT(onEdited())); }
//------------------------------------------------------------------------ // create all stuff for the toolbar //------------------------------------------------------------------------ void ApplicationWindow::createToolbar() { QPixmap openIcon(fileopen); QPixmap newIcon(filenew); QPixmap quitIcon(quit); QToolBar *fileTools = new QToolBar(tr("VRB Toolbar"), this); fileTools->layout()->setSpacing(2); fileTools->layout()->setMargin(0); addToolBar(fileTools); QAction *exitAction = fileTools->addAction(quitIcon, tr("Exit"), qApp, SLOT(closeAllWindows())); exitAction->setToolTip(tr("exit")); QAction *newAction = fileTools->addAction(newIcon, tr("New"), this, SLOT(newDoc())); newAction->setToolTip(tr("new")); QAction *openAction = fileTools->addAction(openIcon, tr("Open File"), this, SLOT(choose())); openAction->setToolTip(tr("open file")); }
void tst_QToolBar::task191727_layout() { QMainWindow mw; QToolBar *toolBar = mw.addToolBar("test"); toolBar->addAction("one"); QAction *action = toolBar->addAction("two"); QLineEdit *lineedit = new QLineEdit; lineedit->setMaximumWidth(50); toolBar->addWidget(lineedit); mw.resize(400, 400); mw.show(); QWidget *actionwidget = toolBar->widgetForAction(action); QVERIFY(qAbs(lineedit->pos().x() - (actionwidget->geometry().right() + 1 + toolBar->layout()->spacing())) < 2); }
void BitcoinGUI::createToolBars() { QToolBar *homeToolBar = new QToolBar(this); QToolBar *menuToolBar = new QToolBar(this); homeToolBar->setObjectName("homeToolBar"); menuToolBar->setObjectName("menuToolBar"); // homeToolBar->setFixedWidth(300); // homeToolBar->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); menuToolBar->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); homeToolBar->setMovable(false); menuToolBar->setMovable(false); homeToolBar->setFloatable(false); menuToolBar->setFloatable(false); homeToolBar->setContextMenuPolicy(Qt::PreventContextMenu); menuToolBar->setContextMenuPolicy(Qt::PreventContextMenu); homeToolBar->setToolButtonStyle(Qt::ToolButtonTextBesideIcon); menuToolBar->setToolButtonStyle(Qt::ToolButtonTextOnly); homeToolBar->addAction(bitstarAction); homeToolBar->setIconSize(QSize(24, 24)); menuToolBar->layout()->setSpacing(0); // Add a spacer, so all menuToolBar items are right aligned... QWidget* spacer = new QWidget(); spacer->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); menuToolBar->addWidget(spacer); QToolButton *overviewButton = new QToolButton; overviewButton->setDefaultAction(overviewAction); overviewButton->setObjectName("overviewMenu"); menuToolBar->addWidget(overviewButton); QToolButton *sendCoinsButton = new QToolButton; sendCoinsButton->setDefaultAction(sendCoinsAction); sendCoinsButton->setObjectName("sendcoinsMenu"); menuToolBar->addWidget(sendCoinsButton); QToolButton *receiveCoinsButton = new QToolButton; receiveCoinsButton->setDefaultAction(receiveCoinsAction); receiveCoinsButton->setObjectName("receivecoinsMenu"); menuToolBar->addWidget(receiveCoinsButton); QToolButton *historyButton = new QToolButton; historyButton->setDefaultAction(historyAction); historyButton->setObjectName("historyMenu"); menuToolBar->addWidget(historyButton); QToolButton *addressBookButton = new QToolButton; addressBookButton->setDefaultAction(addressBookAction); addressBookButton->setObjectName("addressBookMenu"); menuToolBar->addWidget(addressBookButton); lockToggleButton = new QToolButton; lockToggleButton->setDefaultAction(lockWalletToggleAction); lockToggleButton->setObjectName("lockToggleMenu"); lockToggleAction = menuToolBar->addWidget(lockToggleButton); addToolBar(homeToolBar); addToolBar(menuToolBar); }
SignalFileBrowserWindow::SignalFileBrowserWindow(QWidget* parent) : QMainWindow(parent) { setWindowTitle(title); signalViewer = new SignalViewer(this); setCentralWidget(signalViewer); // Construct dock widgets. setDockNestingEnabled(true); QDockWidget* trackManagerDockWidget = new QDockWidget("Track Manager", this); trackManagerDockWidget->setObjectName("Track Manager QDockWidget"); trackManager = new TrackManager(this); trackManagerDockWidget->setWidget(trackManager); QDockWidget* eventManagerDockWidget = new QDockWidget("Event Manager", this); eventManagerDockWidget->setObjectName("Event Manager QDockWidget"); eventManager = new EventManager(this); eventManager->setReferences(signalViewer->getCanvas()); eventManagerDockWidget->setWidget(eventManager); QDockWidget* eventTypeDockWidget = new QDockWidget("EventType Manager", this); eventTypeDockWidget->setObjectName("EventType Manager QDockWidget"); eventTypeManager = new EventTypeManager(this); eventTypeDockWidget->setWidget(eventTypeManager); QDockWidget* montageManagerDockWidget = new QDockWidget("Montage Manager", this); montageManagerDockWidget->setObjectName("Montage Manager QDockWidget"); montageManager = new MontageManager(this); montageManagerDockWidget->setWidget(montageManager); addDockWidget(Qt::RightDockWidgetArea, trackManagerDockWidget); tabifyDockWidget(trackManagerDockWidget, eventManagerDockWidget); tabifyDockWidget(eventManagerDockWidget, eventTypeDockWidget); tabifyDockWidget(eventTypeDockWidget, montageManagerDockWidget); // Construct File actions. QAction* openFileAction = new QAction("&Open File", this); openFileAction->setShortcut(QKeySequence::Open); openFileAction->setToolTip("Open an existing file."); openFileAction->setStatusTip(openFileAction->toolTip()); connect(openFileAction, SIGNAL(triggered()), this, SLOT(openFile())); QAction* closeFileAction = new QAction("Close File", this); closeFileAction->setShortcut(QKeySequence::Close); closeFileAction->setToolTip("Close the currently opened file."); closeFileAction->setStatusTip(closeFileAction->toolTip()); connect(closeFileAction, SIGNAL(triggered()), this, SLOT(closeFile())); QAction* saveFileAction = new QAction("Save File", this); saveFileAction->setShortcut(QKeySequence::Save); saveFileAction->setToolTip("Save the currently opened file."); saveFileAction->setStatusTip(saveFileAction->toolTip()); connect(saveFileAction, SIGNAL(triggered()), this, SLOT(saveFile())); // Construct Zoom actions. QAction* horizontalZoomInAction = new QAction("Horizontal Zoom In", this); horizontalZoomInAction->setShortcut(QKeySequence("Alt++")); horizontalZoomInAction->setToolTip("Zoom in time line."); horizontalZoomInAction->setStatusTip(horizontalZoomInAction->toolTip()); connect(horizontalZoomInAction, SIGNAL(triggered()), this, SLOT(horizontalZoomIn())); QAction* horizontalZoomOutAction = new QAction("Horizontal Zoom Out", this); horizontalZoomOutAction->setShortcut(QKeySequence("Alt+-")); horizontalZoomOutAction->setToolTip("Zoom out time line."); horizontalZoomOutAction->setStatusTip(horizontalZoomOutAction->toolTip()); connect(horizontalZoomOutAction, SIGNAL(triggered()), this, SLOT(horizontalZoomOut())); QAction* verticalZoomInAction = new QAction("Vertical Zoom In", this); verticalZoomInAction->setShortcut(QKeySequence("Shift++")); verticalZoomInAction->setToolTip("Zoom in amplitudes of signals."); verticalZoomInAction->setStatusTip(verticalZoomInAction->toolTip()); connect(verticalZoomInAction, SIGNAL(triggered()), this, SLOT(verticalZoomIn())); QAction* verticalZoomOutAction = new QAction("Vertical Zoom Out", this); verticalZoomOutAction->setShortcut(QKeySequence("Shift+-")); verticalZoomOutAction->setToolTip("Zoom out amplitudes of signals."); verticalZoomOutAction->setStatusTip(verticalZoomOutAction->toolTip()); connect(verticalZoomOutAction, SIGNAL(triggered()), this, SLOT(verticalZoomOut())); // Construct Time Mode action group. timeModeActionGroup = new QActionGroup(this); QAction* timeModeAction0 = new QAction("Sample", this); timeModeAction0->setToolTip("Samples from the start."); timeModeAction0->setStatusTip(timeModeAction0->toolTip()); connect(timeModeAction0, SIGNAL(triggered()), this, SLOT(timeMode0())); timeModeAction0->setActionGroup(timeModeActionGroup); timeModeAction0->setCheckable(true); QAction* timeModeAction1 = new QAction("Offset", this); timeModeAction1->setToolTip("Time offset from the start."); timeModeAction1->setStatusTip(timeModeAction1->toolTip()); connect(timeModeAction1, SIGNAL(triggered()), this, SLOT(timeMode1())); timeModeAction1->setActionGroup(timeModeActionGroup); timeModeAction1->setCheckable(true); QAction* timeModeAction2 = new QAction("Real", this); timeModeAction2->setToolTip("Real time."); timeModeAction2->setStatusTip(timeModeAction2->toolTip()); connect(timeModeAction2, SIGNAL(triggered()), this, SLOT(timeMode2())); timeModeAction2->setActionGroup(timeModeActionGroup); timeModeAction2->setCheckable(true); // Construct Time Line Interval action group. timeLineIntervalActionGroup = new QActionGroup(this); QAction* timeLineOffAction = new QAction("Off", this); timeLineOffAction->setToolTip("Turn off the time lines."); timeLineOffAction->setStatusTip(timeLineOffAction->toolTip()); connect(timeLineOffAction, &QAction::triggered, [this] () { if (file != nullptr) { file->getInfoTable()->setTimeLineInterval(0); } }); setTimeLineIntervalAction = new QAction("Set", this); setTimeLineIntervalAction->setActionGroup(timeLineIntervalActionGroup); connect(setTimeLineIntervalAction, &QAction::triggered, [this] () { if (file != nullptr) { double value = file->getInfoTable()->getTimeLineInterval(); if (value == 0) { value = 1; } bool ok; value = QInputDialog::getDouble(this, "Set the interval", "Please, enter the value for the time line interval here:", value, 0, 1000*1000*1000, 2, &ok); if (ok) { file->getInfoTable()->setTimeLineInterval(value); } } }); // Tool bars. const int spacing = 3; // Construct File tool bar. QToolBar* fileToolBar = addToolBar("File Tool Bar"); fileToolBar->setObjectName("File QToolBar"); fileToolBar->layout()->setSpacing(spacing); fileToolBar->addAction(openFileAction); fileToolBar->addAction(closeFileAction); fileToolBar->addAction(saveFileAction); // Construct Filter tool bar. QToolBar* filterToolBar = addToolBar("Filter Tool Bar"); filterToolBar->setObjectName("Filter QToolBar"); filterToolBar->layout()->setSpacing(spacing); QLabel* label = new QLabel("LF:", this); label->setToolTip("Low-pass Filter frequency"); filterToolBar->addWidget(label); lowpassComboBox = new QComboBox(this); lowpassComboBox->setSizeAdjustPolicy(QComboBox::AdjustToContents); lowpassComboBox->setMaximumWidth(150); lowpassComboBox->setEditable(true); filterToolBar->addWidget(lowpassComboBox); label = new QLabel("HF:", this); label->setToolTip("High-pass Filter frequency"); filterToolBar->addWidget(label); highpassComboBox = new QComboBox(this); highpassComboBox->setSizeAdjustPolicy(QComboBox::AdjustToContents); highpassComboBox->setMaximumWidth(150); highpassComboBox->setEditable(true); filterToolBar->addWidget(highpassComboBox); notchCheckBox = new QCheckBox("Notch:", this); notchCheckBox->setToolTip("Notch Filter on/off"); notchCheckBox->setLayoutDirection(Qt::RightToLeft); filterToolBar->addWidget(notchCheckBox); // Construct Select tool bar. QToolBar* selectToolBar = addToolBar("Select Tool bar"); selectToolBar->setObjectName("Select QToolBar"); selectToolBar->layout()->setSpacing(spacing); selectToolBar->addWidget(new QLabel("Montage:", this)); montageComboBox = new QComboBox(this); montageComboBox->setSizeAdjustPolicy(QComboBox::AdjustToContents); montageComboBox->setMaximumWidth(200); selectToolBar->addWidget(montageComboBox); selectToolBar->addWidget(new QLabel("Event Type:", this)); eventTypeComboBox = new QComboBox(this); eventTypeComboBox->setSizeAdjustPolicy(QComboBox::AdjustToContents); eventTypeComboBox->setMaximumWidth(200); selectToolBar->addWidget(eventTypeComboBox); // Construct Zoom tool bar. QToolBar* zoomToolBar = addToolBar("Zoom Tool Bar"); zoomToolBar->setObjectName("Zoom QToolBar"); zoomToolBar->layout()->setSpacing(spacing); zoomToolBar->addAction(horizontalZoomInAction); zoomToolBar->addAction(horizontalZoomOutAction); zoomToolBar->addAction(verticalZoomInAction); zoomToolBar->addAction(verticalZoomOutAction); // Construct File menu. QMenu* fileMenu = menuBar()->addMenu("&File"); fileMenu->addAction(openFileAction); fileMenu->addAction(closeFileAction); fileMenu->addAction(saveFileAction); // Construct View menu. QMenu* viewMenu = menuBar()->addMenu("&View"); viewMenu->addAction(horizontalZoomInAction); viewMenu->addAction(horizontalZoomOutAction); viewMenu->addAction(verticalZoomInAction); viewMenu->addAction(verticalZoomOutAction); QMenu* timeModeMenu = new QMenu("Time Mode", this); timeModeMenu->addAction(timeModeAction0); timeModeMenu->addAction(timeModeAction1); timeModeMenu->addAction(timeModeAction2); viewMenu->addMenu(timeModeMenu); QMenu* timeLineIntervalMenu = new QMenu("Time Line Interval", this); timeLineIntervalMenu->addAction(timeLineOffAction); timeLineIntervalMenu->addAction(setTimeLineIntervalAction); viewMenu->addMenu(timeLineIntervalMenu); // Construct Window menu. QMenu* windowMenu = menuBar()->addMenu("&Window"); windowMenu->addAction(trackManagerDockWidget->toggleViewAction()); windowMenu->addAction(eventManagerDockWidget->toggleViewAction()); windowMenu->addAction(eventTypeDockWidget->toggleViewAction()); windowMenu->addAction(montageManagerDockWidget->toggleViewAction()); windowMenu->addSeparator(); windowMenu->addAction(fileToolBar->toggleViewAction()); windowMenu->addAction(filterToolBar->toggleViewAction()); windowMenu->addAction(selectToolBar->toggleViewAction()); windowMenu->addAction(zoomToolBar->toggleViewAction()); // Construct status bar. timeModeStatusLabel = new QLabel(this); timeModeStatusLabel->setContextMenuPolicy(Qt::ActionsContextMenu); timeModeStatusLabel->addAction(timeModeAction0); timeModeStatusLabel->addAction(timeModeAction1); timeModeStatusLabel->addAction(timeModeAction2); statusBar()->addPermanentWidget(timeModeStatusLabel); timeStatusLabel = new QLabel(this); timeStatusLabel->setContextMenuPolicy(Qt::ActionsContextMenu); timeStatusLabel->addAction(timeModeAction0); timeStatusLabel->addAction(timeModeAction1); timeStatusLabel->addAction(timeModeAction2); statusBar()->addPermanentWidget(timeStatusLabel); positionStatusLabel = new QLabel(this); positionStatusLabel->setContextMenuPolicy(Qt::ActionsContextMenu); positionStatusLabel->addAction(timeModeAction0); positionStatusLabel->addAction(timeModeAction1); positionStatusLabel->addAction(timeModeAction2); statusBar()->addPermanentWidget(positionStatusLabel); cursorStatusLabel = new QLabel(this); cursorStatusLabel->setContextMenuPolicy(Qt::ActionsContextMenu); cursorStatusLabel->addAction(timeModeAction0); cursorStatusLabel->addAction(timeModeAction1); cursorStatusLabel->addAction(timeModeAction2); statusBar()->addPermanentWidget(cursorStatusLabel); // Restore settings. restoreGeometry(PROGRAM_OPTIONS.settings("SignalFileBrowserWindow geometry").toByteArray()); restoreState(PROGRAM_OPTIONS.settings("SignalFileBrowserWindow state").toByteArray()); }