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; }
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 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()); } } } }
//------------------------------------------------------------------------------ QWidget *FeedPropertiesDialog::createGeneralTab() { QWidget *tab = new QWidget(); QGridLayout *layoutGeneralGrid = new QGridLayout(); QLabel *labelTitleCapt = new QLabel(tr("Title:")); QLabel *labelHomepageCapt = new QLabel(tr("Homepage:")); QLabel *labelURLCapt = new QLabel(tr("Feed URL:")); QHBoxLayout *layoutGeneralTitle = new QHBoxLayout(); editTitle = new LineEdit(); ToolButton *loadTitleButton = new ToolButton(); loadTitleButton->setIcon(QIcon(":/images/updateFeed")); loadTitleButton->setIconSize(QSize(16, 16)); loadTitleButton->setToolTip(tr("Load Title")); loadTitleButton->setFocusPolicy(Qt::NoFocus); QMenu *selectIconMenu = new QMenu(); selectIconMenu->addAction(tr("Load Favicon")); selectIconMenu->addSeparator(); selectIconMenu->addAction(tr("Select Icon...")); selectIconButton_ = new QToolButton(this); selectIconButton_->setIconSize(QSize(16, 16)); selectIconButton_->setToolTip(tr("Select Icon")); selectIconButton_->setFocusPolicy(Qt::NoFocus); selectIconButton_->setPopupMode(QToolButton::MenuButtonPopup); selectIconButton_->setMenu(selectIconMenu); layoutGeneralTitle->addWidget(editTitle, 1); layoutGeneralTitle->addWidget(loadTitleButton); layoutGeneralTitle->addWidget(selectIconButton_); editURL = new LineEdit(); disableUpdate_ = new QCheckBox(tr("Disable update")); disableUpdate_->setChecked(false); updateEnable_ = new QCheckBox(tr("Automatically update every")); updateInterval_ = new QSpinBox(); updateInterval_->setEnabled(false); updateInterval_->setRange(1, 9999); connect(updateEnable_, SIGNAL(toggled(bool)), updateInterval_, SLOT(setEnabled(bool))); updateIntervalType_ = new QComboBox(this); updateIntervalType_->setEnabled(false); QStringList intervalTypeList; intervalTypeList << tr("seconds") << tr("minutes") << tr("hours"); updateIntervalType_->addItems(intervalTypeList); connect(updateEnable_, SIGNAL(toggled(bool)), updateIntervalType_, SLOT(setEnabled(bool))); QHBoxLayout *updateFeedsLayout = new QHBoxLayout(); updateFeedsLayout->setMargin(0); updateFeedsLayout->addWidget(updateEnable_); updateFeedsLayout->addWidget(updateInterval_); updateFeedsLayout->addWidget(updateIntervalType_); updateFeedsLayout->addStretch(); connect(disableUpdate_, SIGNAL(toggled(bool)), updateEnable_, SLOT(setDisabled(bool))); connect(disableUpdate_, SIGNAL(toggled(bool)), updateInterval_, SLOT(setDisabled(bool))); connect(disableUpdate_, SIGNAL(toggled(bool)), updateIntervalType_, SLOT(setDisabled(bool))); starredOn_ = new QCheckBox(tr("Starred")); displayOnStartup = new QCheckBox(tr("Display in new tab on startup")); duplicateNewsMode_ = new QCheckBox(tr("Automatically delete duplicate news")); QHBoxLayout *layoutGeneralHomepage = new QHBoxLayout(); labelHomepage = new QLabel(); labelHomepage->setOpenExternalLinks(true); layoutGeneralHomepage->addWidget(labelHomepageCapt); layoutGeneralHomepage->addWidget(labelHomepage, 1); layoutGeneralGrid->addWidget(labelTitleCapt, 0, 0); layoutGeneralGrid->addLayout(layoutGeneralTitle, 0 ,1); layoutGeneralGrid->addWidget(labelURLCapt, 1, 0); layoutGeneralGrid->addWidget(editURL, 1, 1); QVBoxLayout *tabLayout = new QVBoxLayout(tab); tabLayout->setMargin(10); tabLayout->setSpacing(5); tabLayout->addLayout(layoutGeneralGrid); tabLayout->addLayout(layoutGeneralHomepage); tabLayout->addSpacing(15); tabLayout->addWidget(disableUpdate_); tabLayout->addLayout(updateFeedsLayout); tabLayout->addSpacing(15); tabLayout->addWidget(starredOn_); tabLayout->addWidget(displayOnStartup); tabLayout->addWidget(duplicateNewsMode_); tabLayout->addStretch(); connect(loadTitleButton, SIGNAL(clicked()), this, SLOT(setDefaultTitle())); connect(selectIconButton_, SIGNAL(clicked()), this, SLOT(selectIcon())); connect(selectIconMenu->actions().at(0), SIGNAL(triggered()), this, SLOT(loadDefaultIcon())); connect(selectIconMenu->actions().at(2), SIGNAL(triggered()), this, SLOT(selectIcon())); if (!isFeed_) { loadTitleButton->hide(); selectIconButton_->hide(); labelURLCapt->hide(); editURL->hide(); labelHomepageCapt->hide(); labelHomepage->hide(); starredOn_->hide(); duplicateNewsMode_->hide(); } return tab; }