本文整理汇总了C++中KToolBar::addAction方法的典型用法代码示例。如果您正苦于以下问题:C++ KToolBar::addAction方法的具体用法?C++ KToolBar::addAction怎么用?C++ KToolBar::addAction使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类KToolBar
的用法示例。
在下文中一共展示了KToolBar::addAction方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: setupScriptPanel
QWidget* MainWindow::setupScriptPanel()
{
m_hScriptSplitter = new QSplitter(this);
m_hScriptSplitter->setOrientation(Qt::Horizontal);
KToolBar *executeCommands = new KToolBar(this);
executeCommands->setToolButtonStyle(Qt::ToolButtonTextUnderIcon);
executeCommands->setOrientation(Qt::Vertical);
m_runScript = new QAction(QIcon::fromTheme("media-playback-start"), i18nc("@action:intoolbar Script Execution", "Run"), this);
m_runScript->setToolTip(i18nc("@info:tooltip", "Execute currently active script on active graph document."));
m_stopScript = new QAction(QIcon::fromTheme("process-stop"), i18nc("@action:intoolbar Script Execution", "Stop"), this);
m_stopScript->setToolTip(i18nc("@info:tooltip", "Stop script execution."));
m_stopScript->setEnabled(false);
executeCommands->addAction(m_runScript);
executeCommands->addAction(m_stopScript);
// add actions to action collection to be able to set shortcuts on them in the ui
actionCollection()->addAction("_runScript", m_runScript);
actionCollection()->addAction("_stopScript", m_stopScript);
connect(m_runScript, &QAction::triggered, this, &MainWindow::executeScript);
connect(m_stopScript, &QAction::triggered, this, &MainWindow::stopScript);
m_hScriptSplitter->addWidget(m_codeEditorWidget);
m_hScriptSplitter->addWidget(m_outputWidget);
QWidget *scriptInterface = new QWidget(this);
scriptInterface->setLayout(new QHBoxLayout);
scriptInterface->layout()->addWidget(m_hScriptSplitter);
scriptInterface->layout()->addWidget(executeCommands);
return scriptInterface;
}
示例2: placesModel
FileBrowser::Private::Private( FileBrowser *parent )
: placesModel( 0 )
, showingPlaces( false )
, q( parent )
{
KHBox *topHBox = new KHBox( q );
KToolBar *navigationToolbar = new KToolBar( topHBox );
navigationToolbar->setToolButtonStyle( Qt::ToolButtonIconOnly );
navigationToolbar->setIconDimensions( 16 );
backAction = KStandardAction::back( q, SLOT(back()), topHBox );
forwardAction = KStandardAction::forward( q, SLOT(forward()), topHBox );
backAction->setEnabled( false );
forwardAction->setEnabled( false );
upAction = KStandardAction::up( q, SLOT(up()), topHBox );
homeAction = KStandardAction::home( q, SLOT(home()), topHBox );
placesAction = new KAction( KIcon( "folder-remote" ),
i18nc( "Show Dolphin Places the user configured", "Places" ),
topHBox );
navigationToolbar->addAction( backAction );
navigationToolbar->addAction( forwardAction );
navigationToolbar->addAction( upAction );
navigationToolbar->addAction( homeAction );
navigationToolbar->addAction( placesAction );
searchWidget = new SearchWidget( topHBox, false );
searchWidget->setClickMessage( i18n( "Filter Files" ) );
fileView = new FileView( q );
}
示例3: placesModel
FileBrowser::Private::Private( FileBrowser *parent )
: placesModel( 0 )
, q( parent )
{
KHBox *topHBox = new KHBox( q );
KToolBar *navigationToolbar = new KToolBar( topHBox );
navigationToolbar->setToolButtonStyle( Qt::ToolButtonIconOnly );
navigationToolbar->setIconDimensions( 16 );
backAction = KStandardAction::back( q, SLOT(back()), topHBox );
forwardAction = KStandardAction::forward( q, SLOT(forward()), topHBox );
backAction->setEnabled( false );
forwardAction->setEnabled( false );
upAction = KStandardAction::up( q, SLOT(up()), topHBox );
homeAction = KStandardAction::home( q, SLOT(home()), topHBox );
refreshAction = new KAction( KIcon("view-refresh"), i18n( "Refresh" ), topHBox );
QObject::connect( refreshAction, SIGNAL(triggered(bool)), q, SLOT(refresh()) );
navigationToolbar->addAction( backAction );
navigationToolbar->addAction( forwardAction );
navigationToolbar->addAction( upAction );
navigationToolbar->addAction( homeAction );
navigationToolbar->addAction( refreshAction );
searchWidget = new SearchWidget( topHBox, false );
searchWidget->setClickMessage( i18n( "Filter Files" ) );
fileView = new FileView( q );
}
示例4: KMainWindow
KUI_project::KUI_project(QWidget* parent): KMainWindow(parent)
{
model = 0;
trayIcon = new KSystemTrayIcon("media-playback-stop", 0 );
connect(trayIcon, SIGNAL( activated(QSystemTrayIcon::ActivationReason)),
this, SLOT( unhideSlot() ) );
path.append( QDir::homePath() );
recArea.setCoords( 0, 0, 0, 0);
setupConfig();
this->resize( 700, 300 );
collection = new KActionCollection(this);
setupCentralWidget();
menuBar = new KMenuBar;
setupMenuFile();
setupMenuWindow();
setupMenuSettings();
menuBar->addMenu(helpMenu());
this->setMenuBar(menuBar);
setupActions();
KToolBar *tools = new KToolBar(i18n("&Tools"), this);
tools->addAction(collection->action("new_file"));
tools->addAction(collection->action("open_file"));
tools->addAction(collection->action("add"));
collection->action("add")->setEnabled( false );
tools->addAction(collection->action("remove"));
collection->action("remove")->setEnabled( false );
//tools->addAction(collection->action("save_file"));
tools->setToolButtonStyle(Qt::ToolButtonIconOnly);
playBar = new MainToolBar( collection, this);
playBar->setAccessibleDescription("Play Bar");
this->addToolBar(Qt::BottomToolBarArea, playBar);
connect( playBar->timeSlider, SIGNAL( sliderMoved(int) ),
this, SLOT( seekSlot(int) ) );
}
示例5: QDockWidget
MessageDock::MessageDock( const QString& title, QWidget* parent, Qt::WindowFlags flags )
: QDockWidget( title, parent, flags ),
d( new MessageDockPrivate )
{
setObjectName( "MessageDock" );
d->view = new QListWidget( this );
d->view->addItem( new QListWidgetItem( i18n( "Welcome to Gluon Creator %1", GluonCore::Global::versionString() ), d->view ) );
d->view->setSelectionMode( QAbstractItemView::ExtendedSelection );
connect( GluonEngine::Game::instance(), SIGNAL( showDebug( const QString& ) ), SLOT( showDebug( const QString& ) ) );
QWidget* widget = new QWidget( this );
QVBoxLayout* layout = new QVBoxLayout();
layout->setContentsMargins( 0, 0, 0, 0 );
layout->setSpacing( 0 );
widget->setLayout( layout );
KToolBar* toolBar = new KToolBar( this );
toolBar->setIconDimensions( 16 );
QAction* selectAll = toolBar->addAction( KIcon( "edit-select-all" ), i18n( "Select All" ), this, SLOT( selectAll() ) );
d->view->addAction( selectAll );
QAction* copy = toolBar->addAction( KIcon( "edit-copy" ), i18n( "Copy" ), this, SLOT( copy() ) );
d->view->addAction( copy );
KAction* separator = new KAction( d->view );
separator->setSeparator( true );
d->view->addAction( separator );
QAction* clearSelection = toolBar->addAction( KIcon( "edit-clear-list" ), i18n( "Clear Selection" ), this, SLOT( clearSelection() ) );
d->view->addAction( clearSelection );
QAction* clearAll = toolBar->addAction( KIcon( "edit-clear" ), i18n( "Clear All" ), d->view, SLOT( clear() ) );
d->view->addAction( clearAll );
layout->addWidget( toolBar );
layout->addWidget( d->view );
setWidget( widget );
}
示例6: QWidget
DataOutputWidget::DataOutputWidget(QWidget *parent)
: QWidget(parent)
, m_model(new DataOutputModel(this))
, m_view(new DataOutputView(this))
, m_isEmpty(true)
{
m_view->setModel(m_model);
QHBoxLayout *layout = new QHBoxLayout(this);
m_dataLayout = new QVBoxLayout();
KToolBar *toolbar = new KToolBar(this);
toolbar->setOrientation(Qt::Vertical);
toolbar->setToolButtonStyle(Qt::ToolButtonIconOnly);
toolbar->setIconSize(QSize(16, 16));
/// TODO: disable actions if no results are displayed or selected
KAction *action;
action = new KAction( KIcon("distribute-horizontal-x"), i18nc("@action:intoolbar", "Resize columns to contents"), this);
toolbar->addAction(action);
connect(action, SIGNAL(triggered()), this, SLOT(resizeColumnsToContents()));
action = new KAction( KIcon("distribute-vertical-y"), i18nc("@action:intoolbar", "Resize rows to contents"), this);
toolbar->addAction(action);
connect(action, SIGNAL(triggered()), this, SLOT(resizeRowsToContents()));
action = new KAction( KIcon("edit-copy"), i18nc("@action:intoolbar", "Copy"), this);
toolbar->addAction(action);
m_view->addAction(action);
connect(action, SIGNAL(triggered()), this, SLOT(slotCopySelected()));
action = new KAction( KIcon("document-export-table"), i18nc("@action:intoolbar", "Export..."), this);
toolbar->addAction(action);
m_view->addAction(action);
connect(action, SIGNAL(triggered()), this, SLOT(slotExport()));
action = new KAction( KIcon("edit-clear"), i18nc("@action:intoolbar", "Clear"), this);
toolbar->addAction(action);
connect(action, SIGNAL(triggered()), this, SLOT(clearResults()));
toolbar->addSeparator();
KToggleAction *toggleAction = new KToggleAction( KIcon("applications-education-language"), i18nc("@action:intoolbar", "Use system locale"), this);
toolbar->addAction(toggleAction);
connect(toggleAction, SIGNAL(triggered()), this, SLOT(slotToggleLocale()));
m_dataLayout->addWidget(m_view);
layout->addWidget(toolbar);
layout->addLayout(m_dataLayout);
layout->setContentsMargins(0, 0, 0, 0);
setLayout(layout);
}
示例7: KMainWindow
FileDigger::FileDigger(MergedRepository *pRepository, QWidget *pParent)
: KMainWindow(pParent)
{
setWindowIcon(KIcon(QLatin1String("chronometer")));
KToolBar *lAppToolBar = toolBar();
lAppToolBar->addAction(KStandardAction::quit(this, SLOT(close()), this));
QSplitter *lSplitter = new QSplitter();
mMergedVfsModel = new MergedVfsModel(pRepository, this);
mMergedVfsView = new QTreeView();
mMergedVfsView->setHeaderHidden(true);
mMergedVfsView->setSelectionMode(QAbstractItemView::SingleSelection);
mMergedVfsView->setModel(mMergedVfsModel);
lSplitter->addWidget(mMergedVfsView);
connect(mMergedVfsView->selectionModel(), SIGNAL(currentChanged(QModelIndex,QModelIndex)),
this, SLOT(updateVersionModel(QModelIndex,QModelIndex)));
mVersionView = new QListView();
mVersionView->setSelectionMode(QAbstractItemView::SingleSelection);
mVersionModel = new VersionListModel(this);
mVersionView->setModel(mVersionModel);
VersionListDelegate *lVersionDelegate = new VersionListDelegate(mVersionView,this);
mVersionView->setItemDelegate(lVersionDelegate);
lSplitter->addWidget(mVersionView);
connect(lVersionDelegate, SIGNAL(openRequested(QModelIndex)), SLOT(open(QModelIndex)));
connect(lVersionDelegate, SIGNAL(restoreRequested(QModelIndex)), SLOT(restore(QModelIndex)));
mMergedVfsView->setFocus();
//expand all levels from the top until the node has more than one child
QModelIndex lIndex;
forever {
mMergedVfsView->expand(lIndex);
if(mMergedVfsModel->rowCount(lIndex) == 1) {
lIndex = mMergedVfsModel->index(0, 0, lIndex);
} else {
break;
}
}
mMergedVfsView->selectionModel()->setCurrentIndex(lIndex.child(0,0), QItemSelectionModel::Select);
setCentralWidget(lSplitter);
}
示例8: QDockWidget
KonsolePreviewer::KonsolePreviewer(const QString & title, QWidget *parent, const QString& projectType,
const QString& packagePath)
: QDockWidget(title, parent),
m_textEdit(0),
m_projectType(projectType),
m_packagePath(packagePath)
{
QVBoxLayout *layout = new QVBoxLayout();
KToolBar *toolBar = new KToolBar(this, true, true);
KAction *clear = KStandardAction::clear(this, SLOT(clearOutput()), this);
KAction *save = KStandardAction::save(this, SLOT(saveOutput()), this);
//we want those only for the kwin scripts
if (m_projectType == "KWin/Script") {
KAction *execute = new KAction(this);
execute->setText("Execute");
execute->setIcon(KIcon("system-run"));
connect(execute, SIGNAL(triggered(bool)), this, SLOT(executeKWinScript()));
//add it to toolbar
toolBar->addAction(execute);
}
示例9: fixedFont
TextOutputWidget::TextOutputWidget(QWidget *parent)
: QWidget(parent)
{
m_succesTextColor = QColor::fromRgb(3, 191, 3);
m_succesBackgroundColor = QColor::fromRgb(231, 247, 231);
m_errorTextColor = QColor::fromRgb(191, 3, 3);
m_errorBackgroundColor = QColor::fromRgb(247, 231, 231);
m_layout = new QHBoxLayout(this);
m_output = new QTextEdit();
m_output->setReadOnly(true);
QFont fixedFont(KGlobalSettings::fixedFont());
m_output->setCurrentFont(fixedFont);
KToolBar *toolbar = new KToolBar(this);
toolbar->setOrientation(Qt::Vertical);
toolbar->setToolButtonStyle(Qt::ToolButtonIconOnly);
toolbar->setIconSize(QSize(16, 16));
/// TODO: disable actions if no results are displayed
KAction *action;
action = new KAction( KIcon("edit-clear"), i18nc("@action:intoolbar", "Clear"), this);
toolbar->addAction(action);
connect(action, SIGNAL(triggered()), m_output, SLOT(clear()));
m_layout->addWidget(toolbar);
m_layout->addWidget(m_output, 1);
setLayout(m_layout);
}
示例10: KVBox
Playlist::Widget::Widget( QWidget* parent )
: KVBox( parent )
{
setContentsMargins( 1, 1, 1, 1 );
m_searchWidget = new ProgressiveSearchWidget( this );
//this is really only useful for debugging at the moment, so dont show it to users and testers
/*m_sortBox = new QComboBox( this );
m_sortBox->insertItem( 0, "Album", Album);
m_sortBox->insertItem( 1, "AlbumArtist", Album);
m_sortBox->insertItem( 2, "Artist", Artist );
m_sortBox->insertItem( 3, "Bitrate", Bitrate );
m_sortBox->insertItem( 4, "Bpm", Bpm );
m_sortBox->insertItem( 5, "Comment", Comment );
m_sortBox->insertItem( 6, "Composer", Composer );
m_sortBox->insertItem( 7, "Directory", Directory );
m_sortBox->insertItem( 8, "DiscNumber", DiscNumber );
m_sortBox->insertItem( 9, "Filename", Filename );
m_sortBox->insertItem( 10, "Filesize", Filesize );
m_sortBox->insertItem( 11, "Genre", Genre );
m_sortBox->insertItem( 12, "LastPlayed", LastPlayed );
m_sortBox->insertItem( 13, "Length", Length );
m_sortBox->insertItem( 14, "Mood", Mood );
m_sortBox->insertItem( 15, "PlayCount", PlayCount );
m_sortBox->insertItem( 16, "Rating", Rating );
m_sortBox->insertItem( 17, "SampleRate", SampleRate );
m_sortBox->insertItem( 18, "Score", Score );
m_sortBox->insertItem( 29, "Source", Source );
m_sortBox->insertItem( 30, "Title", Title );
m_sortBox->insertItem( 31, "TrackNumber", TrackNumber );
m_sortBox->insertItem( 32, "Type", Type );
m_sortBox->insertItem( 33, "Year", Year );
connect( m_sortBox, SIGNAL( activated( int ) ), this, SLOT( sort( int ) ) );*/
QWidget * layoutHolder = new QWidget( this );
QVBoxLayout* mainPlaylistlayout = new QVBoxLayout( layoutHolder );
mainPlaylistlayout->setContentsMargins( 0, 0, 0, 0 );
m_playlistView = new PrettyListView( this );
m_playlistView->show();
connect( m_searchWidget, SIGNAL( filterChanged( const QString &, int, bool ) ), m_playlistView, SLOT( find( const QString &, int, bool ) ) );
connect( m_searchWidget, SIGNAL( next( const QString &, int ) ), m_playlistView, SLOT( findNext( const QString &, int ) ) );
connect( m_searchWidget, SIGNAL( previous( const QString &, int ) ), m_playlistView, SLOT( findPrevious( const QString &, int ) ) );
connect( m_searchWidget, SIGNAL( filterCleared() ), m_playlistView, SLOT( clearSearchTerm() ) );
connect( m_searchWidget, SIGNAL( showOnlyMatches( bool ) ), m_playlistView, SLOT( showOnlyMatches( bool ) ) );
connect( m_searchWidget, SIGNAL( activateFilterResult() ), m_playlistView, SLOT( playFirstSelected() ) );
connect( m_searchWidget, SIGNAL( downPressed() ), m_playlistView, SLOT( setFocus() ) );
connect( m_playlistView, SIGNAL( found() ), m_searchWidget, SLOT( match() ) );
connect( m_playlistView, SIGNAL( notFound() ), m_searchWidget, SLOT( noMatch() ) );
connect( LayoutManager::instance(), SIGNAL( activeLayoutChanged() ), m_playlistView, SLOT( reset() ) );
mainPlaylistlayout->setSpacing( 0 );
mainPlaylistlayout->addWidget( m_playlistView );
KHBox *barBox = new KHBox( this );
barBox->setMargin( 0 );
KToolBar *plBar = new Amarok::ToolBar( barBox );
plBar->setObjectName( "PlaylistToolBar" );
Model::instance();
// the Controller ctor creates the undo/redo actions that we use below, so we want
// to make sure that it's been constructed and the the actions registered
Controller::instance();
{
//START Playlist toolbar
plBar->setSizePolicy( QSizePolicy::Minimum, QSizePolicy::Preferred );
plBar->setIconDimensions( 22 );
plBar->setMovable( false );
plBar->addAction( new KToolBarSpacerAction( this ) );
plBar->addAction( Amarok::actionCollection()->action( "playlist_clear" ) );
//FIXME this action should go in ActionController, but we don't have any visibility to the view
KAction *action = new KAction( KIcon( "music-amarok" ), i18n("Show active track"), this );
connect( action, SIGNAL( triggered( bool ) ), m_playlistView, SLOT( scrollToActiveTrack() ) );
plBar->addAction( action );
plBar->addSeparator();
plBar->addAction( Amarok::actionCollection()->action( "playlist_undo" ) );
plBar->addAction( Amarok::actionCollection()->action( "playlist_redo" ) );
plBar->addSeparator();
plBar->addAction( Amarok::actionCollection()->action( "playlist_save" ) );
plBar->addAction( Amarok::actionCollection()->action( "playlist_export" ) );
plBar->addSeparator();
Playlist::LayoutConfigAction *layoutConfigAction = new Playlist::LayoutConfigAction( this );
plBar->addAction( layoutConfigAction );
QToolButton *tbutton = qobject_cast<QToolButton*>(plBar->widgetForAction( layoutConfigAction ) );
if( tbutton )
tbutton->setPopupMode( QToolButton::InstantPopup );
//.........这里部分代码省略.........
示例11: 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;
}
}