static void settings_clicked(G_GNUC_UNUSED GtkButton *button, RingMainWindow *win) { g_return_if_fail(IS_RING_MAIN_WINDOW(win)); RingMainWindowPrivate *priv = RING_MAIN_WINDOW_GET_PRIVATE(win); /* check which view to show */ if (!priv->show_settings) { /* show the settings */ /* make sure we are not showing a call view so we don't have more than one clutter stage at a time */ selection_changed(QModelIndex(), win); /* show settings */ gtk_image_set_from_icon_name(GTK_IMAGE(priv->image_settings), "emblem-ok-symbolic", GTK_ICON_SIZE_LARGE_TOOLBAR); gtk_widget_show(priv->hbox_settings); /* make sure to start preview if we're showing the video settings */ if (priv->last_settings_view == priv->media_settings_view) media_settings_view_show_preview(MEDIA_SETTINGS_VIEW(priv->media_settings_view), TRUE); gtk_stack_set_transition_type(GTK_STACK(priv->stack_main_view), GTK_STACK_TRANSITION_TYPE_SLIDE_UP); gtk_stack_set_visible_child(GTK_STACK(priv->stack_main_view), priv->last_settings_view); priv->show_settings = TRUE; } else { /* hide the settings */ priv->show_settings = FALSE; /* show working dialog in case save operation takes time */ GtkWidget *working = ring_dialog_working(GTK_WIDGET(win), NULL); gtk_window_present(GTK_WINDOW(working)); /* now save after the time it takes to transition back to the call view (400ms) * the save doesn't happen before the "working" dialog is presented * the timeout function should destroy the "working" dialog when done saving */ g_timeout_add_full(G_PRIORITY_DEFAULT, 400, (GSourceFunc)save_accounts, working, NULL); /* show calls */ gtk_image_set_from_icon_name(GTK_IMAGE(priv->image_settings), "emblem-system-symbolic", GTK_ICON_SIZE_LARGE_TOOLBAR); gtk_widget_hide(priv->hbox_settings); /* make sure video preview is stopped, in case it was started */ media_settings_view_show_preview(MEDIA_SETTINGS_VIEW(priv->media_settings_view), FALSE); gtk_stack_set_transition_type(GTK_STACK(priv->stack_main_view), GTK_STACK_TRANSITION_TYPE_SLIDE_DOWN); gtk_stack_set_visible_child_name(GTK_STACK(priv->stack_main_view), CALL_VIEW_NAME); /* show the view which was selected previously */ selection_changed(RecentModel::instance().selectionModel()->currentIndex(), win); } }
DialogSpectraTemplates::DialogSpectraTemplates(XMLableDB<Qpx::Spectrum::Template> &newdb, std::vector<Qpx::Detector> current_dets, QString savedir, QWidget *parent) : QDialog(parent), ui(new Ui::DialogSpectraTemplates), table_model_(newdb), selection_model_(&table_model_), templates_(newdb), current_dets_(current_dets), root_dir_(savedir) { ui->setupUi(this); ui->spectraSetupView->setModel(&table_model_); ui->spectraSetupView->setItemDelegate(&special_delegate_); ui->spectraSetupView->setSelectionModel(&selection_model_); ui->spectraSetupView->verticalHeader()->hide(); ui->spectraSetupView->horizontalHeader()->setStretchLastSection(true); ui->spectraSetupView->horizontalHeader()->setSectionResizeMode(QHeaderView::ResizeToContents); ui->spectraSetupView->verticalHeader()->setSectionResizeMode(QHeaderView::ResizeToContents); ui->spectraSetupView->setSelectionBehavior(QAbstractItemView::SelectRows); ui->spectraSetupView->setSelectionMode(QAbstractItemView::ExtendedSelection); ui->spectraSetupView->show(); connect(&selection_model_, SIGNAL(selectionChanged(QItemSelection,QItemSelection)), this, SLOT(selection_changed(QItemSelection,QItemSelection))); connect(ui->spectraSetupView, SIGNAL(doubleClicked(QModelIndex)), this, SLOT(selection_double_clicked(QModelIndex))); table_model_.update(); ui->spectraSetupView->resizeColumnsToContents(); ui->spectraSetupView->resizeRowsToContents(); }
void select(Fl_Type* item, int value) { item->new_selected = value != 0; if (item->new_selected != item->selected) { selection_changed(item); widget_browser->redraw(); } }
TranslationSpinRow(View *view, Gtk::TreeView *rfo_tree, const char *box_name) : m_inhibit_update(false), m_view(view) { view->m_builder->get_widget (box_name, m_box); for (uint i = 0; i < 3; i++) { m_box->add (*new Gtk::Label (axis_names[i])); m_xyz[i] = new Gtk::SpinButton(); m_xyz[i]->set_numeric(); m_xyz[i]->set_digits (1); m_xyz[i]->set_increments (0.5, 10); m_xyz[i]->set_range(-500.0, +500.0); m_box->add (*m_xyz[i]); m_xyz[i]->signal_value_changed().connect (sigc::bind(sigc::mem_fun(*this, &TranslationSpinRow::spin_value_changed), (int)i)); /* Add statusbar message */ stringstream oss; oss << "Move object in " << axis_names[i] << "-direction (mm)"; m_view->add_statusbar_msg(m_xyz[i], oss.str().c_str()); } selection_changed(); m_box->show_all(); rfo_tree->get_selection()->signal_changed().connect (sigc::mem_fun(*this, &TranslationSpinRow::selection_changed)); }
void ViewWidget::mouse_left_press_event(QMouseEvent *event) { (void)event; const bool ctrl_pressed = QApplication::keyboardModifiers() & Qt::ControlModifier; // Clear selection if control is not pressed and this item is unselected if ((!mouse_down_item_ || !mouse_down_item_->selected()) && !ctrl_pressed) clear_selection(); // Set the signal selection state if the item has been clicked if (mouse_down_item_) { if (ctrl_pressed) mouse_down_item_->select(!mouse_down_item_->selected()); else mouse_down_item_->select(true); } // Save the offsets of any signals which will be dragged bool item_dragged = false; const auto items = this->items(); for (auto &i : items) if (i->selected()) { item_dragged = true; i->drag(); } // Do the background drag if (!item_dragged) drag(); selection_changed(); }
void tunit_recall::pre_show(CVideo& /*video*/, twindow& window) { tlistbox& recall_list = find_widget<tlistbox>(&window, "unit_list", false); recall_list.set_callback_value_change(selection_changed_callback); tmulti_page& multi_page = find_widget<tmulti_page>( &window, "unit_page", false); std::map<std::string, unsigned> ellipsize_to; ellipsize_to["name"] = 15; ellipsize_to["type"] = 18; ellipsize_to["traits"] = 25; foreach(const unit& u, team_.recall_list()) { std::map<std::string, string_map> data = get_unit_info(u, ellipsize_to); recall_list.add_row(data); multi_page.add_page(data); //tgrid& unit = multi_page.page_grid(multi_page.get_page_count() - 1); } recall_list.select_row(0); selection_changed(&window, 0); }
static void prefs_page_init (MooPrefsPage *page, PrefsPageXml *gxml) { GtkListStore *store; GtkTreeModel *model; GSList *l, *plugins; model = gtk_tree_view_get_model (gxml->treeview); store = GTK_LIST_STORE (model); gtk_list_store_clear (store); plugins = moo_list_plugins (); for (l = plugins; l != NULL; l = l->next) { GtkTreeIter iter; MooPlugin *plugin = l->data; if (moo_plugin_visible (plugin)) { gtk_list_store_append (store, &iter); gtk_list_store_set (store, &iter, COLUMN_ENABLED, moo_plugin_enabled (plugin), COLUMN_PLUGIN_ID, moo_plugin_id (plugin), COLUMN_PLUGIN_NAME, moo_plugin_name (plugin), -1); } } selection_changed (gtk_tree_view_get_selection (gxml->treeview), gxml); g_slist_free (plugins); sync_pages (g_object_get_data (G_OBJECT (page), "moo-plugin-prefs-dialog")); }
BaseTreeDock::BaseTreeDock(QString window_title, QString object_name, bool requires_refresh, QWidget *parent, Qt::WindowFlags flags) : BaseDock(parent, flags) , m_collapsed(true) { setWindowTitle(window_title); setObjectName(object_name); setFeatures(QDockWidget::AllDockWidgetFeatures); setAllowedAreas(Qt::AllDockWidgetAreas); m_arr_in = QIcon(":img/arrow-in.png"); m_arr_out = QIcon(":img/arrow-out.png"); QWidget *w = new QWidget(); QVBoxLayout *l = new QVBoxLayout(); w->setLayout(l); m_tree_view = new QTreeWidget(this); m_tree_view->setEditTriggers(QAbstractItemView::NoEditTriggers); m_tree_view->setDropIndicatorShown(false); m_tree_view->setProperty("showSortIndicator",QVariant(true)); m_tree_view->setSelectionMode(QAbstractItemView::ExtendedSelection); QHBoxLayout *s = new QHBoxLayout(); QLabel *lbl_search = new QLabel(tr("Search"),this); s->addWidget(lbl_search); m_le_search = new QLineEdit(this); m_le_search->setObjectName("le_search"); s->addWidget(m_le_search); m_btn_toggle_tree = new QPushButton(this); m_btn_toggle_tree->setIcon(m_arr_out); s->addWidget(m_btn_toggle_tree); QPushButton *btn_clear_search = new QPushButton(this); QIcon icn_cross(":img/cross.png"); btn_clear_search->setIcon(icn_cross); s->addWidget(btn_clear_search); l->addLayout(s); QPushButton *btn = new QPushButton(tr("Clear Filter"),this); w->layout()->addWidget(m_tree_view); w->layout()->addWidget(btn); setWidget(w); connect(btn, SIGNAL(clicked()),this,SLOT(clear_filter())); connect(m_le_search, SIGNAL(textChanged(QString)), this, SLOT(search_changed(QString))); connect(btn_clear_search, SIGNAL(clicked()),this,SLOT(clear_search())); connect(m_btn_toggle_tree, SIGNAL(clicked()), this, SLOT(toggle_tree())); connect(m_tree_view, SIGNAL(itemSelectionChanged()), this, SLOT(selection_changed())); m_requires_refresh = requires_refresh; if(DT){ connect(DT,SIGNAL(units_refreshed()),this,SLOT(refresh())); } }
void EditUmlClassInfoDialog::changeCanvas(Canvas* canvas) { if (m_canvas) { disconnect(m_canvas, 0, this, 0); disconnect(this, 0, m_canvas, 0); } m_canvas = canvas; connect(m_canvas, SIGNAL(selectionChanged()), this, SLOT(selection_changed())); }
// delete from parent: void Fl_Type::remove() { if (previous_brother) previous_brother->next_brother = next_brother; else if (parent) parent->first_child = next_brother; else Fl_Type::first = next_brother; if (next_brother) next_brother->previous_brother = previous_brother; previous_brother = next_brother = 0; if (parent) parent->remove_child(this); parent = 0; widget_browser->relayout(); selection_changed(0); }
ThoughtsDock::ThoughtsDock(QWidget *parent, Qt::WindowFlags flags) : BaseDock(parent, flags) { setWindowTitle(tr("Thoughts")); setObjectName("dock_thoughts"); setFeatures(QDockWidget::AllDockWidgetFeatures); setAllowedAreas(Qt::AllDockWidgetAreas); QWidget *w = new QWidget(); QVBoxLayout *l = new QVBoxLayout(); w->setLayout(l); // THOUGHTS TABLE tw_thoughts = new QTableWidget(this); tw_thoughts->setColumnCount(3); tw_thoughts->setEditTriggers(QTableWidget::NoEditTriggers); tw_thoughts->setWordWrap(true); tw_thoughts->setShowGrid(false); tw_thoughts->setGridStyle(Qt::NoPen); tw_thoughts->setAlternatingRowColors(true); tw_thoughts->setSelectionMode(QAbstractItemView::ExtendedSelection); tw_thoughts->setSelectionBehavior(QAbstractItemView::SelectRows); tw_thoughts->setHorizontalHeaderLabels(QStringList() << "Thought" << "Count" << "Description"); tw_thoughts->verticalHeader()->hide(); tw_thoughts->horizontalHeader()->setSectionResizeMode(0, QHeaderView::Interactive); tw_thoughts->horizontalHeader()->setSectionResizeMode(1, QHeaderView::Interactive); tw_thoughts->horizontalHeader()->setSectionResizeMode(2, QHeaderView::Interactive); tw_thoughts->setColumnWidth(0,100); tw_thoughts->setColumnWidth(1,50); tw_thoughts->horizontalHeader()->setStretchLastSection(true); QHBoxLayout *s = new QHBoxLayout(); QLabel *lbl_search = new QLabel("Search",this); s->addWidget(lbl_search); QLineEdit *le_search = new QLineEdit(this); le_search->setObjectName("le_search"); s->addWidget(le_search); QPushButton *btn_clear_search = new QPushButton(this); QIcon icn(":img/cross.png"); btn_clear_search->setIcon(icn); s->addWidget(btn_clear_search); l->addLayout(s); QPushButton *btn = new QPushButton("Clear Filter",this); w->layout()->addWidget(tw_thoughts); w->layout()->addWidget(btn); setWidget(w); connect(tw_thoughts,SIGNAL(itemSelectionChanged()),this,SLOT(selection_changed())); connect(btn, SIGNAL(clicked()),this,SLOT(clear_filter())); connect(le_search, SIGNAL(textChanged(QString)),this, SLOT(search_changed(QString))); connect(btn_clear_search, SIGNAL(clicked()),this,SLOT(clear_search())); }
void Pane::directory_ready(File_info_list files) { bool old_state_stored = false; QString new_current_uri; QModelIndex old_current_index; QItemSelection old_selection; QPoint old_scroll_pos; if (sender() == pending_directory) { if (pending_directory && directory && pending_directory->get_uri() == directory->get_parent_uri()) { new_current_uri = directory->get_uri(); } if (directory) delete directory; directory = pending_directory; emit uri_changed(); pending_directory = 0; ui->loading_indicator->hide(); ui->address->setText(directory->get_uri()); } else if (sender() == directory) { //it's a refresh, we need to store selection state old_state_stored = true; old_current_index = ui->list->currentIndex(); old_selection = ui->list->selectionModel()->selection(); old_scroll_pos.setX(ui->list->horizontalScrollBar()->value()); old_scroll_pos.setY(ui->list->verticalScrollBar()->value()); } else { qWarning("Unknown sender"); return; } file_list_model.set_data(files); if (file_list_model.rowCount() > 0) { ui->list->setCurrentIndex(file_list_model.index(0, 0)); } ui->list->clearSelection(); ui->loading_indicator->hide(); if (old_state_stored) { ui->list->setCurrentIndex(old_current_index); ui->list->selectionModel()->select(old_selection, QItemSelectionModel::SelectCurrent); ui->list->horizontalScrollBar()->setValue(old_scroll_pos.x()); ui->list->verticalScrollBar()->setValue(old_scroll_pos.y()); } if (!new_current_uri.isEmpty()) { ui->list->selectionModel()->setCurrentIndex(file_list_model.index_for_uri(new_current_uri), QItemSelectionModel::NoUpdate); } ui->list->horizontalHeader()->resizeSections(QHeaderView::ResizeToContents); emit selection_changed(); }
void delete_all(int selected_only) { for (Fl_Type *f = Fl_Type::first; f;) { if (f->selected || !selected_only) { Fl_Type* next = f->next_brother; delete f; f = next; } else { f = f->walk(); } } if(!selected_only) { include_H_from_C = 1; images_dir = ""; //"./"; } selection_changed(0); }
void OptionsScreen::select_left() { OptionItem * item; unsigned int count; item = items->at(selected_item); if(item->options == NULL) return; count = (unsigned int)item->options->size(); if(item->selected == 0) item->selected = count - 1; else item->selected--; selection_changed(); }
void OptionsScreen::select_right() { OptionItem * item; unsigned int count; item = items->at(selected_item); if(item->options == NULL) return; count = (unsigned int)item->options->size(); if(item->selected == (count - 1)) item->selected = 0; else item->selected++; selection_changed(); }
void selectionChanged_() { selection_changed(); }
Pane::Pane(QWidget *parent) : QWidget(parent), ui(new Ui::Pane) { directory = 0; pending_directory = 0; ui->setupUi(this); ui->list->setModel(&file_list_model); ui->list->installEventFilter(this); ui->list->viewport()->installEventFilter(this); ui->list->horizontalHeader()->setResizeMode(QHeaderView::ResizeToContents); QFontMetrics font_metrics(ui->list->font()); ui->list->verticalHeader()->setFixedWidth(10 + font_metrics.width(">")); ui->address->installEventFilter(this); ready = true; main_window = 0; connect(ui->address, SIGNAL(returnPressed()), this, SLOT(on_go_clicked())); ui->loading_indicator->hide(); QMovie* loading_movie = new QMovie(":/loading.gif", QByteArray(), ui->loading_indicator); ui->loading_indicator->setMovie(loading_movie); loading_movie->start(); connect(ui->list->selectionModel(), SIGNAL(currentChanged(QModelIndex,QModelIndex)), this, SLOT(current_index_changed(QModelIndex,QModelIndex))); connect(ui->list->selectionModel(), SIGNAL(currentChanged(QModelIndex,QModelIndex)), this, SIGNAL(selection_changed())); connect(ui->list->selectionModel(), SIGNAL(selectionChanged(QItemSelection,QItemSelection)), this, SIGNAL(selection_changed())); }
// slot: called when selection changes void Pstable::selection_update(int row) { procview->procs[row]->selected = isSelected(row); emit selection_changed(); }
void Widget_List::flags_changed(const Fl_Menu_*, Fl_Widget* w) { Fl_Type* item = (Fl_Type*)(w->user_data()); item->open_ = w->value(); item->new_selected = w->selected(); if (item->new_selected != item->selected) selection_changed(item); }
void msg_list_window::add_msgs_page(const msgs_filter* f, bool if_results _UNUSED_) { m_filter = new msgs_filter(*f); QFont body_font; QFont list_font; QByteArray headerview_setup; msgs_page* current = m_pages->current_page(); // current may be null if we're instantiating the first page if (current) { body_font = m_msgview->font(); list_font = m_qlist->font(); if (m_qlist->sender_recipient_swapped()) m_qlist->swap_sender_recipient(false); headerview_setup = m_qlist->header()->saveState(); } // new splitter QStackedWidget* stackw = m_pages->stacked_widget(); QSplitter* l=new QSplitter(Qt::Vertical, this); stackw->addWidget(l); m_qlist = new mail_listview(l); m_qlist->set_threaded(display_vars.m_threaded); m_qlist->m_msg_window=this; if (current) m_qlist->setFont(list_font); m_qlist->init_columns(); if (current) m_qlist->header()->restoreState(headerview_setup); if (!m_filter->m_fetched) m_filter->fetch(m_qlist); else m_filter->make_list(m_qlist); msg_list_postprocess(); m_msgview = new message_view(l, this); if (current) m_msgview->setFont(body_font); connect(m_msgview, SIGNAL(on_demand_show_request()), this, SLOT(display_msg_contents())); connect(m_msgview, SIGNAL(popup_body_context_menu()), this, SLOT(body_menu())); connect(m_msgview, SIGNAL(page_back()), this, SLOT(move_backward())); connect(m_msgview, SIGNAL(page_forward()), this, SLOT(move_forward())); m_qAttch = new attch_listview(l); connect(m_qAttch, SIGNAL(itemDoubleClicked(QTreeWidgetItem*,int)), this, SLOT(attch_selected(QTreeWidgetItem*,int))); connect(m_qAttch, SIGNAL(init_progress(const QString)), this, SLOT(install_progressbar(const QString))); connect(m_qAttch, SIGNAL(progress(int)), this, SLOT(show_progress(int))); connect(m_qAttch, SIGNAL(finish_progress()), this, SLOT(uninstall_progressbar())); connect(this, SIGNAL(abort_progress()), m_qAttch, SLOT(download_aborted())); // splitter for 3 panes: list of messages / body / attachments list static const int splitter_default_sizes[3] = {100,400,25}; QList<int> lsizes; if (current) { lsizes = current->m_page_splitter->sizes(); // don't allow any zero size for panels. This is necessary to avoid having the // attachment list being almost invisible to the user for (int i=0; i<3; i++) { if (lsizes.at(i)==0) { lsizes.replace(i, splitter_default_sizes[i]); } } } else { for (int i=0; i<3; i++) { int sz; QString key; key.sprintf("display/msglist/panel%d_size", i+1); if (get_config().exists(key)) { sz=get_config().get_number(key); if (sz==0) sz=splitter_default_sizes[i]; } else sz=splitter_default_sizes[i]; lsizes.append(sz); } } /* avoid changing the listview's height each time the attachments view is shown or hidden */ l->setStretchFactor(l->indexOf(m_qlist), 0); l->setStretchFactor(l->indexOf(m_msgview), 1); l->setStretchFactor(l->indexOf(m_qAttch), 0); l->setSizes(lsizes); m_qAttch->hide(); m_wSearch=NULL; connect(m_qlist,SIGNAL(selection_changed()), this,SLOT(mails_selected())); connect(m_qlist,SIGNAL(doubleClicked(const QModelIndex&)), this,SLOT(mail_reply_all())); connect(m_qlist, SIGNAL(clicked(const QModelIndex&)), this, SLOT(action_click_msg_list(const QModelIndex&))); connect(m_qlist, SIGNAL(scroll_page_down()), m_msgview, SLOT(page_down())); if (m_pages->next_page()) { // we're in the middle of a page list, and asked to go forward. // let's remove all the pages that are after the current position m_pages->cut_pages(m_pages->next_page()); } int max_pages=get_config().get_number("msg_window_pages"); if (max_pages<2) max_pages=2; if (m_pages->count() >= max_pages) { free_msgs_page(); if (m_pages->count() >= max_pages) { // Still no room for a new page? OK, forget it DBG_PRINTF(5,"not enough pages!"); return; } } // allocate and use a new page msgs_page* page = new msgs_page(); page->m_page_filter = m_filter; page->m_page_msgview = m_msgview; page->m_page_attach = m_qAttch; page->m_page_qlist = m_qlist; page->m_page_current_item = NULL; page->m_page_splitter = l; page->m_msgs_window = this; page->m_query_lvitem_id = m_query_lv->current_id(); m_pages->add_page(page); m_pages->raise_page(page); m_tags_box->reset_tags(); enable_forward_backward(); }
BOOL EditClientsDialog::event_command(int control_id, int notify_code) { if(control_id == IDCANCEL) { end(0); return TRUE; } else if(control_id == IDOK) { end(1); return TRUE; } else if(notify_code == LBN_SELCHANGE && control_id == ID_LB_CLIENTS) selection_changed(); else if(notify_code == BN_CLICKED) switch(control_id) { case ID_BT_DELETECLIENT: { int i = m_list_box->get_current_selection(); if(i >= 0 && static_cast<size_t>(i) < m_clients.size()) { m_clients.erase(m_clients.begin() + i); m_list_box->delete_string(i); // There is no longer a selection EnableWindow(GetDlgItem(m_hwnd, ID_BT_DELETECLIENT), FALSE); EnableWindow(GetDlgItem(m_hwnd, ID_BT_SAVECLIENT), FALSE); } return TRUE; } case ID_BT_SAVECLIENT: { int i = m_list_box->get_current_selection(); if(i >= 0 && static_cast<size_t>(i) < m_clients.size()) { EditBoxWrapper name_box(m_hwnd, ID_EB_CLIENTNAME); string name; name_box.get_text(name); m_clients[i].m_name = name; m_clients[i].m_path = m_path; // Name may change, so update the list box m_list_box->set_string(i, name.c_str()); // set_string() deselects, so select it again. m_list_box->set_current_selection(i); } return TRUE; } case ID_BT_ADDCLIENT: { EditBoxWrapper name_box(m_hwnd, ID_EB_CLIENTNAME); string name; name_box.get_text(name); if(name.length() == 0 || m_path.length() == 0) MessageBox(m_hwnd, "You must enter a name and select a path", "Error", MB_OK | MB_ICONINFORMATION); else { m_clients.push_back(ClientItem(name.c_str(), m_path.c_str())); int i = m_list_box->add_string(name.c_str()); if(i != -1) { m_list_box->set_current_selection(i); selection_changed(); } } return TRUE; } case ID_BT_CHOOSEPATH: choose_path(); return TRUE; } return FALSE; }
BOOL EditServersDialog::event_command(int control_id, int notify_code) { if(control_id == IDCANCEL) { end(0); return TRUE; } else if(control_id == IDOK) { end(1); return TRUE; } else if(notify_code == LBN_SELCHANGE && control_id == ID_LB_SERVERS) selection_changed(); else if(notify_code == BN_CLICKED) switch(control_id) { case ID_BT_DELETESERVER: { int i = m_list_box->get_current_selection(); if(i >= 0 && static_cast<size_t>(i) < m_servers.size()) { m_servers.erase(m_servers.begin() + i); m_list_box->delete_string(i); // There is no longer a selection EnableWindow(GetDlgItem(m_hwnd, ID_BT_DELETESERVER), FALSE); EnableWindow(GetDlgItem(m_hwnd, ID_BT_SAVESERVER), FALSE); } return TRUE; } case ID_BT_SAVESERVER: { int i = m_list_box->get_current_selection(); if(i >= 0 && static_cast<size_t>(i) < m_servers.size()) { EditBoxWrapper name_box(m_hwnd, ID_EB_SERVERNAME), addr_box(m_hwnd, ID_EB_SERVERADDRESS), uname_box(m_hwnd, ID_EB_SERVERUSERNAME), passwd_box(m_hwnd, ID_EB_SERVERPASSWORD); ; string name; name_box.get_text(name); m_servers[i].m_name = name; addr_box.get_text(m_servers[i].m_address); uname_box.get_text(m_servers[i].m_username); passwd_box.get_text(m_servers[i].m_password); // Name may change, so update the list box m_list_box->set_string(i, name.c_str()); // set_string() deselects, so select it again. m_list_box->set_current_selection(i); } return TRUE; } case ID_BT_ADDSERVER: { EditBoxWrapper name_box(m_hwnd, ID_EB_SERVERNAME), addr_box(m_hwnd, ID_EB_SERVERADDRESS), uname_box(m_hwnd, ID_EB_SERVERUSERNAME), passwd_box(m_hwnd, ID_EB_SERVERPASSWORD); ; string name, address, username, password; name_box.get_text(name); addr_box.get_text(address); uname_box.get_text(username); passwd_box.get_text(password); if(name.length() == 0 || address.length() == 0) MessageBox(m_hwnd, "You must enter a name and address", "Error", MB_OK | MB_ICONINFORMATION); else { m_servers.push_back(ServerItem(name.c_str(), address.c_str(), username.c_str(), password.c_str())); int i = m_list_box->add_string(name.c_str()); if(i != -1) { m_list_box->set_current_selection(i); selection_changed(); } } return TRUE; } } return FALSE; }
static void ring_main_window_init(RingMainWindow *win) { RingMainWindowPrivate *priv = RING_MAIN_WINDOW_GET_PRIVATE(win); gtk_widget_init_template(GTK_WIDGET(win)); /* set window icon */ GError *error = NULL; GdkPixbuf* icon = gdk_pixbuf_new_from_resource("/cx/ring/RingGnome/ring-symbol-blue", &error); if (icon == NULL) { g_debug("Could not load icon: %s", error->message); g_clear_error(&error); } else gtk_window_set_icon(GTK_WINDOW(win), icon); /* set menu icon */ GdkPixbuf* image_ring = gdk_pixbuf_new_from_resource_at_scale("/cx/ring/RingGnome/ring-symbol-blue", -1, 24, TRUE, &error); if (image_ring == NULL) { g_debug("Could not load icon: %s", error->message); g_clear_error(&error); } else gtk_image_set_from_pixbuf(GTK_IMAGE(priv->image_ring), image_ring); /* ring menu */ GtkBuilder *builder = gtk_builder_new_from_resource("/cx/ring/RingGnome/ringgearsmenu.ui"); GMenuModel *menu = G_MENU_MODEL(gtk_builder_get_object(builder, "menu")); gtk_menu_button_set_menu_model(GTK_MENU_BUTTON(priv->ring_menu), menu); g_object_unref(builder); /* settings icon */ gtk_image_set_from_icon_name(GTK_IMAGE(priv->image_settings), "emblem-system-symbolic", GTK_ICON_SIZE_LARGE_TOOLBAR); /* connect settings button signal */ g_signal_connect(priv->ring_settings, "clicked", G_CALLBACK(settings_clicked), win); /* add the call view to the main stack */ gtk_stack_add_named(GTK_STACK(priv->stack_main_view), priv->vbox_call_view, CALL_VIEW_NAME); if (has_ring_account()) { /* user has ring account, so show the call view right away */ gtk_stack_set_visible_child(GTK_STACK(priv->stack_main_view), priv->vbox_call_view); } else { /* user has to create the ring account */ show_account_creation(win); } /* init the settings views */ priv->account_settings_view = account_view_new(); gtk_stack_add_named(GTK_STACK(priv->stack_main_view), priv->account_settings_view, ACCOUNT_SETTINGS_VIEW_NAME); priv->media_settings_view = media_settings_view_new(); gtk_stack_add_named(GTK_STACK(priv->stack_main_view), priv->media_settings_view, MEDIA_SETTINGS_VIEW_NAME); priv->general_settings_view = general_settings_view_new(); gtk_stack_add_named(GTK_STACK(priv->stack_main_view), priv->general_settings_view, GENERAL_SETTINGS_VIEW_NAME); /* make the setting we will show first the active one */ gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(priv->radiobutton_general_settings), TRUE); priv->last_settings_view = priv->general_settings_view; /* connect the settings button signals to switch settings views */ g_signal_connect(priv->radiobutton_media_settings, "toggled", G_CALLBACK(show_media_settings), win); g_signal_connect(priv->radiobutton_account_settings, "toggled", G_CALLBACK(show_account_settings), win); g_signal_connect(priv->radiobutton_general_settings, "toggled", G_CALLBACK(show_general_settings), win); /* populate the notebook */ auto smart_view = recent_contacts_view_new(); gtk_container_add(GTK_CONTAINER(priv->scrolled_window_smartview), smart_view); auto contacts_view = contacts_view_new(); gtk_container_add(GTK_CONTAINER(priv->scrolled_window_contacts), contacts_view); auto history_view = history_view_new(); gtk_container_add(GTK_CONTAINER(priv->scrolled_window_history), history_view); /* welcome/default view */ priv->welcome_view = ring_welcome_view_new(); g_object_ref(priv->welcome_view); // gtk_stack_add_named(GTK_STACK(priv->stack_call_view), welcome_view, DEFAULT_VIEW_NAME); gtk_container_add(GTK_CONTAINER(priv->frame_call), priv->welcome_view); gtk_widget_show(priv->welcome_view); /* call/chat selection */ QObject::connect( RecentModel::instance().selectionModel(), &QItemSelectionModel::currentChanged, [win](const QModelIndex current, G_GNUC_UNUSED const QModelIndex & previous) { if (auto call = RecentModel::instance().getActiveCall(current)) { /* if the call is on hold, we want to put it off hold automatically * when switching to it */ if (call->state() == Call::State::HOLD) call << Call::Action::HOLD; } selection_changed(current, win); } ); /* connect to dataChanged of the RecentModel to see if we need to change the view */ QObject::connect( &RecentModel::instance(), &RecentModel::dataChanged, [win](const QModelIndex & topLeft, G_GNUC_UNUSED const QModelIndex & bottomRight, G_GNUC_UNUSED const QVector<int> & roles) { /* it is possible for dataChanged to be emitted inside of a dataChanged handler or * some other signal; since the connection is via a lambda, Qt would cause the * handler to be called directly. This is not behaviour we usually want, so we call our * function via g_idle so that it gets called after the initial handler is done. */ if (topLeft == RecentModel::instance().selectionModel()->currentIndex()) g_idle_add((GSourceFunc)selected_item_changed, win); } ); g_signal_connect(priv->button_placecall, "clicked", G_CALLBACK(search_entry_placecall), win); g_signal_connect(priv->search_entry, "activate", G_CALLBACK(search_entry_placecall), win); /* autocompletion */ priv->q_completion_model = new NumberCompletionModel(); /* autocompletion renderers */ GtkCellArea *completion_area = gtk_cell_area_box_new(); /* photo renderer */ GtkCellRenderer *renderer = gtk_cell_renderer_pixbuf_new(); gtk_cell_area_box_pack_start(GTK_CELL_AREA_BOX(completion_area), renderer, TRUE, /* expand */ TRUE, /* align */ TRUE); /* fixed size */ gtk_cell_layout_set_cell_data_func(GTK_CELL_LAYOUT(completion_area), renderer, (GtkCellLayoutDataFunc)autocompletion_photo_render, NULL, NULL); /* name renderer */ renderer = gtk_cell_renderer_text_new(); g_object_set(G_OBJECT(renderer), "ellipsize", PANGO_ELLIPSIZE_END, NULL); gtk_cell_area_box_pack_start(GTK_CELL_AREA_BOX(completion_area), renderer, TRUE, /* expand */ TRUE, /* align */ TRUE); /* fixed size */ gtk_cell_layout_set_cell_data_func(GTK_CELL_LAYOUT(completion_area), renderer, (GtkCellLayoutDataFunc)autocompletion_name_render, NULL, NULL); /* number renderer */ renderer = gtk_cell_renderer_text_new(); g_object_set(G_OBJECT(renderer), "ellipsize", PANGO_ELLIPSIZE_END, NULL); gtk_cell_area_box_pack_start(GTK_CELL_AREA_BOX(completion_area), renderer, TRUE, /* expand */ TRUE, /* align */ TRUE); /* fixed size */ gtk_cell_layout_set_cell_data_func(GTK_CELL_LAYOUT(completion_area), renderer, (GtkCellLayoutDataFunc)autocompletion_number_render, NULL, NULL); /* account renderer */ renderer = gtk_cell_renderer_text_new(); g_object_set(G_OBJECT(renderer), "ellipsize", PANGO_ELLIPSIZE_END, NULL); gtk_cell_area_box_pack_start(GTK_CELL_AREA_BOX(completion_area), renderer, TRUE, /* expand */ TRUE, /* align */ TRUE); /* fixed size */ gtk_cell_layout_set_cell_data_func(GTK_CELL_LAYOUT(completion_area), renderer, (GtkCellLayoutDataFunc)autocompletion_account_render, NULL, NULL); GtkEntryCompletion *entry_completion = gtk_entry_completion_new_with_area(completion_area); GtkQTreeModel *completion_model = gtk_q_tree_model_new( (QAbstractItemModel *)priv->q_completion_model, 1, Qt::DisplayRole, G_TYPE_STRING); gtk_entry_completion_set_model(entry_completion, GTK_TREE_MODEL(completion_model)); gtk_entry_set_completion(GTK_ENTRY(priv->search_entry), entry_completion); gtk_entry_completion_set_match_func( entry_completion, (GtkEntryCompletionMatchFunc) completion_match_func, NULL, NULL); /* connect signal to when text is entered in the entry */ g_signal_connect(priv->search_entry, "changed", G_CALLBACK(search_entry_text_changed), win); g_signal_connect(entry_completion, "match-selected", G_CALLBACK(select_autocompletion), win); /* connect to incoming call and focus */ QObject::connect( &CallModel::instance(), &CallModel::incomingCall, [=](Call* call) { CallModel::instance().selectionModel()->setCurrentIndex( CallModel::instance().getIndex(call), QItemSelectionModel::ClearAndSelect); } ); /* react to digit key press events */ g_signal_connect(win, "key-press-event", G_CALLBACK(dtmf_pressed), NULL); /* set the search entry placeholder text */ gtk_entry_set_placeholder_text(GTK_ENTRY(priv->search_entry), C_("Please try to make the translation 50 chars or less so that it fits into the layout", "Search contacts or enter number")); }
FormEfficiencyCalibration::FormEfficiencyCalibration(QSettings &settings, XMLableDB<Qpx::Detector>& newDetDB, QWidget *parent) : QWidget(parent), ui(new Ui::FormEfficiencyCalibration), detectors_(newDetDB), settings_(settings) { ui->setupUi(this); this->setWindowTitle("Efficiency calib"); loadSettings(); style_fit.default_pen = QPen(Qt::blue, 0); style_pts.themes["selected"] = QPen(Qt::black, 7); ui->PlotCalib->setLabels("channel", "energy"); ui->tablePeaks->verticalHeader()->hide(); ui->tablePeaks->setColumnCount(4); ui->tablePeaks->setHorizontalHeaderLabels({"chan", "energy", "cps", QString(QChar(0x03B5)) + "-rel"}); ui->tablePeaks->setSelectionBehavior(QAbstractItemView::SelectRows); ui->tablePeaks->setSelectionMode(QAbstractItemView::ExtendedSelection); ui->tablePeaks->setEditTriggers(QAbstractItemView::NoEditTriggers); ui->tablePeaks->horizontalHeader()->setStretchLastSection(true); ui->tablePeaks->horizontalHeader()->setSectionResizeMode(QHeaderView::ResizeToContents); ui->tablePeaks->show(); connect(ui->tablePeaks, SIGNAL(itemSelectionChanged()), this, SLOT(selection_changed_in_table())); connect(ui->PlotCalib, SIGNAL(selection_changed()), this, SLOT(selection_changed_in_calib_plot())); ui->PlotCalib->set_scale_type_x("Logarithmic"); ui->PlotCalib->set_scale_type_y("Logarithmic"); ui->isotopes->show(); connect(ui->isotopes, SIGNAL(isotopeSelected()), this, SLOT(isotope_chosen())); QShortcut* shortcut = new QShortcut(QKeySequence(QKeySequence::Delete), ui->tablePeaks); connect(shortcut, SIGNAL(activated()), this, SLOT(on_pushMarkerRemove_clicked())); ui->isotopes->set_editable(false); //file formats for opening mca spectra std::vector<std::string> spectypes = Qpx::Spectrum::Factory::getInstance().types(); QStringList filetypes; for (auto &q : spectypes) { Qpx::Spectrum::Template* type_template = Qpx::Spectrum::Factory::getInstance().create_template("1D"); if (!type_template->input_types.empty()) filetypes.push_back("Spectrum " + QString::fromStdString(q) + "(" + catExtensions(type_template->input_types) + ")"); delete type_template; } mca_load_formats_ = catFileTypes(filetypes); ui->plotSpectrum->setFit(&fit_data_); connect(ui->plotSpectrum, SIGNAL(selection_changed(std::set<double>)), this, SLOT(update_selection(std::set<double>))); connect(ui->plotSpectrum, SIGNAL(data_changed()), this, SLOT(update_data())); connect(ui->spectrumSelector, SIGNAL(itemSelected(SelectorItem)), this, SLOT(spectrumDetails(SelectorItem))); connect(ui->spectrumSelector, SIGNAL(itemToggled(SelectorItem)), this, SLOT(spectrumLooksChanged(SelectorItem))); }