本文整理汇总了C++中KToolBar::addWidget方法的典型用法代码示例。如果您正苦于以下问题:C++ KToolBar::addWidget方法的具体用法?C++ KToolBar::addWidget怎么用?C++ KToolBar::addWidget使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类KToolBar
的用法示例。
在下文中一共展示了KToolBar::addWidget方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: QDialog
InteractiveConsole::InteractiveConsole(QWidget *parent)
: QDialog(parent),
m_splitter(new QSplitter(Qt::Vertical, this)),
m_editorPart(0),
m_editor(0),
m_output(0),
m_loadAction(KStandardAction::open(this, SLOT(openScriptFile()), this)),
m_saveAction(KStandardAction::saveAs(this, SLOT(saveScript()), this)),
m_clearAction(KStandardAction::clear(this, SLOT(clearEditor()), this)),
m_executeAction(new QAction(QIcon::fromTheme(QStringLiteral("system-run")), i18n("&Execute"), this)),
m_plasmaAction(new QAction(QIcon::fromTheme(QStringLiteral("plasma")), i18nc("Toolbar Button to switch to Plasma Scripting Mode", "Plasma"), this)),
m_kwinAction(new QAction(QIcon::fromTheme(QStringLiteral("kwin")), i18nc("Toolbar Button to switch to KWin Scripting Mode", "KWin"), this)),
m_snippetsMenu(new QMenu(i18n("Templates"), this)),
m_fileDialog(0),
m_closeWhenCompleted(false),
m_mode(PlasmaConsole)
{
addAction(KStandardAction::close(this, SLOT(close()), this));
addAction(m_saveAction);
addAction(m_clearAction);
setWindowTitle(i18n("Desktop Shell Scripting Console"));
setAttribute(Qt::WA_DeleteOnClose);
//setButtons(QDialog::None);
QWidget *widget = new QWidget(m_splitter);
QVBoxLayout *editorLayout = new QVBoxLayout(widget);
QLabel *label = new QLabel(i18n("Editor"), widget);
QFont f = label->font();
f.setBold(true);
label->setFont(f);
editorLayout->addWidget(label);
connect(m_snippetsMenu, &QMenu::aboutToShow, this, &InteractiveConsole::populateTemplatesMenu);
QToolButton *loadTemplateButton = new QToolButton(this);
loadTemplateButton->setPopupMode(QToolButton::InstantPopup);
loadTemplateButton->setMenu(m_snippetsMenu);
loadTemplateButton->setText(i18n("Load"));
connect(loadTemplateButton, &QToolButton::triggered, this, &InteractiveConsole::loadTemplate);
QToolButton *useTemplateButton = new QToolButton(this);
useTemplateButton->setPopupMode(QToolButton::InstantPopup);
useTemplateButton->setMenu(m_snippetsMenu);
useTemplateButton->setText(i18n("Use"));
connect(useTemplateButton, &QToolButton::triggered, this, &InteractiveConsole::useTemplate);
QActionGroup *modeGroup = new QActionGroup(this);
modeGroup->addAction(m_plasmaAction);
modeGroup->addAction(m_kwinAction);
m_plasmaAction->setCheckable(true);
m_kwinAction->setCheckable(true);
m_plasmaAction->setChecked(true);
connect(modeGroup, &QActionGroup::triggered, this, &InteractiveConsole::modeSelectionChanged);
KToolBar *toolBar = new KToolBar(this, true, false);
toolBar->setToolButtonStyle(Qt::ToolButtonTextBesideIcon);
toolBar->addAction(m_loadAction);
toolBar->addAction(m_saveAction);
toolBar->addAction(m_clearAction);
toolBar->addAction(m_executeAction);
toolBar->addAction(m_plasmaAction);
toolBar->addAction(m_kwinAction);
toolBar->addWidget(loadTemplateButton);
toolBar->addWidget(useTemplateButton);
editorLayout->addWidget(toolBar);
KService::List offers = KServiceTypeTrader::self()->query(QStringLiteral("KTextEditor/Document"));
foreach (const KService::Ptr service, offers) {
m_editorPart = service->createInstance<KTextEditor::Document>(widget);
if (m_editorPart) {
m_editorPart->setHighlightingMode(QStringLiteral("JavaScript/PlasmaDesktop"));
KTextEditor::View * view = m_editorPart->createView(widget);
view->setContextMenu(view->defaultContextMenu());
KTextEditor::ConfigInterface *config = qobject_cast<KTextEditor::ConfigInterface*>(view);
if (config) {
config->setConfigValue(QStringLiteral("line-numbers"), true);
config->setConfigValue(QStringLiteral("dynamic-word-wrap"), true);
}
editorLayout->addWidget(view);
connect(m_editorPart, &KTextEditor::Document::textChanged,
this, &InteractiveConsole::scriptTextChanged);
break;
}
}
示例2: QWidget
DynamicCategory::DynamicCategory( QWidget* parent )
: QWidget( parent )
, m_biasListView( 0 )
, m_biasModel( 0 )
, m_biasDelegate( 0 )
{
bool enabled = AmarokConfig::dynamicMode();
setContentsMargins(0,0,0,0);
m_vLayout = new QVBoxLayout( this );
m_onOffCheckbox = new QCheckBox( this );
m_onOffCheckbox->setIcon( KIcon( "dynamic-amarok" ) );
m_onOffCheckbox->setText( i18n( "On" ) );
m_onOffCheckbox->setToolTip( i18n( "Turn dynamic mode on." ) );
m_onOffCheckbox->setCheckable( true );
m_onOffCheckbox->setSizePolicy( QSizePolicy::Preferred, QSizePolicy::Fixed );
QObject::connect( m_onOffCheckbox, SIGNAL( toggled( bool ) ), this, SLOT( OnOff ( bool ) ) );
QObject::connect( (const QObject*)Amarok::actionCollection()->action( "playlist_clear" ), SIGNAL( triggered( bool ) ), this, SLOT( playlistCleared() ) );
m_repopulateButton = new QPushButton( this );
m_repopulateButton->setText( i18n("Repopulate") );
m_repopulateButton->setToolTip( i18n("Replace the upcoming tracks with fresh ones.") );
m_repopulateButton->setIcon( KIcon( "view-refresh-amarok" ) );
m_repopulateButton->setEnabled( enabled );
m_repopulateButton->setSizePolicy(
QSizePolicy( QSizePolicy::Preferred, QSizePolicy::Preferred ) );
QObject::connect( m_repopulateButton, SIGNAL( clicked(bool) ), The::playlistActions(), SLOT( repopulateDynamicPlaylist() ) );
KHBox* presetLayout = new KHBox( this );
QLabel* presetLabel = new QLabel( i18n( "Playlist:" ), presetLayout );
m_presetComboBox = new KComboBox( presetLayout );
m_presetComboBox->setPalette( QApplication::palette() );
DynamicModel::instance()->loadPlaylists();
m_presetComboBox->setModel( DynamicModel::instance() );
connect( DynamicModel::instance(), SIGNAL( changeActive( int ) ),
m_presetComboBox, SLOT(setCurrentIndex(int)) );
connect( DynamicModel::instance(), SIGNAL( enableDynamicMode( bool ) ),
SLOT(enableDynamicMode(bool)) );
connect( m_presetComboBox, SIGNAL(currentIndexChanged( int ) ),
this, SLOT(playlistSelectionChanged( int ) ) );
presetLabel->setBuddy( m_presetComboBox );
presetLayout->setStretchFactor( m_presetComboBox, 1 );
KToolBar* presetToolbar = new KToolBar( presetLayout );
presetToolbar->setToolButtonStyle( Qt::ToolButtonIconOnly );
presetToolbar->setMovable( false );
presetToolbar->setFloatable( false );
presetToolbar->setSizePolicy( QSizePolicy::MinimumExpanding, QSizePolicy::Preferred );
m_saveButton = new QToolButton( presetToolbar );
//m_saveButton->setText( i18n("Save") );
m_saveButton->setIcon( KIcon( "document-save-amarok" ) );
m_saveButton->setToolTip( i18n( "Save the preset." ) );
presetToolbar->addWidget( m_saveButton );
connect( m_saveButton, SIGNAL( clicked( bool ) ), SLOT( save() ) );
m_deleteButton = new QToolButton( presetToolbar );
//m_deleteButton->setText( i18n("Delete") );
m_deleteButton->setEnabled( false );
m_deleteButton->setIcon( KIcon( "edit-delete-amarok" ) );
m_deleteButton->setToolTip( i18n( "Delete the preset.") );
presetToolbar->addWidget( m_deleteButton );
connect( m_deleteButton, SIGNAL(clicked(bool)),
DynamicModel::instance(), SLOT(removeActive()) );
m_biasListView = new QListView( this );
m_biasListView->setFrameShape( QFrame::NoFrame );
m_biasListView->setAlternatingRowColors( true );
The::paletteHandler()->updateItemView( m_biasListView );
connect( The::paletteHandler(), SIGNAL( newPalette( const QPalette & ) ), SLOT( newPalette( const QPalette & ) ) );
m_biasModel = new DynamicBiasModel( m_biasListView );
m_biasListView->setModel( m_biasModel );
connect( m_biasModel, SIGNAL(playlistModified(Dynamic::BiasedPlaylistPtr)),
DynamicModel::instance(), SLOT(playlistModified(Dynamic::BiasedPlaylistPtr)) );
m_biasDelegate = new DynamicBiasDelegate( m_biasListView );
m_biasListView->setItemDelegate( m_biasDelegate );
m_vLayout->addWidget( m_onOffCheckbox );
//.........这里部分代码省略.........
示例3: BrowserCategory
PlaylistBrowserNS::DynamicCategory::DynamicCategory( QWidget* parent )
: BrowserCategory( "dynamic category", parent )
{
setPrettyName( i18n( "Dynamic Playlists" ) );
setShortDescription( i18n( "Dynamically updating parameter based playlists" ) );
setIcon( KIcon( "dynamic-amarok" ) );
setLongDescription( i18n( "With a dynamic playlist, Amarok becomes your own personal dj, automatically selecting tracks for you, based on a number of parameters that you select." ) );
setImagePath( KStandardDirs::locate( "data", "amarok/images/hover_info_dynamic_playlists.png" ) );
// set background
if( AmarokConfig::showBrowserBackgroundImage() )
setBackgroundImage( imagePath() );
bool enabled = AmarokConfig::dynamicMode();
setContentsMargins( 0, 0, 0, 0 );
KHBox* controls2Layout = new KHBox( this );
QLabel *label;
label = new QLabel( i18n( "Previous:" ), controls2Layout );
label->setAlignment( Qt::AlignRight | Qt::AlignVCenter );
m_previous = new QSpinBox( controls2Layout );
m_previous->setMinimum( 0 );
m_previous->setToolTip( i18n( "Number of previous tracks to remain in the playlist." ) );
m_previous->setValue( AmarokConfig::previousTracks() );
QObject::connect( m_previous, SIGNAL(valueChanged(int)), this, SLOT(setPreviousTracks(int)) );
label = new QLabel( i18n( "Upcoming:" ), controls2Layout );
// label->setSizePolicy( QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding );
label->setAlignment( Qt::AlignRight | Qt::AlignVCenter );
m_upcoming = new QSpinBox( controls2Layout );
m_upcoming->setMinimum( 1 );
m_upcoming->setToolTip( i18n( "Number of upcoming tracks to add to the playlist." ) );
m_upcoming->setValue( AmarokConfig::upcomingTracks() );
QObject::connect( m_upcoming, SIGNAL(valueChanged(int)), this, SLOT(setUpcomingTracks(int)) );
QObject::connect( (const QObject*)Amarok::actionCollection()->action( "playlist_clear" ), SIGNAL(triggered(bool)), this, SLOT(playlistCleared()) );
QObject::connect( (const QObject*)Amarok::actionCollection()->action( "disable_dynamic" ), SIGNAL(triggered(bool)), this, SLOT(playlistCleared()), Qt::DirectConnection );
// -- the tool bar
KHBox* presetLayout = new KHBox( this );
KToolBar* presetToolbar = new KToolBar( presetLayout );
presetToolbar->setIconSize( QSize( 22, 22 ) );
presetToolbar->setToolButtonStyle( Qt::ToolButtonIconOnly );
presetToolbar->setMovable( false );
presetToolbar->setFloatable( false );
presetToolbar->setSizePolicy( QSizePolicy::MinimumExpanding, QSizePolicy::Preferred );
m_onOffButton = new QToolButton( presetToolbar );
m_onOffButton->setText( i18nc( "Turn dynamic mode on", "On") );
m_onOffButton->setCheckable( true );
m_onOffButton->setIcon( KIcon( "dynamic-amarok" ) );
m_onOffButton->setToolTip( i18n( "Turn dynamic mode on." ) );
presetToolbar->addWidget( m_onOffButton );
m_duplicateButton = new QToolButton( presetToolbar );
m_duplicateButton->setText( i18n("Duplicates") );
m_duplicateButton->setCheckable( true );
m_duplicateButton->setChecked( allowDuplicates() );
m_duplicateButton->setIcon( KIcon( "edit-copy" ) );
m_duplicateButton->setToolTip( i18n( "Allow duplicate songs in result" ) );
presetToolbar->addWidget( m_duplicateButton );
m_addButton = new QToolButton( presetToolbar );
m_addButton->setText( i18n("New") );
m_addButton->setIcon( KIcon( "document-new" ) );
m_addButton->setToolTip( i18n( "New playlist" ) );
presetToolbar->addWidget( m_addButton );
m_editButton = new QToolButton( presetToolbar );
m_editButton->setText( i18n("Edit") );
m_editButton->setIcon( KIcon( "document-properties-amarok" ) );
m_editButton->setToolTip( i18n( "Edit the selected playlist or bias" ) );
presetToolbar->addWidget( m_editButton );
m_deleteButton = new QToolButton( presetToolbar );
m_deleteButton->setText( i18n("Delete") );
m_deleteButton->setEnabled( false );
m_deleteButton->setIcon( KIcon( "edit-delete" ) );
m_deleteButton->setToolTip( i18n( "Delete the selected playlist or bias") );
presetToolbar->addWidget( m_deleteButton );
m_repopulateButton = new QPushButton( presetLayout );
m_repopulateButton->setText( i18n("Repopulate") );
m_repopulateButton->setToolTip( i18n("Replace the upcoming tracks with fresh ones.") );
m_repopulateButton->setIcon( KIcon( "view-refresh-amarok" ) );
m_repopulateButton->setEnabled( enabled );
// m_repopulateButton->setSizePolicy( QSizePolicy( QSizePolicy::Preferred, QSizePolicy::Preferred ) );
QObject::connect( m_repopulateButton, SIGNAL(clicked(bool)), The::playlistActions(), SLOT(repopulateDynamicPlaylist()) );
//.........这里部分代码省略.........