LevelEditorWindow::LevelEditorWindow() { //QHBoxLayout *mainLayout = new QHBoxLayout(); //setLayout( mainLayout ); /*DebugMenus::menu = new DebugMenus(); DebugMenus::menu->setVisible( false ); DebugMenus::inject( layout() );*/ handle = new LevelEditorHandle(); setCentralWidget( handle ); QMenu* fileMenu = menuBar()->addMenu("File"); QAction* action; fileMenu->addAction(action = new QAction("Load Wavefront (.obj) File", this)); action->setShortcut(QKeySequence::New); connect(action, SIGNAL(triggered()), this, SLOT(loadObj())); fileMenu->addAction(action = new QAction("Save Level Binary", this)); action->setShortcuts(QKeySequence::Save); connect(action, SIGNAL(triggered()), this, SLOT(saveNative())); fileMenu->addAction(action = new QAction("Save Level Binary File as..", this)); action->setShortcuts(QKeySequence::SaveAs); connect(action, SIGNAL(triggered()), this, SLOT(saveNativeAs())); fileMenu->addAction(action = new QAction("Load Level Binary", this)); action->setShortcuts(QKeySequence::Open); connect(action, SIGNAL(triggered()), this, SLOT(loadNative())); }
//---------------------------------------------------------------------- // 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())); }