KTextEditor::View* HtmlEditor::createView( QWidget* parent ) { KTextEditor::Document *document = mEditor->createDocument( parent ); bool result = document->setHighlightingMode( "html" ); if ( result ) { kDebug() << "Syntax highlighting enabled"; } KTextEditor::View *view = document->createView( parent ); QMenu *menu = view->defaultContextMenu(); KTextEditor::ConfigInterface *interface = qobject_cast< KTextEditor::ConfigInterface* >( view ); if ( interface ) { KAction *actWordWrap = new KAction( i18n( "Dynamic Word Wrap" ), view ); actWordWrap->setCheckable( true ); connect( actWordWrap, SIGNAL(triggered(bool)), this, SLOT(toggleWordWrap()) ); KAction *actLineNumber = new KAction( i18n("Show line numbers"), view ); actLineNumber->setCheckable( true ); connect( actLineNumber, SIGNAL(triggered(bool)), this, SLOT(toggleLineNumber()) ); QMenu *options = new QMenu( i18n( "Options" ), qobject_cast< QWidget* >( view ) ); options->addAction( actWordWrap ); options->addAction( actLineNumber ); menu->addSeparator(); menu->addMenu( options ); interface->setConfigValue( "dynamic-word-wrap", true ); actWordWrap->setChecked( true ); } view->setContextMenu( menu ); return view; }
void TransfersView::populateHeaderActions() { m_headerMenu->clear(); m_headerMenu->addTitle(i18n("Select columns")); QSignalMapper *columnMapper = new QSignalMapper(this); connect(columnMapper, SIGNAL(mapped(int)), SLOT(slotHideSection(int))); //Create for each column an action with the column-header as name QVector<KAction*> orderedMenuItems(header()->count()); for (int i = 0; i < header()->count(); ++i) { KAction *action = new KAction(this); action->setText(model()->headerData(i, Qt::Horizontal).toString()); action->setCheckable(true); action->setChecked(!header()->isSectionHidden(i)); orderedMenuItems[header()->visualIndex(i)] = action; connect(action, SIGNAL(toggled(bool)), columnMapper, SLOT(map())); columnMapper->setMapping(action, i); } //append the sorted actions for (int i = 0; i < orderedMenuItems.count(); ++i) { m_headerMenu->addAction(orderedMenuItems[i]); } }
void KUI_project::setupMenuWindow() { KMenu *windowMenu = new KMenu(i18n("&Window"),this); KAction *showDesktop = new KAction(i18n("Show &Desktop"),this); showDesktop->setCheckable(true); showDesktop->setChecked(true); //connect(showDesktop, SIGNAL(triggered(bool)), defaultCentral, SLOT(screenVis())); windowMenu->addAction(showDesktop); KAction *showCamera = new KAction(i18n("Show &Camera"),this); showCamera->setCheckable(true); showCamera->setChecked(true); windowMenu->addAction(showCamera); //connect(showCamera, SIGNAL(triggered(bool)), defaultCentral, SLOT(cameraVis())); menuBar->addMenu(windowMenu); }
void ThemeManager::populateThemeMenu() { if (!d->themeMenuAction) return; QString theme(currentThemeName()); d->themeMenuAction->menu()->clear(); delete d->themeMenuActionGroup; d->themeMenuActionGroup = new QActionGroup(d->themeMenuAction); connect(d->themeMenuActionGroup, SIGNAL(triggered(QAction*)), this, SLOT(slotChangePalette())); KAction* action = new KAction(defaultThemeName(), d->themeMenuActionGroup); action->setCheckable(true); d->themeMenuAction->addAction(action); const QStringList schemeFiles = KGlobal::dirs()->findAllResources("data", "color-schemes/*.colors", KStandardDirs::NoDuplicates); QMap<QString, QAction*> actionMap; for (int i = 0; i < schemeFiles.size(); ++i) { const QString filename = schemeFiles.at(i); const QFileInfo info(filename); KSharedConfigPtr config = KSharedConfig::openConfig(filename); QIcon icon = createSchemePreviewIcon(config); KConfigGroup group(config, "General"); const QString name = group.readEntry("Name", info.baseName()); action = new KAction(name, d->themeMenuActionGroup); d->themeMap.insert(name, filename); action->setIcon(icon); action->setCheckable(true); actionMap.insert(name, action); } // sort the list QStringList actionMapKeys = actionMap.keys(); actionMapKeys.sort(); foreach(const QString& name, actionMapKeys) { d->themeMenuAction->addAction(actionMap.value(name)); }
KMarkNote::KMarkNote(QWidget* parent) : KXmlGuiWindow(parent) , isPreview(false) { KAction* previewAction = actionCollection()->addAction("file_preview", this, SLOT(togglePreview())); previewAction->setIcon(KIcon("document-preview")); previewAction->setText(i18n("Preview")); previewAction->setCheckable(true); m_view = new MainView(parent, previewAction); m_note = m_view->note; setupAction(); setupUI(); setupConnect(); }
void MediaPlayerActivity::setupActions() { play_action = new KAction(KIcon("media-playback-start"),i18n("Play"),this); connect(play_action,SIGNAL(triggered()),this,SLOT(play())); ac->addAction("media_play",play_action); pause_action = new KAction(KIcon("media-playback-pause"),i18n("Pause"),this); connect(pause_action,SIGNAL(triggered()),this,SLOT(pause())); ac->addAction("media_pause",pause_action); stop_action = new KAction(KIcon("media-playback-stop"),i18n("Stop"),this); connect(stop_action,SIGNAL(triggered()),this,SLOT(stop())); ac->addAction("media_stop",stop_action); prev_action = new KAction(KIcon("media-skip-backward"),i18n("Previous"),this); connect(prev_action,SIGNAL(triggered()),this,SLOT(prev())); ac->addAction("media_prev",prev_action); next_action = new KAction(KIcon("media-skip-forward"),i18n("Next"),this); connect(next_action,SIGNAL(triggered()),this,SLOT(next())); ac->addAction("media_next",next_action); show_video_action = new KToggleAction(KIcon("video-x-generic"),i18n("Show Video"),this); connect(show_video_action,SIGNAL(toggled(bool)),this,SLOT(showVideo(bool))); ac->addAction("show_video",show_video_action); add_media_action = new KAction(KIcon("document-open"),i18n("Add Media"),this); connect(add_media_action,SIGNAL(triggered()),play_list,SLOT(addMedia())); ac->addAction("add_media",add_media_action); clear_action = new KAction(KIcon("edit-clear-list"),i18n("Clear Playlist"),this); connect(clear_action,SIGNAL(triggered()),play_list,SLOT(clearPlayList())); ac->addAction("clear_play_list",clear_action); volume = new KAction(this); volume->setDefaultWidget(new Phonon::VolumeSlider(media_player->output(),this)); ac->addAction("volume",volume); KAction* tfs = new KAction(KIcon("view-fullscreen"),i18n("Toggle Fullscreen"),this); tfs->setShortcut(Qt::Key_F); tfs->setCheckable(true); ac->addAction("video_fullscreen", tfs); }
MediaWidget::MediaWidget(KMenu *menu_, KToolBar *toolBar, KActionCollection *collection, QWidget *parent) : QWidget(parent), menu(menu_), displayMode(NormalMode), automaticResize(ResizeOff), blockBackendUpdates(false), muted(false), screenSaverSuspended(false), showElapsedTime(true) { dummySource.reset(new MediaSource()); source = dummySource.data(); QBoxLayout *layout = new QVBoxLayout(this); layout->setMargin(0); QPalette palette = QWidget::palette(); palette.setColor(backgroundRole(), Qt::black); setPalette(palette); setAutoFillBackground(true); setAcceptDrops(true); setFocusPolicy(Qt::StrongFocus); backend = VlcMediaWidget::createVlcMediaWidget(this); if (backend == NULL) { backend = new DummyMediaWidget(this); } backend->connectToMediaWidget(this); layout->addWidget(backend); osdWidget = new OsdWidget(this); actionPrevious = new KAction(KIcon(QLatin1String("media-skip-backward")), i18n("Previous"), this); actionPrevious->setShortcut(KShortcut(Qt::Key_PageUp, Qt::Key_MediaPrevious)); connect(actionPrevious, SIGNAL(triggered()), this, SLOT(previous())); toolBar->addAction(collection->addAction(QLatin1String("controls_previous"), actionPrevious)); menu->addAction(actionPrevious); actionPlayPause = new KAction(this); actionPlayPause->setShortcut(KShortcut(Qt::Key_Space, Qt::Key_MediaPlay)); textPlay = i18n("Play"); textPause = i18n("Pause"); iconPlay = KIcon(QLatin1String("media-playback-start")); iconPause = KIcon(QLatin1String("media-playback-pause")); connect(actionPlayPause, SIGNAL(triggered(bool)), this, SLOT(pausedChanged(bool))); toolBar->addAction(collection->addAction(QLatin1String("controls_play_pause"), actionPlayPause)); menu->addAction(actionPlayPause); actionStop = new KAction(KIcon(QLatin1String("media-playback-stop")), i18n("Stop"), this); actionStop->setShortcut(KShortcut(Qt::Key_Backspace, Qt::Key_MediaStop)); connect(actionStop, SIGNAL(triggered()), this, SLOT(stop())); toolBar->addAction(collection->addAction(QLatin1String("controls_stop"), actionStop)); menu->addAction(actionStop); actionNext = new KAction(KIcon(QLatin1String("media-skip-forward")), i18n("Next"), this); actionNext->setShortcut(KShortcut(Qt::Key_PageDown, Qt::Key_MediaNext)); connect(actionNext, SIGNAL(triggered()), this, SLOT(next())); toolBar->addAction(collection->addAction(QLatin1String("controls_next"), actionNext)); menu->addAction(actionNext); menu->addSeparator(); fullScreenAction = new KAction(KIcon(QLatin1String("view-fullscreen")), i18nc("'Playback' menu", "Full Screen Mode"), this); fullScreenAction->setShortcut(Qt::Key_F); connect(fullScreenAction, SIGNAL(triggered()), this, SLOT(toggleFullScreen())); menu->addAction(collection->addAction(QLatin1String("view_fullscreen"), fullScreenAction)); minimalModeAction = new KAction(KIcon(QLatin1String("view-fullscreen")), i18nc("'Playback' menu", "Minimal Mode"), this); minimalModeAction->setShortcut(Qt::Key_Period); connect(minimalModeAction, SIGNAL(triggered()), this, SLOT(toggleMinimalMode())); menu->addAction(collection->addAction(QLatin1String("view_minimal_mode"), minimalModeAction)); audioStreamBox = new KComboBox(toolBar); connect(audioStreamBox, SIGNAL(currentIndexChanged(int)), this, SLOT(currentAudioStreamChanged(int))); toolBar->addWidget(audioStreamBox); audioStreamModel = new QStringListModel(toolBar); audioStreamBox->setModel(audioStreamModel); subtitleBox = new KComboBox(toolBar); textSubtitlesOff = i18nc("subtitle selection entry", "off"); connect(subtitleBox, SIGNAL(currentIndexChanged(int)), this, SLOT(currentSubtitleChanged(int))); toolBar->addWidget(subtitleBox); subtitleModel = new QStringListModel(toolBar); subtitleBox->setModel(subtitleModel); KMenu *audioMenu = new KMenu(i18nc("'Playback' menu", "Audio"), this); KAction *action = new KAction(KIcon(QLatin1String("audio-volume-high")), i18nc("'Audio' menu", "Increase Volume"), this); action->setShortcut(KShortcut(Qt::Key_Plus, Qt::Key_VolumeUp)); connect(action, SIGNAL(triggered()), this, SLOT(increaseVolume())); audioMenu->addAction(collection->addAction(QLatin1String("controls_increase_volume"), action)); action = new KAction(KIcon(QLatin1String("audio-volume-low")), i18nc("'Audio' menu", "Decrease Volume"), this); action->setShortcut(KShortcut(Qt::Key_Minus, Qt::Key_VolumeDown)); connect(action, SIGNAL(triggered()), this, SLOT(decreaseVolume())); audioMenu->addAction(collection->addAction(QLatin1String("controls_decrease_volume"), action)); muteAction = new KAction(i18nc("'Audio' menu", "Mute Volume"), this); mutedIcon = KIcon(QLatin1String("audio-volume-muted")); unmutedIcon = KIcon(QLatin1String("audio-volume-medium")); muteAction->setIcon(unmutedIcon); muteAction->setShortcut(KShortcut(Qt::Key_M, Qt::Key_VolumeMute)); connect(muteAction, SIGNAL(triggered()), this, SLOT(mutedChanged())); toolBar->addAction(collection->addAction(QLatin1String("controls_mute_volume"), muteAction)); audioMenu->addAction(muteAction); menu->addMenu(audioMenu); KMenu *videoMenu = new KMenu(i18nc("'Playback' menu", "Video"), this); menu->addMenu(videoMenu); menu->addSeparator(); deinterlaceAction = new KAction(KIcon(QLatin1String("format-justify-center")), i18nc("'Video' menu", "Deinterlace"), this); deinterlaceAction->setCheckable(true); deinterlaceAction->setChecked( KGlobal::config()->group("MediaObject").readEntry("Deinterlace", true)); deinterlaceAction->setShortcut(Qt::Key_I); connect(deinterlaceAction, SIGNAL(toggled(bool)), this, SLOT(deinterlacingChanged(bool))); backend->setDeinterlacing(deinterlaceAction->isChecked()); videoMenu->addAction(collection->addAction(QLatin1String("controls_deinterlace"), deinterlaceAction)); KMenu *aspectMenu = new KMenu(i18nc("'Video' menu", "Aspect Ratio"), this); QActionGroup *aspectGroup = new QActionGroup(this); connect(aspectGroup, SIGNAL(triggered(QAction*)), this, SLOT(aspectRatioChanged(QAction*))); action = new KAction(i18nc("'Aspect Ratio' menu", "Automatic"), aspectGroup); action->setCheckable(true); action->setChecked(true); action->setData(AspectRatioAuto); aspectMenu->addAction(collection->addAction(QLatin1String("controls_aspect_auto"), action)); action = new KAction(i18nc("'Aspect Ratio' menu", "Fit to Window"), aspectGroup); action->setCheckable(true); action->setData(AspectRatioWidget); aspectMenu->addAction(collection->addAction(QLatin1String("controls_aspect_widget"), action)); action = new KAction(i18nc("'Aspect Ratio' menu", "4:3"), aspectGroup); action->setCheckable(true); action->setData(AspectRatio4_3); aspectMenu->addAction(collection->addAction(QLatin1String("controls_aspect_4_3"), action)); action = new KAction(i18nc("'Aspect Ratio' menu", "16:9"), aspectGroup); action->setCheckable(true); action->setData(AspectRatio16_9); aspectMenu->addAction(collection->addAction(QLatin1String("controls_aspect_16_9"), action)); // Changes aspect ratio "a la VLC" currentAspectRatio=AspectRatioAuto; action = new KAction(KIcon(QLatin1String("chainAspectRatio")), i18nc("'Aspect Ratio' menu", "Chain ratio"), this); action->setShortcut(Qt::CTRL+Qt::Key_A); connect(action, SIGNAL(triggered()), this, SLOT(chainAspectRatio())); aspectMenu->addAction(collection->addAction(QLatin1String("chainAspectRatio"), action)); // Switches scale "a la VLC" currentAspectRatio=AspectRatioAuto; action = new KAction(KIcon(QLatin1String("switchScale")), i18nc("'Aspect Ratio' menu", "Switch scale"), this); action->setShortcut(Qt::SHIFT+Qt::Key_O); connect(action, SIGNAL(triggered()), this, SLOT(switchScale())); aspectMenu->addAction(collection->addAction(QLatin1String("switchScale"), action)); videoMenu->addMenu(aspectMenu); KMenu *autoResizeMenu = new KMenu(i18n("Automatic Resize"), this); QActionGroup *autoResizeGroup = new QActionGroup(this); // we need an event even if you select the currently selected item autoResizeGroup->setExclusive(false); connect(autoResizeGroup, SIGNAL(triggered(QAction*)), this, SLOT(autoResizeTriggered(QAction*))); action = new KAction(i18nc("automatic resize", "Off"), autoResizeGroup); action->setCheckable(true); action->setData(0); autoResizeMenu->addAction(collection->addAction(QLatin1String("controls_autoresize_off"), action)); action = new KAction(i18nc("automatic resize", "Original Size"), autoResizeGroup); action->setCheckable(true); action->setData(1); autoResizeMenu->addAction(collection->addAction(QLatin1String("controls_autoresize_original"), action)); action = new KAction(i18nc("automatic resize", "Double Size"), autoResizeGroup); action->setCheckable(true); action->setData(2); autoResizeMenu->addAction(collection->addAction(QLatin1String("controls_autoresize_double"), action)); int autoResizeFactor = KGlobal::config()->group("MediaObject").readEntry("AutoResizeFactor", 0); switch (autoResizeFactor) { case 1: automaticResize = OriginalSize; autoResizeGroup->actions().at(1)->setChecked(true); break; case 2: automaticResize = DoubleSize; autoResizeGroup->actions().at(2)->setChecked(true); break; default: automaticResize = ResizeOff; autoResizeGroup->actions().at(0)->setChecked(true); break; } videoMenu->addMenu(autoResizeMenu); action = new KAction(i18n("Volume Slider"), this); volumeSlider = new QSlider(toolBar); volumeSlider->setFocusPolicy(Qt::NoFocus); volumeSlider->setOrientation(Qt::Horizontal); volumeSlider->setRange(0, 100); volumeSlider->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Fixed); volumeSlider->setToolTip(action->text()); volumeSlider->setValue(KGlobal::config()->group("MediaObject").readEntry("Volume", 100)); connect(volumeSlider, SIGNAL(valueChanged(int)), this, SLOT(volumeChanged(int))); backend->setVolume(volumeSlider->value()); action->setDefaultWidget(volumeSlider); toolBar->addAction(collection->addAction(QLatin1String("controls_volume_slider"), action)); jumpToPositionAction = new KAction(KIcon(QLatin1String("go-jump")), i18nc("@action:inmenu", "Jump to Position..."), this); jumpToPositionAction->setShortcut(Qt::CTRL + Qt::Key_J); connect(jumpToPositionAction, SIGNAL(triggered()), this, SLOT(jumpToPosition())); menu->addAction(collection->addAction(QLatin1String("controls_jump_to_position"), jumpToPositionAction)); navigationMenu = new KMenu(i18nc("playback menu", "Skip"), this); menu->addMenu(navigationMenu); menu->addSeparator(); int shortSkipDuration = Configuration::instance()->getShortSkipDuration(); int longSkipDuration = Configuration::instance()->getLongSkipDuration(); connect(Configuration::instance(), SIGNAL(shortSkipDurationChanged(int)), this, SLOT(shortSkipDurationChanged(int))); connect(Configuration::instance(), SIGNAL(longSkipDurationChanged(int)), this, SLOT(longSkipDurationChanged(int))); longSkipBackwardAction = new KAction(KIcon(QLatin1String("media-skip-backward")), i18nc("submenu of 'Skip'", "Skip %1s Backward", longSkipDuration), this); longSkipBackwardAction->setShortcut(Qt::SHIFT + Qt::Key_Left); connect(longSkipBackwardAction, SIGNAL(triggered()), this, SLOT(longSkipBackward())); navigationMenu->addAction( collection->addAction(QLatin1String("controls_long_skip_backward"), longSkipBackwardAction)); shortSkipBackwardAction = new KAction(KIcon(QLatin1String("media-skip-backward")), i18nc("submenu of 'Skip'", "Skip %1s Backward", shortSkipDuration), this); shortSkipBackwardAction->setShortcut(Qt::Key_Left); connect(shortSkipBackwardAction, SIGNAL(triggered()), this, SLOT(shortSkipBackward())); navigationMenu->addAction( collection->addAction(QLatin1String("controls_skip_backward"), shortSkipBackwardAction)); shortSkipForwardAction = new KAction(KIcon(QLatin1String("media-skip-forward")), i18nc("submenu of 'Skip'", "Skip %1s Forward", shortSkipDuration), this); shortSkipForwardAction->setShortcut(Qt::Key_Right); connect(shortSkipForwardAction, SIGNAL(triggered()), this, SLOT(shortSkipForward())); navigationMenu->addAction( collection->addAction(QLatin1String("controls_skip_forward"), shortSkipForwardAction)); longSkipForwardAction = new KAction(KIcon(QLatin1String("media-skip-forward")), i18nc("submenu of 'Skip'", "Skip %1s Forward", longSkipDuration), this); longSkipForwardAction->setShortcut(Qt::SHIFT + Qt::Key_Right); connect(longSkipForwardAction, SIGNAL(triggered()), this, SLOT(longSkipForward())); navigationMenu->addAction( collection->addAction(QLatin1String("controls_long_skip_forward"), longSkipForwardAction)); toolBar->addAction(KIcon(QLatin1String("player-time")), i18n("Seek Slider"))->setEnabled(false); action = new KAction(i18n("Seek Slider"), this); seekSlider = new SeekSlider(toolBar); seekSlider->setFocusPolicy(Qt::NoFocus); seekSlider->setOrientation(Qt::Horizontal); seekSlider->setToolTip(action->text()); connect(seekSlider, SIGNAL(valueChanged(int)), this, SLOT(seek(int))); action->setDefaultWidget(seekSlider); toolBar->addAction(collection->addAction(QLatin1String("controls_position_slider"), action)); menuAction = new KAction(KIcon(QLatin1String("media-optical-video")), i18nc("dvd navigation", "DVD Menu"), this); connect(menuAction, SIGNAL(triggered()), this, SLOT(toggleMenu())); menu->addAction(collection->addAction(QLatin1String("controls_toggle_menu"), menuAction)); titleMenu = new KMenu(i18nc("dvd navigation", "Title"), this); titleGroup = new QActionGroup(this); connect(titleGroup, SIGNAL(triggered(QAction*)), this, SLOT(currentTitleChanged(QAction*))); menu->addMenu(titleMenu); chapterMenu = new KMenu(i18nc("dvd navigation", "Chapter"), this); chapterGroup = new QActionGroup(this); connect(chapterGroup, SIGNAL(triggered(QAction*)), this, SLOT(currentChapterChanged(QAction*))); menu->addMenu(chapterMenu); angleMenu = new KMenu(i18nc("dvd navigation", "Angle"), this); angleGroup = new QActionGroup(this); connect(angleGroup, SIGNAL(triggered(QAction*)), this, SLOT(currentAngleChanged(QAction*))); menu->addMenu(angleMenu); action = new KAction(i18n("Switch between elapsed and remaining time display"), this); timeButton = new QPushButton(toolBar); timeButton->setFocusPolicy(Qt::NoFocus); timeButton->setToolTip(action->text()); connect(timeButton, SIGNAL(clicked(bool)), this, SLOT(timeButtonClicked())); action->setDefaultWidget(timeButton); toolBar->addAction(collection->addAction(QLatin1String("controls_time_button"), action)); QTimer *timer = new QTimer(this); timer->start(50000); connect(timer, SIGNAL(timeout()), this, SLOT(checkScreenSaver())); }
CCppcheckWidget::CCppcheckWidget(QWidget* inpParent, CCppcheckPlugin *inpCppcheckPlugin) : QTreeView(inpParent), m_pCppcheckPlugin(inpCppcheckPlugin) { setObjectName("cppcheck plugin report"); setWindowTitle("cppcheck"); setWindowIcon(KIcon("cppcheck")); setRootIsDecorated(true); setWhatsThis("cppcheck plugin report"); setModel(m_pCppcheckPlugin->getModel()); KAction *pCheckCurrentFile = new KAction(this); pCheckCurrentFile->setShortcutContext(Qt::WidgetWithChildrenShortcut); pCheckCurrentFile->setText(i18n("(Re-)launch cppcheck on the current file")); pCheckCurrentFile->setToolTip(i18n("(Re-)launch cppcheck on the current file")); pCheckCurrentFile->setIcon(KIcon("view-refresh")); connect(pCheckCurrentFile, SIGNAL(triggered(bool)), model(), SLOT(parseCurrentFile())); addAction(pCheckCurrentFile); KAction *pActionShowErrors = new KAction(this); addAction(pActionShowErrors); pActionShowErrors->setCheckable(true); pActionShowErrors->setChecked(false); pActionShowErrors->setText(i18n("Show errors")); pActionShowErrors->setToolTip(i18n("Show errors")); pActionShowErrors->setIcon(KIcon("user-busy")); model()->setShowErrors(true); connect(pActionShowErrors, SIGNAL(triggered(bool)), model(), SLOT(setShowErrors(bool))); KAction *pActionShowWarnings = new KAction(this); addAction(pActionShowWarnings); pActionShowWarnings->setCheckable(true); pActionShowWarnings->setChecked(false); pActionShowWarnings->setText(i18n("Show warnings")); pActionShowWarnings->setToolTip(i18n("Show warnings")); pActionShowWarnings->setIcon(KIcon("dialog-warning")); model()->setShowWarnings(true); connect(pActionShowWarnings, SIGNAL(triggered(bool)), model(), SLOT(setShowWarnings(bool))); KAction *pActionShowStyle = new KAction(this); addAction(pActionShowStyle); pActionShowStyle->setCheckable(true); pActionShowStyle->setChecked(false); pActionShowStyle->setText(i18n("Show style warnings")); pActionShowStyle->setToolTip(i18n("Show style warnings")); pActionShowStyle->setIcon(KIcon("help-hint")); model()->setShowStyle(true); connect(pActionShowStyle, SIGNAL(triggered(bool)), model(), SLOT(setShowStyle(bool))); KAction *pActionShowPortability = new KAction(this); addAction(pActionShowPortability); pActionShowPortability->setCheckable(true); pActionShowPortability->setChecked(false); pActionShowPortability->setText(i18n("Show portability warnings")); pActionShowPortability->setToolTip(i18n("Show portability warnings")); pActionShowPortability->setIcon(KIcon("office-chart-ring")); model()->setShowPortability(true); connect(pActionShowPortability, SIGNAL(triggered(bool)), model(), SLOT(setShowPortability(bool))); KAction *pActionShowPerformance = new KAction(this); addAction(pActionShowPerformance); pActionShowPerformance->setCheckable(true); pActionShowPerformance->setChecked(false); pActionShowPerformance->setText(i18n("Show performance warnings")); pActionShowPerformance->setToolTip(i18n("Show performance warnings")); pActionShowPerformance->setIcon(KIcon("fork")); model()->setShowPerformance(true); connect(pActionShowPerformance, SIGNAL(triggered(bool)), model(), SLOT(setShowPerformance(bool))); KAction *pActionShowInformation = new KAction(this); addAction(pActionShowInformation); pActionShowInformation->setCheckable(true); pActionShowInformation->setChecked(false); pActionShowInformation->setText(i18n("Show information messages")); pActionShowInformation->setToolTip(i18n("Show information messages")); pActionShowInformation->setIcon(KIcon("help-about")); model()->setShowInformation(true); connect(pActionShowInformation, SIGNAL(triggered(bool)), model(), SLOT(setShowInformation(bool))); }
void MainWindow::setupPanels() { kDebug() << "setup panels..."; KAction* a; // STEP 1 // Setup history panel m_historyPanel = new HistoryPanel(i18n("History Panel"), this); connect(m_historyPanel, SIGNAL(openUrl(const KUrl&, const Rekonq::OpenType &)), Application::instance(), SLOT(loadUrl(const KUrl&, const Rekonq::OpenType &))); connect(m_historyPanel, SIGNAL(itemHovered(QString)), this, SLOT(notifyMessage(QString))); connect(m_historyPanel, SIGNAL(destroyed()), Application::instance(), SLOT(saveConfiguration())); addDockWidget(Qt::LeftDockWidgetArea, m_historyPanel); // setup history panel action a = (KAction *) m_historyPanel->toggleViewAction(); a->setShortcut(KShortcut(Qt::CTRL + Qt::Key_H)); a->setIcon(KIcon("view-history")); actionCollection()->addAction(QL1S("show_history_panel"), a); // STEP 2 // Setup bookmarks panel m_bookmarksPanel = new BookmarksPanel(i18n("Bookmarks Panel"), this); connect(m_bookmarksPanel, SIGNAL(openUrl(const KUrl&, const Rekonq::OpenType &)), Application::instance(), SLOT(loadUrl(const KUrl&, const Rekonq::OpenType &))); connect(m_bookmarksPanel, SIGNAL(itemHovered(QString)), this, SLOT(notifyMessage(QString))); connect(m_bookmarksPanel, SIGNAL(destroyed()), Application::instance(), SLOT(saveConfiguration())); addDockWidget(Qt::LeftDockWidgetArea, m_bookmarksPanel); Application::bookmarkProvider()->registerBookmarkPanel(m_bookmarksPanel); // setup bookmarks panel action a = (KAction *) m_bookmarksPanel->toggleViewAction(); a->setShortcut(KShortcut(Qt::CTRL + Qt::SHIFT + Qt::Key_B)); a->setIcon(KIcon("bookmarks-organize")); actionCollection()->addAction(QL1S("show_bookmarks_panel"), a); // STEP 3 // Setup webinspector panel m_webInspectorPanel = new WebInspectorPanel(i18n("Web Inspector"), this); connect(mainView(), SIGNAL(currentChanged(int)), m_webInspectorPanel, SLOT(changeCurrentPage())); a = new KAction(KIcon("tools-report-bug"), i18n("Web &Inspector"), this); a->setCheckable(true); actionCollection()->addAction(QL1S("web_inspector"), a); connect(a, SIGNAL(triggered(bool)), m_webInspectorPanel, SLOT(toggle(bool))); addDockWidget(Qt::BottomDockWidgetArea, m_webInspectorPanel); m_webInspectorPanel->hide(); // STEP 4 // Setup Network analyzer panel m_analyzerPanel = new NetworkAnalyzerPanel( i18n("Network Analyzer"), this); connect(mainView(), SIGNAL(currentChanged(int)), m_analyzerPanel, SLOT(changeCurrentPage())); a = new KAction(KIcon("document-edit-decrypt-verify"), i18n("Network Analyzer"), this); a->setCheckable(true); actionCollection()->addAction(QL1S("net_analyzer"), a); connect(a, SIGNAL(triggered(bool)), this, SLOT(enableNetworkAnalysis(bool))); addDockWidget(Qt::BottomDockWidgetArea, m_analyzerPanel); m_analyzerPanel->hide(); }
void TokenWithLayout::fillMenu( QMenu * menu ) { DEBUG_BLOCK KAction *boldAction = new KAction( KIcon( "format-text-bold"), i18n( "Bold" ), menu ); boldAction->setObjectName( ActionBoldName ); boldAction->setCheckable( true ); boldAction->setChecked( m_bold ); KAction *italicAction = new KAction( KIcon( "format-text-italic"), i18n( "Italic" ), menu ); italicAction->setObjectName( ActionItalicName ); italicAction->setCheckable( true ); italicAction->setChecked( m_italic ); KAction *alignLeftAction = new KAction( KIcon( "format-justify-left"), i18n( "Left" ), menu ); KAction *alignCenterAction = new KAction( KIcon( "format-justify-center"), i18n( "Center" ), menu ); KAction *alignRightAction = new KAction( KIcon( "format-justify-right"), i18n( "Right" ), menu ); alignLeftAction->setObjectName( ActionAlignLeftName ); alignLeftAction->setCheckable( true ); alignCenterAction->setObjectName( ActionAlignCenterName ); alignCenterAction->setCheckable( true ); alignRightAction->setObjectName( ActionAlignRightName ); alignRightAction->setCheckable( true ); if ( m_alignment & Qt::AlignLeft ) alignLeftAction->setChecked( true ); else if ( m_alignment & Qt::AlignHCenter ) alignCenterAction->setChecked( true ); else if ( m_alignment & Qt::AlignRight ) alignRightAction->setChecked( true ); QActionGroup *alignmentGroup = new QActionGroup( menu ); alignmentGroup->addAction( alignLeftAction ); alignmentGroup->addAction( alignCenterAction ); alignmentGroup->addAction( alignRightAction ); menu->addAction( boldAction ); menu->addAction( italicAction ); menu->addSeparator()->setText( i18n( "Alignment" ) ); menu->addAction( alignLeftAction ); menu->addAction( alignCenterAction ); menu->addAction( alignRightAction ); menu->addSeparator()->setText( i18n( "Width" ) ); menu->adjustSize(); int orgHeight = menu->height(); KHBox * sliderBox = new KHBox( menu ); sliderBox->setFixedWidth( menu->width() - 4 ); sliderBox->move( sliderBox->pos().x() + 2, orgHeight ); QSlider * slider = new QSlider( Qt::Horizontal, sliderBox ); slider->setMaximum( 100 ); slider->setMinimum( 0 ); // this should really not be done here as it makes upward assumptions // it was however done in setWidth with similar upward assumptions as well // solution: the popup stuff -iff- should be done in the dialog or the editWidget if ( parentWidget() ) { if ( TokenDropTarget *editWidget = qobject_cast<TokenDropTarget*>( parentWidget() ) ) { qreal spareWidth = 100.0; int row = editWidget->row( this ); if ( row > -1 ) { QList<Token*> tokens = editWidget->drags( row ); foreach (Token *t, tokens) { if (t == this) continue; if ( TokenWithLayout *twl = qobject_cast<TokenWithLayout*>( t ) ) spareWidth -= twl->width() * 100.0; } } int max = qMax( spareWidth, 0.0 ); debug() << "slider max value: " << max; if ( max >= m_width * 100.0 ) slider->setMaximum( qMax( spareWidth, 0.0 ) ); else slider->setMaximum( m_width * 100.0 ); }
//---------------------------------------------------------------------- // KJOTSMAIN //---------------------------------------------------------------------- KJotsComponent::KJotsComponent(QWidget* parent, KActionCollection *collection) : QWidget(parent) { actionCollection = collection; searchDialog = 0; activeAnchor.clear(); QDBusConnection dbus = QDBusConnection::sessionBus(); dbus.registerObject("/KJotsComponent", this, QDBusConnection::ExportScriptableSlots); // // Main widget // splitter = new QSplitter(this); splitter->setOpaqueResize( KGlobalSettings::opaqueResize() ); bookshelf = new Bookshelf(splitter); stackedWidget = new QStackedWidget(splitter); editor = new KJotsEdit(stackedWidget); editor->createActions(actionCollection); editor->setEnabled(false); stackedWidget->addWidget(editor); browser = new KJotsBrowser(stackedWidget); browser->setEnabled(false); stackedWidget->addWidget(browser); QVBoxLayout *bookGrid = new QVBoxLayout(this); bookGrid->setMargin(KDialog::marginHint()); bookGrid->setSpacing(KDialog::spacingHint()); bookGrid->addWidget(splitter, 0, 0); bookGrid->setMargin(0); splitter->setStretchFactor(1, 1); // I've moved as much I could into DelayedInitialization(), but the XML // gui builder won't insert things properly if they don't get in there early. KAction *action; action = actionCollection->addAction( "go_next_book"); action->setText( i18n("Next Book") ); action->setIcon(KIcon("go-down")); action->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_D)); connect(action, SIGNAL(triggered()), bookshelf, SLOT(nextBook())); action = actionCollection->addAction( "go_prev_book"); action->setText( i18n("Previous Book") ); action->setIcon(KIcon("go-up")); action->setShortcut(QKeySequence(Qt::CTRL + Qt::SHIFT + Qt::Key_D)); connect(action, SIGNAL(triggered()), bookshelf, SLOT(prevBook())); action = actionCollection->addAction( "go_next_page"); action->setText( i18n("Next Page") ); action->setIcon(KIcon("go-next")); action->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_PageDown)); connect(action, SIGNAL(triggered()), bookshelf, SLOT(nextPage())); action = actionCollection->addAction( "go_prev_page" ); action->setText( i18n("Previous Page") ); action->setIcon(KIcon("go-previous")); action->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_PageUp)); connect(action, SIGNAL(triggered()), bookshelf, SLOT(prevPage())); action = actionCollection->addAction( "new_page"); action->setText( i18n("&New Page") ); action->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_N)); action->setIcon(KIcon("document-new")); connect(action, SIGNAL(triggered()), SLOT(newPage())); action = actionCollection->addAction("new_book"); action->setText(i18n("New &Book...")); action->setShortcut(QKeySequence(Qt::CTRL + Qt::SHIFT + Qt::Key_N)); action->setIcon(KIcon("address-book-new")); connect(action, SIGNAL(triggered()), SLOT(createNewBook())); exportMenu = actionCollection->add<KActionMenu>("save_to"); exportMenu->setText(i18n("Export")); exportMenu->setIcon(KIcon("document-export")); action = actionCollection->addAction("save_to_ascii"); action->setText(i18n("To Text File...")); action->setIcon(KIcon("text-plain")); connect(action, SIGNAL(triggered()), SLOT(saveAscii())); exportMenu->menu()->addAction( action ); action = actionCollection->addAction("save_to_html"); action->setText(i18n("To HTML File...")); action->setIcon(KIcon("text-html")); connect(action, SIGNAL(triggered()), SLOT(saveHtml())); exportMenu->menu()->addAction( action ); action = actionCollection->addAction("save_to_book"); action->setText(i18n("To Book File...")); action->setIcon(KIcon("x-office-address-book")); connect(action, SIGNAL(triggered()), SLOT(saveNative())); exportMenu->menu()->addAction( action ); action = actionCollection->addAction("import"); action->setText(i18n("Import...")); action->setIcon(KIcon("document-import")); connect(action, SIGNAL(triggered()), SLOT(importBook())); action = actionCollection->addAction("del_page"); action->setText(i18n("&Delete Page")); action->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_Delete)); action->setIcon(KIcon("edit-delete-page")); connect(action, SIGNAL(triggered()), SLOT(deletePage())); action = actionCollection->addAction("del_folder"); action->setText(i18n("Delete Boo&k")); action->setShortcut(QKeySequence(Qt::CTRL + Qt::SHIFT + Qt::Key_Delete)); action->setIcon(KIcon("edit-delete")); connect(action, SIGNAL(triggered()), SLOT(deleteBook())); action = actionCollection->addAction("del_mult"); action->setText(i18n("Delete Selected")); action->setIcon(KIcon("edit-delete")); connect(action, SIGNAL(triggered()), SLOT(deleteMultiple())); action = actionCollection->addAction("manual_save"); action->setText(i18n("Manual Save")); action->setIcon(KIcon("document-save")); action->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_S)); connect(action, SIGNAL(triggered()), SLOT(saveAll())); action = actionCollection->addAction("auto_bullet"); action->setText(i18n("Auto Bullets")); action->setIcon(KIcon("format-list-unordered")); action->setCheckable(true); action = actionCollection->addAction("auto_decimal"); action->setText(i18n("Auto Decimal List")); action->setIcon(KIcon("format-list-ordered")); action->setCheckable(true); action = actionCollection->addAction("manage_link"); action->setText(i18n("Link")); action->setIcon(KIcon("insert-link")); action = actionCollection->addAction("insert_checkmark"); action->setText(i18n("Insert Checkmark")); action->setIcon(KIcon("checkmark")); action->setEnabled(false); KStandardAction::print(this, SLOT(onPrint()), actionCollection); action = KStandardAction::cut(editor, SLOT(cut()), actionCollection); connect(editor, SIGNAL(copyAvailable(bool)), action, SLOT(setEnabled(bool))); action->setEnabled(false); action = KStandardAction::copy(this, SLOT(copy()), actionCollection); connect(editor, SIGNAL(copyAvailable(bool)), action, SLOT(setEnabled(bool))); connect(browser, SIGNAL(copyAvailable(bool)), action, SLOT(setEnabled(bool))); action->setEnabled(false); action = actionCollection->addAction("copyIntoTitle"); action->setText(i18n("Copy &into Page Title")); action->setShortcut(QKeySequence(Qt::CTRL+Qt::Key_T)); action->setIcon(KIcon("edit-copy")); connect(action, SIGNAL(triggered()), SLOT(copySelection())); connect(editor, SIGNAL(copyAvailable(bool)), action, SLOT(setEnabled(bool))); action->setEnabled(false); KStandardAction::pasteText(editor, SLOT(paste()), actionCollection); KStandardAction::find( this, SLOT( onShowSearch() ), actionCollection ); action = KStandardAction::findNext( this, SLOT( onRepeatSearch() ), actionCollection ); action->setEnabled(false); KStandardAction::replace( this, SLOT( onShowReplace() ), actionCollection ); action = actionCollection->addAction("rename_entry"); action->setText(i18n("Rename...")); action->setIcon(KIcon("edit-rename")); action->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_M)); connect(action, SIGNAL(triggered()), SLOT(onRenameEntry())); action = actionCollection->addAction("insert_date"); action->setText(i18n("Insert Date")); action->setShortcut(QKeySequence(Qt::CTRL + Qt::SHIFT + Qt::Key_I)); action->setIcon(KIcon("view-calendar-time-spent")); connect(action, SIGNAL(triggered()), SLOT(insertDate())); action = actionCollection->addAction("change_color"); action->setIcon(KIcon("format-fill-color")); action->setText(i18n("Change Color...")); // connected to protected slot in bookshelf.cpp action = actionCollection->addAction("copy_link_address"); action->setText(i18n("Copy Link Address")); // connected to protected slot in bookshelf.cpp action = actionCollection->addAction("paste_plain_text"); action->setText(i18nc("@action Paste the text in the clipboard without rich text formatting.", "Paste Plain Text")); connect(action, SIGNAL(triggered()), editor, SLOT(pastePlainText())); KStandardAction::preferences(this, SLOT(configure()), actionCollection); bookmarkMenu = actionCollection->add<KActionMenu>("bookmarks"); bookmarkMenu->setText(i18n("&Bookmarks")); KJotsBookmarks* bookmarks = new KJotsBookmarks(bookshelf); /*KBookmarkMenu *bmm =*/ new KBookmarkMenu( KBookmarkManager::managerForFile(KStandardDirs::locateLocal("data","kjots/bookmarks.xml"), "kjots"), bookmarks, bookmarkMenu->menu(), actionCollection); m_autosaveTimer = new QTimer(this); // // Set startup size. // if (!KJotsSettings::splitterSizes().isEmpty()) { splitter->setSizes(KJotsSettings::splitterSizes()); } updateConfiguration(); QTimer::singleShot(0, this, SLOT(DelayedInitialization())); //connect new slots connect(bookshelf, SIGNAL(itemSelectionChanged()), SLOT(updateCaption())); connect(bookshelf, SIGNAL(itemSelectionChanged()), SLOT(updateMenu())); connect(bookshelf, SIGNAL(itemChanged(QTreeWidgetItem*, int)), SLOT(onItemRenamed(QTreeWidgetItem*, int))); connect(m_autosaveTimer, SIGNAL(timeout()), SLOT(autoSave())); }