本文整理汇总了C++中KPushButton类的典型用法代码示例。如果您正苦于以下问题:C++ KPushButton类的具体用法?C++ KPushButton怎么用?C++ KPushButton使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了KPushButton类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: QWidget
KSaneWidget::KSaneWidget(QWidget* parent)
: QWidget(parent), d(new KSaneWidgetPrivate)
{
KPushButton *openDialog = new KPushButton;
openDialog->setText(i18n("Open scan dialog"));
QHBoxLayout *lay = new QHBoxLayout;
lay->addWidget(openDialog);
setLayout(lay);
connect(openDialog, SIGNAL(clicked()), d, SLOT(ReOpenDialog()));
// Forward signals from the private class
//connect(d, SIGNAL(scanProgress(int)), this, SIGNAL(scanProgress(int)));
connect(d, SIGNAL(ImageReady(QByteArray &, int, int, int, int)),
this, SIGNAL(imageReady(QByteArray &, int, int, int, int)));
//connect(d, SIGNAL(scanDone(int, QString)), this, SIGNAL(scanDone(int, QString)));
}
示例2: KPushButton
void EstateDetails::addButton(QString command, QString caption, bool enabled)
{
KPushButton *button = new KPushButton(caption, this);
m_buttons.append(button);
m_buttonCommandMap[(QObject *)button] = command;
m_buttonBox->addWidget(button);
if (m_estate)
{
QColor bgColor, fgColor;
bgColor = m_estate->bgColor().light(110);
fgColor = ( bgColor.red() + bgColor.green() + bgColor.blue() < 255 ) ? Qt::white : Qt::black;
button->setPaletteForegroundColor( fgColor );
button->setPaletteBackgroundColor( bgColor );
}
button->setEnabled(enabled);
button->show();
connect(button, SIGNAL(pressed()), this, SLOT(buttonPressed()));
}
示例3: ConfigGui
ConfigGuiSunbird::ConfigGuiSunbird( const QSync::Member &member, QWidget *parent )
: ConfigGui( member, parent )
{
QTabWidget *tabWidget = new QTabWidget( this );
topLayout()->addWidget( tabWidget );
mLocalWidget = new QWidget( tabWidget );
mLocalLayout = new QVBoxLayout( mLocalWidget, KDialog::spacingHint() );
mWebdavWidget = new QWidget( tabWidget );
mWebdavLayout = new QVBoxLayout( mWebdavWidget, KDialog::spacingHint() );
tabWidget->addTab( mLocalWidget, i18n( "Local Calendars" ) );
tabWidget->addTab( mWebdavWidget, i18n( "WebDAV Calendars" ) );
KPushButton *mLocalAddButton = new KPushButton( mLocalWidget );
mLocalAddButton->setText( i18n( "Add new calendar" ) );
mLocalAddButton->setSizePolicy( QSizePolicy( QSizePolicy::Fixed, QSizePolicy::Fixed ) );
mLocalLayout->addWidget( mLocalAddButton );
connect( mLocalAddButton, SIGNAL( clicked() ),
this, SLOT( addLocalCalendar() ) );
KPushButton *mWebdavAddButton = new KPushButton( mWebdavWidget );
mWebdavAddButton->setText( i18n( "Add new calendar" ) );
mWebdavAddButton->setSizePolicy( QSizePolicy( QSizePolicy::Fixed, QSizePolicy::Fixed ) );
mWebdavLayout->addWidget( mWebdavAddButton );
connect( mWebdavAddButton, SIGNAL( clicked() ),
this, SLOT( addWebdavCalendar() ) );
mLocalSpacer = new QSpacerItem( 20, 40, QSizePolicy::Expanding );
mLocalLayout->addItem( mLocalSpacer );
mWebdavSpacer = new QSpacerItem( 20, 40, QSizePolicy::Expanding );
mWebdavLayout->addItem( mWebdavSpacer );
}
示例4: KMainWindow
MainWindow::MainWindow(QWidget *parent)
: KMainWindow(parent)
{
QWidget *central_widget = new QWidget(this);
QVBoxLayout *central_layout = new QVBoxLayout(this);
QHBoxLayout *h_layout = new QHBoxLayout(this);
QVBoxLayout *v_layout = new QVBoxLayout(this);
QHBoxLayout *layout = new QHBoxLayout(this);
layout->addWidget(new QLabel(i18n("tag:"), this));
layout->addWidget(tag = new KLineEdit(this));
v_layout->addLayout(layout);
layout = new QHBoxLayout(this);
layout->addWidget(new QLabel(i18n("text:"), this));
layout->addWidget(text = new KTextEdit(this));
text->setMaximumHeight(100);
v_layout->addLayout(layout);
h_layout->addLayout(v_layout);
KPushButton *button = new KPushButton(i18n("Search"), this);
connect(button, SIGNAL(clicked()), this, SLOT(query()));
h_layout->addWidget(button);
central_layout->addLayout(h_layout);
central_layout->addWidget(new QLabel(i18n("Result:"), this));
central_layout->addWidget(result = new KTextBrowser(this));
central_layout->addWidget(new QLabel(i18n("Url:"), this));
central_layout->addWidget(url = new KTextBrowser(this));
central_widget->setLayout(central_layout);
setCentralWidget(central_widget);
setMinimumSize(650,485);
if (Nepomuk2::ResourceManager::instance()->init())
button->setEnabled(false);
}
示例5: QHBoxLayout
void LocalCalendar::initGui()
{
QBoxLayout *bottomLayout = new QHBoxLayout();
mDaysCheckBox = new QCheckBox( this );
mDaysCheckBox->setText( i18n( "Sync only events newer than" ) );
mDaysSpinBox = new QSpinBox( this );
mDaysSpinBox->setDisabled( true );
mDaysSpinBox->setSizePolicy( QSizePolicy( QSizePolicy::Fixed, QSizePolicy::Fixed ) );
connect( mDaysCheckBox, SIGNAL( toggled( bool ) ),
this, SLOT( toggleDays( bool ) ) );
bottomLayout->addWidget( mDaysCheckBox );
bottomLayout->addWidget( mDaysSpinBox );
bottomLayout->addWidget( new QLabel( i18n( "day(s)" ), this ) );
QGridLayout *localLayout = new QGridLayout( this );
mPathRequester = new KURLRequester( this );
KPushButton *removeButton = new KPushButton( this );
removeButton->setSizePolicy( QSizePolicy( QSizePolicy::Fixed, QSizePolicy::Fixed ) );
removeButton->setText( i18n( "Remove" ) );
connect( removeButton, SIGNAL( clicked() ),
this, SLOT( deleteWidget() ) );
mDefaultCheckBox = new QCheckBox( this );
mDefaultCheckBox->setText( i18n( "Set as Default" ) );
localLayout->addItem( new QSpacerItem( 40, 20, QSizePolicy::Expanding ), 0, 0 );
localLayout->addWidget( new QLabel( i18n( "Location:" ), this ), 1, 0 );
localLayout->addWidget( mPathRequester, 1, 1 );
localLayout->addItem( new QSpacerItem( 40, 20, QSizePolicy::Fixed ), 1, 2 );
localLayout->addWidget( removeButton, 1, 3 );
localLayout->addMultiCellLayout( bottomLayout, 2, 2, 0, 2 );
localLayout->addWidget( mDefaultCheckBox, 2, 3 );
}
示例6: KSqueezedTextLabel
QList<QWidget*> CommentItemsViewDelegate::createItemWidgets() const
{
QList<QWidget*> list;
KSqueezedTextLabel* author = new KSqueezedTextLabel();
author->setOpenExternalLinks( true );
// not so nice - work around constness to install the event filter
CommentItemsViewDelegate* delegate = const_cast<CommentItemsViewDelegate*>( this );
author->installEventFilter( delegate );
list << author;
KSqueezedTextLabel* title = new KSqueezedTextLabel();
title->setOpenExternalLinks( true );
list << title;
KSqueezedTextLabel* dateTime = new KSqueezedTextLabel();
dateTime->setOpenExternalLinks( true );
list << dateTime;
KSqueezedTextLabel* rating = new KSqueezedTextLabel();
rating->setOpenExternalLinks( true );
list << rating;
KSqueezedTextLabel* body = new KSqueezedTextLabel();
body->setOpenExternalLinks( true );
body->setSizePolicy( QSizePolicy::Maximum, QSizePolicy::MinimumExpanding );
list << body;
KPushButton* replyButton = new KPushButton();
replyButton->setSizePolicy( QSizePolicy::Maximum, QSizePolicy::MinimumExpanding );
list << replyButton;
setBlockedEventTypes( replyButton, QList<QEvent::Type>() << QEvent::MouseButtonPress
<< QEvent::MouseButtonRelease << QEvent::MouseButtonDblClick );
connect( replyButton, SIGNAL( clicked() ), SLOT( slotReplyClicked() ) );
return list;
}
示例7: updateItemWidgets
void ServiceItemDelegate::updateItemWidgets(const QList<QWidget*> widgets,
const QStyleOptionViewItem& option,
const QPersistentModelIndex& index) const
{
QCheckBox* checkBox = static_cast<QCheckBox*>(widgets[0]);
KPushButton *configureButton = static_cast<KPushButton*>(widgets[1]);
const int itemHeight = sizeHint(option, index).height();
// Update the checkbox showing the service name and icon
const QAbstractItemModel* model = index.model();
checkBox->setText(model->data(index).toString());
const QString iconName = model->data(index, Qt::DecorationRole).toString();
if (!iconName.isEmpty()) {
checkBox->setIcon(KIcon(iconName));
}
checkBox->setChecked(model->data(index, Qt::CheckStateRole).toBool());
const bool configurable = model->data(index, ServiceModel::ConfigurableRole).toBool();
int checkBoxWidth = option.rect.width();
if (configurable) {
checkBoxWidth -= configureButton->sizeHint().width();
}
checkBox->resize(checkBoxWidth, checkBox->sizeHint().height());
checkBox->move(0, (itemHeight - checkBox->height()) / 2);
// Update the configuration button
if (configurable) {
configureButton->setEnabled(checkBox->isChecked());
configureButton->setIcon(KIcon("configure"));
configureButton->resize(configureButton->sizeHint());
configureButton->move(option.rect.right() - configureButton->width(),
(itemHeight - configureButton->height()) / 2);
}
configureButton->setVisible(configurable);
}
示例8: QFrame
void kiptablesgenerator::setupInterfacesPage()
{
interfacesPage = new QFrame(this);
QVBoxLayout *layout = new QVBoxLayout(interfacesPage);
QLabel *intro = new QLabel(i18n(
"<p>Which of the following interfaces do you want to filter?</p>"
"<p>It is strongly advised <b>not</b> to filter '<tt>lo</tt>'.</p>"), interfacesPage);
intro->show();
layout->addWidget(intro);
KListBox *interfaces = new KListBox(interfacesPage);
char buffer[IFNAMSIZ];
for(unsigned int i = 1; if_indextoname(i, buffer) != NULL; i++)
{
interfaces->insertItem((QString)buffer);
}
interfaces->setSelectionMode(QListBox::Multi);
for (unsigned short i = 0; i < interfaces->count(); i++)
if (interfaces->item(i)->text() != "lo")
interfaces->setSelected(i, true);
interfaces->show();
layout->addWidget(interfaces);
namedWidgets["iInterfaces"] = interfaces;
KPushButton *newInterface = new KPushButton(i18n("A&dd Interface..."), interfacesPage);
newInterface->show();
layout->addWidget(newInterface);
connect(newInterface, SIGNAL(clicked()), this, SLOT(slotNewInterface()));
interfacesPage->show();
this->addPage(interfacesPage, i18n("Interfaces"));
}
示例9: QVBox
SearchPane::SearchPane( FileBrowser *parent )
: QVBox( parent )
, m_lineEdit( 0 )
, m_listView( 0 )
, m_lister( 0 )
{
QFrame *container = new QVBox( this, "container" );
container->hide();
{
QFrame *box = new QHBox( container );
box->setMargin( 5 );
box->setBackgroundMode( Qt::PaletteBase );
m_lineEdit = new ClickLineEdit( i18n("Search here..."), box );
connect( m_lineEdit, SIGNAL(textChanged( const QString& )), SLOT(searchTextChanged( const QString& )) );
m_listView = new KURLView( container );
container->setFrameStyle( m_listView->frameStyle() );
container->setMargin( 5 );
container->setBackgroundMode( Qt::PaletteBase );
m_listView->setFrameStyle( QFrame::NoFrame );
connect( m_listView, SIGNAL(executed( QListViewItem* )), SLOT(activate( QListViewItem* )) );
}
KPushButton *button = new KPushButton( KGuiItem( i18n("&Show Search Panel"), "find" ), this );
button->setToggleButton( true );
connect( button, SIGNAL(toggled( bool )), SLOT(toggle( bool )) );
m_lister = new MyDirLister( true /*delay mimetypes*/ );
insertChild( m_lister );
connect( m_lister, SIGNAL(newItems( const KFileItemList& )), SLOT(searchMatches( const KFileItemList& )) );
connect( m_lister, SIGNAL(completed()), SLOT(searchComplete()) );
}
示例10: kDebug
void ItemsViewDelegate::updateItemWidgets( const QList<QWidget*> widgets,
const QStyleOptionViewItem& option,
const QPersistentModelIndex& index ) const
{
const GluonPlayer::GameItemsModel* model = qobject_cast<const GluonPlayer::GameItemsModel*>( index.model() );
if( !model )
{
kDebug() << "Warning - Invalid Model!";
return;
}
// setup the install button
int margin = option.fontMetrics.height() / 2;
int right = option.rect.width();
const_cast<QSize&>( m_buttonSize ) = QSize( 32, 32 );
KPushButton* playButton = qobject_cast<KPushButton*>( widgets.at( DelegatePlayButton ) );
if( playButton )
{
playButton->setIcon( KIcon( "media-playback-start" ) );
playButton->setSizePolicy( QSizePolicy::Maximum, QSizePolicy::MinimumExpanding );
playButton->resize( m_buttonSize );
playButton->move( right - playButton->width() - margin, option.fontMetrics.height() + playButton->height() * 0.5 );
}
GameTextLabel* gameName = qobject_cast<GameTextLabel*>( widgets.at( DelegateGameName ) );
// gameName->setWordWrap(true);
if( gameName )
{
gameName->move( margin + m_buttonSize.width() * 3, option.fontMetrics.height() );
gameName->resize( QSize( option.rect.width() - ( margin * 4 ) - m_buttonSize.width() * 4, option.fontMetrics.height() * 2 ) );
gameName->setText( index.data( GluonPlayer::GameItemsModel::GameNameRole ).toString() );
}
GameTextLabel* gameDescription = qobject_cast<GameTextLabel*>( widgets.at( DelegateGameDescription ) );
// gameName->setWordWrap(true);
if( gameDescription )
{
gameDescription->move( margin + m_buttonSize.width() * 3, option.fontMetrics.height() * 1 + gameName->size().height() );
gameDescription->resize( QSize( option.rect.width() - ( margin * 4 ) - m_buttonSize.width() * 4, option.fontMetrics.height() * 2 ) );
gameDescription->setText( index.data( GluonPlayer::GameItemsModel::GameDescriptionRole ).toString() );
}
}
示例11: KVBox
DietWizardDialog::DietWizardDialog( QWidget *parent, RecipeDB *db ) : KVBox( parent )
{
// Initialize internal variables
database = db;
mealNumber = 1;
dayNumber = 1;
dietRList = new RecipeList();
//Design the dialog
setSpacing( 5 );
// Options Box
optionsBox = new KHBox( this );
daysSliderBox = new QGroupBox( optionsBox );
daysSliderBox->setTitle( i18nc( "@label:slider", "Number of Days" ) );
QHBoxLayout *daysSliderBoxLayout = new QHBoxLayout;
daysSliderBox->setLayout( daysSliderBoxLayout );
dayNumberLabel = new QLabel;
dayNumberLabel->setText( "- 1 -" );
dayNumberLabel->setAlignment( Qt::AlignCenter );
dayNumberSelector = new QSlider;
daysSliderBoxLayout->addWidget( dayNumberSelector );
daysSliderBoxLayout->addWidget( dayNumberLabel );
dayNumberSelector->setOrientation( Qt::Horizontal );
dayNumberSelector->setRange( 1, 10 );
dayNumberSelector->setSingleStep( 1 );
dayNumberSelector->setPageStep( 1 );
dayNumberSelector->setTickPosition( QSlider::TicksBelow );
dayNumberSelector->setFixedWidth( 100 );
mealsSliderBox = new QGroupBox( optionsBox );
mealsSliderBox->setTitle( i18nc( "@label:slider", "Meals per Day" ) );
QHBoxLayout *mealsSliderBoxLayout = new QHBoxLayout;
mealsSliderBox->setLayout( mealsSliderBoxLayout );
mealNumberLabel = new QLabel;
mealNumberLabel->setText( "- 1 -" );
mealNumberLabel->setAlignment( Qt::AlignCenter );
mealNumberSelector = new QSlider;
mealsSliderBoxLayout->addWidget( mealNumberSelector );
mealsSliderBoxLayout->addWidget( mealNumberLabel );
mealNumberSelector->setOrientation( Qt::Horizontal );
mealNumberSelector->setRange( 1, 10 );
mealNumberSelector->setSingleStep( 1 );
mealNumberSelector->setPageStep( 1 );
mealNumberSelector->setTickPosition( QSlider::TicksBelow );
mealNumberSelector->setFixedWidth( 100 );
// Tabs
mealTabs = new KTabWidget( this );
mealTabs->setContentsMargins( 5 , 5, 5, 5 );
// Button bar
KHBox *bottom_layout = new KHBox( this );
//bottom_layout->layout()->addItem( new QSpacerItem( 10,10, QSizePolicy::MinimumExpanding, QSizePolicy::Fixed ) );
okButton = new KPushButton( bottom_layout );
okButton->setIcon( KIcon( "dialog-ok" ) );
okButton->setText( i18nc( "@action:button", "Create the diet" ) );
KPushButton *clearButton = new KPushButton( bottom_layout );
clearButton->setIcon( KIcon( "edit-clear" ) );
clearButton->setText( i18nc( "@action:button Clear Diet","Clear" ) );
// Create Tabs
//don't use newTab, it'll load data and we don't want it to do that at startup
mealTab = new MealInput( mealTabs, database );
// keep this string the same as when creating the other tabs to ease translation
mealTabs->addTab( mealTab, i18ncp( "@title:tab" , "Meal 1" , "Meal %1" , 1 ) );
mealTabs->setCurrentIndex( mealTabs->indexOf( mealTab ) );
// Signals & Slots
connect( mealNumberSelector, SIGNAL( valueChanged( int ) ), this, SLOT( changeMealNumber( int ) ) );
connect( dayNumberSelector, SIGNAL( valueChanged( int ) ), this, SLOT( changeDayNumber( int ) ) );
connect( okButton, SIGNAL( clicked() ), this, SLOT( createDiet() ) );
connect( clearButton, SIGNAL( clicked() ), this, SLOT( clear() ) );
}
示例12: QWidget
CKeyReferenceWidget::CKeyReferenceWidget( CSwordBibleModuleInfo *mod, CSwordVerseKey *key, QWidget *parent, const char *name) : QWidget(parent,name) {
updatelock = false;
m_module = mod;
setFocusPolicy(QWidget::WheelFocus);
// Erase button
KGuiItem erase_picture;
erase_picture.setIconName("locationbar_erase");
KPushButton *clearRef = new KPushButton(this);
clearRef->setGuiItem(erase_picture);
connect(clearRef, SIGNAL(clicked( ) ), SLOT(slotClearRef( )));
m_bookScroller = new CScrollerWidgetSet(this);
m_textbox = new CKeyReferenceLineEdit( this );
setKey(key); // The order of these two functions is important.
setModule();
m_chapterScroller = new CScrollerWidgetSet(this);
m_verseScroller = new CScrollerWidgetSet(this);
m_mainLayout = new QHBoxLayout( this );
m_mainLayout->addWidget(clearRef);
m_mainLayout->addWidget(m_bookScroller);
m_mainLayout->addWidget(m_textbox);
m_mainLayout->addWidget(m_chapterScroller);
m_mainLayout->addWidget(m_verseScroller);
setTabOrder(m_textbox, 0);
m_bookScroller->setToolTips(
CResMgr::displaywindows::bibleWindow::nextBook::tooltip,
CResMgr::displaywindows::general::scrollButton::tooltip,
CResMgr::displaywindows::bibleWindow::previousBook::tooltip
);
m_chapterScroller->setToolTips(
CResMgr::displaywindows::bibleWindow::nextChapter::tooltip,
CResMgr::displaywindows::general::scrollButton::tooltip,
CResMgr::displaywindows::bibleWindow::previousChapter::tooltip
);
m_verseScroller->setToolTips(
CResMgr::displaywindows::bibleWindow::nextVerse::tooltip,
CResMgr::displaywindows::general::scrollButton::tooltip,
CResMgr::displaywindows::bibleWindow::previousVerse::tooltip
);
// signals and slots connections
connect(m_bookScroller, SIGNAL(change(int)), SLOT(slotBookChange(int)));
connect(m_bookScroller, SIGNAL(scroller_pressed()), SLOT(slotUpdateLock()));
connect(m_bookScroller, SIGNAL(scroller_released()), SLOT(slotUpdateUnlock()));
connect(m_textbox, SIGNAL(returnPressed()), SLOT(slotReturnPressed()));
connect(m_chapterScroller, SIGNAL(change(int)), SLOT(slotChapterChange(int)));
connect(m_chapterScroller, SIGNAL(scroller_pressed()), SLOT(slotUpdateLock()));
connect(m_chapterScroller, SIGNAL(scroller_released()), SLOT(slotUpdateUnlock()));
connect(m_verseScroller, SIGNAL(change(int)), SLOT(slotVerseChange(int)));
connect(m_verseScroller, SIGNAL(scroller_pressed()), SLOT(slotUpdateLock()));
connect(m_verseScroller, SIGNAL(scroller_released()), SLOT(slotUpdateUnlock()));
}
示例13: KPushButton
void CommandMonitorItem::setupActions() {
KPushButton* btnView = new KPushButton();
btnView->setIcon(KIcon(KStandardDirs::locate( "appdata", "pixmap/22x22/eye.png")));
btnView->setMinimumSize(40,22);
btnView->setStyleSheet("border: 1px black solid;border-color:#555555;border-style:solid;border-radius:3px;");
actionLayout->addWidget(btnView);
QObject::connect(btnView, SIGNAL(clicked()), this, SLOT(connectTerm()));
KPushButton* btnStartNow = new KPushButton();
btnStartNow->setIcon(KIcon("arrow-right"));
btnStartNow->setMinimumSize(40,22);
btnStartNow->setStyleSheet("border: 1px black solid;border-color:#555555;border-style:solid;border-radius:3px;");
actionLayout->addWidget(btnStartNow);
KPushButton* btnPause = new KPushButton();
btnPause->setIcon(KIcon(KStandardDirs::locate( "appdata", "pixmap/22x22/pause.png")));
btnPause->setMinimumSize(40,22);
btnPause->setStyleSheet("border: 1px black solid;border-color:#555555;border-style:solid;border-radius:3px;");
actionLayout->addWidget(btnPause);
KPushButton* btnStop = new KPushButton();
btnStop->setIcon(KIcon("dialog-close"));
btnStop->setMinimumSize(40,22);
btnStop->setStyleSheet("border: 1px black solid;border-color:#555555;border-style:solid;border-radius:3px;");
actionLayout->addWidget(btnStop);
horizontalSpacer = new QSpacerItem(40, 20, QSizePolicy::Expanding, QSizePolicy::Minimum);
actionLayout->addItem(horizontalSpacer);
}
示例14: QWidget
CollectionSetup::CollectionSetup( QWidget *parent )
: QWidget( parent )
, m_rescanDirAction( new QAction( this ) )
{
m_ui.setupUi(this);
setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Expanding );
setObjectName( "CollectionSetup" );
s_instance = this;
if( KGlobalSettings::graphicEffectsLevel() != KGlobalSettings::NoEffects )
m_ui.view->setAnimated( true );
connect( m_ui.view, SIGNAL(clicked(QModelIndex)),
this, SIGNAL(changed()) );
connect( m_ui.view, SIGNAL(pressed(QModelIndex)),
this, SLOT(slotPressed(QModelIndex)) );
connect( m_rescanDirAction, SIGNAL(triggered()),
this, SLOT(slotRescanDirTriggered()) );
KPushButton *rescan = new KPushButton( KIcon( "collection-rescan-amarok" ), i18n( "Full rescan" ), m_ui.buttonContainer );
rescan->setToolTip( i18n( "Rescan your entire collection. This will <i>not</i> delete any statistics." ) );
connect( rescan, SIGNAL(clicked()), CollectionManager::instance(), SLOT(startFullScan()) );
KPushButton *import = new KPushButton( KIcon( "tools-wizard" ), i18n( "Import" ), m_ui.buttonContainer );
import->setToolTip( i18n( "Import collection and/or statistics from older Amarok versions, the batch scanner or media players." ) );
connect( import, SIGNAL(clicked()), this, SLOT(importCollection()) );
QHBoxLayout *buttonLayout = new QHBoxLayout();
buttonLayout->addWidget( rescan );
buttonLayout->addWidget( import );
m_ui.buttonContainer->setLayout( buttonLayout );
m_recursive = new QCheckBox( i18n("&Scan folders recursively (requires full rescan if newly checked)"), m_ui.checkboxContainer );
m_monitor = new QCheckBox( i18n("&Watch folders for changes"), m_ui.checkboxContainer );
connect( m_recursive, SIGNAL(toggled(bool)), this, SIGNAL(changed()) );
connect( m_monitor , SIGNAL(toggled(bool)), this, SIGNAL(changed()) );
QVBoxLayout *checkboxLayout = new QVBoxLayout();
checkboxLayout->addWidget( m_recursive );
checkboxLayout->addWidget( m_monitor );
m_ui.checkboxContainer->setLayout( checkboxLayout );
m_recursive->setToolTip( i18n( "If selected, Amarok will read all subfolders." ) );
m_monitor->setToolTip( i18n( "If selected, the collection folders will be watched "
"for changes.\nThe watcher will not notice changes behind symbolic links." ) );
m_recursive->setChecked( AmarokConfig::scanRecursively() );
m_monitor->setChecked( AmarokConfig::monitorChanges() );
// set the model _after_ constructing the checkboxes
m_model = new CollectionFolder::Model( this );
m_ui.view->setModel( m_model );
#ifndef Q_OS_WIN
m_ui.view->setRootIndex( m_model->setRootPath( QDir::rootPath() ) );
#else
m_ui.view->setRootIndex( m_model->setRootPath( m_model->myComputer().toString() ) );
#endif
Collections::Collection *primaryCollection = CollectionManager::instance()->primaryCollection();
QStringList dirs = primaryCollection ? primaryCollection->property( "collectionFolders" ).toStringList() : QStringList();
m_model->setDirectories( dirs );
// make sure that the tree is expanded to show all selected items
foreach( const QString &dir, dirs )
{
QModelIndex index = m_model->index( dir );
m_ui.view->scrollTo( index, QAbstractItemView::EnsureVisible );
}
示例15: KConfigDialog
AmarokConfigDialog::AmarokConfigDialog( QWidget *parent, const char* name, KConfigSkeleton *config )
: KConfigDialog( parent, name, config )
, m_engineConfig( 0 )
, m_opt4( 0 )
{
setWFlags( WDestructiveClose );
// IMPORTANT Don't simply change the page names, they are used as identifiers in other parts of the app.
m_opt1 = new Options1( 0, "General" );
m_opt2 = new Options2( 0, "Appearance" );
m_opt4 = new Options4( 0, "Playback" );
Options5 *opt5 = new Options5( 0, "OSD" );
QVBox *opt6 = new QVBox;
m_opt7 = new Options7( 0, "Collection" );
Options8 *opt8 = new Options8( 0, "Scrobbler" );
QVBox *opt9 = new QVBox;
// Sound System
opt6->setName( "Engine" );
opt6->setSpacing( KDialog::spacingHint() );
QWidget *groupBox, *aboutEngineButton;
groupBox = new QGroupBox( 2, Qt::Horizontal, i18n("Sound System"), opt6 );
m_engineConfigFrame = new QGroupBox( 1, Qt::Horizontal, opt6 );
m_soundSystem = new QComboBox( false, groupBox );
aboutEngineButton = new QPushButton( i18n("About"), groupBox );
QToolTip::add( m_soundSystem, i18n("Click to select the sound system to use for playback.") );
QToolTip::add( aboutEngineButton, i18n("Click to get the plugin information.") );
/// Populate the engine selection combo box
KTrader::OfferList offers = PluginManager::query( "[X-KDE-amaroK-plugintype] == 'engine'" );
KTrader::OfferList::ConstIterator end( offers.end() );
for( KTrader::OfferList::ConstIterator it = offers.begin(); it != end; ++it ) {
// Don't list the <no engine> (void engine) entry if it's not currenty active,
// cause there's no point in choosing this engine (it's a dummy, after all).
if( (*it)->property( "X-KDE-amaroK-name" ).toString() == "void-engine"
&& AmarokConfig::soundSystem() != "void-engine" ) continue;
m_soundSystem->insertItem( (*it)->name() );
// Save name properties in QMap for lookup
m_pluginName[(*it)->name()] = (*it)->property( "X-KDE-amaroK-name" ).toString();
m_pluginAmarokName[(*it)->property( "X-KDE-amaroK-name" ).toString()] = (*it)->name();
}
// Collection
#if !defined(USE_MYSQL) && !defined(USE_POSTGRESQL)
m_opt7->databaseBox->hide();
#endif
#ifndef USE_MYSQL
//FIXME we do this because this widget breaks the Apply button (always enabled).
//It breaks because it is set to type="password" in the .kcfg file. Setting to
//type="string" also fixes this bug, but means the password is stored in plain
//text. This is a temporary fix so that the majority of users get a fixed Apply
//button.
delete m_opt7->dbSetupFrame->kcfg_MySqlPassword2;
#endif
m_opt7->collectionFoldersBox->setColumns( 1 );
new CollectionSetup( m_opt7->collectionFoldersBox ); //TODO this widget doesn't update the apply/ok buttons
// Media Devices
opt9->setName( "Media Devices" );
opt9->setSpacing( KDialog::spacingHint() );
QVBox *topbox = new QVBox( opt9 );
topbox->setSpacing( KDialog::spacingHint() );
QGroupBox *mediaBox = new QGroupBox( 2, Qt::Horizontal, i18n("Media Devices"), topbox );
mediaBox->setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Minimum );
QVBox *vbox = new QVBox( mediaBox );
vbox->setSpacing( KDialog::spacingHint() );
m_deviceManager = new MediumPluginManager( vbox );
QHBox *hbox = new QHBox( topbox );
hbox->setSpacing( KDialog::spacingHint() );
hbox->setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Minimum );
KPushButton *autodetect = new KPushButton( i18n( "Autodetect Devices" ), hbox );
autodetect->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
connect( autodetect, SIGNAL(clicked()), m_deviceManager, SLOT(redetectDevices()) );
KPushButton *add = new KPushButton( i18n( "Add Device..." ), hbox );
add->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
connect( add, SIGNAL(clicked()), m_deviceManager, SLOT(newDevice()) );
QFrame *frame = new QFrame( topbox );
frame->setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Expanding );
// add pages
addPage( m_opt1, i18n( "General" ), "misc", i18n( "Configure General Options" ) );
addPage( m_opt2, i18n( "Appearance" ), "colors", i18n( "Configure amaroK's Appearance" ) );
addPage( m_opt4, i18n( "Playback" ), "kmix", i18n( "Configure Playback" ) );
addPage( opt5, i18n( "OSD" ), "tv", i18n( "Configure On-Screen-Display" ) );
addPage( opt6, i18n( "Engine" ), "amarok", i18n( "Configure Engine" ) );
addPage( m_opt7, i18n( "Collection" ), amaroK::icon( "collection" ), i18n( "Configure Collection" ) );
addPage( opt8, i18n( "last.fm" ), "audioscrobbler", i18n( "Configure last.fm Support" ) );
addPage( opt9, i18n( "Media Devices" ), amaroK::icon( "device" ), i18n( "Configure Portable Player Support" ) );
// Show information labels (must be done after insertions)
QObjectList *list = queryList( "QLabel", "infoPixmap" );
for( QObject *label = list->first(); label; label = list->next() )
static_cast<QLabel*>(label)->setPixmap( QMessageBox::standardIcon( QMessageBox::Information ) );
delete list;
//.........这里部分代码省略.........