void BookmarksToolbar::showBookmarkContextMenu(const QPoint &pos) { Q_UNUSED(pos) ToolButton* button = qobject_cast<ToolButton*>(sender()); if (!button) { return; } QVariant buttonPointer = QVariant::fromValue((void*) button); QMenu menu; menu.addAction(tr("Open bookmark"), this, SLOT(loadClickedBookmark()))->setData(buttonPointer); menu.addAction(tr("Open bookmark in new tab"), this, SLOT(loadClickedBookmarkInNewTab()))->setData(buttonPointer); menu.addSeparator(); menu.addAction(qIconProvider->fromTheme("go-next"), tr("Move right"), this, SLOT(moveRight()))->setData(buttonPointer); menu.addAction(qIconProvider->fromTheme("go-previous"), tr("Move left"), this, SLOT(moveLeft()))->setData(buttonPointer); menu.addAction(tr("Edit bookmark"), this, SLOT(editBookmark()))->setData(buttonPointer); menu.addSeparator(); menu.addAction(qIconProvider->fromTheme("list-remove"), tr("Remove bookmark"), this, SLOT(removeButton()))->setData(buttonPointer); //Prevent choosing first option with double rightclick QPoint position = button->mapToGlobal(pos); QPoint p(position.x(), position.y() + 1); menu.exec(p); }
void ToolBar::addAction(QAction* action) { ToolButton* button = new ToolButton(this); button->setAutoRaise(true); button->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Expanding); button->setDefaultAction(action); hbox->addWidget(button); }
MainWindow::MainWindow() : BWindow(BRect(0, 0, 300, 400), "Caya", B_TITLED_WINDOW, 0), fWorkspaceChanged(false) { fStatusView = new StatusView("statusView"); SearchBarTextControl* searchBox = new SearchBarTextControl(new BMessage(kSearchContact)); fListView = new RosterListView("buddyView"); fListView->SetInvocationMessage(new BMessage(CAYA_OPEN_CHAT_WINDOW)); BScrollView* scrollView = new BScrollView("scrollview", fListView, B_WILL_DRAW, false, true); // Wrench menu BPopUpMenu* wrenchMenu = new BPopUpMenu("Wrench"); (void)wrenchMenu->AddItem(new BMenuItem("About" B_UTF8_ELLIPSIS, new BMessage(B_ABOUT_REQUESTED))); (void)wrenchMenu->AddItem(new BSeparatorItem()); (void)wrenchMenu->AddItem(new BMenuItem("Preferences" B_UTF8_ELLIPSIS, new BMessage(CAYA_SHOW_SETTINGS))); (void)wrenchMenu->AddItem(new BSeparatorItem()); (void)wrenchMenu->AddItem(new BMenuItem("Quit", new BMessage(B_QUIT_REQUESTED))); wrenchMenu->SetTargetForItems(this); // Tool icon BResources* res = CayaResources(); BBitmap* toolIcon = IconFromResources(res, kToolIcon); delete res; // Wrench tool button ToolButton* wrench = new ToolButton(NULL, NULL); wrench->SetBitmap(toolIcon); wrench->SetMenu(wrenchMenu); SetLayout(new BGridLayout(1, 2)); AddChild(BGridLayoutBuilder(1, 2) .Add(searchBox, 0, 0) .Add(wrench, 1, 0) .Add(scrollView, 0, 1, 2) .Add(fStatusView, 0, 2, 2) .SetInsets(5, 5, 5, 10) ); AddShortcut('a', B_COMMAND_KEY, new BMessage(B_ABOUT_REQUESTED)); MoveTo(BAlert::AlertPosition(Bounds().Width(), Bounds().Height() / 2)); // Filter messages using Server fServer = new Server(); AddFilter(fServer); CenterOnScreen(); //TODO check for errors here ReplicantStatusView::InstallReplicant(); }
void ToolBox::AddButton(int id, wxString label, int width, wxBoxSizer *box, int pad, int height, wxPanel *pan) { if(pan == NULL) pan = activepanel; if(height == 0) height = buttonheight; //wxButton *button = new (_NORMAL_BLOCK, __FILE__, __LINE__) wxButton(pan, id, label, wxDefaultPosition, wxSize(width, height)); ToolButton *button = new ToolButton(pan, id, label, wxDefaultPosition, wxSize(width, height), mainwin->diagbox); button->SetFont(confont); box->Add(button, 0, wxALIGN_CENTRE_HORIZONTAL|wxALIGN_CENTRE_VERTICAL|wxTOP|wxBOTTOM, pad); }
PlotTab( bool parametric, QWidget *parent ): QMainWindow( parent ) { Plot *plot = new Plot( parametric, this ); setCentralWidget( plot ); QToolBar *toolBar = new QToolBar( this ); #ifndef QT_NO_PRINTER ToolButton *btnPrint = new ToolButton( "Print", toolBar ); toolBar->addWidget( btnPrint ); QObject::connect( btnPrint, SIGNAL( clicked() ), plot, SLOT( printPlot() ) ); #endif ToolButton *btnOverlay = new ToolButton( "Overlay", toolBar ); btnOverlay->setCheckable( true ); toolBar->addWidget( btnOverlay ); QObject::connect( btnOverlay, SIGNAL( toggled( bool ) ), plot, SLOT( setOverlaying( bool ) ) ); if ( parametric ) { QComboBox *parameterBox = new QComboBox( toolBar ); parameterBox->addItem( "Uniform" ); parameterBox->addItem( "Centripetral" ); parameterBox->addItem( "Chordal" ); parameterBox->addItem( "Manhattan" ); toolBar->addWidget( parameterBox ); connect( parameterBox, SIGNAL( activated( const QString & ) ), plot, SLOT( setParametric( const QString & ) ) ); parameterBox->setCurrentIndex( 2 ); // chordal plot->setParametric( parameterBox->currentText() ); ToolButton *btnClosed = new ToolButton( "Closed", toolBar ); btnClosed->setCheckable( true ); toolBar->addWidget( btnClosed ); QObject::connect( btnClosed, SIGNAL( toggled( bool ) ), plot, SLOT( setClosed( bool ) ) ); } QComboBox *boundaryBox = new QComboBox( toolBar ); boundaryBox->addItem( "Natural" ); boundaryBox->addItem( "Linear Runout" ); boundaryBox->addItem( "Parabolic Runout" ); boundaryBox->addItem( "Cubic Runout" ); boundaryBox->addItem( "Not a Knot" ); toolBar->addWidget( boundaryBox ); connect( boundaryBox, SIGNAL( activated( const QString & ) ), plot, SLOT( setBoundaryCondition( const QString & ) ) ); addToolBar( toolBar ); }
void BookmarksToolbar::loadClickedBookmark() { ToolButton* button = qobject_cast<ToolButton*>(sender()); if (!button) { return; } Bookmark bookmark = button->data().value<Bookmark>(); p_QupZilla->loadAddress(bookmark.url); }
void BookmarksToolbar::loadClickedBookmarkInNewTab() { ToolButton* button = qobject_cast<ToolButton*>(sender()); if (!button) { return; } Bookmark bookmark = button->data().value<Bookmark>(); p_QupZilla->tabWidget()->addView(bookmark.url); }
ToolButton* LauncherWidget::addToolButton(int w, int h, Webbox::Data::LaunchProperty *_p) // QString iconPath, QString buttonText) { QFont font = ProfileInstance().AppFont; font.setPointSize(11); //QPixmap p; //p.loadFromData(_p->getIcon()); ToolButton *btn = new ToolButton(w, h, QPixmap(Webbox::Config::AllCfg::getIconPath()+"/"+_p->icon_name)); btn->setText(_p->name_cn); btn->setFont(font); return btn; }
void BookmarksToolbar::editBookmark() { QAction* act = qobject_cast<QAction*> (sender()); if (!act) { return; } ToolButton* button = static_cast<ToolButton*>(act->data().value<void*>()); if (!button) { return; } Bookmark b = button->data().value<Bookmark>(); QDialog* dialog = new QDialog(this); QFormLayout* layout = new QFormLayout(dialog); QLabel* label = new QLabel(dialog); QLineEdit* editUrl = new QLineEdit(dialog); QLineEdit* editTitle = new QLineEdit(dialog); QDialogButtonBox* box = new QDialogButtonBox(dialog); box->addButton(QDialogButtonBox::Ok); box->addButton(QDialogButtonBox::Cancel); connect(box, SIGNAL(rejected()), dialog, SLOT(reject())); connect(box, SIGNAL(accepted()), dialog, SLOT(accept())); label->setText(tr("Edit bookmark: ")); layout->addRow(label); layout->addRow(new QLabel(tr("Title: ")), editTitle); layout->addRow(new QLabel(tr("Url: ")), editUrl); layout->addRow(box); editUrl->setText(b.url.toString()); editTitle->setText(b.title); editUrl->setCursorPosition(0); editTitle->setCursorPosition(0); dialog->setWindowTitle(tr("Edit Bookmark")); dialog->setMinimumSize(400, 100); dialog->exec(); if (dialog->result() == QDialog::Rejected) { return; } QUrl url = QUrl::fromEncoded(editUrl->text().toUtf8()); QString title = editTitle->text(); if (url.isEmpty() || title.isEmpty()) { return; } m_bookmarksModel->editBookmark(b.id, title, url, b.folder); }
void BookmarksToolbar::showOnlyIconsChanged() { m_toolButtonStyle = m_bookmarksModel->isShowingOnlyIconsInToolbar() ? Qt::ToolButtonIconOnly : Qt::ToolButtonTextBesideIcon; for (int i = 0; i < m_layout->count(); ++i) { ToolButton* button = qobject_cast<ToolButton*>(m_layout->itemAt(i)->widget()); if (!button) { continue; } button->setToolButtonStyle(m_toolButtonStyle); } }
void ToolSelectionWindow::_AddTool(const DrawingTool* tool) { BMessage* message = new BMessage(HS_TOOL_CHANGED); message->AddUInt32("buttons", 0); message->AddInt32(skTool, tool->Type()); ToolButton* button = new ToolButton(tool->Name(), message, tool->Icon()); button->ResizeToPreferred(); fMatrixView->AddSubView(button); gToolMap.insert(std::make_pair(tool->Type(), button)); }
PreferencesAccounts::PreferencesAccounts() : BView("Accounts", B_WILL_DRAW) { fListView = new BListView("accountsListView"); fListView->SetInvocationMessage(new BMessage(kEditAccount)); fListView->SetSelectionMessage(new BMessage(kSelect)); BScrollView* scrollView = new BScrollView("scrollView", fListView, B_WILL_DRAW, false, true); ProtocolManager* pm = ProtocolManager::Get(); fProtosMenu = new BPopUpMenu(NULL, true); for (uint32 i = 0; i < pm->CountProtocolAddOns(); i++) { CayaProtocolAddOn* addOn = pm->ProtocolAddOnAt(i); ProtocolSettings* settings = new ProtocolSettings(addOn); // Add accounts to list view _LoadListView(settings); // Add menu items BMessage* msg = new BMessage(kAddAccount); msg->AddPointer("settings", settings); BitmapMenuItem* item = new BitmapMenuItem( addOn->FriendlySignature(), msg, addOn->Icon()); fProtosMenu->AddItem(item); } ToolButton* proto = new ToolButton("+", NULL); proto->SetMenu(fProtosMenu); fDelButton = new ToolButton("-", new BMessage(kDelAccount)); fEditButton = new ToolButton("Edit...", new BMessage(kEditAccount)); fDelButton->SetEnabled(false); fEditButton->SetEnabled(false); const float spacing = be_control_look->DefaultItemSpacing(); SetLayout(new BGroupLayout(B_HORIZONTAL, spacing)); AddChild(BGroupLayoutBuilder(B_VERTICAL) .Add(scrollView) .AddGroup(B_HORIZONTAL, spacing) .Add(proto) .Add(fDelButton) .AddGlue() .Add(fEditButton) .End() .SetInsets(spacing, spacing, spacing, spacing) ); }
int BookmarksToolbar::indexOfLastBookmark() { for (int i = m_layout->count() - 1; i >= 0; i--) { ToolButton* button = qobject_cast<ToolButton*>(m_layout->itemAt(i)->widget()); if (!button) { continue; } if (!button->menu()) { return i + 1; } } return 0; }
void BookmarksToolbar::removeButton() { QAction* act = qobject_cast<QAction*> (sender()); if (!act) { return; } ToolButton* button = (ToolButton*) act->data().value<void*>(); if (!button) { return; } Bookmark bookmark = button->data().value<Bookmark>(); m_bookmarksModel->removeBookmark(bookmark.id); }
void BookmarksToolbar::folderDeleted(const QString &name) { int index = indexOfLastBookmark(); for (int i = index; i < m_layout->count(); i++) { ToolButton* button = qobject_cast<ToolButton*>(m_layout->itemAt(i)->widget()); if (!button) { continue; } if (button->text() == name) { delete button; return; } } }
void BookmarksToolbar::removeBookmark(const BookmarksModel::Bookmark &bookmark) { for (int i = 0; i < m_layout->count(); i++) { ToolButton* button = qobject_cast<ToolButton*>(m_layout->itemAt(i)->widget()); if (!button) { continue; } Bookmark book = button->data().value<Bookmark>(); if (book == bookmark) { delete button; return; } } }
void BookmarksToolbar::loadFolderBookmarksInTabs() { ToolButton* b = qobject_cast<ToolButton*>(sender()); if (!b) { return; } QString folder = b->text(); if (folder.isEmpty()) { return; } foreach (const Bookmark &b, m_bookmarksModel->folderBookmarks(folder)) { p_QupZilla->tabWidget()->addView(b.url, b.title, Qz::NT_NotSelectedTab); } }
void Xaman::initXamanButton () { QString consulta; consulta.append("SELECT * FROM xaman"); QSqlQuery consultar; consultar.prepare(consulta); if(!consultar.exec()){ QMessageBox::warning(this, "Error", "No se ha encontrado informaciĆ³n."); } //Configuracion de la tabla que contiene el estado de las maquinas int fila=0; int col=0; ui->tableWidget->setRowCount(0); ui->tableWidget->insertRow(0); ui->tableWidget->setRowHeight(0,80); //Ciclo por item de la lista de maquinas while(consultar.next()){ //Se crea el boton para representar a cada maquina //QToolButton *button = new QToolButton(ui->scrollArea); ToolButton *button = new ToolButton(ui->scrollArea); //qDebug() << consultar.value(0); //IP //qDebug() << consultar.value(1); //MAC //qDebug() << consultar.value(2); //Nombre del equipo //Configuraciones del boton button->setText(consultar.value(2).toString()); button->setIp(consultar.value(0).toString()); button->setMac(consultar.value(1).toString()); button->update(); if(col<9){ ui->tableWidget->setCellWidget(fila,col,button); ui->tableWidget->setColumnWidth(col,ui->tableWidget->width()/8); col++; if(col==8){ col=0; fila++; ui->tableWidget->insertRow(fila); ui->tableWidget->setRowHeight(fila,80); } } buttons.insert(num_clientes, button); num_clientes++; } }
void BookmarksToolbar::folderRenamed(const QString &before, const QString &after) { int index = indexOfLastBookmark(); for (int i = index; i < m_layout->count(); i++) { ToolButton* button = qobject_cast<ToolButton*>(m_layout->itemAt(i)->widget()); if (!button) { continue; } if (button->text() == before) { button->setText(after); button->menu()->setTitle(after); return; } } }
QWidget *LeftToolBox::createButton(const QString &name,QButtonGroup *group,const int id) { ToolButton *carButton = new ToolButton; carButton->setCheckable(true); carButton->setIcon(QIcon(QPixmap(name).scaled(30,30,Qt::KeepAspectRatio))); carButton->setIconSize(QSize(50,50)); if (group != 0){ group->addButton(carButton, id); } QGridLayout *layout = new QGridLayout; layout->addWidget(carButton,0,0,Qt::AlignHCenter); QWidget *widget = new QWidget; widget->setLayout(layout); return widget; }
Variant CreateDialog::get_drag_data_fw(const Point2 &p_point, Control *p_from) { TreeItem *ti = favorites->get_item_at_position(p_point); if (ti) { Dictionary d; d["type"] = "create_favorite_drag"; d["class"] = ti->get_text(0); ToolButton *tb = memnew(ToolButton); tb->set_icon(ti->get_icon(0)); tb->set_text(ti->get_text(0)); set_drag_preview(tb); return d; } return Variant(); }
void SetBackgrounds() { if (!mSkin) return; wxSize size = GetClientSize(); if (size!=mLastSize) { wxRect r( wxPoint(0,0), size ); mLastSize = size; for(int t=0;t<mTools.size();t++) { ToolButton *tool = mTools[t]->mTool; if (tool) tool->SetBackground(mSkin,r,tool->GetPosition()); } } }
void ToolBar::changeIconSizeSub(QLayout* layout, const QSize& iconSize) { int n = layout->count(); for(int i=0; i < n; ++i){ QLayoutItem* item = layout->itemAt(i); QLayout * childLayout = dynamic_cast<QLayout*>(item); if(childLayout){ changeIconSizeSub(childLayout, iconSize); } QWidgetItem* widgetItem = dynamic_cast<QWidgetItem*>(item); if(widgetItem){ QWidget* widget = widgetItem->widget(); ToolButton* button = dynamic_cast<ToolButton*>(widget); if(button){ button->setIconSize(mainWindow->iconSize()); } } } }
void BookmarksToolbar::loadClickedBookmarkInNewTab() { ToolButton* button = 0; QAction* act = qobject_cast<QAction*> (sender()); if (act) { button = static_cast<ToolButton*>(act->data().value<void*>()); } if (!button) { button = qobject_cast<ToolButton*>(sender()); } if (!button) { return; } Bookmark bookmark = button->data().value<Bookmark>(); p_QupZilla->tabWidget()->addView(bookmark.url, bookmark.title); }
void BookmarksToolbar::loadClickedBookmark() { ToolButton* button = 0; QAction* act = qobject_cast<QAction*> (sender()); if (act) { button = static_cast<ToolButton*>(act->data().value<void*>()); } if (!button) { button = qobject_cast<ToolButton*>(sender()); } if (!button) { return; } Bookmark bookmark = button->data().value<Bookmark>(); p_QupZilla->loadAddress(bookmark.url); }
void BookmarksToolbar::moveLeft() { QAction* act = qobject_cast<QAction*> (sender()); if (!act) { return; } ToolButton* button = static_cast<ToolButton*>(act->data().value<void*>()); int index = m_layout->indexOf(button); if (index == 0) { return; } ToolButton* buttonLeft = qobject_cast<ToolButton*> (m_layout->itemAt(index - 1)->widget()); if (!buttonLeft) { return; } Bookmark bookmark = button->data().value<Bookmark>(); Bookmark bookmarkLeft = buttonLeft->data().value<Bookmark>(); QSqlQuery query; query.prepare("UPDATE bookmarks SET position=? WHERE id=?"); query.addBindValue(index - 1); query.addBindValue(bookmark.id); mApp->dbWriter()->executeQuery(query); query.prepare("UPDATE bookmarks SET position=? WHERE id=?"); query.addBindValue(index); query.addBindValue(bookmarkLeft.id); mApp->dbWriter()->executeQuery(query); QWidget* w = m_layout->takeAt(index)->widget(); m_layout->insertWidget(index - 1, w); }
void BookmarksToolbar::moveRight() { QAction* act = qobject_cast<QAction*> (sender()); if (!act) { return; } ToolButton* button = (ToolButton*) act->data().value<void*>(); int index = m_layout->indexOf(button); if (index == m_layout->count() - 1) { return; } ToolButton* buttonRight = qobject_cast<ToolButton*> (m_layout->itemAt(index + 1)->widget()); if (!buttonRight || buttonRight->menu()) { return; } Bookmark bookmark = button->data().value<Bookmark>(); Bookmark bookmarkRight = buttonRight->data().value<Bookmark>(); QSqlQuery query; query.prepare("UPDATE bookmarks SET toolbar_position=? WHERE id=?"); query.addBindValue(index + 1); query.addBindValue(bookmark.id); mApp->dbWriter()->executeQuery(query); query.prepare("UPDATE bookmarks SET toolbar_position=? WHERE id=?"); query.addBindValue(index); query.addBindValue(bookmarkRight.id); mApp->dbWriter()->executeQuery(query); QWidget* w = m_layout->takeAt(index)->widget(); m_layout->insertWidget(index + 1, w); }
ToolButton* ToolBar::addButton(const QIcon& icon, const QString& tooltip) { ToolButton* button = new ToolButton(this); #ifdef Q_OS_MAC // Force auto-raize type if(dynamic_cast<QMacStyle*>(button->style())){ button->setStyle(&cleanlooks); } #endif button->setIconSize(mainWindow->iconSize()); button->setIcon(icon); button->setAutoRaise(true); button->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Expanding); if(!tooltip.isEmpty()){ button->setToolTip(tooltip); } hbox->addWidget(button); return button; }
void BookmarksToolbar::addBookmark(const BookmarksModel::Bookmark &bookmark) { if (bookmark.folder != "bookmarksToolbar") { return; } QString title = bookmark.title; if (title.length() > 15) { title.truncate(13); title += ".."; } QVariant v; v.setValue<Bookmark>(bookmark); ToolButton* button = new ToolButton(this); button->setText(title); button->setData(v); button->setIcon(bookmark.icon); button->setToolButtonStyle(Qt::ToolButtonTextBesideIcon); button->setToolTip(bookmark.url.toEncoded()); button->setAutoRaise(true); button->setWhatsThis(bookmark.title); button->setContextMenuPolicy(Qt::CustomContextMenu); connect(button, SIGNAL(clicked()), this, SLOT(loadClickedBookmark())); connect(button, SIGNAL(middleMouseClicked()), this, SLOT(loadClickedBookmarkInNewTab())); connect(button, SIGNAL(controlClicked()), this, SLOT(loadClickedBookmarkInNewTab())); connect(button, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(showBookmarkContextMenu(QPoint))); int indexForBookmark = indexOfLastBookmark(); m_layout->insertWidget(indexForBookmark, button); QSqlQuery query; query.prepare("UPDATE bookmarks SET toolbar_position=? WHERE id=?"); query.addBindValue(indexForBookmark); query.addBindValue(bookmark.id); mApp->dbWriter()->executeQuery(query); }
SizeGrip::SizeGrip(QWidget *parent) : QWidget(parent) { QBoxLayout *l=new QBoxLayout(QBoxLayout::TopToBottom, this); l->addItem(new QSpacerItem(1, 0, QSizePolicy::Maximum, QSizePolicy::Preferred)); QSizeGrip *grip=new QSizeGrip(this); l->addWidget(grip); l->setMargin(0); l->setSpacing(0); l->setAlignment(Qt::AlignBottom); ToolButton tb; tb.move(65535, 65535); tb.setToolButtonStyle(Qt::ToolButtonIconOnly); tb.setIcon(Icons::self()->albumIcon); tb.ensurePolished(); tb.setAttribute(Qt::WA_DontShowOnScreen); tb.setVisible(true); setMinimumWidth(qMax(grip->sizeHint().width(), tb.sizeHint().width())); setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Preferred); }