void SCgWindow::createToolBar() { mToolBar = new QToolBar(this); mToolBar->setIconSize(QSize(32, 32)); QActionGroup* group = new QActionGroup(mToolBar); // Select mode QAction *action = new QAction(findIcon("tool-select.png"), tr("Selection mode"), mToolBar); action->setCheckable(true); action->setChecked(true); action->setShortcut(QKeySequence(tr("1", "Selection mode"))); group->addAction(action); mToolBar->addAction(action); mMode2Action[SCgScene::Mode_Select] = action; connect(action, SIGNAL(triggered()), this, SLOT(onSelectMode())); //Pair creation mode action = new QAction(findIcon("tool-pair.png"), tr("Pair creation mode"), mToolBar); action->setCheckable(true); action->setShortcut(QKeySequence(tr("2", "Pair creation mode"))); group->addAction(action); mToolBar->addAction(action); mMode2Action[SCgScene::Mode_Pair] = action; connect(action, SIGNAL(triggered()), this, SLOT(onPairMode())); //Bus creation mode action = new QAction(findIcon("tool-bus.png"), tr("Bus creation mode"), mToolBar); action->setCheckable(true); action->setShortcut(QKeySequence(tr("3", "Bus creation mode"))); group->addAction(action); mToolBar->addAction(action); mMode2Action[SCgScene::Mode_Bus] = action; connect(action, SIGNAL(triggered()), this, SLOT(onBusMode())); //Contour creation mode action = new QAction(findIcon("tool-contour.png"), tr("Contour creation mode"), mToolBar); action->setCheckable(true); action->setShortcut(QKeySequence(tr("4", "Contour creation mode"))); group->addAction(action); mToolBar->addAction(action); mMode2Action[SCgScene::Mode_Contour] = action; connect(action, SIGNAL(triggered()), this, SLOT(onContourMode())); // mToolBar->addSeparator(); // // align group button QToolButton *alignButton = new QToolButton(mToolBar); alignButton->setIcon(findIcon("tool-align.png")); alignButton->setPopupMode(QToolButton::InstantPopup); mToolBar->addWidget(alignButton); //Grid alignment action = new QAction(findIcon("tool-align-grid.png"), tr("Grid alignment"), mToolBar); action->setCheckable(false); action->setShortcut(QKeySequence(tr("5", "Grid alignment"))); alignButton->addAction(action); connect(action, SIGNAL(triggered()), this, SLOT(onGridAlignment())); // tuple alignment action = new QAction(findIcon("tool-align-tuple.png"), tr("Tuple alignment"), mToolBar); action->setCheckable(false); action->setShortcut(QKeySequence(tr("6", "Tuple alignment"))); alignButton->addAction(action); connect(action, SIGNAL(triggered()), this, SLOT(onTupleAlignment())); //Vertical alignment action = new QAction(findIcon("tool-align-vert.png"), tr("Vertical alignment"), mToolBar); action->setCheckable(false); action->setShortcut(QKeySequence(tr("7", "Vertical alignment"))); alignButton->addAction(action); connect(action, SIGNAL(triggered()), this, SLOT(onVerticalAlignment())); //Horizontal alignment action = new QAction(findIcon("tool-align-horz.png"), tr("Horizontal alignment"), mToolBar); action->setCheckable(false); action->setShortcut(QKeySequence(tr("8", "Horizontal alignment"))); alignButton->addAction(action); connect(action, SIGNAL(triggered()), this, SLOT(onHorizontalAlignment())); // Energy-based layout action = new QAction(findIcon("tool-align-energy.png"), tr("Energy-based layout"), mToolBar); action->setCheckable(false); action->setShortcut(QKeySequence(tr("9", "Energy-based layout"))); alignButton->addAction(action); connect(action, SIGNAL(triggered()), this, SLOT(onEnergyBasedLayout())); // selection group button QToolButton *selectButton = new QToolButton(mToolBar); selectButton->setIcon(findIcon("tool-select-group.png")); selectButton->setPopupMode(QToolButton::InstantPopup); mToolBar->addWidget(selectButton); // input/output selection action = new QAction(findIcon("tool-select-inout.png"), tr("Select input/output"), mToolBar); action->setCheckable(false); selectButton->addAction(action); connect(action, SIGNAL(triggered()), this, SLOT(onSelectInputOutput())); // sbgraph selection action = new QAction(findIcon("tool-select-subgraph.png"), tr("Select subgraph"), mToolBar); action->setCheckable(false); selectButton->addAction(action); connect(action, SIGNAL(triggered()), this, SLOT(onSelectSubgraph())); mToolBar->addSeparator(); action = new QAction(findIcon("tool-export-image.png"), tr("Export image"), mToolBar); action->setCheckable(false); action->setShortcut(QKeySequence(tr("0", "Export image"))); mToolBar->addAction(action); connect(action, SIGNAL(triggered()), this, SLOT(onExportImage())); action = new QAction(findIcon("tool-print.png"), tr("Print"), mToolBar); action->setCheckable(false); action->setShortcut(QKeySequence(tr("0", "Print"))); mToolBar->addAction(action); connect(action, SIGNAL(triggered()), this, SLOT(onPrint())); // mToolBar->addSeparator(); //Scale combobox QComboBox* b = new QComboBox(mToolBar); b->setFixedWidth(55); b->setEditable(true); b->setInsertPolicy(QComboBox::NoInsert); b->addItems(SCgWindow::mScales); b->setCurrentIndex(mScales.indexOf("100")); mZoomFactorLine = b->lineEdit(); mZoomFactorLine->setInputMask("D90%"); mToolBar->addWidget(b); connect(mZoomFactorLine, SIGNAL(textChanged(const QString&)), mView, SLOT(setScale(const QString&))); connect(mView, SIGNAL(scaleChanged(qreal)), this, SLOT(onViewScaleChanged(qreal))); // //Zoom in //action = new QAction(findIcon("tool-zoom-in.png"), tr("Zoom in"), mToolBar); action = new QAction("+",mToolBar); action->setToolTip(tr("Zoom in")); action->setCheckable(false); action->setShortcut(QKeySequence(tr("+", "Zoom in"))); mToolBar->addAction(action); connect(action, SIGNAL(triggered()), this, SLOT(onZoomIn())); //slider scale mZoomSlider = new QSlider(); mZoomSlider->setFixedWidth(40); mZoomSlider->setSizeIncrement(25,180/25); mZoomSlider->setFixedHeight(180); mZoomSlider->setToolTip(tr("Scale")); mZoomSlider->setMinimum(mZoomSliderMinValue); mZoomSlider->setValue(100); mZoomSlider->setMaximum(mZoomSliderMaxValue); mToolBar->addWidget(mZoomSlider); connect(mZoomSlider,SIGNAL(valueChanged(int)),this,SLOT(onmZoomSliderMove(int))); //Zoom out // action = new QAction(findIcon("tool-zoom-out.png"), tr("Zoom out"), mToolBar); action = new QAction("-", mToolBar); action->setToolTip(tr("Zoom out")); action->setCheckable(false); action->setShortcut(QKeySequence(tr("-", "Zoom out"))); mToolBar->addAction(action); connect(action, SIGNAL(triggered()), this, SLOT(onZoomOut())); mToolBar->setWindowTitle(tr("SCg Tools")); mToolBar->setObjectName("SCgMainToolBar"); //! @bug toolbar state is not saved mToolBar->setMovable(false); }
//---------------------------------------------------------------------- // 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())); }