QAction* CodeNavigator::configMenu(QWidget *parent) { static QAction *configAction = nullptr; if (!configAction) { configAction = new QAction(QIcon::fromTheme(QStringLiteral("applications-development")), QObject::tr("Code Navigation"), parent); auto menu = new QMenu(parent); auto group = new QActionGroup(parent); group->setExclusive(true); QSettings settings; settings.beginGroup(QStringLiteral("CodeNavigator")); const auto currentIdx = settings.value(QStringLiteral("IDE"), -1).toInt(); for (int i = 0; i < ide_settings_size; ++i) { auto action = new QAction(menu); action->setText(QObject::tr(ide_settings[i].name)); if (ide_settings[i].icon) action->setIcon(QIcon::fromTheme(ide_settings[i].icon)); action->setCheckable(true); action->setChecked(currentIdx == i); action->setData(i); action->setEnabled(!QStandardPaths::findExecutable(ide_settings[i].app).isEmpty()); group->addAction(action); menu->addAction(action); } menu->addSeparator(); auto action = new QAction(menu); action->setText(QObject::tr("Custom...")); action->setCheckable(true); action->setChecked(currentIdx == -1); group->addAction(action); menu->addAction(action); QObject::connect(group, &QActionGroup::triggered, [parent](QAction *action) { QSettings settings; settings.beginGroup(QStringLiteral("CodeNavigator")); if (!action->data().isValid()) { const auto customCmd = QInputDialog::getText( parent, QObject::tr("Custom Code Navigation"), QObject::tr("Specify command to use for code navigation, '%f' will be replaced by the file name, '%l' by the line number."), QLineEdit::Normal, settings.value(QStringLiteral("CustomCommand")).toString() ); if (!customCmd.isEmpty()) { settings.setValue(QStringLiteral("CustomCommand"), customCmd); settings.setValue(QStringLiteral("IDE"), -1); } return; } const auto defaultIdx = action->data().toInt(); settings.setValue(QStringLiteral("IDE"), defaultIdx); }); configAction->setMenu(menu); } return configAction; }
//***************************************************************************** bool Kwave::MenuItem::specialCommand(const QString &command) { Kwave::Parser parser(command); if (command == _("#checkable")) { // checking/selecting of the item (non-exclusive) setCheckable(true); } else if (parser.command() == _("#exclusive")) { // join to a list of groups QString group = parser.firstParam(); while (group.length()) { if (!m_exclusive_group.length()) { m_exclusive_group = group; joinGroup(group, Kwave::MenuGroup::EXCLUSIVE); } else if (m_exclusive_group != group) { qWarning("menu item '%s' already member of " "exclusive group '%s'", DBG(name()), DBG(m_exclusive_group)); } group = parser.nextParam(); } // make the item checkable setCheckable(true); return true; } else if (command == _("#hidden")) { setVisible(false); } return (Kwave::MenuNode::specialCommand(command)); }
DesktopSwitchButton::DesktopSwitchButton(QWidget * parent, int index, const QString &path, const QString &shortcut, const QString &title) : QToolButton(parent) , m_shortcut(0) , mIndex(index) { setText(QString::number(index + 1)); setCheckable(true); setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); if (!shortcut.isEmpty()) { QString description = tr("Switch to desktop %1").arg(index + 1); if (!title.isEmpty()) { description.append(QString(" (%1)").arg(title)); } m_shortcut = GlobalKeyShortcut::Client::instance()->addAction(QString(), path, description, this); if (m_shortcut) { if (m_shortcut->shortcut().isEmpty()) m_shortcut->changeShortcut(shortcut); connect(m_shortcut, SIGNAL(activated()), this, SIGNAL(activated())); } } if (!title.isEmpty()) { setToolTip(title); } }
StelShortcut::StelShortcut(const QString &id, StelShortcutGroup* group, const QString &text, const QString &primaryKey, const QString &altKey, bool checkable, bool autoRepeat, bool global, QGraphicsWidget *parent) : m_id(id), m_temporary(false) { if (parent == NULL) { parent = StelMainGraphicsView::getInstance().getStelAppGraphicsWidget(); } m_action = new QAction(parent); m_action->setObjectName(id); m_group = group; setText(text); setPrimaryKey(primaryKey); setAltKey(altKey); setCheckable(checkable); setAutoRepeat(autoRepeat); setGlobal(global); parent->addAction(m_action); }
void PageNavigator::makeNumberedButtons() { for (QAbstractButton * button : m_buttonGroup->buttons().toVector().toStdVector()) { m_buttonGroup->removeButton(button); if(button) { delete button; button = nullptr; } } int id = 0; QString num; for(int i = 0; i < m_numPagesListed; ++i) { auto button = new QPushButton(); button->setText(num.setNum(i+1)); button->setFixedSize(40,20); button->setCheckable(true); m_buttonLayout->addWidget(button); m_buttonGroup->addButton(button); m_buttonGroup->setId(button, id++); } if(m_buttonGroup->button(0)) { m_buttonGroup->button(0)->setChecked(true); } OS_ASSERT(m_numPagesListed == m_buttonGroup->buttons().size()); }
CSVWidget::PushButton::PushButton (const QIcon& icon, Type type, const QString& tooltip, QWidget *parent) : QPushButton (icon, "", parent), mKeepOpen (false), mType (type), mToolTip (tooltip) { setCheckable (type==Type_Mode); setExtendedToolTip (tooltip); }
void PatVerticalTabWidget::addTab( int id, QString toolTip, const QString & selectedImagePath, const QString & unSelectedImagePath, const QString & disabledImagePath, const QString & doneImagePath, bool enabled ) { auto button = new QPushButton(m_tabBar); button->setFixedSize(QSize(39,42)); button->setToolTip(toolTip); button->setCheckable(true); button->setEnabled(enabled); m_buttonGroup->addButton(button); m_buttonGroup->setId(button,m_buttonGroup->buttons().size() - 1); m_selectedPixmaps.push_back(selectedImagePath); m_unSelectedPixmaps.push_back(unSelectedImagePath); m_disabledPixmaps.push_back(disabledImagePath); m_donePixmaps.push_back(doneImagePath); setCurrentIndex(0); }
QFESPIMB040SimpleCameraConfig::QFESPIMB040SimpleCameraConfig(QWidget* parent): QGroupBox(parent) { m_camViewID=0; m_extManager=NULL; camView=NULL; locked=false; restartPreview=false; m_magnification=1; m_lastUserPreview=""; // initialize raw image memory ... viewData.reset(); // create widgets and actions createWidgets(); createActions(); displayStates(QFESPIMB040SimpleCameraConfig::Disconnected); if (cmbAcquisitionDevice->count()<=0) displayStates(QFESPIMB040SimpleCameraConfig::Inactive); init(0, NULL, "", NULL); setCheckable(true); setChecked(true); }
// Slots //============================================================ // Connected to this->customContextMenuRequested void Chain::Chain_Tableview::slot_customContextMenuRequested(QPoint const& pos) { // Assume this has the right model type and cast to it Chain_Table_Model* true_model = static_cast<Chain_Table_Model*>(this->model()); // Get the index at the given position QModelIndex index = this->indexAt(pos); // If the model correct and not nullptr, and the index we're at is within the chain data if (true_model && true_model->is_within_chain(index)) { // Make a context menu QMenu context_menu{}; // Add an action as a title that is the tooltip (date) of the given data point context_menu.addAction(true_model->get_tooltip(index))->setEnabled(false); context_menu.addSeparator(); // Make an action for setting the data and capture the pointer to it auto did_stuff_action = context_menu.addAction("Did Stuff?"); // Make that action checkable and set its state to that of the data did_stuff_action->setCheckable(true); did_stuff_action->setChecked(true_model->link_did_stuff(index)); // Connect the action to a lambda that will set the data appropriately when the action is triggered QObject::connect(did_stuff_action, &QAction::toggled, [true_model, &index] (bool state) { true_model->set_link_did_stuff(index, state); } ); // Execute the menu at the cursor position context_menu.exec(QCursor::pos()); // this one isn't putting the menu in the right place. //context_menu.exec(this->mapToGlobal(pos)); } }
GameButton::GameButton(int width, QString nom, QString desc, QString path, bool pwd, bool steam, QString gameID, QWidget *parent) : QCommandLinkButton (parent), nom (nom), desc (desc), path (path), pwd (pwd), steam (steam), gameID (gameID), proc (new QProcess(this)) { //Définition de l'apparence du bouton setMaximumSize(width / 21.875f, (width / 21.875f)); setIconSize(QSize(maximumWidth()-16, maximumHeight()-16)); setIcon(QIcon("./icons/" + nom + ".png")); setCheckable(true); //On définit le working directory du jeu représenté proc->setWorkingDirectory(QFileInfo(path).absolutePath()); //connexion signaux/slots connect(this, SIGNAL(clicked()), this, SLOT(click())); connect(proc, SIGNAL(error(QProcess::ProcessError)), this, SLOT(error(QProcess::ProcessError))); connect(proc, SIGNAL(started()), this, SLOT(started())); connect(proc, SIGNAL(finished(int)), this, SLOT(finished(int))); }
LayoutButton::LayoutButton(QString text, QWidget *parent) : QPushButton(parent) { setObjectName("LayoutButton"); setCheckable(true); m_text = text; m_iconLabel = new QLabel(this); QPixmap pix(":img/tick_hover.png"); m_iconLabel->setPixmap(pix); m_iconLabel->setMinimumSize(pix.size()); m_textLabel = new QLabel; m_textLabel->setObjectName("LayoutTextLabel"); m_textLabel->setText(text); m_iconLabel->hide(); QHBoxLayout* m_Layout = new QHBoxLayout; m_Layout->setContentsMargins(20, 0, 0, 0); m_Layout->setSpacing(0); m_Layout->addSpacing(5); m_Layout->addWidget(m_textLabel); m_Layout->addStretch(); setLayout(m_Layout); m_iconLabel->move(this->x() + 5, this->y() + 4); updateStyle(":/skin/layoutbutton.qss", this); }
void QtPropertyItem::ApplyDataFlags() { if(NULL != itemData) { int dataFlags = itemData->GetFlags(); if(dataFlags & QtPropertyData::FLAG_IS_CHECKABLE) { setCheckable(true); if(itemData->GetValue().toBool()) { setCheckState(Qt::Checked); } } if(dataFlags & QtPropertyData::FLAG_IS_DISABLED) { setEnabled(false); } if(dataFlags & QtPropertyData::FLAG_IS_NOT_EDITABLE) { setEditable(false); } } }
void RoundItemButton::initUI() { m_itemIcon->setFocusPolicy(Qt::NoFocus); m_itemIcon->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum); m_itemText->setWordWrap(true); m_itemText->setStyleSheet("color: rgba(255, 255, 255, 255);" "font-size:16px; margin:0 5px;"); m_itemText->setAlignment(Qt::AlignHCenter | Qt::AlignTop); m_itemText->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); QVBoxLayout *mainLayout = new QVBoxLayout; mainLayout->setMargin(0); mainLayout->addSpacing(10); mainLayout->addWidget(m_itemIcon); mainLayout->setAlignment(m_itemIcon, Qt::AlignHCenter); mainLayout->addWidget(m_itemText); setFocusPolicy(Qt::NoFocus); setFocusPolicy(Qt::StrongFocus); setLayout(mainLayout); setFixedSize(QSize(140, 140)); setCheckable(true); QGraphicsDropShadowEffect *nameShadow = new QGraphicsDropShadowEffect(m_itemText); nameShadow->setBlurRadius(16); nameShadow->setColor(QColor(0, 0, 0, 85)); nameShadow->setOffset(0, 4); // m_itemText->setGraphicsEffect(nameShadow); }
PokemonBoxButton::PokemonBoxButton(int num) : num(num) { setText(tr("e&%1").arg(num+1)); setIcon(Theme::WhiteBall()); setCheckable(true); setAcceptDrops(true); }
CWizToolButton(QWidget* parent = 0) : QPushButton(parent) { setFocusPolicy(Qt::NoFocus); setCheckable(true); setIconSize(QSize(24, 24)); setMaximumSize(24, 24); }
LXQtTaskButton::LXQtTaskButton(const WId window, LXQtTaskBar * taskbar, QWidget *parent) : QToolButton(parent), mWindow(window), mUrgencyHint(false), mOrigin(Qt::TopLeftCorner), mDrawPixmap(false), mParentTaskBar(taskbar), mPlugin(mParentTaskBar->plugin()), mDNDTimer(new QTimer(this)) { Q_ASSERT(taskbar); setCheckable(true); setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); setMinimumWidth(1); setMinimumHeight(1); setToolButtonStyle(Qt::ToolButtonTextBesideIcon); setAcceptDrops(true); updateText(); updateIcon(); mDNDTimer->setSingleShot(true); mDNDTimer->setInterval(700); connect(mDNDTimer, SIGNAL(timeout()), this, SLOT(activateWithDraggable())); connect(LXQt::Settings::globalSettings(), SIGNAL(iconThemeChanged()), this, SLOT(updateIcon())); connect(mParentTaskBar, &LXQtTaskBar::iconByClassChanged, this, &LXQtTaskButton::updateIcon); }
/*! Constructs a QtColorPicker widget. The popup will display a grid with \a cols columns, or if \a cols is -1, the number of columns will be calculated automatically. If \a enableColorDialog is true, the popup will also have a "More" button (signified by an ellipsis "...") that presents a QColorDialog when clicked. After constructing a QtColorPicker, call insertColor() to add individual colors to the popup grid, or call setStandardColors() to add all the standard colors in one go. The \a parent argument is passed to QFrame's constructor. \sa QFrame */ QtColorPicker::QtColorPicker(QWidget *parent, int cols, bool enableColorDialog) : QPushButton(parent), popup(0), withColorDialog(enableColorDialog), _labels(false) { setFocusPolicy(Qt::StrongFocus); setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Fixed); setAutoDefault(false); setAutoFillBackground(true); setCheckable(true); // Set text setText(tr("Black")); firstInserted = false; // Create and set icon col = Qt::black; dirty = true; // Create color grid popup and connect to it. popup = new ColorPickerPopup(this, cols, withColorDialog, this); connect(popup, SIGNAL(selected(const QColor &)), SLOT(setCurrentColor(const QColor &))); connect(popup, SIGNAL(hid()), SLOT(popupClosed())); // Connect this push button's pressed() signal. connect(this, SIGNAL(toggled(bool)), SLOT(buttonPressed(bool))); }
KexiToggleViewModeAction::KexiToggleViewModeAction( Kexi::ViewMode mode, QObject* parent)//, QObject* receiver, const char* slot) : QAction( KIcon(Kexi::iconNameForViewMode(mode)), Kexi::nameForViewMode(mode, true/*withAmpersand*/), parent) // , d( new Private ) { // d->mode = mode; // connect(this, SIGNAL(toggled(bool)), this, SLOT(slotToggled(bool))); // if (receiver && slot) // connect(this, SIGNAL(switchedTo(Kexi::ViewMode)), receiver, slot); setCheckable(true); if (mode == Kexi::DataViewMode) { setObjectName("view_data_mode"); setToolTip(i18n("Switch to data view")); setWhatsThis(i18n("Switches to data view.")); } else if (mode == Kexi::DesignViewMode) { setObjectName("view_design_mode"); setToolTip(i18n("Switch to design view")); setWhatsThis(i18n("Switches to design view.")); } else if (mode == Kexi::TextViewMode) { setObjectName("view_text_mode"); setToolTip(i18n("Switch to text view")); setWhatsThis(i18n("Switches to text view.")); } else { kWarning() << "KexiToggleViewModeAction: invalid mode " << mode; } }
AbstractMusicAction::AbstractMusicAction(const QString& text, SimpleEntryTool* tool) : KAction(text, tool) , m_isVoiceAware(false) , m_tool(tool) { setCheckable(true); }
MyPushButton::MyPushButton(int index) : QPushButton(0) { _index = index; setCheckable(true); setMaximumWidth(30); connect(this, SIGNAL(toggled(bool)), this, SLOT(handleClick())); }
RazorTaskButton::RazorTaskButton(const Window window, QWidget *parent) : QToolButton(parent), mWindow(window) { setCheckable(true); setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); setMinimumWidth(1); setMinimumHeight(1); setToolButtonStyle(Qt::ToolButtonTextBesideIcon); setAcceptDrops(true); updateText(); updateIcon(); connect(this, SIGNAL(clicked(bool)), this, SLOT(btnClicked(bool))); connect(this, SIGNAL(toggled(bool)), this, SLOT(checkedChanged(bool))); XWindowAttributes oldAttr; XGetWindowAttributes(QX11Info::display(), mWindow, &oldAttr); XSetWindowAttributes newAttr; newAttr.event_mask = oldAttr.your_event_mask | PropertyChangeMask; XChangeWindowAttributes(QX11Info::display(), mWindow, CWEventMask, &newAttr); setStyle(&mStyle); }
void CollapsibleInspectorHeader::createLayout() { setContentsMargins(0,0,0,0); setFixedHeight(50); setSizePolicy(QSizePolicy::Preferred,QSizePolicy::Fixed); setObjectName("CollapsibleInspectorHeader"); setCheckable(true); QHBoxLayout * mainHLayout = new QHBoxLayout(); mainHLayout->setContentsMargins(0,0,0,0); mainHLayout->setSpacing(10); setLayout(mainHLayout); // Arrow m_arrowLabel = new QLabel(); mainHLayout->addWidget(m_arrowLabel); // Name QLabel * textLabel = new QLabel(m_text); textLabel->setWordWrap(false); textLabel->setObjectName("H2"); mainHLayout->addWidget(textLabel); // Stretch mainHLayout->addStretch(); bool isConnected = connect(this,SIGNAL(toggled(bool)), this,SLOT(on_toggled(bool))); OS_ASSERT(isConnected); setChecked(false); }
RazorTaskButton::RazorTaskButton(const Window window, QWidget *parent) : QToolButton(parent), mWindow(window) { setCheckable(true); setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); setMinimumWidth(1); setMinimumHeight(1); setToolButtonStyle(Qt::ToolButtonTextBesideIcon); setAcceptDrops(true); updateText(); updateIcon(); connect(this, SIGNAL(clicked(bool)), this, SLOT(btnClicked(bool))); connect(this, SIGNAL(toggled(bool)), this, SLOT(checkedChanged(bool))); XSelectInput(QX11Info::display(), mWindow, EnterWindowMask|FocusChangeMask|PropertyChangeMask|StructureNotifyMask); XSetWindowAttributes attr; attr.event_mask = PropertyChangeMask; XChangeWindowAttributes(QX11Info::display(), QX11Info::appRootWindow(), CWEventMask, &attr); setStyle(&mStyle); }
QStatusButton::QStatusButton(int number,const QString &text,QWidget *parent): QToolButton(parent), m_number(QString::number(number)), m_text(text), m_flashTimer(new QTimeLine(1000,this)) { setFocusPolicy(Qt::NoFocus); setCheckable(true); QFont fnt=QApplication::font(); setFont(fnt); setStyleSheet(buttonSheet); m_flashTimer->setDirection(QTimeLine::Forward); m_flashTimer->setCurveShape(QTimeLine::SineCurve); m_flashTimer->setFrameRange(0,92); connect(m_flashTimer,SIGNAL(valueChanged(qreal)),this,SLOT(update())); connect(m_flashTimer,SIGNAL(finished()),this,SLOT(update())); m_label=new QLabel(this); fnt.setBold(true); fnt.setPixelSize(11); m_label->setFont(fnt); m_label->setAlignment(Qt::AlignCenter); m_label->setStyleSheet("background-color:#818181;color:white;border-radius:6px;padding-left:4px;padding:4px;"); m_label->setSizePolicy(QSizePolicy::Fixed,QSizePolicy::Fixed); m_label->hide(); }
wxQtAction::wxQtAction( wxMenu *parent, int id, const wxString &text, const wxString &help, wxItemKind kind, wxMenu *subMenu, wxMenuItem *handler ) : QAction( wxQtConvertString( text ), parent->GetHandle() ), wxQtSignalHandler< wxMenuItem >( handler ) { setStatusTip( wxQtConvertString( help )); if ( subMenu != NULL ) setMenu( subMenu->GetHandle() ); if ( id == wxID_SEPARATOR ) setSeparator( true ); switch ( kind ) { case wxITEM_SEPARATOR: setSeparator( true ); break; case wxITEM_CHECK: case wxITEM_RADIO: setCheckable( true ); break; case wxITEM_NORMAL: // Normal for a menu item. break; case wxITEM_DROPDOWN: case wxITEM_MAX: // Not applicable for menu items. break; } connect( this, &QAction::triggered, this, &wxQtAction::onActionTriggered ); }
/*! Constructor of the QtMultiSliderHelper. The \a parent object holds the Parent of the QAbstractButton. */ QtSvgToggleSwitch::QtSvgToggleSwitch(QWidget * parent) : QAbstractButton(parent) { m_rendererButtonOff = new QSvgRenderer(this); m_rendererButtonOn = new QSvgRenderer(this); setCheckable(true); }
TabButton::TabButton(QWidget *parent) : QPushButton(parent), isLeftBtnHold(false) { setFlat(true); setCheckable(true); setAutoExclusive(true); setAutoDefault(false); setAcceptDrops(true); parentHeight = QPushButton::sizeHint().height(); label = new QLabel(this); label->setPixmap(WulforUtil::getInstance()->getPixmap(WulforUtil::eiEDITDELETE).scaled(CLOSEPXWIDTH, CLOSEPXWIDTH, Qt::IgnoreAspectRatio, Qt::SmoothTransformation)); label->setFixedSize(QSize(LABELWIDTH, LABELWIDTH)); label->setAlignment(Qt::AlignCenter | Qt::AlignVCenter); px_label = new QLabel(this); px_label->setFixedSize(QSize(LABELWIDTH, LABELWIDTH)); px_label->setAlignment(Qt::AlignCenter | Qt::AlignVCenter); installEventFilter(this); label->installEventFilter(this); updateGeometry(); }
void CollapsibleInspectorHeader::createLayout() { setContentsMargins(0,0,0,0); setFixedHeight(50); setSizePolicy(QSizePolicy::Preferred,QSizePolicy::Fixed); setObjectName("CollapsibleInspectorHeader"); setCheckable(true); QHBoxLayout * mainHLayout = new QHBoxLayout(); mainHLayout->setContentsMargins(10,0,10,0); mainHLayout->setSpacing(7); setLayout(mainHLayout); // Arrow m_arrowLabel = new QLabel(); mainHLayout->addWidget(m_arrowLabel, 0, Qt::AlignLeft); // Name QLabel * textLabel = new QLabel(m_text); textLabel->setWordWrap(false); textLabel->setObjectName("H2"); mainHLayout->addWidget(textLabel, 0, Qt::AlignLeft); // Stretch mainHLayout->addStretch(); connect(this, &CollapsibleInspectorHeader::toggled, this, &CollapsibleInspectorHeader::on_toggled); setChecked(false); }
ByteSourceGuiButton::ByteSourceGuiButton(ByteSourceAbstract *bytesource, GuiHelper *nguiHelper, QWidget *parent) : QPushButton(parent) { byteSource = bytesource; guiHelper = nguiHelper; guidia = nullptr; localAction = nullptr; localAction = new(std::nothrow) QAction(tr(""), this); if (localAction == nullptr) { qFatal("Cannot allocate memory for QAction X{"); } localAction->setCheckable(true); setCheckable(true); setToolTip(tr("Configuration panel")); setIcon(QIcon(":/Images/icons/configure-5.png")); setMaximumWidth(25); //setDefaultAction(localAction); setFlat(true); gui = byteSource->getGui(); if (gui != nullptr) { connect(localAction, &QAction::toggled, this, &ByteSourceGuiButton::onToggle,Qt::UniqueConnection); connect(this, &ByteSourceGuiButton::toggled, this, &ByteSourceGuiButton::onToggle,Qt::UniqueConnection); } else { localAction->setToolTip(tr("No settings available for this source")); setDisabled(true); setVisible(false); } }
FixedCheckBox::FixedCheckBox(QWidget *parent) : QCheckBox(parent) { setCheckable(false); mDefaultValue = false; mTickState = false; }