TextEdit::TextEdit(QWidget *parent) : QMainWindow(parent) { setToolButtonStyle(Qt::ToolButtonFollowStyle); setupFileActions(); setupEditActions(); setupTextActions(); { QMenu *helpMenu = new QMenu(tr("Help"), this); menuBar()->addMenu(helpMenu); helpMenu->addAction(tr("About"), this, SLOT(about())); helpMenu->addAction(tr("About &Qt"), qApp, SLOT(aboutQt())); } textEdit = new QTextEdit(this); connect(textEdit, SIGNAL(currentCharFormatChanged(QTextCharFormat)), this, SLOT(currentCharFormatChanged(QTextCharFormat))); connect(textEdit, SIGNAL(cursorPositionChanged()), this, SLOT(cursorPositionChanged())); setCentralWidget(textEdit); textEdit->setFocus(); setCurrentFileName(QString()); fontChanged(textEdit->font()); colorChanged(textEdit->textColor()); alignmentChanged(textEdit->alignment()); connect(textEdit->document(), SIGNAL(modificationChanged(bool)), actionSave, SLOT(setEnabled(bool))); connect(textEdit->document(), SIGNAL(modificationChanged(bool)), this, SLOT(setWindowModified(bool))); connect(textEdit->document(), SIGNAL(undoAvailable(bool)), actionUndo, SLOT(setEnabled(bool))); connect(textEdit->document(), SIGNAL(redoAvailable(bool)), actionRedo, SLOT(setEnabled(bool))); setWindowModified(textEdit->document()->isModified()); actionSave->setEnabled(textEdit->document()->isModified()); actionUndo->setEnabled(textEdit->document()->isUndoAvailable()); actionRedo->setEnabled(textEdit->document()->isRedoAvailable()); connect(actionUndo, SIGNAL(triggered()), textEdit, SLOT(undo())); connect(actionRedo, SIGNAL(triggered()), textEdit, SLOT(redo())); actionCut->setEnabled(false); actionCopy->setEnabled(false); connect(actionCut, SIGNAL(triggered()), textEdit, SLOT(cut())); connect(actionCopy, SIGNAL(triggered()), textEdit, SLOT(copy())); connect(actionPaste, SIGNAL(triggered()), textEdit, SLOT(paste())); connect(textEdit, SIGNAL(copyAvailable(bool)), actionCut, SLOT(setEnabled(bool))); connect(textEdit, SIGNAL(copyAvailable(bool)), actionCopy, SLOT(setEnabled(bool))); #ifndef QT_NO_CLIPBOARD connect(QApplication::clipboard(), SIGNAL(dataChanged()), this, SLOT(clipboardDataChanged())); #endif QString initialFile = ":/example.html"; const QStringList args = QCoreApplication::arguments(); if (args.count() == 2) initialFile = args.at(1); if (!load(initialFile)) fileNew(); }
void Plugin::handleShowList () { auto rootWM = Proxy_->GetRootWindowsManager (); ICoreTabWidget *tw = rootWM->GetTabWidget (rootWM->GetPreferredWindowIndex ()); if (tw->WidgetCount () < 2) return; QWidget *widget = new QWidget (nullptr, Qt::Popup | Qt::FramelessWindowHint); widget->setAttribute (Qt::WA_TranslucentBackground); widget->setWindowModality (Qt::ApplicationModal); QVBoxLayout *layout = new QVBoxLayout (); layout->setSpacing (1); layout->setContentsMargins (1, 1, 1, 1); const int currentIdx = tw->CurrentIndex (); QToolButton *toFocus = 0; QList<QToolButton*> allButtons; for (int i = 0, count = tw->WidgetCount (); i < count; ++i) { const QString& origText = tw->TabText (i); QString title = QString ("[%1] ").arg (i + 1) + origText; if (title.size () > 100) title = title.left (100) + "..."; QAction *action = new QAction (tw->TabIcon (i), title, this); action->setToolTip (origText); action->setProperty ("TabIndex", i); action->setProperty ("ICTW", QVariant::fromValue<ICoreTabWidget*> (tw)); connect (action, SIGNAL (triggered ()), this, SLOT (navigateToTab ())); connect (action, SIGNAL (triggered ()), widget, SLOT (deleteLater ())); auto button = new QToolButton (); button->setDefaultAction (action); button->setToolButtonStyle (Qt::ToolButtonTextBesideIcon); button->setSizePolicy (QSizePolicy::Expanding, button->sizePolicy ().verticalPolicy ()); button->setProperty ("OrigText", origText); layout->addWidget (button); if (currentIdx == i) toFocus = button; allButtons << button; } widget->installEventFilter (new ListEventFilter (allButtons, this, widget)); widget->setLayout (layout); layout->update (); layout->activate (); const QRect& rect = QApplication::desktop ()-> screenGeometry (rootWM->GetPreferredWindow ()); QPoint pos = rect.center (); const QSize& size = widget->sizeHint () / 2; pos -= QPoint (size.width (), size.height ()); widget->move (pos); widget->show (); if (toFocus) toFocus->setFocus (); }
//This is the button that will be inside the file uploader and image uploader GridButton::GridButton(QWidget *parent) : QToolButton(parent) { index = 0; setToolButtonStyle(Qt::ToolButtonTextUnderIcon); }
void ComponentDock::setupTree() { auto mainFrame = new QFrame(this); auto vlayout = new QVBoxLayout(mainFrame); vlayout->setMargin(0); vlayout->setSpacing(0); // tree comTree = new QTreeWidget(this); comTree->setMinimumWidth(230); comTree->setHeaderLabel("Components Editor"); comTree->setHeaderHidden(true); comTree->setSelectionMode(QAbstractItemView::SingleSelection); comTree->setExpandsOnDoubleClick(false); comTree->setRootIsDecorated(false); comTree->setIndentation(0); comTree->setAnimated(true); comTree->setFocusPolicy(Qt::FocusPolicy::NoFocus); comTree->setVerticalScrollMode(QAbstractItemView::ScrollMode::ScrollPerPixel); comTree->setStyleSheet("QTreeView {background-color: rgb(88,88,88);" "padding-right: 3px;" "padding-left: 3px;" "selection-background-color: transparent;}"); connect(comTree, &QTreeWidget::expanded, this, &ComponentDock::onExpand); connect(comTree, &QTreeWidget::collapsed, this, &ComponentDock::onCollpase); vlayout->addWidget(comTree); // prefab frame prefabFrame = new QFrame(this); auto hLayout = new QHBoxLayout(prefabFrame); hLayout->setMargin(0); hLayout->setSpacing(0); auto btnApply = new QToolButton(prefabFrame); preApply->setData(qVariantFromValue((void *)btnApply)); btnApply->setSizePolicy(QSizePolicy::Policy::Preferred, QSizePolicy::Policy::Fixed); btnApply->setDefaultAction(preApply); btnApply->setToolButtonStyle(Qt::ToolButtonTextOnly); hLayout->addWidget(btnApply); auto btnSelect = new QToolButton(prefabFrame); preSelect->setData(qVariantFromValue((void *)btnSelect)); btnSelect->setSizePolicy(QSizePolicy::Policy::Preferred, QSizePolicy::Policy::Fixed); btnSelect->setDefaultAction(preSelect); btnSelect->setToolButtonStyle(Qt::ToolButtonTextOnly); hLayout->addWidget(btnSelect); auto btnRevert = new QToolButton(prefabFrame); preRevert->setData(qVariantFromValue((void *)btnRevert)); btnRevert->setSizePolicy(QSizePolicy::Policy::Preferred, QSizePolicy::Policy::Fixed); btnRevert->setDefaultAction(preRevert); btnRevert->setToolButtonStyle(Qt::ToolButtonTextOnly); hLayout->addWidget(btnRevert); vlayout->addWidget(prefabFrame); prefabFrame->hide(); connect(mtypes, &QMenu::triggered, this, &ComponentDock::actAdd); this->setWidget(mainFrame); }
TimeToolBar::TimeToolBar(CelestiaCore* _appCore, const QString& title, QWidget* parent) : QToolBar(title, parent), appCore(_appCore) { #if 0 // Text-only buttons setToolButtonStyle(Qt::ToolButtonTextOnly); QAction* reverseTimeAction = new QAction(QString("< >"), this); reverseTimeAction->setToolTip(_("Reverse time")); QAction* slowTimeAction = new QAction(QString("<<|"), this); slowTimeAction->setToolTip(_("10x slower")); QAction* halfTimeAction = new QAction(QString("<|"), this); halfTimeAction->setToolTip(_("2x slower")); QAction* pauseAction = new QAction(QString("||"), this); pauseAction->setToolTip(_("Pause time")); QAction* realTimeAction = new QAction(QString(">"), this); realTimeAction->setToolTip(_("Real time")); QAction* doubleTimeAction = new QAction(QString(">>"), this); doubleTimeAction->setToolTip(_("2x faster")); QAction* fastTimeAction = new QAction(QString(">>>"), this); fastTimeAction->setToolTip(_("10x faster")); #else QAction* reverseTimeAction = new QAction(QIcon(":/icons/time-reverse.png"), _("Reverse time"), this); QAction* slowTimeAction = new QAction(QIcon(":/icons/time-slower.png"), _("10x slower"), this); QAction* halfTimeAction = new QAction(QIcon(":/icons/time-half.png"), _("2x slower"), this); QAction* pauseAction = new QAction(QIcon(":/icons/time-pause.png"), _("Pause time"), this); QAction* realTimeAction = new QAction(QIcon(":/icons/time-realtime.png"), _("Real time"), this); QAction* doubleTimeAction = new QAction(QIcon(":/icons/time-double.png"), _("2x faster"), this); QAction* fastTimeAction = new QAction(QIcon(":/icons/time-faster.png"), _("10x faster"), this); QAction* currentTimeAction = new QAction(QIcon(":icons/time-currenttime.png"), _("Set to current time"), this); #endif connect(reverseTimeAction, SIGNAL(triggered()), this, SLOT(slotReverseTime())); addAction(reverseTimeAction); connect(slowTimeAction, SIGNAL(triggered()), this, SLOT(slotSlower())); addAction(slowTimeAction); connect(halfTimeAction, SIGNAL(triggered()), this, SLOT(slotHalfTime())); addAction(halfTimeAction); connect(pauseAction, SIGNAL(triggered()), this, SLOT(slotPauseTime())); addAction(pauseAction); connect(realTimeAction, SIGNAL(triggered()), this, SLOT(slotRealTime())); addAction(realTimeAction); connect(doubleTimeAction, SIGNAL(triggered()), this, SLOT(slotDoubleTime())); addAction(doubleTimeAction); connect(fastTimeAction, SIGNAL(triggered()), this, SLOT(slotFaster())); addAction(fastTimeAction); connect(currentTimeAction, SIGNAL(triggered()), this, SLOT(slotCurrentTime())); addAction(currentTimeAction); }
void MainToolBar::onOrientationChanged(Qt::Orientation orientation) { setToolButtonStyle(orientation == Qt::Horizontal ? Qt::ToolButtonFollowStyle : Qt::ToolButtonIconOnly); }
StartupView::StartupView( QWidget * parent ) : QWidget( parent ) { m_templateListModel = std::shared_ptr<TemplateListModel>( new TemplateListModel() ); setStyleSheet("openstudio--StartupView { background: #E6E6E6; }"); #ifdef Q_OS_MAC setWindowFlags(Qt::FramelessWindowHint); #else setWindowFlags(Qt::CustomizeWindowHint); #endif auto recentProjectsView = new QWidget(); recentProjectsView->setStyleSheet("QWidget { background: #F2F2F2; }"); auto recentProjectsLayout = new QVBoxLayout(); recentProjectsLayout->setContentsMargins(10,10,10,10); QLabel * recentProjectsLabel = new QLabel("Recent Projects"); recentProjectsLabel->setStyleSheet("QLabel { font: bold }"); recentProjectsLayout->addWidget(recentProjectsLabel,0,Qt::AlignTop); recentProjectsView->setLayout(recentProjectsLayout); auto openButton = new QToolButton(); openButton->setText("Open File"); openButton->setStyleSheet("QToolButton { font: bold; }"); openButton->setToolButtonStyle(Qt::ToolButtonTextBesideIcon); QIcon openIcon(":/images/open_file.png"); openButton->setIcon(openIcon); openButton->setIconSize(QSize(40,40)); connect(openButton, &QToolButton::clicked, this, &StartupView::openClicked); auto importButton = new QToolButton(); importButton->setText("Import Idf"); importButton->setStyleSheet("QToolButton { font: bold; }"); importButton->setToolButtonStyle(Qt::ToolButtonTextBesideIcon); QIcon importIcon(":/images/import_file.png"); importButton->setIcon(importIcon); importButton->setIconSize(QSize(40,40)); connect(importButton, &QToolButton::clicked, this, &StartupView::importClicked); /* QToolButton * importSDDButton = new QToolButton(); importSDDButton->setText("Import SDD"); importSDDButton->setStyleSheet("QToolButton { font: bold; }"); importSDDButton->setToolButtonStyle(Qt::ToolButtonTextBesideIcon); QIcon importSDDIcon(":/images/import_file.png"); importSDDButton->setIcon(importSDDIcon); importSDDButton->setIconSize(QSize(40,40)); connect(importSDDButton, &QToolButton::clicked, this, &StartupView::importSDDClicked); */ auto projectChooserView = new QWidget(); projectChooserView->setFixedWidth(238); projectChooserView->setStyleSheet("QWidget { background: #F2F2F2; }"); auto projectChooserLayout = new QVBoxLayout(); projectChooserLayout->setContentsMargins(10,10,10,10); QLabel * projectChooserLabel = new QLabel("Create New From Template"); projectChooserLabel->setStyleSheet("QLabel { font: bold }"); projectChooserLayout->addWidget(projectChooserLabel,0,Qt::AlignTop); m_listView = new QListView(); m_listView->setViewMode(QListView::IconMode); m_listView->setModel(m_templateListModel.get()); m_listView->setFocusPolicy(Qt::NoFocus); m_listView->setFlow(QListView::LeftToRight); m_listView->setUniformItemSizes(true); m_listView->setSelectionMode(QAbstractItemView::SingleSelection); projectChooserLayout->addWidget(m_listView); projectChooserView->setLayout(projectChooserLayout); m_projectDetailView = new QWidget(); m_projectDetailView->setStyleSheet("QWidget { background: #F2F2F2; }"); auto projectDetailLayout = new QVBoxLayout(); projectDetailLayout->setContentsMargins(10,10,10,10); m_projectDetailView->setLayout(projectDetailLayout); auto footerView = new QWidget(); footerView->setObjectName("FooterView"); footerView->setStyleSheet("QWidget#FooterView { background: #E6E6E6; }"); footerView->setMaximumHeight(50); footerView->setMinimumHeight(50); auto cancelButton = new QPushButton(); cancelButton->setObjectName("StandardGrayButton"); cancelButton->setMinimumSize(QSize(99,28)); #ifdef OPENSTUDIO_PLUGIN cancelButton->setText("Cancel"); connect(cancelButton, &QPushButton::clicked, this, &StartupView::hide); #else #ifdef Q_OS_MAC cancelButton->setText("Quit"); #else cancelButton->setText("Exit"); #endif connect(cancelButton, &QPushButton::clicked, OpenStudioApp::instance(), &OpenStudioApp::quit); #endif cancelButton->setStyleSheet("QPushButton { font: bold; }"); auto chooseButton = new QPushButton(); chooseButton->setObjectName("StandardBlueButton"); chooseButton->setText("Choose"); chooseButton->setMinimumSize(QSize(99,28)); connect(chooseButton, &QPushButton::clicked, this, &StartupView::newFromTemplateSlot); chooseButton->setStyleSheet("QPushButton { font: bold; }"); auto hFooterLayout = new QHBoxLayout(); hFooterLayout->setSpacing(25); hFooterLayout->setContentsMargins(0,0,0,0); hFooterLayout->addStretch(); hFooterLayout->addWidget(cancelButton); hFooterLayout->addWidget(chooseButton); footerView->setLayout(hFooterLayout); auto hLayout = new QHBoxLayout(); auto vLayout = new QVBoxLayout(); auto vOpenLayout = new QVBoxLayout(); vOpenLayout->addWidget(recentProjectsView); vOpenLayout->addWidget(openButton); vOpenLayout->addWidget(importButton); //vOpenLayout->addWidget(importSDDButton); hLayout->addLayout(vOpenLayout); hLayout->addWidget(projectChooserView); hLayout->addWidget(m_projectDetailView,1); vLayout->addSpacing(50); vLayout->addLayout(hLayout); vLayout->addWidget(footerView); setLayout(vLayout); connect(m_listView, &QListView::clicked, this, &StartupView::showDetailsForItem); m_listView->setCurrentIndex(m_templateListModel->index(0,0)); showDetailsForItem(m_templateListModel->index(0,0)); }
KoColorPopupButton::KoColorPopupButton(QWidget *parent) : QToolButton(parent) { setToolButtonStyle(Qt::ToolButtonIconOnly); }
int QToolBar::qt_metacall(QMetaObject::Call _c, int _id, void **_a) { _id = QWidget::qt_metacall(_c, _id, _a); if (_id < 0) return _id; if (_c == QMetaObject::InvokeMetaMethod) { switch (_id) { case 0: actionTriggered((*reinterpret_cast< QAction*(*)>(_a[1]))); break; case 1: movableChanged((*reinterpret_cast< bool(*)>(_a[1]))); break; case 2: allowedAreasChanged((*reinterpret_cast< Qt::ToolBarAreas(*)>(_a[1]))); break; case 3: orientationChanged((*reinterpret_cast< Qt::Orientation(*)>(_a[1]))); break; case 4: iconSizeChanged((*reinterpret_cast< const QSize(*)>(_a[1]))); break; case 5: toolButtonStyleChanged((*reinterpret_cast< Qt::ToolButtonStyle(*)>(_a[1]))); break; case 6: topLevelChanged((*reinterpret_cast< bool(*)>(_a[1]))); break; case 7: setIconSize((*reinterpret_cast< const QSize(*)>(_a[1]))); break; case 8: setToolButtonStyle((*reinterpret_cast< Qt::ToolButtonStyle(*)>(_a[1]))); break; case 9: d_func()->_q_toggleView((*reinterpret_cast< bool(*)>(_a[1]))); break; case 10: d_func()->_q_updateIconSize((*reinterpret_cast< const QSize(*)>(_a[1]))); break; case 11: d_func()->_q_updateToolButtonStyle((*reinterpret_cast< Qt::ToolButtonStyle(*)>(_a[1]))); break; default: ; } _id -= 12; } #ifndef QT_NO_PROPERTIES else if (_c == QMetaObject::ReadProperty) { void *_v = _a[0]; switch (_id) { case 0: *reinterpret_cast< bool*>(_v) = isMovable(); break; case 1: *reinterpret_cast< Qt::ToolBarAreas*>(_v) = allowedAreas(); break; case 2: *reinterpret_cast< Qt::Orientation*>(_v) = orientation(); break; case 3: *reinterpret_cast< QSize*>(_v) = iconSize(); break; case 4: *reinterpret_cast< Qt::ToolButtonStyle*>(_v) = toolButtonStyle(); break; case 5: *reinterpret_cast< bool*>(_v) = isFloating(); break; case 6: *reinterpret_cast< bool*>(_v) = isFloatable(); break; } _id -= 7; } else if (_c == QMetaObject::WriteProperty) { void *_v = _a[0]; switch (_id) { case 0: setMovable(*reinterpret_cast< bool*>(_v)); break; case 1: setAllowedAreas(*reinterpret_cast< Qt::ToolBarAreas*>(_v)); break; case 2: setOrientation(*reinterpret_cast< Qt::Orientation*>(_v)); break; case 3: setIconSize(*reinterpret_cast< QSize*>(_v)); break; case 4: setToolButtonStyle(*reinterpret_cast< Qt::ToolButtonStyle*>(_v)); break; case 6: setFloatable(*reinterpret_cast< bool*>(_v)); break; } _id -= 7; } else if (_c == QMetaObject::ResetProperty) { _id -= 7; } else if (_c == QMetaObject::QueryPropertyDesignable) { bool *_b = reinterpret_cast<bool*>(_a[0]); switch (_id) { case 0: *_b = (qobject_cast<QMainWindow*>(parentWidget())!=0); break; case 1: *_b = (qobject_cast<QMainWindow*>(parentWidget())!=0); break; case 2: *_b = (qobject_cast<QMainWindow*>(parentWidget())==0); break; } _id -= 7; } else if (_c == QMetaObject::QueryPropertyScriptable) { _id -= 7; } else if (_c == QMetaObject::QueryPropertyStored) { _id -= 7; } else if (_c == QMetaObject::QueryPropertyEditable) { _id -= 7; } else if (_c == QMetaObject::QueryPropertyUser) { _id -= 7; } #endif // QT_NO_PROPERTIES return _id; }
BigButton::BigButton(QWidget *parent) : QToolButton(parent) { setIconSize(QSize(50,50)); setToolButtonStyle(Qt::ToolButtonTextUnderIcon); setMinimumWidth(70); }
void ToolBar::LoadSettings() { setToolButtonStyle( Qt::ToolButtonStyle( AlexandraSettings::GetInstance()->GetMainWindowToolbarStyle() ) ); }
BrailleMusicEditor::BrailleMusicEditor(QWidget *parent) : QMainWindow(parent), ok(this), fail(this), lilypond(this) { #ifdef Q_OS_OSX setUnifiedTitleAndToolBarOnMac(true); #endif setToolButtonStyle(Qt::ToolButtonFollowStyle); setupFileActions(); setupEditActions(); setupOptionsActions(); setupSoundEffects(); { auto helpMenu = new QMenu(tr("Help"), this); menuBar()->addMenu(helpMenu); helpMenu->addAction(tr("About"), this, SLOT(about())); helpMenu->addAction(tr("About &Qt"), qApp, SLOT(aboutQt())); helpMenu->addAction(tr("&Report a problem..."), this, SLOT(reportBug())); } textEdit = new QTextEdit(this); textEdit->setWordWrapMode(QTextOption::NoWrap); connect(textEdit, &QTextEdit::cursorPositionChanged, this, &BrailleMusicEditor::cursorPositionChanged); connect(textEdit, &QTextEdit::textChanged, this, &BrailleMusicEditor::textChanged); svgScrollArea = new QScrollArea(this); svgScrollArea->setFocusPolicy(Qt::NoFocus); auto splitter = new QSplitter(Qt::Vertical); splitter->addWidget(textEdit); splitter->addWidget(svgScrollArea); QSettings settings; if (settings.value("ui/persist_layout",1).toInt() && settings.contains("ui/layout_data")) { splitter->restoreState(settings.value("ui/layout_data").toByteArray()); } else { splitter->setStretchFactor(0, 1); splitter->setStretchFactor(1, 1); } setCentralWidget(splitter); textEdit->setFocus(); setCurrentFileName(QString()); QFont textFont("Helvetica"); textFont.setStyleHint(QFont::SansSerif); textEdit->setFont(textFont); fontChanged(textEdit->font()); colorChanged(textEdit->textColor()); connect(textEdit->document(), &QTextDocument::modificationChanged, actionSave, &QAction::setEnabled); connect(textEdit->document(), &QTextDocument::modificationChanged, this, &BrailleMusicEditor::setWindowModified); connect(textEdit->document(), &QTextDocument::undoAvailable, actionUndo, &QAction::setEnabled); connect(textEdit->document(), &QTextDocument::redoAvailable, actionRedo, &QAction::setEnabled); setWindowModified(textEdit->document()->isModified()); actionSave->setEnabled(textEdit->document()->isModified()); actionUndo->setEnabled(textEdit->document()->isUndoAvailable()); actionRedo->setEnabled(textEdit->document()->isRedoAvailable()); connect(actionUndo, &QAction::triggered, textEdit, &QTextEdit::undo); connect(actionRedo, &QAction::triggered, textEdit, &QTextEdit::redo); actionCut->setEnabled(false); actionCopy->setEnabled(false); connect(actionCut, &QAction::triggered, textEdit, &QTextEdit::cut); connect(actionCopy, &QAction::triggered, textEdit, &QTextEdit::copy); connect(actionPaste, &QAction::triggered, textEdit, &QTextEdit::paste); connect(textEdit, &QTextEdit::copyAvailable, actionCut, &QAction::setEnabled); connect(textEdit, &QTextEdit::copyAvailable, actionCopy, &QAction::setEnabled); #ifndef QT_NO_CLIPBOARD connect(QApplication::clipboard(), SIGNAL(dataChanged()), this, SLOT(clipboardDataChanged())); #endif connect(&lilypond, &QProcess::started, this, &BrailleMusicEditor::lilyPondStarted); connect(&lilypond, static_cast<void (QProcess::*)(int, QProcess::ExitStatus)> (&QProcess::finished), this, &BrailleMusicEditor::lilyPondFinished); connect(&lilypond, static_cast<void (QProcess::*)(QProcess::ProcessError)> (&QProcess::error), this, &BrailleMusicEditor::lilyPondError); QString initialFile = ":/examples/bwv988-v01.bmc"; const QStringList args = QCoreApplication::arguments(); if (args.count() == 2) initialFile = args.at(1); if (!load(initialFile)) fileNew(); }
void SketchToolButton::setupIcons(const QString &imageName, bool hasStates) { setIconSize(QSize(37,24)); setToolButtonStyle(Qt::ToolButtonTextUnderIcon); AbstractStatesButton::setupIcons(imageName, hasStates); }
void ComponentDock::setupHTools() { htools = new QFrame(this); auto vlayout = new QVBoxLayout(htools); vlayout->setMargin(2); vlayout->setSpacing(0); auto hlayoutTitle = new QHBoxLayout(); hlabel = new QLabel(htools); hlabel->setText("Components Editor "); hlabel->setStyleSheet("color: lightGray;"); hlayoutTitle->addWidget(hlabel); auto sepBrush = QBrush(Qt::gray, Qt::BrushStyle::Dense6Pattern); QPalette sepPalette; sepPalette.setBrush(QPalette::Background, sepBrush); auto seprator = new QLabel(htools); seprator->setAutoFillBackground(true); seprator->setPalette(sepPalette); seprator->setMaximumHeight(10); hlayoutTitle->addWidget(seprator, 1, Qt::AlignBottom); auto btnClose = new QToolButton(htools); btnClose->setText("X"); btnClose->setStyleSheet("color: lightGray\n"); btnClose->setAutoRaise(true); btnClose->setMaximumWidth(16); btnClose->setMaximumHeight(16); hlayoutTitle->addWidget(btnClose); connect(btnClose, &QToolButton::clicked, this, &QDockWidget::hide); vlayout->addLayout(hlayoutTitle); auto hlayout = new QHBoxLayout(htools); hlayout->setMargin(0); auto btnAddComps = new QToolButton(htools); btnAddComps->setMenu(mtypes); btnAddComps->setDefaultAction(addDefComp); btnAddComps->setIcon(QIcon(":/icons/add")); btnAddComps->setPopupMode(QToolButton::MenuButtonPopup); btnAddComps->setToolButtonStyle(Qt::ToolButtonIconOnly); hlayout->addWidget(btnAddComps); hlayout->addStretch(1); // lua table name llabel = new QLabel(htools); hlayout->addWidget(llabel); vlayout->addLayout(hlayout); auto hlayout2 = new QHBoxLayout(htools); hlayout2->setMargin(0); auto lblLayer = new QLabel(this); lblLayer->setText("Layer: "); hlayout2->addWidget(lblLayer); spnLayer = new QSpinBox(this); spnLayer->setMinimum(0); spnLayer->setMaximum(KENTITY_LAYER_SIZE); connect(spnLayer, static_cast<void(QSpinBox::*)(int)>(&QSpinBox::valueChanged), this, &ComponentDock::layerChanged); hlayout2->addWidget(spnLayer, 1); hlayout2->addSpacing(5); auto lblOrder = new QLabel(this); lblOrder->setText("Z: "); hlayout2->addWidget(lblOrder); spnZOrder = new QSpinBox(this); spnZOrder->setMinimum(0); spnZOrder->setMaximum(9999999); spnZOrder->setValue(0); connect(spnZOrder, static_cast<void(QSpinBox::*)(int)>(&QSpinBox::valueChanged), this, &ComponentDock::zorderChanged); hlayout2->addWidget(spnZOrder, 1); hlayout2->addSpacing(5); // static chkStatic = new QCheckBox(this); chkStatic->setText("Static"); connect(chkStatic, &QCheckBox::stateChanged, this, &ComponentDock::staticChanged); hlayout2->addWidget(chkStatic); hlayout2->addSpacing(5); vlayout->addLayout(hlayout2); auto hlayout3 = new QHBoxLayout(htools); hlayout3->setMargin(0); hlayout3->setSpacing(0); auto btnCollpaseAll = new QToolButton(htools); btnCollpaseAll->setIcon(QIcon(":/icons/col")); btnCollpaseAll->setToolButtonStyle(Qt::ToolButtonIconOnly); connect(btnCollpaseAll, &QToolButton::clicked, comTree, &QTreeWidget::collapseAll); hlayout3->addWidget(btnCollpaseAll); hlayout3->addSpacing(5); ledit = new QLineEdit(htools); ledit->setPlaceholderText("Search"); ledit->addAction(QIcon(":/icons/search"), QLineEdit::ActionPosition::TrailingPosition); ledit->setStyleSheet("background-color: gray;"); connect(ledit, &QLineEdit::textChanged, this, &ComponentDock::actSearch); hlayout3->addWidget(ledit, 1); vlayout->addLayout(hlayout3); htools->setLayout(vlayout); setTitleBarWidget(htools); }
void SketchToolButton::setupIcons(const QString &imageName) { setIconSize(QSize(32,32)); setToolButtonStyle(Qt::ToolButtonTextUnderIcon); AbstractStatesButton::setupIcons(imageName); }
void QmitkExtWorkbenchWindowAdvisor::PostWindowCreate() { // very bad hack... berry::IWorkbenchWindow::Pointer window = this->GetWindowConfigurer()->GetWindow(); QMainWindow* mainWindow = qobject_cast<QMainWindow*> (window->GetShell()->GetControl()); if (!windowIcon.isEmpty()) { mainWindow->setWindowIcon(QIcon(windowIcon)); } mainWindow->setContextMenuPolicy(Qt::PreventContextMenu); /*mainWindow->setStyleSheet("color: white;" "background-color: #808080;" "selection-color: #659EC7;" "selection-background-color: #808080;" " QMenuBar {" "background-color: #808080; }");*/ // Load selected icon theme QStringList searchPaths = QIcon::themeSearchPaths(); searchPaths.push_front( QString(":/org_mitk_icons/icons/") ); QIcon::setThemeSearchPaths( searchPaths ); berry::IPreferencesService* prefService = berry::Platform::GetPreferencesService(); berry::IPreferences::Pointer stylePref = prefService->GetSystemPreferences()->Node(berry::QtPreferences::QT_STYLES_NODE); QString iconTheme = stylePref->Get(berry::QtPreferences::QT_ICON_THEME, "<<default>>"); if( iconTheme == QString( "<<default>>" ) ) { iconTheme = QString( "tango" ); } QIcon::setThemeName( iconTheme ); // ==== Application menu ============================ QMenuBar* menuBar = mainWindow->menuBar(); menuBar->setContextMenuPolicy(Qt::PreventContextMenu); #ifdef __APPLE__ menuBar->setNativeMenuBar(true); #else menuBar->setNativeMenuBar(false); #endif QAction* fileOpenAction = new QmitkFileOpenAction(QIcon::fromTheme("document-open",QIcon(":/org_mitk_icons/icons/tango/scalable/actions/document-open.svg")), window); fileOpenAction->setShortcut(QKeySequence::Open); QAction* fileSaveAction = new QmitkFileSaveAction(QIcon(":/org.mitk.gui.qt.ext/Save_48.png"), window); fileSaveAction->setShortcut(QKeySequence::Save); fileSaveProjectAction = new QmitkExtFileSaveProjectAction(window); fileSaveProjectAction->setIcon(QIcon::fromTheme("document-save",QIcon(":/org_mitk_icons/icons/tango/scalable/actions/document-save.svg"))); closeProjectAction = new QmitkCloseProjectAction(window); closeProjectAction->setIcon(QIcon::fromTheme("edit-delete",QIcon(":/org_mitk_icons/icons/tango/scalable/actions/edit-delete.svg"))); auto perspGroup = new QActionGroup(menuBar); std::map<QString, berry::IViewDescriptor::Pointer> VDMap; // sort elements (converting vector to map...) QList<berry::IViewDescriptor::Pointer>::const_iterator iter; berry::IViewRegistry* viewRegistry = berry::PlatformUI::GetWorkbench()->GetViewRegistry(); const QList<berry::IViewDescriptor::Pointer> viewDescriptors = viewRegistry->GetViews(); bool skip = false; for (iter = viewDescriptors.begin(); iter != viewDescriptors.end(); ++iter) { // if viewExcludeList is set, it contains the id-strings of view, which // should not appear as an menu-entry in the menu if (viewExcludeList.size() > 0) { for (int i=0; i<viewExcludeList.size(); i++) { if (viewExcludeList.at(i) == (*iter)->GetId()) { skip = true; break; } } if (skip) { skip = false; continue; } } if ((*iter)->GetId() == "org.blueberry.ui.internal.introview") continue; if ((*iter)->GetId() == "org.mitk.views.imagenavigator") continue; if ((*iter)->GetId() == "org.mitk.views.viewnavigatorview") continue; std::pair<QString, berry::IViewDescriptor::Pointer> p( (*iter)->GetLabel(), (*iter)); VDMap.insert(p); } std::map<QString, berry::IViewDescriptor::Pointer>::const_iterator MapIter; for (MapIter = VDMap.begin(); MapIter != VDMap.end(); ++MapIter) { berry::QtShowViewAction* viewAction = new berry::QtShowViewAction(window, (*MapIter).second); viewActions.push_back(viewAction); } if (!USE_EXPERIMENTAL_COMMAND_CONTRIBUTIONS) { QMenu* fileMenu = menuBar->addMenu("&File"); fileMenu->setObjectName("FileMenu"); fileMenu->addAction(fileOpenAction); fileMenu->addAction(fileSaveAction); fileMenu->addAction(fileSaveProjectAction); fileMenu->addAction(closeProjectAction); fileMenu->addSeparator(); QAction* fileExitAction = new QmitkFileExitAction(window); fileExitAction->setIcon(QIcon::fromTheme("system-log-out",QIcon(":/org_mitk_icons/icons/tango/scalable/actions/system-log-out.svg"))); fileExitAction->setShortcut(QKeySequence::Quit); fileExitAction->setObjectName("QmitkFileExitAction"); fileMenu->addAction(fileExitAction); // another bad hack to get an edit/undo menu... QMenu* editMenu = menuBar->addMenu("&Edit"); undoAction = editMenu->addAction(QIcon::fromTheme("edit-undo",QIcon(":/org_mitk_icons/icons/tango/scalable/actions/edit-undo.svg")), "&Undo", QmitkExtWorkbenchWindowAdvisorHack::undohack, SLOT(onUndo()), QKeySequence("CTRL+Z")); undoAction->setToolTip("Undo the last action (not supported by all modules)"); redoAction = editMenu->addAction(QIcon::fromTheme("edit-redo",QIcon(":/org_mitk_icons/icons/tango/scalable/actions/edit-redo.svg")) , "&Redo", QmitkExtWorkbenchWindowAdvisorHack::undohack, SLOT(onRedo()), QKeySequence("CTRL+Y")); redoAction->setToolTip("execute the last action that was undone again (not supported by all modules)"); // ==== Window Menu ========================== QMenu* windowMenu = menuBar->addMenu("Window"); if (showNewWindowMenuItem) { windowMenu->addAction("&New Window", QmitkExtWorkbenchWindowAdvisorHack::undohack, SLOT(onNewWindow())); windowMenu->addSeparator(); } QMenu* perspMenu = windowMenu->addMenu("&Open Perspective"); QMenu* viewMenu; if (showViewMenuItem) { viewMenu = windowMenu->addMenu("Show &View"); viewMenu->setObjectName("Show View"); } windowMenu->addSeparator(); resetPerspAction = windowMenu->addAction("&Reset Perspective", QmitkExtWorkbenchWindowAdvisorHack::undohack, SLOT(onResetPerspective())); if(showClosePerspectiveMenuItem) closePerspAction = windowMenu->addAction("&Close Perspective", QmitkExtWorkbenchWindowAdvisorHack::undohack, SLOT(onClosePerspective())); windowMenu->addSeparator(); windowMenu->addAction("&Preferences...", QmitkExtWorkbenchWindowAdvisorHack::undohack, SLOT(onEditPreferences()), QKeySequence("CTRL+P")); // fill perspective menu berry::IPerspectiveRegistry* perspRegistry = window->GetWorkbench()->GetPerspectiveRegistry(); QList<berry::IPerspectiveDescriptor::Pointer> perspectives( perspRegistry->GetPerspectives()); skip = false; for (QList<berry::IPerspectiveDescriptor::Pointer>::iterator perspIt = perspectives.begin(); perspIt != perspectives.end(); ++perspIt) { // if perspectiveExcludeList is set, it contains the id-strings of perspectives, which // should not appear as an menu-entry in the perspective menu if (perspectiveExcludeList.size() > 0) { for (int i=0; i<perspectiveExcludeList.size(); i++) { if (perspectiveExcludeList.at(i) == (*perspIt)->GetId()) { skip = true; break; } } if (skip) { skip = false; continue; } } QAction* perspAction = new berry::QtOpenPerspectiveAction(window, *perspIt, perspGroup); mapPerspIdToAction.insert((*perspIt)->GetId(), perspAction); } perspMenu->addActions(perspGroup->actions()); if (showViewMenuItem) { for (auto viewAction : viewActions) { viewMenu->addAction(viewAction); } } // ===== Help menu ==================================== QMenu* helpMenu = menuBar->addMenu("&Help"); helpMenu->addAction("&Welcome",this, SLOT(onIntro())); helpMenu->addAction("&Open Help Perspective", this, SLOT(onHelpOpenHelpPerspective())); helpMenu->addAction("&Context Help",this, SLOT(onHelp()), QKeySequence("F1")); helpMenu->addAction("&About",this, SLOT(onAbout())); // ===================================================== } else { //undoAction = new QAction(QIcon::fromTheme("edit-undo",QIcon(":/org_mitk_icons/icons/tango/scalable/actions/edit-undo.svg")), // "&Undo", nullptr); undoAction = new QmitkUndoAction(QIcon::fromTheme("edit-undo",QIcon(":/org_mitk_icons/icons/tango/scalable/actions/edit-undo.svg")), nullptr); undoAction->setShortcut(QKeySequence::Undo); redoAction = new QmitkRedoAction(QIcon::fromTheme("edit-redo",QIcon(":/org_mitk_icons/icons/tango/scalable/actions/edit-redo.svg")), nullptr); redoAction->setShortcut(QKeySequence::Redo); } // toolbar for showing file open, undo, redo and other main actions auto mainActionsToolBar = new QToolBar; mainActionsToolBar->setObjectName("mainActionsToolBar"); mainActionsToolBar->setContextMenuPolicy(Qt::PreventContextMenu); #ifdef __APPLE__ mainActionsToolBar->setToolButtonStyle ( Qt::ToolButtonTextUnderIcon ); #else mainActionsToolBar->setToolButtonStyle ( Qt::ToolButtonTextBesideIcon ); #endif imageNavigatorAction = new QAction(QIcon(":/org.mitk.gui.qt.ext/Slider.png"), "&Image Navigator", nullptr); bool imageNavigatorViewFound = window->GetWorkbench()->GetViewRegistry()->Find("org.mitk.views.imagenavigator"); if(this->GetWindowConfigurer()->GetWindow()->GetWorkbench()->GetEditorRegistry()->FindEditor("org.mitk.editors.dicomeditor")) { openDicomEditorAction = new QmitkOpenDicomEditorAction(QIcon(":/org.mitk.gui.qt.ext/dcm-icon.png"),window); } if (imageNavigatorViewFound) { QObject::connect(imageNavigatorAction, SIGNAL(triggered(bool)), QmitkExtWorkbenchWindowAdvisorHack::undohack, SLOT(onImageNavigator())); imageNavigatorAction->setCheckable(true); // add part listener for image navigator imageNavigatorPartListener.reset(new PartListenerForImageNavigator(imageNavigatorAction)); window->GetPartService()->AddPartListener(imageNavigatorPartListener.data()); berry::IViewPart::Pointer imageNavigatorView = window->GetActivePage()->FindView("org.mitk.views.imagenavigator"); imageNavigatorAction->setChecked(false); if (imageNavigatorView) { bool isImageNavigatorVisible = window->GetActivePage()->IsPartVisible(imageNavigatorView); if (isImageNavigatorVisible) imageNavigatorAction->setChecked(true); } imageNavigatorAction->setToolTip("Toggle image navigator for navigating through image"); } viewNavigatorAction = new QAction(QIcon(":/org.mitk.gui.qt.ext/view-manager_48.png"),"&View Navigator", nullptr); viewNavigatorFound = window->GetWorkbench()->GetViewRegistry()->Find("org.mitk.views.viewnavigatorview"); if (viewNavigatorFound) { QObject::connect(viewNavigatorAction, SIGNAL(triggered(bool)), QmitkExtWorkbenchWindowAdvisorHack::undohack, SLOT(onViewNavigator())); viewNavigatorAction->setCheckable(true); // add part listener for view navigator viewNavigatorPartListener.reset(new PartListenerForViewNavigator(viewNavigatorAction)); window->GetPartService()->AddPartListener(viewNavigatorPartListener.data()); berry::IViewPart::Pointer viewnavigatorview = window->GetActivePage()->FindView("org.mitk.views.viewnavigatorview"); viewNavigatorAction->setChecked(false); if (viewnavigatorview) { bool isViewNavigatorVisible = window->GetActivePage()->IsPartVisible(viewnavigatorview); if (isViewNavigatorVisible) viewNavigatorAction->setChecked(true); } viewNavigatorAction->setToolTip("Toggle View Navigator"); } mainActionsToolBar->addAction(fileOpenAction); mainActionsToolBar->addAction(fileSaveProjectAction); mainActionsToolBar->addAction(closeProjectAction); mainActionsToolBar->addAction(undoAction); mainActionsToolBar->addAction(redoAction); if(this->GetWindowConfigurer()->GetWindow()->GetWorkbench()->GetEditorRegistry()->FindEditor("org.mitk.editors.dicomeditor")) { mainActionsToolBar->addAction(openDicomEditorAction); } if (imageNavigatorViewFound) { mainActionsToolBar->addAction(imageNavigatorAction); } if (viewNavigatorFound) { mainActionsToolBar->addAction(viewNavigatorAction); } mainWindow->addToolBar(mainActionsToolBar); // ==== Perspective Toolbar ================================== auto qPerspectiveToolbar = new QToolBar; qPerspectiveToolbar->setObjectName("perspectiveToolBar"); if (showPerspectiveToolbar) { qPerspectiveToolbar->addActions(perspGroup->actions()); mainWindow->addToolBar(qPerspectiveToolbar); } else delete qPerspectiveToolbar; // ==== View Toolbar ================================== auto qToolbar = new QToolBar; qToolbar->setObjectName("viewToolBar"); if (showViewToolbar) { mainWindow->addToolBar(qToolbar); for (auto viewAction : viewActions) { qToolbar->addAction(viewAction); } } else delete qToolbar; QSettings settings(GetQSettingsFile(), QSettings::IniFormat); mainWindow->restoreState(settings.value("ToolbarPosition").toByteArray()); auto qStatusBar = new QStatusBar(); //creating a QmitkStatusBar for Output on the QStatusBar and connecting it with the MainStatusBar auto statusBar = new QmitkStatusBar(qStatusBar); //disabling the SizeGrip in the lower right corner statusBar->SetSizeGripEnabled(false); auto progBar = new QmitkProgressBar(); qStatusBar->addPermanentWidget(progBar, 0); progBar->hide(); // progBar->AddStepsToDo(2); // progBar->Progress(1); mainWindow->setStatusBar(qStatusBar); if (showMemoryIndicator) { auto memoryIndicator = new QmitkMemoryUsageIndicatorView(); qStatusBar->addPermanentWidget(memoryIndicator, 0); } }
DeckView::DeckView(QWidget *parent) : QWidget(parent), timestamp(0), waiting(false), sideHidden(false) { if(config->bg) { setStyleSheet("color: white; font-size: 16px"); } else { setStyleSheet("font-size: 16px"); } toolbar = new QToolBar; toolbar->setStyleSheet("color: black; font-size: 12px"); undoAction = new QAction(toolbar); undoAction->setIcon(QIcon(":/icons/undo.png")); undoAction->setToolTip(config->getStr("action", "undo", "撤销")); toolbar->addAction(undoAction); redoAction = new QAction(toolbar); redoAction->setIcon(QIcon(":/icons/redo.png")); redoAction->setToolTip(config->getStr("action", "redo", "重做")); toolbar->addAction(redoAction); toolbar->addSeparator(); auto newAction = new QAction(toolbar); newAction->setIcon(QIcon(":/icons/new.png")); newAction->setToolTip(config->getStr("action", "new", "新建")); toolbar->addAction(newAction); auto saveAction = new QAction(toolbar); saveAction->setIcon(QIcon(":/icons/save.png")); saveAction->setToolTip(config->getStr("action", "save", "保存")); toolbar->addAction(saveAction); auto saveAsAction = new QAction(toolbar); saveAsAction->setIcon(QIcon(":/icons/saveas.png")); saveAsAction->setToolTip(config->getStr("action", "saveas", "另存为")); toolbar->addAction(saveAsAction); auto printAction = new QAction(toolbar); printAction->setIcon(QIcon(":/icons/print.png")); printAction->setToolTip(config->getStr("action", "print", "截图")); toolbar->addAction(printAction); toolbar->addSeparator(); auto deleteAction = new QAction(toolbar); deleteAction->setIcon(QIcon(":/icons/delete.png")); deleteAction->setToolTip(config->getStr("action", "delete", "删除卡组")); toolbar->addAction(deleteAction); toolbar->addSeparator(); abortAction = new QAction(toolbar); abortAction->setIcon(QIcon(":/icons/abort.png")); abortAction->setToolTip(config->getStr("action", "abort", "中止")); abortAction->setEnabled(false); toolbar->addAction(abortAction); toolbar->addSeparator(); auto hideButton = new QToolButton; hideButton->setToolButtonStyle(Qt::ToolButtonTextBesideIcon); auto hideAction = new QAction("Side", hideButton); hideAction->setIcon(QIcon(":/icons/side.png")); hideButton->addAction(hideAction); hideButton->setDefaultAction(hideAction); toolbar->addWidget(hideButton); auto spacer = new QWidget; spacer->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); toolbar->addWidget(spacer); toolbar->addSeparator(); auto sortAction = new QAction(toolbar); sortAction->setIcon(QIcon(":/icons/sort.png")); sortAction->setToolTip(config->getStr("action", "sort", "排序")); toolbar->addAction(sortAction); auto shuffleAction = new QAction(toolbar); shuffleAction->setIcon(QIcon(":/icons/shuffle.png")); shuffleAction->setToolTip(config->getStr("action", "shuffle", "打乱")); toolbar->addAction(shuffleAction); auto clearAction = new QAction(toolbar); clearAction->setIcon(QIcon(":/icons/clear.png")); clearAction->setToolTip(config->getStr("action", "clear", "清空")); toolbar->addAction(clearAction); toolbar->addSeparator(); auto homeAction = new QAction(toolbar); homeAction->setIcon(QIcon(":/icons/home.png")); homeAction->setToolTip(config->getStr("action", "home", "主页")); toolbar->addAction(homeAction); auto helpAction = new QAction(toolbar); helpAction->setIcon(QIcon(":/icons/help.png")); helpAction->setToolTip(config->getStr("action", "help", "帮助")); toolbar->addAction(helpAction); mainDeck = new DeckWidget(nullptr, 4, 10); auto notExtraFilter = [](quint32 id) { auto card = cardPool->getCard(id); return card && !card->inExtra(); }; mainDeck->filter = notExtraFilter; auto t1 = new DeckSizeLabel(config->getStr("label", "main", "主卡组")); auto mt = new MainDeckLabel; extraDeck = new DeckWidget(nullptr, 1, 10); auto extraFilter = [](quint32 id) { auto card = cardPool->getCard(id); return card && card->inExtra(); }; extraDeck->filter = extraFilter; sideDeck = new DeckWidget(nullptr, 1, 10); auto t2 = new DeckSizeLabel(config->getStr("label", "extra", "额外卡组")); auto et = new ExtraDeckLabel; st = new DeckSizeLabel(config->getStr("label", "side", "副卡组")); auto extFilter = [this](quint32 id) { int sum = 0; sum += mainDeck->countCard(id); sum += extraDeck->countCard(id); sum += sideDeck->countCard(id); return sum < limitCards->getLimit(id); }; mainDeck->extFilter = extFilter; extraDeck->extFilter = extFilter; sideDeck->extFilter = extFilter; auto snapshotMaker = [this]() { makeSnapshot(); }; mainDeck->makeSnapShot = snapshotMaker; extraDeck->makeSnapShot = snapshotMaker; sideDeck->makeSnapShot = snapshotMaker; connect(mainDeck, &DeckWidget::sizeChanged, t1, &DeckSizeLabel::changeSize); connect(mainDeck, &DeckWidget::deckChanged, mt, &MainDeckLabel::deckChanged); connect(mainDeck, &DeckWidget::currentIdChanged, this, &DeckView::currentIdChanged); connect(extraDeck, &DeckWidget::sizeChanged, t2, &DeckSizeLabel::changeSize); connect(extraDeck, &DeckWidget::deckChanged, et, &ExtraDeckLabel::deckChanged); connect(extraDeck, &DeckWidget::currentIdChanged, this, &DeckView::currentIdChanged); connect(sideDeck, &DeckWidget::sizeChanged, st, &DeckSizeLabel::changeSize); connect(sideDeck, &DeckWidget::currentIdChanged, this, &DeckView::currentIdChanged); connect(sortAction, &QAction::triggered, this, &DeckView::sort); connect(clearAction, &QAction::triggered, this, &DeckView::clearDeck); connect(helpAction, &QAction::triggered, this, &DeckView::help); connect(mainDeck, &DeckWidget::clickId, this, &DeckView::clickId); connect(extraDeck, &DeckWidget::clickId, this, &DeckView::clickId); connect(sideDeck, &DeckWidget::clickId, this, &DeckView::clickId); connect(shuffleAction, &QAction::triggered, mainDeck, &DeckWidget::shuffle); connect(undoAction, &QAction::triggered, this, &DeckView::undo); connect(redoAction, &QAction::triggered, this, &DeckView::redo); connect(saveAction, &QAction::triggered, this, &DeckView::saveSlot); connect(saveAsAction, &QAction::triggered, this, &DeckView::save); connect(newAction, &QAction::triggered, this, &DeckView::newDeck); connect(deleteAction, &QAction::triggered, this, &DeckView::deleteDeck); connect(abortAction, &QAction::triggered, this, &DeckView::abort); connect(homeAction, &QAction::triggered, this, &DeckView::home); connect(printAction, &QAction::triggered, this, &DeckView::print); connect(hideAction, &QAction::triggered, this, &DeckView::hideSide); connect(mainDeck, &DeckWidget::details, this, &DeckView::details); connect(extraDeck, &DeckWidget::details, this, &DeckView::details); connect(sideDeck, &DeckWidget::details, this, &DeckView::details); auto vbox = new QVBoxLayout; auto hbox = new QHBoxLayout; vbox->addWidget(toolbar); hbox->addWidget(t1); hbox->addWidget(mt); vbox->addLayout(hbox); vbox->addWidget(mainDeck, 4); hbox = new QHBoxLayout; hbox->addWidget(t2); hbox->addWidget(et); vbox->addLayout(hbox); vbox->addWidget(extraDeck, 1); vbox->addWidget(st); vbox->addWidget(sideDeck, 1); setLayout(vbox); updateButtons(); }
ToolButton( const char *text, QToolBar *toolBar ): QToolButton( toolBar ) { setText( text ); setToolButtonStyle( Qt::ToolButtonTextUnderIcon ); }
MainToolBar::MainToolBar(QWidget *parent) : QToolBar(parent) , mCommandButton(new CommandButton(this)) { setObjectName(QLatin1String("MainToolBar")); setWindowTitle(tr("Main Toolbar")); setToolButtonStyle(Qt::ToolButtonFollowStyle); QIcon newIcon(QLatin1String(":images/24x24/document-new.png")); QIcon openIcon(QLatin1String(":images/24x24/document-open.png")); QIcon saveIcon(QLatin1String(":images/24x24/document-save.png")); QIcon undoIcon(QLatin1String(":images/24x24/edit-undo.png")); QIcon redoIcon(QLatin1String(":images/24x24/edit-redo.png")); newIcon.addFile(QLatin1String(":images/16x16/document-new.png")); openIcon.addFile(QLatin1String(":images/16x16/document-open.png")); saveIcon.addFile(QLatin1String(":images/16x16/document-save.png")); redoIcon.addFile(QLatin1String(":images/16x16/edit-redo.png")); undoIcon.addFile(QLatin1String(":images/16x16/edit-undo.png")); mNewButton = new QToolButton(this); mOpenAction = new QAction(this); mSaveAction = new QAction(this); QMenu *newMenu = new QMenu(this); newMenu->addAction(ActionManager::action("NewMap")); newMenu->addAction(ActionManager::action("NewTileset")); mNewButton->setMenu(newMenu); mNewButton->setPopupMode(QToolButton::InstantPopup); QUndoGroup *undoGroup = DocumentManager::instance()->undoGroup(); mUndoAction = undoGroup->createUndoAction(this, tr("Undo")); mRedoAction = undoGroup->createRedoAction(this, tr("Redo")); mNewButton->setIcon(newIcon); mOpenAction->setIcon(openIcon); mSaveAction->setIcon(saveIcon); mUndoAction->setIcon(undoIcon); mRedoAction->setIcon(redoIcon); Utils::setThemeIcon(mNewButton, "document-new"); Utils::setThemeIcon(mOpenAction, "document-open"); Utils::setThemeIcon(mSaveAction, "document-save"); Utils::setThemeIcon(mRedoAction, "edit-redo"); Utils::setThemeIcon(mUndoAction, "edit-undo"); mRedoAction->setPriority(QAction::LowPriority); addWidget(mNewButton); addAction(mOpenAction); addAction(mSaveAction); addSeparator(); addAction(mUndoAction); addAction(mRedoAction); addSeparator(); addWidget(mCommandButton); DocumentManager *documentManager = DocumentManager::instance(); connect(mOpenAction, &QAction::triggered, documentManager, &DocumentManager::openFileDialog); connect(mSaveAction, &QAction::triggered, documentManager, &DocumentManager::saveFile); connect(documentManager, &DocumentManager::currentDocumentChanged, this, &MainToolBar::currentDocumentChanged); connect(this, &MainToolBar::orientationChanged, this, &MainToolBar::onOrientationChanged); retranslateUi(); }
Expander::Expander(Kite::KComponent *Comp, QTreeWidget *Parent): QObject(Parent), expandable(true) { chandle = Comp->getHandle(); ctype = Comp->getType(); QString name = Comp->getTypeName().c_str(); if (ctype == Kite::CTypes::Logic) { name.append(" "); name.append(Comp->getName().c_str()); } head = new QTreeWidgetItem(Parent); head->setFlags(head->flags() ^ Qt::ItemIsDropEnabled); head->setChildIndicatorPolicy(QTreeWidgetItem::ShowIndicator); head->setText(0, name); head->setHidden(true); auto headFrame = new QFrame(Parent); auto headLayout = new QVBoxLayout(headFrame); headLayout->setMargin(0); headLayout->addSpacing(3); btnExpand = new QPushButton(Parent); btnExpand->setObjectName("btnExpand"); btnExpand->setIcon(QIcon(":/icons/exp")); btnExpand->setText(name); btnExpand->setFocusPolicy(Qt::NoFocus); btnExpand->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Fixed); btnExpand->setStyleSheet("QPushButton { text-align: left;" "color: rgb(255, 255, 255);" "background-color: rgb(38, 38, 38);" "border: 1px solid rgb(38, 38, 38);" "border-radius: 3px;}"); headLayout->addWidget(btnExpand); auto hlayout = new QHBoxLayout(btnExpand); hlayout->setMargin(0); hlayout->setSpacing(0); hlayout->addStretch(1); // dependecy label if (!Comp->getDependency().empty()) { auto lblDep = new QLabel(btnExpand); lblDep->setText("<img src=\":/icons/depend\" height=\"16\" width=\"16\" >"); lblDep->setStyleSheet("QToolTip { border: 1px solid #2c2c2c; background-color: #242424; color: white;}"); QString tooltip("<font color=\"orange\">Dependency List:</font>"); auto depList = Comp->getDependency(); for (auto it = depList.begin(); it != depList.end(); ++it) { tooltip += "\n" + QString(Kite::getCTypesName((*it)).c_str()); } lblDep->setToolTip(tooltip); hlayout->addWidget(lblDep); hlayout->addSpacing(2); } // remove on zero dependency label if (Comp->getRemoveOnZeroDep()) { auto lblZeroDep = new QLabel(btnExpand); lblZeroDep->setText("<img src=\":/icons/remzdep\" height=\"16\" width=\"16\" >"); lblZeroDep->setStyleSheet("QToolTip { border: 1px solid #2c2c2c; background-color: #242424; color: white;}"); lblZeroDep->setToolTip("Will be removed automatically if there is no dependence on it"); hlayout->addWidget(lblZeroDep); hlayout->addSpacing(2); } // remove button auto btnClose = new QToolButton(btnExpand); btnClose->setContentsMargins(0, 0, 0, 0); btnClose->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred); btnClose->setIcon(QIcon(":/icons/close")); btnClose->setIconSize(QSize(8, 8)); btnClose->setToolButtonStyle(Qt::ToolButtonIconOnly); btnClose->setAutoRaise(true); btnClose->setStyleSheet("QToolTip { border: 1px solid #2c2c2c; background-color: #242424; color: white;}"); btnClose->setToolTip("Remove Component"); hlayout->addWidget(btnClose); Parent->setItemWidget(head, 0, headFrame); content = new ComponentView(Comp, Parent); content->setStyleSheet("QFrame {background-color: rgb(58, 58, 58);\n" "border: 1px solid rgb(58, 58, 58);\n" "border-bottom-left-radius: 3px;\n" "border-bottom-right-radius: 3px;}"); connect(content, &ComponentView::updateResList, this, &Expander::updateResList); connect(content, &ComponentView::componentEdited, this, &Expander::componentEdited); connect(content, &ComponentView::requestRes, this, &Expander::requestRes); connect(content, &ComponentView::requestPropValue, this, &Expander::requestPropValue); auto child = new QTreeWidgetItem(head); child->setDisabled(true); Parent->setItemWidget(child, 0, content); connect(btnExpand, &QPushButton::pressed, this, &Expander::expClicked); connect(btnClose, &QToolButton::clicked, this, &Expander::clsClicked); }
QT_BEGIN_NAMESPACE MainWindow::MainWindow(CmdLineParser *cmdLine, QWidget *parent) : QMainWindow(parent) , m_bookmarkWidget(0) , m_filterCombo(0) , m_toolBarMenu(0) , m_cmdLine(cmdLine) , m_progressWidget(0) , m_qtDocInstaller(0) , m_connectedInitSignals(false) { TRACE_OBJ setToolButtonStyle(Qt::ToolButtonFollowStyle); setDockOptions(dockOptions() | AllowNestedDocks); QString collectionFile; if (usesDefaultCollection()) { MainWindow::collectionFileDirectory(true); collectionFile = MainWindow::defaultHelpCollectionFileName(); } else { collectionFile = cmdLine->collectionFile(); } HelpEngineWrapper &helpEngineWrapper = HelpEngineWrapper::instance(collectionFile); BookmarkManager *bookMarkManager = BookmarkManager::instance(); if (!initHelpDB(!cmdLine->collectionFileGiven())) { qDebug("Fatal error: Help engine initialization failed. " "Error message was: %s\nAssistant will now exit.", qPrintable(HelpEngineWrapper::instance().error())); std::exit(1); } m_centralWidget = new CentralWidget(this); setCentralWidget(m_centralWidget); m_indexWindow = new IndexWindow(this); QDockWidget *indexDock = new QDockWidget(tr("Index"), this); indexDock->setObjectName(QLatin1String("IndexWindow")); indexDock->setWidget(m_indexWindow); addDockWidget(Qt::LeftDockWidgetArea, indexDock); m_contentWindow = new ContentWindow; QDockWidget *contentDock = new QDockWidget(tr("Contents"), this); contentDock->setObjectName(QLatin1String("ContentWindow")); contentDock->setWidget(m_contentWindow); addDockWidget(Qt::LeftDockWidgetArea, contentDock); m_searchWindow = new SearchWidget(helpEngineWrapper.searchEngine()); m_searchWindow->setFont(!helpEngineWrapper.usesBrowserFont() ? qApp->font() : helpEngineWrapper.browserFont()); QDockWidget *searchDock = new QDockWidget(tr("Search"), this); searchDock->setObjectName(QLatin1String("SearchWindow")); searchDock->setWidget(m_searchWindow); addDockWidget(Qt::LeftDockWidgetArea, searchDock); QDockWidget *bookmarkDock = new QDockWidget(tr("Bookmarks"), this); bookmarkDock->setObjectName(QLatin1String("BookmarkWindow")); bookmarkDock->setWidget(m_bookmarkWidget = bookMarkManager->bookmarkDockWidget()); addDockWidget(Qt::LeftDockWidgetArea, bookmarkDock); QDockWidget *openPagesDock = new QDockWidget(tr("Open Pages"), this); openPagesDock->setObjectName(QLatin1String("Open Pages")); OpenPagesManager *openPagesManager = OpenPagesManager::createInstance(this, usesDefaultCollection(), m_cmdLine->url()); openPagesDock->setWidget(openPagesManager->openPagesWidget()); addDockWidget(Qt::LeftDockWidgetArea, openPagesDock); connect(m_centralWidget, SIGNAL(addBookmark(QString, QString)), bookMarkManager, SLOT(addBookmark(QString, QString))); connect(bookMarkManager, SIGNAL(escapePressed()), this, SLOT(activateCurrentCentralWidgetTab())); connect(bookMarkManager, SIGNAL(setSource(QUrl)), m_centralWidget, SLOT(setSource(QUrl))); connect(bookMarkManager, SIGNAL(setSourceInNewTab(QUrl)), openPagesManager, SLOT(createPage(QUrl))); QHelpSearchEngine *searchEngine = helpEngineWrapper.searchEngine(); connect(searchEngine, SIGNAL(indexingStarted()), this, SLOT(indexingStarted())); connect(searchEngine, SIGNAL(indexingFinished()), this, SLOT(indexingFinished())); QString defWindowTitle = tr("Qt Assistant"); setWindowTitle(defWindowTitle); setupActions(); statusBar()->show(); m_centralWidget->connectTabBar(); setupFilterToolbar(); setupAddressToolbar(); const QString windowTitle = helpEngineWrapper.windowTitle(); setWindowTitle(windowTitle.isEmpty() ? defWindowTitle : windowTitle); QByteArray iconArray = helpEngineWrapper.applicationIcon(); if (iconArray.size() > 0) { QPixmap pix; pix.loadFromData(iconArray); QIcon appIcon(pix); qApp->setWindowIcon(appIcon); } else { QIcon appIcon(QLatin1String(":/qt-project.org/assistant/images/assistant-128.png")); qApp->setWindowIcon(appIcon); } QToolBar *toolBar = addToolBar(tr("Bookmark Toolbar")); toolBar->setObjectName(QLatin1String("Bookmark Toolbar")); bookMarkManager->setBookmarksToolbar(toolBar); // Show the widget here, otherwise the restore geometry and state won't work // on x11. show(); toolBar->hide(); toolBarMenu()->addAction(toolBar->toggleViewAction()); QByteArray ba(helpEngineWrapper.mainWindow()); if (!ba.isEmpty()) restoreState(ba); ba = helpEngineWrapper.mainWindowGeometry(); if (!ba.isEmpty()) { restoreGeometry(ba); } else { tabifyDockWidget(contentDock, indexDock); tabifyDockWidget(indexDock, bookmarkDock); tabifyDockWidget(bookmarkDock, searchDock); contentDock->raise(); const QRect screen = QApplication::desktop()->screenGeometry(); resize(4*screen.width()/5, 4*screen.height()/5); adjustSize(); // make sure we won't start outside of the screen move(screen.center() - rect().center()); } if (!helpEngineWrapper.hasFontSettings()) { helpEngineWrapper.setUseAppFont(false); helpEngineWrapper.setUseBrowserFont(false); helpEngineWrapper.setAppFont(qApp->font()); helpEngineWrapper.setAppWritingSystem(QFontDatabase::Latin); helpEngineWrapper.setBrowserFont(qApp->font()); helpEngineWrapper.setBrowserWritingSystem(QFontDatabase::Latin); } else { updateApplicationFont(); } updateAboutMenuText(); QTimer::singleShot(0, this, SLOT(insertLastPages())); if (m_cmdLine->enableRemoteControl()) (void)new RemoteControl(this); if (m_cmdLine->contents() == CmdLineParser::Show) showContents(); else if (m_cmdLine->contents() == CmdLineParser::Hide) hideContents(); if (m_cmdLine->index() == CmdLineParser::Show) showIndex(); else if (m_cmdLine->index() == CmdLineParser::Hide) hideIndex(); if (m_cmdLine->bookmarks() == CmdLineParser::Show) showBookmarksDockWidget(); else if (m_cmdLine->bookmarks() == CmdLineParser::Hide) hideBookmarksDockWidget(); if (m_cmdLine->search() == CmdLineParser::Show) showSearch(); else if (m_cmdLine->search() == CmdLineParser::Hide) hideSearch(); if (m_cmdLine->contents() == CmdLineParser::Activate) showContents(); else if (m_cmdLine->index() == CmdLineParser::Activate) showIndex(); else if (m_cmdLine->bookmarks() == CmdLineParser::Activate) showBookmarksDockWidget(); if (!m_cmdLine->currentFilter().isEmpty()) { const QString &curFilter = m_cmdLine->currentFilter(); if (helpEngineWrapper.customFilters().contains(curFilter)) helpEngineWrapper.setCurrentFilter(curFilter); } if (usesDefaultCollection()) QTimer::singleShot(0, this, SLOT(lookForNewQtDocumentation())); else checkInitState(); connect(&helpEngineWrapper, SIGNAL(documentationRemoved(QString)), this, SLOT(documentationRemoved(QString))); connect(&helpEngineWrapper, SIGNAL(documentationUpdated(QString)), this, SLOT(documentationUpdated(QString))); setTabPosition(Qt::AllDockWidgetAreas, QTabWidget::North); GlobalActions::instance()->updateActions(); if (helpEngineWrapper.addressBarEnabled()) showNewAddress(); }
TextEdit::TextEdit(QWidget *parent) : QMainWindow(parent) { setToolButtonStyle(Qt::ToolButtonFollowStyle); setupFileActions(); setupEditActions(); setupTextActions(); { // QMenu *helpMenu = new QMenu(tr("Help"), this); // menuBar()->addMenu(helpMenu); // helpMenu->addAction(tr("About"), this, SLOT(about())); // helpMenu->addAction(tr("About &Qt"), qApp, SLOT(aboutQt())); } textEdit = new QTextEdit(this); ////////////////////////////////////////////////// connect(textEdit, SIGNAL(currentCharFormatChanged(QTextCharFormat)), this, SLOT(currentCharFormatChanged(QTextCharFormat))); connect(textEdit, SIGNAL(cursorPositionChanged()), this, SLOT(cursorPositionChanged())); /////////// //setCentralWidget(textEdit); //blank=new Blank(this); //setCentralWidget(blank); //create a transparent canvas and put it on the top of textEdit image =new MyCanvas(900,800,this); textEdit->setFixedSize(QSize(800,800)); textEdit->setBackgroundRole(QPalette::Light); //scrollArea对象的背景色设为Dark image->setFixedSize(QSize(800,800)); image->setStyleSheet(QString::fromUtf8("border:1px solid #000000;")); QScrollArea* scrollArea = new QScrollArea; scrollArea->setFixedSize(QSize(1800,900)); //scrollArea->setWidget(image); //将画布添加到scrollArea中 scrollArea->setBackgroundRole(QPalette::Light); //scrollArea对象的背景色设为Dark //scrollArea->setBackgroundColor(QColor::white); // QStackedLayout *stackedLayout = new QStackedLayout; // stackedLayout->addWidget(image); // stackedLayout->addWidget(textEdit); // stackedLayout->setStackingMode(QStackedLayout::StackAll); QHBoxLayout* hLayout=new QHBoxLayout(); hLayout->addWidget(textEdit); hLayout->addWidget(image); // scrollArea->setLayout(stackedLayout); scrollArea->setLayout(hLayout); //scrollArea->setGeometry(QRect(50,50,800,800)); setCentralWidget(scrollArea); //将scrollArea加入到主窗口的中心区new QPainter(this); scrollArea->setAlignment(Qt::AlignHCenter); //after canvas handle the mouse-drag event, emit it to the edittext for farther handling connect(image,SIGNAL(mouseMoveSig(QMouseEvent*)),this,SLOT(onMouseMove(QMouseEvent*))); //connect(image,SIGNAL(mouseMoveSig(QMouseEvent*)),textEdit,SLOT(mouseMoveEvent(QMouseEvent*))); //connect(image,SIGNAL(mouseMoveSig(QMouseEvent*)),textEdit,SLOT(cursorPositionChanged(QMouseEvent*))); //connect(this,SIGNAL(mouseMoveSig(QMouseEvent*)),image,SLOT(mouseMoveSlot(QMouseEvent*))); //connect(textEdit,SIGNAL(mouseMoveEvent(QMouseEvent*)),image,SLOT(mouseMoveSlot(QMouseEvent*))); // textEdit->setFocus(); setCurrentFileName(QString()); fontChanged(textEdit->font()); colorChanged(textEdit->textColor()); alignmentChanged(textEdit->alignment()); connect(textEdit->document(), SIGNAL(modificationChanged(bool)), actionSave, SLOT(setEnabled(bool))); connect(textEdit->document(), SIGNAL(modificationChanged(bool)), this, SLOT(setWindowModified(bool))); connect(textEdit->document(), SIGNAL(undoAvailable(bool)), actionUndo, SLOT(setEnabled(bool))); connect(textEdit->document(), SIGNAL(redoAvailable(bool)), actionRedo, SLOT(setEnabled(bool))); setWindowModified(textEdit->document()->isModified()); actionSave->setEnabled(textEdit->document()->isModified()); actionUndo->setEnabled(textEdit->document()->isUndoAvailable()); actionRedo->setEnabled(textEdit->document()->isRedoAvailable()); connect(actionUndo, SIGNAL(triggered()), textEdit, SLOT(undo())); connect(actionRedo, SIGNAL(triggered()), textEdit, SLOT(redo())); actionCut->setEnabled(false); actionCopy->setEnabled(false); connect(actionCut, SIGNAL(triggered()), textEdit, SLOT(cut())); connect(actionCopy, SIGNAL(triggered()), textEdit, SLOT(copy())); connect(actionPaste, SIGNAL(triggered()), textEdit, SLOT(paste())); connect(textEdit, SIGNAL(copyAvailable(bool)), actionCut, SLOT(setEnabled(bool))); connect(textEdit, SIGNAL(copyAvailable(bool)), actionCopy, SLOT(setEnabled(bool))); #ifndef QT_NO_CLIPBOARD connect(QApplication::clipboard(), SIGNAL(dataChanged()), this, SLOT(clipboardDataChanged())); #endif //QString initialFile = ":/data/example.html"; QString initialFile = ":/data/test.txt"; const QStringList args = QCoreApplication::arguments(); if (args.count() == 2) initialFile = args.at(1); if (!load(initialFile)) fileNew(); }