MainWindow::MainWindow() { contents = new QWidget(this); mainImage = new QLabel(this); statistics = new QLabel(this); iteration = 0; QHBoxLayout *layout = new QHBoxLayout(); addMenu(); addToolbar(); drawField(); layout->addWidget(mainImage); layout->addWidget(statistics); contents->setLayout(layout); setCentralWidget(contents); }
void ActionConfigDialog::slotAddToolbar() { emit addToolbar(); QString toolbarName; QListViewItem *item; ToolbarTabWidget *tb = ToolbarTabWidget::ref(); for (int i = 0; i < tb->count(); i++) { toolbarName = tb->label(i); if (!actionTreeView->findItem(toolbarName, 0)) { item = actionTreeView->lastItem(); if (item->parent()) item = item->parent(); new KListViewItem(actionTreeView, item, i18n(toolbarName.utf8())); break; } } }
ParticlePreview::ParticlePreview() { // Add one additional toolbar for particle-related stuff Gtk::Toolbar* toolbar = Gtk::manage(new Gtk::Toolbar); toolbar->set_toolbar_style(Gtk::TOOLBAR_ICONS); _showAxesButton = Gtk::manage(new Gtk::ToggleToolButton); _showAxesButton->signal_toggled().connect( sigc::mem_fun(this, &ParticlePreview::queue_draw) ); _showAxesButton->set_icon_widget(*Gtk::manage(new Gtk::Image( GlobalUIManager().getLocalPixbufWithMask("axes.png")))); _showAxesButton->set_tooltip_text(_("Show coordinate axes")); Gtk::ToolButton* reloadButton = Gtk::manage(new Gtk::ToolButton); reloadButton->set_icon_widget(*Gtk::manage(new Gtk::Image(Gtk::Stock::REFRESH, Gtk::ICON_SIZE_MENU))); reloadButton->set_tooltip_text(_("Reload Particle Defs")); IEventPtr ev = GlobalEventManager().findEvent("ReloadParticles"); ev->connectWidget(reloadButton); _showWireFrameButton = Gtk::manage(new Gtk::ToggleToolButton); _showWireFrameButton->set_icon_widget(*Gtk::manage(new Gtk::Image( GlobalUIManager().getLocalPixbufWithMask("wireframe.png")))); _showWireFrameButton->set_tooltip_text(_("Show wireframe")); _showWireFrameButton->signal_toggled().connect( sigc::mem_fun(this, &ParticlePreview::queue_draw) ); _automaticLoopButton = Gtk::manage(new Gtk::ToggleToolButton(_("Auto Loop"))); _automaticLoopButton->set_tooltip_text(_("Auto Loop")); toolbar->insert(*_showAxesButton, 0); toolbar->insert(*_showWireFrameButton, 0); toolbar->insert(*_automaticLoopButton, 0); toolbar->insert(*reloadButton, 0); addToolbar(*toolbar); }
ActionConfigDialog::ActionConfigDialog(const QDict<ToolbarEntry> &toolbarList, KMainWindow* parent, const char* name, bool modal, WFlags fl, const QString& defaultAction ) :ActionConfigDialogS( parent, name, modal, fl ) { m_mainWindow = parent; m_toolbarList = toolbarList; buttonOk->setIconSet(SmallIconSet("button_ok")); buttonCancel->setIconSet(SmallIconSet("button_cancel")); buttonApply->setIconSet(SmallIconSet("apply")); //buttonHelp->setIconSet(SmallIconSet("help")); currentAction = 0L; m_toolbarItem = 0L; connect(actionTreeView, SIGNAL(contextMenu(KListView *,QListViewItem *,const QPoint &)), SLOT(slotContextMenu(KListView *,QListViewItem *,const QPoint &))); connect(actionTreeView, SIGNAL(selectionChanged(QListViewItem *)), SLOT(slotSelectionChanged(QListViewItem *))); connect(shortcutKeyButton, SIGNAL(capturedShortcut(const KShortcut &)), SLOT(slotShortcutCaptured(const KShortcut &))); connect(scriptPath, SIGNAL(activated(const QString&)), SLOT(slotTextChanged(const QString&))); connect(this, SIGNAL(addToolbar()), m_mainWindow, SLOT(slotAddToolbar())); connect(this, SIGNAL(removeToolbar(const QString&)), m_mainWindow, SLOT(slotRemoveToolbar(const QString&))); connect(this, SIGNAL(deleteUserAction(KAction*)), m_mainWindow, SLOT(slotDeleteAction(KAction*))); connect(this, SIGNAL(configureToolbars(const QString&)), m_mainWindow, SLOT(slotConfigureToolbars(const QString&))); //fill up the tree view with the toolbars and actions actionTreeView->setSorting(-1); allActionsItem = new KListViewItem(actionTreeView, i18n("All")); actionTreeView->insertItem(allActionsItem); QListViewItem *item, *oldItem = allActionsItem; KAction *action; QString toolbarName; QString toolbarId; ToolbarTabWidget *tb = ToolbarTabWidget::ref(); QRegExp r("\\&(?!\\&)"); KActionCollection *ac = m_mainWindow->actionCollection(); for (int i = 0; i < tb->count(); i++) { toolbarName = tb->label(i); toolbarName.replace(r, ""); item = new KListViewItem(actionTreeView, oldItem, i18n(toolbarName.utf8())); actionTreeView->insertItem(item); toolbarId = tb->id(i); QListViewItem *oldActionItem = 0L; ToolbarEntry *p_toolbar = m_toolbarList[toolbarId]; if (p_toolbar) { QDomNode node = p_toolbar->guiClient->domDocument().firstChild().firstChild().firstChild(); while (!node.isNull()) { if (node.nodeName() == "Action") { action = ac->action(node.toElement().attribute("name")); if (action) { oldActionItem = new KListViewItem(item, oldActionItem, action->text().replace(r,""), action->shortcut().toString(), action->name()); oldActionItem->setPixmap(0, SmallIcon(action->icon()) ); } } node = node.nextSibling(); } if (tb->label(tb->currentPageIndex()).replace(r, "") == toolbarName) { item->setOpen(true); if (item->firstChild()) { if (defaultAction.isEmpty()) { actionTreeView->setCurrentItem(item->firstChild()); } else { QListViewItem *actionItem = item->firstChild(); while (actionItem && actionItem->depth() > 0) { if (actionItem->text(0) == defaultAction || actionItem->text(0) == defaultAction + "...") { actionTreeView->setCurrentItem(actionItem); break; } actionItem = actionItem->nextSibling(); } } } } } oldItem = item; } uint acCount = ac->count(); for (uint i = 0; i < acCount; i++) { action = ac->action(i); item = new KListViewItem(allActionsItem, action->text().replace(r, ""), action->shortcut().toString(), action->name()); item->setPixmap(0, SmallIcon(action->icon()) ); } allActionsItem->sortChildItems(0, true); treeMenu = new KPopupMenu(actionTreeView); treeMenu->insertItem(i18n("&Add New Toolbar"), this, SLOT(slotAddToolbar())); treeMenu->insertItem(i18n("&Remove Toolbar"), this, SLOT(slotRemoveToolbar())); treeMenu->insertItem(i18n("&Edit Toolbar"), this, SLOT(slotEditToolbar())); globalShortcuts = KGlobal::config()->entryMap( "Global Shortcuts" ); }
KSlovar::KSlovar() : KMainWindow( 0, "KSlovar" ), m_dictionarydlg(0), m_recievedPackages(0) { KSlovar::m_instance=this; m_configDialog=new KSConfigDialog(this, "settings", Configuration::self()); new KStatusBar(this); statusBar()->insertItem(i18n("Ready."), 0); if(!QFile::exists(locateLocal("config", "kslovarrc", false))) { slotFirstRunWizard(); } else { if(Configuration::autoUpdateLanguage()) { slotDownloadLanguage(); } else { loadLanguages(); } } m_welcomeMessage=i18n("<h1>Welcome to KSlovar</h1> <p>This is an editor and viewer that is capable of creating, editing and showing diferent kinds of dictionaries.</p><p>If you encounter any bugs, please send a bug report to [email protected].</p>"); registerButtons(); addMenu(); addToolbar(); QHBox * horiz = new QHBox(this); m_split = new QSplitter(horiz); QVBox * vert = new QVBox(m_split); vert->setMaximumWidth(200); vert->setMinimumWidth(200); m_search = new KSSearchLine(vert); m_list = new KSListView( vert ); m_list->addColumn("name"); m_list->setColumnWidth(0, 193); m_list->setFullWidth(true); m_search->setList(m_list); KSData::instance()->setMainList(m_list); m_browser=new KHTMLPart(m_split); m_browser->setEncoding("utf-8", true); m_browser->view()->viewport()->installEventFilter(this); //For searching with middle click slotClose(); connect( m_browser->browserExtension(), SIGNAL( openURLRequest( const KURL &, const KParts::URLArgs & ) ), this, SLOT( slotShowBrowser(const KURL &, const KParts::URLArgs &) ) ); connect(m_list, SIGNAL( selectionChanged(QListViewItem *)), this, SLOT( slotShowList(QListViewItem *) ) ); connect(m_list, SIGNAL(doubleClicked( QListViewItem *)), this, SLOT(slotEditPhrase())); connect(kapp, SIGNAL(shutDown()), this, SLOT(slotClose())); connect(m_list, SIGNAL(contextMenu(KListView*, QListViewItem*, const QPoint&)), this, SLOT(showPopup( KListView*, QListViewItem*, const QPoint& ))); connect(m_list, SIGNAL(recievedPackage(bool, bool)), this, SLOT(slotCountPackages(bool, bool))); setCentralWidget(horiz); }