/*! \reimp */ void QToolButton::actionEvent(QActionEvent *event) { Q_D(QToolButton); QAction *action = event->action(); switch (event->type()) { case QEvent::ActionChanged: if (action == d->defaultAction) setDefaultAction(action); // update button state break; case QEvent::ActionAdded: connect(action, SIGNAL(triggered()), this, SLOT(_q_actionTriggered())); break; case QEvent::ActionRemoved: if (d->defaultAction == action) d->defaultAction = 0; #ifndef QT_NO_MENU if (action == d->menuAction) d->menuAction = 0; #endif action->disconnect(this); break; default: ; } QAbstractButton::actionEvent(event); }
ActionLabel::ActionLabel(QAction *action, QWidget *parent) : QToolButton(parent) { init(); setDefaultAction(action); }
QuickLaunchButton::QuickLaunchButton(QuickLaunchAction * act, ILXQtPanelPlugin * plugin, QWidget * parent) : QToolButton(parent), mAct(act), mPlugin(plugin) { setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); setAcceptDrops(true); setAutoRaise(true); setDefaultAction(mAct); mAct->setParent(this); mMoveLeftAct = new QAction(XdgIcon::fromTheme("go-previous"), tr("Move left"), this); connect(mMoveLeftAct, SIGNAL(triggered()), this, SIGNAL(movedLeft())); mMoveRightAct = new QAction(XdgIcon::fromTheme("go-next"), tr("Move right"), this); connect(mMoveRightAct, SIGNAL(triggered()), this, SIGNAL(movedRight())); mDeleteAct = new QAction(XdgIcon::fromTheme("dialog-close"), tr("Remove from quicklaunch"), this); connect(mDeleteAct, SIGNAL(triggered()), this, SLOT(selfRemove())); addAction(mDeleteAct); mMenu = new QMenu(this); mMenu->addAction(mAct); mMenu->addSeparator(); mMenu->addAction(mMoveLeftAct); mMenu->addAction(mMoveRightAct); mMenu->addSeparator(); mMenu->addAction(mDeleteAct); setContextMenuPolicy(Qt::CustomContextMenu); connect(this, SIGNAL(customContextMenuRequested(const QPoint&)), this, SLOT(this_customContextMenuRequested(const QPoint&))); }
DockButton::DockButton(QAction *defaultAction, QWidget *parent) : QToolButton(parent) { Q_ASSERT(defaultAction); setDefaultAction(defaultAction); }
/** * Constructor. */ QG_GraphicView::QG_GraphicView(QWidget* parent, Qt::WindowFlags f, RS_Document* doc) :RS_GraphicView(parent, f) ,device("Mouse") ,curCad(new QCursor(QPixmap(":ui/cur_cad_bmp.png"), CURSOR_SIZE, CURSOR_SIZE)) ,curDel(new QCursor(QPixmap(":ui/cur_del_bmp.png"), CURSOR_SIZE, CURSOR_SIZE)) ,curSelect(new QCursor(QPixmap(":ui/cur_select_bmp.png"), CURSOR_SIZE, CURSOR_SIZE)) ,curMagnifier(new QCursor(QPixmap(":ui/cur_glass_bmp.png"), CURSOR_SIZE, CURSOR_SIZE)) ,curHand(new QCursor(QPixmap(":ui/cur_hand_bmp.png"), CURSOR_SIZE, CURSOR_SIZE)) ,redrawMethod(RS2::RedrawAll) ,isSmoothScrolling(false) { RS_DEBUG->print("QG_GraphicView::QG_GraphicView().."); if (doc) { setContainer(doc); doc->setGraphicView(this); setDefaultAction(new RS_ActionDefault(*doc, *this)); } setFactorX(4.0); setFactorY(4.0); setBorders(10, 10, 10, 10); setMouseTracking(true); setFocusPolicy(Qt::NoFocus); // SourceForge issue 45 (Left-mouse drag shrinks window) setAttribute(Qt::WA_NoMousePropagation); view_rect = LC_Rect(toGraph(0, 0), toGraph(getWidth(), getHeight())); }
void SBWidget::FoldTabClass (const TabClassInfo& tc, QAction *newAct) { if (!TabClass2Folder_.contains (tc.TabClass_)) { QAction *foldAct = new QAction (tc.VisibleName_, this); foldAct->setToolTip (tc.Description_); foldAct->setIcon (tc.Icon_); foldAct->setProperty ("Sidebar/TabClass", tc.TabClass_); connect (foldAct, SIGNAL (triggered ()), this, SLOT (showFolded ())); auto tb = new QToolButton; tb->setIconSize (IconSize_); tb->setDefaultAction (foldAct); TabClass2Folder_ [tc.TabClass_] = tb; Ui_.TabsLay_->insertWidget (0, tb); Q_FOREACH (QAction *act, TabClass2Action_ [tc.TabClass_]) AddToFolder (tc.TabClass_, act); } else AddToFolder (tc.TabClass_, newAct); }
void ComboBoxAction:: addActionItem( QAction* a ) { addAction( a ); if (0 == defaultAction()) setDefaultAction(a); }
void PHIAComboButton::setItems( const QStringList &list, int selected ) { if ( _popup ) delete _popup; _popup=new QMenu(); QActionGroup *group=new QActionGroup( _popup ); group->setExclusive( true ); QList <QAction*> actions; for ( int i=0; i<list.count();i++ ) { QAction *action=new QAction( list.at( i ), 0 ); action->setCheckable( true ); action->setData( i ); group->addAction( action ); if ( i==selected ) action->setChecked( true ); actions << action; } _popup->addActions( actions ); _popup->setMinimumWidth( 100 ); if ( actions.count() > selected ) setDefaultAction( actions.at( selected ) ); setMenu( _popup ); connect( _popup, SIGNAL( triggered( QAction* ) ), this, SIGNAL( selectedAction( QAction* ) ) ); }
AccessibleToolButton::AccessibleToolButton(QWidget* parent, QAction* defaultQAction ): QToolButton(parent) { setDefaultAction(defaultQAction); setFocusPolicy(Qt::TabFocus); setAccessibleName(defaultQAction->text()); setAccessibleDescription(defaultQAction->toolTip()); }
/** * \brief Construtor * @param parent as the parent widget * @param action as the related action * @param name as the related object name */ UBActionButton::UBActionButton(QWidget *parent, QAction* action, const char *name):QToolButton(parent) { setObjectName(name); addAction(action); setDefaultAction(action); setIconSize(QSize(BUTTON_SIZE, BUTTON_SIZE)); setToolButtonStyle(Qt::ToolButtonIconOnly); setStyleSheet(QString("QToolButton {color: white; font-weight: bold; font-family: Arial; background-color: transparent; border: none}")); setFocusPolicy(Qt::NoFocus); }
QToolButton* SBWidget::AddTabButton (QAction *act, QLayout *lay) { auto tb = new QToolButton; tb->setIconSize (IconSize_); tb->setDefaultAction (act); lay->addWidget (tb); return tb; }
void ComboBoxAction:: setCheckedAction( QAction* a ) { if (!actions().contains(a)) addActionItem(a); if (a != defaultAction()) { defaultAction()->setChecked(false); } setDefaultAction(a); a->setChecked(true); setChecked(true); }
SketchToolButton::SketchToolButton(const QString &imageName, QWidget *parent, QAction* defaultAction) : QToolButton(parent) { m_imageName = imageName; // nice to have for debugging setupIcons(imageName); //DebugDialog::debug(QString("%1 %2 %3 %4 %5 %6 %7").arg(imageName) //.arg(m_enabledImage.width()).arg(m_enabledImage.height()) //.arg(m_disabledImage.width()).arg(m_disabledImage.height()) //.arg(m_pressedImage.width()).arg(m_pressedImage.height())); if(defaultAction) { setDefaultAction(defaultAction); setText(defaultAction->text()); } }
void ComboBoxAction:: checkAction( QAction* a ) { if (a->isChecked()) { QList<QAction*> l = actions(); for (QList<QAction*>::iterator i = l.begin(); i!=l.end(); i++) if (*i != a) (*i)->setChecked( false ); } if (false == _decheckable) a->setChecked( true ); setDefaultAction( a ); }
SketchToolButton::SketchToolButton(const QString &imageName, QWidget *parent, QList<QAction*> menuActions) : QToolButton(parent) { m_imageName = imageName; // nice to have for debugging setupIcons(imageName); QMenu *menu = new QMenu(this); for(int i=0; i < menuActions.size(); i++) { QAction* act = menuActions[i]; menu->addAction(act); if(i==0) { setDefaultAction(act); } } setMenu(menu); connect(menu,SIGNAL(aboutToHide()),this,SLOT(setEnabledIconAux())); setPopupMode(QToolButton::MenuButtonPopup); }
void SBWidget::AddTrayAction (QAction *act) { connect (act, SIGNAL (destroyed (QObject*)), this, SLOT (handleTrayActDestroyed ())); auto tb = new QToolButton; const int w = maximumWidth () - TrayLay_->margin () * 4; tb->setMaximumSize (w, w); tb->setIconSize (IconSize_); tb->setAutoRaise (true); tb->setDefaultAction (act); tb->setPopupMode (QToolButton::DelayedPopup); TrayAct2Button_ [act] = tb; TrayLay_->addWidget (tb); }
void SBWidget::showFolded () { const auto& tc = sender ()-> property ("Sidebar/TabClass").toByteArray (); QWidget *w = new QWidget (0, Qt::Popup | Qt::FramelessWindowHint | Qt::WindowStaysOnTopHint); w->setWindowOpacity (0.85); w->installEventFilter (new ListEventFilter (w)); auto layout = new QVBoxLayout; layout->setSpacing (0); layout->setContentsMargins (0, 0, 0, 0); Q_FOREACH (QAction *act, TabClass2Action_ [tc]) { auto tb = new QToolButton; tb->setIconSize (IconSize_); tb->setToolButtonStyle (Qt::ToolButtonTextBesideIcon); tb->setDefaultAction (act); tb->setAutoRaise (true); tb->setSizePolicy (QSizePolicy::Expanding, tb->sizePolicy ().verticalPolicy ()); layout->addWidget (tb); QWidget *tabWidget = TabAction2Tab_ [act]; tb->setProperty ("Sidebar/TabPage", QVariant::fromValue<QWidget*> (tabWidget)); tb->setContextMenuPolicy (Qt::CustomContextMenu); connect (tb, SIGNAL (customContextMenuRequested (QPoint)), this, SLOT (handleTabContextMenu (QPoint))); connect (act, SIGNAL (triggered ()), w, SLOT (deleteLater ()), Qt::QueuedConnection); }
BackButton::BackButton(QWebView * webView, QWidget * parent) : QToolButton(parent) , m_webView(webView) { m_defaultAction = new QAction(this); m_defaultAction->setData(-1); setDefaultAction(m_defaultAction); setAutoRaise(true); setIcon(QIcon::fromTheme("go-previous", QIcon(":/go-previous.png"))); setToolTip(trUtf8("Go back")); setShortcut(QKeySequence::Back); setPopupMode(QToolButton::MenuButtonPopup); m_popupMenu = new Menu(this); setMenu(m_popupMenu); updateButton(); connect(m_webView, SIGNAL(urlChanged(const QUrl &)), this, SLOT(updateButton())); connect(m_defaultAction, SIGNAL(triggered()), this, SLOT(goBack())); connect(m_popupMenu, SIGNAL(aboutToShow()), this, SLOT(updatePopupMenu())); }
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(); }
/** * Constructor. */ QG_GraphicView::QG_GraphicView(QWidget* parent, Qt::WindowFlags f, RS_Document* doc) :RS_GraphicView(parent, f) ,hScrollBar(new QG_ScrollBar(Qt::Horizontal, this)) ,vScrollBar(new QG_ScrollBar(Qt::Vertical, this)) ,layout(new QGridLayout(this)) ,gridStatus(new QLabel("-", this)) ,curCad(new QCursor(QPixmap(":ui/cur_cad_bmp.png"), CURSOR_SIZE, CURSOR_SIZE)) ,curDel(new QCursor(QPixmap(":ui/cur_del_bmp.png"), CURSOR_SIZE, CURSOR_SIZE)) ,curSelect(new QCursor(QPixmap(":ui/cur_select_bmp.png"), CURSOR_SIZE, CURSOR_SIZE)) ,curMagnifier(new QCursor(QPixmap(":ui/cur_glass_bmp.png"), CURSOR_SIZE, CURSOR_SIZE)) ,curHand(new QCursor(QPixmap(":ui/cur_hand_bmp.png"), CURSOR_SIZE, CURSOR_SIZE)) ,redrawMethod(RS2::RedrawAll) ,isSmoothScrolling(false) { RS_DEBUG->print("QG_GraphicView::QG_GraphicView().."); RS_DEBUG->print(" Setting Container.."); if (doc) { setContainer(doc); doc->setGraphicView(this); } RS_DEBUG->print(" container set."); setFactorX(4.0); setFactorY(4.0); setOffset(50, 50); setBorders(10, 10, 10, 10); if (doc) { setDefaultAction(new RS_ActionDefault(*doc, *this)); } layout->setMargin(0); layout->setSpacing(0); layout->setColumnStretch(0, 1); layout->setColumnStretch(1, 0); layout->setColumnStretch(2, 0); layout->setRowStretch(0, 1); layout->setRowStretch(1, 0); hScrollBar->setSingleStep(50); hScrollBar->setCursor(Qt::ArrowCursor); layout->addWidget(hScrollBar, 1, 0); layout->addItem(new QSpacerItem(0, hScrollBar->sizeHint().height()), 1, 0); connect(hScrollBar, SIGNAL(valueChanged(int)), this, SLOT(slotHScrolled(int))); vScrollBar->setSingleStep(50); vScrollBar->setCursor(Qt::ArrowCursor); layout->addWidget(vScrollBar, 0, 2); layout->addItem(new QSpacerItem(vScrollBar->sizeHint().width(), 0), 0, 2); connect(vScrollBar, SIGNAL(valueChanged(int)), this, SLOT(slotVScrolled(int))); // Dummy widgets for scrollbar corners: //layout->addWidget(new QWidget(this), 1, 1); //QWidget* w = new QWidget(this); //w->setEraseColor(QColor(255,0,0)); gridStatus->setAlignment(Qt::AlignRight); layout->addWidget(gridStatus, 1, 1, 1, 2); layout->addItem(new QSpacerItem(50, 0), 0, 1); setMouseTracking(true); // flickering under win: //setFocusPolicy(WheelFocus); setFocusPolicy(Qt::NoFocus); // See https://sourceforge.net/tracker/?func=detail&aid=3289298&group_id=342582&atid=1433844 (Left-mouse drag shrinks window) setAttribute(Qt::WA_NoMousePropagation); int aa = RS_SETTINGS->readNumEntry("/Appearance/Antialiasing"); set_antialiasing(aa?true:false); }
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 (); }
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); }
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 CWizButton::setAction(QAction* action) { setDefaultAction(action); }
Configuration::Configuration() { setDebugMode(true); setDefaultAction(FilterRule::ACTION_ACCEPT); }