void MainWindow::m_populate_toolbars() { // the top toolbar, with a title and a search bar QToolBar *top_bar = new QToolBar(this); QHBoxLayout *l = new QHBoxLayout(top_bar); l->setContentsMargins(0,0,0,0); m_title_label = new QLabel("<strong>" + tr("Administration Panel") + "</strong>", this); m_title_label->setIndent(10); m_search_bar = new QLineEdit(this); m_search_bar->setPlaceholderText(tr("Find...")); l->addWidget(m_title_label); l->addStretch(); l->addWidget(m_search_bar); QWidget *w = new QWidget(this); w->setLayout(l); top_bar->addWidget(w); top_bar->setAllowedAreas(Qt::TopToolBarArea); top_bar->setMovable(false); top_bar->setFloatable(false); addToolBar(top_bar); connect(m_search_bar, SIGNAL(textEdited(QString)), this, SLOT(m_search(QString))); // the sidebar with the cat list QToolBar *side_bar = new QToolBar(this); // add an action to return to the home page m_home_act = side_bar->addAction(QIcon::fromTheme("go-home"), tr("Home"), this, SLOT(m_home_clicked())); foreach(Category *cat, m_cats) { QAction *cat_act = side_bar->addAction(cat->icon(), cat->title(), this, SLOT(m_cat_clicked())); cat_act->setProperty("Category", cat->title()); // remember its category with its title }
static void key_action(int key) { int i, size; if(signal_sent) { print_help(); signal_sent = 0; } /* * First, try to process the key by object (subwindow, menu) that * could be on top. */ size = sizeof key_funct/sizeof(int (*)(int)); for(i = 0; i < size; i++) if(key_funct[i](key)) goto SKIP; if(current->keys(key)) goto SKIP; /* cursor movement */ size = sizeof key_handlers/sizeof(struct key_handler); for(i = 0; i < size; i++) if(key_handlers[i].c == key) { key_handlers[i].handler(current); if(can_draw()) pad_draw(); goto SKIP; } switch(key) { case 'c': full_cmd ^= 1; current->redraw(); break; case '/': m_search(); break; case KBD_F1: help(); break; case KBD_ESC: case 'q': curses_end(); exit(0); default: return; } SKIP: dolog("%s: doing refresh\n", __FUNCTION__); wnoutrefresh(main_win); wnoutrefresh(info_win.wd); pad_refresh(); menu_refresh(); box_refresh(); info_refresh(); doupdate(); }