void ImportIconView::showContextMenu(QContextMenuEvent* event) { KMenu popmenu(this); ImportContextMenuHelper cmhelper(&popmenu); cmhelper.addAction("importui_fullscreen"); cmhelper.addAction("options_show_menubar"); cmhelper.addSeparator(); cmhelper.addAction("importui_close"); // -------------------------------------------------------- cmhelper.exec(event->globalPos()); }
void EnfuseStackList::slotContextMenu(const QPoint& p) { KMenu popmenu(this); EnfuseStackItem* item = dynamic_cast<EnfuseStackItem*>(itemAt(p)); if (item) { KAction* rmItem = new KAction(KIcon("dialog-close"), i18n("Remove item"), this); connect(rmItem, SIGNAL(triggered(bool) ), this, SLOT(slotRemoveItem())); popmenu.addAction(rmItem); popmenu.addSeparator(); } KAction* rmAll = new KAction(KIcon("edit-delete-shred"), i18n("Clear all"), this); connect(rmAll, SIGNAL(triggered(bool) ), this, SLOT(clear())); popmenu.addAction(rmAll); popmenu.exec(QCursor::pos()); }
void EnfuseStackList::slotContextMenu(const QPoint& p) { QMenu popmenu(this); EnfuseStackItem* const item = dynamic_cast<EnfuseStackItem*>(itemAt(p)); if (item) { QAction* const rmItem = new QAction(QIcon::fromTheme(QStringLiteral("dialog-close")), i18nc("@item:inmenu", "Remove item"), this); connect(rmItem, SIGNAL(triggered(bool)), this, SLOT(slotRemoveItem())); popmenu.addAction(rmItem); popmenu.addSeparator(); } QAction* const rmAll = new QAction(QIcon::fromTheme(QStringLiteral("edit-delete-shred")), i18nc("@item:inmenu", "Clear all"), this); connect(rmAll, SIGNAL(triggered(bool)), this, SLOT(clear())); popmenu.addAction(rmAll); popmenu.exec(QCursor::pos()); }
void TagMngrListView::contextMenuEvent(QContextMenuEvent* event) { Q_UNUSED(event); KMenu popmenu(this); ContextMenuHelper cmhelper(&popmenu); TagList* const tagList = dynamic_cast<TagList*>(this->parent()); if(!tagList) { return; } KAction* const delAction = new KAction(KIcon("user-trash"), i18n("Delete Selected from List"),this); cmhelper.addAction(delAction, tagList, SLOT(slotDeleteSelected()),false); QModelIndexList sel = this->selectionModel()->selectedIndexes(); if(sel.size() == 1 && sel.first().row() == 0) delAction->setDisabled(true); cmhelper.exec(QCursor::pos()); }
TestMRPPWindow::TestMRPPWindow(HWND parent, std::string title) : MRPWindow(parent, title) { for (int i = 0; i < 8; ++i) { auto but = std::make_shared<WinButton>(this, std::to_string(i)); but->GenericNotifyCallback = [i](GenericNotifications) { readbg() << "you pressed " << i << "\n"; }; add_control(but); } // Button 0 toggless enabled state of button 1 m_controls[0]->GenericNotifyCallback = [this](GenericNotifications) { m_controls[1]->setEnabled(!m_controls[1]->isEnabled()); }; m_envcontrol1 = std::make_shared<EnvelopeControl>(this); // Button 3 toggless enabled state of envelope control m_controls[3]->GenericNotifyCallback = [this](GenericNotifications) { m_envcontrol1->setEnabled(!m_envcontrol1->isEnabled()); }; // Button 7 toggless visible state of button 0 m_controls[7]->GenericNotifyCallback = [this](GenericNotifications) { m_controls[0]->setVisible(!m_controls[0]->isVisible()); }; auto env = std::make_shared<breakpoint_envelope>("foo", LICE_RGBA(255, 255, 255, 255)); env->add_point({ 0.0, 0.5 , envbreakpoint::Power, 0.5 }, true); env->add_point({ 0.5, 0.0 , envbreakpoint::Power, 0.5 }, true); env->add_point({ 1.0, 0.5 }, true); m_envcontrol1->add_envelope(env); m_envcontrol1->GenericNotifyCallback = [this, env](GenericNotifications reason) { //if (reason == GenericNotifications::AfterManipulation) // generate_items_sequence(env, m_edit1->getText().c_str()); }; add_control(m_envcontrol1); // Button 5 does some Xenakios silliness m_controls[5]->GenericNotifyCallback = [this, env](GenericNotifications) { generate_items_sequence(env, m_edit1->getText().c_str()); }; m_label1 = std::make_shared<WinLabel>(this, "This is a label"); add_control(m_label1); m_edit1 = std::make_shared<WinLineEdit>(this, "C:/MusicAudio/pihla_ei/ei_mono_005.wav"); add_control(m_edit1); m_edit1->TextCallback = [this](std::string txt) { m_label1->setText(txt); }; // Button 6 launches bogus work in another thread to demo progress bar m_controls[6]->GenericNotifyCallback = [this](GenericNotifications) { m_progressbar1->setVisible(true); // we don't deal with multiple background tasks now, so disable the button to start the task m_controls[6]->setEnabled(false); static int rseed = 0; auto task = [this](int randseed) { std::mt19937 randgen(randseed); std::uniform_real_distribution<double> randdist(0.0, 1.0); double accum = 0.0; const int iterations = 50000000; double t0 = time_precise(); for (int i = 0; i < iterations; ++i) { accum += randdist(randgen); //accum += randdist(randgen); // Production code should not do this at this granularity, because setProgressValue deals with // an atomic value. but this is just a demo... m_progressbar1->setProgressValue(1.0 / iterations*i); } double t1 = time_precise(); auto finishtask = [=]() { m_edit1->setText(std::to_string(accum) + " elapsed time " + std::to_string(t1-t0)); m_progressbar1->setProgressValue(0.0); m_progressbar1->setVisible(false); m_controls[6]->setEnabled(true); }; execute_in_main_thread(finishtask); }; m_future1 = std::async(std::launch::async, task, rseed); ++rseed; }; // Button 1 shows popup menu m_controls[1]->GenericNotifyCallback = [this, env](GenericNotifications) { PopupMenu popmenu(getWindowHandle()); popmenu.add_menu_item("Menu entry 1", [](PopupMenu::CheckState) {}); popmenu.add_menu_item("Menu entry 2", m_menuitem2state, [this](PopupMenu::CheckState cs) { m_menuitem2state = cs; }); popmenu.add_menu_item("Menu entry 3", m_menuitem3state, [this](PopupMenu::CheckState cs) { m_menuitem3state = cs; }); PopupMenu submenu(getWindowHandle()); submenu.add_menu_item("Submenu entry 1", [](PopupMenu::CheckState) { readbg() << "submenu entry 1\n"; }); submenu.add_menu_item("Submenu entry 2", [](PopupMenu::CheckState) { readbg() << "submenu entry 2\n"; }); PopupMenu subsubmenu(getWindowHandle()); for (int i = 0; i < 8; ++i) { subsubmenu.add_menu_item(std::string("Subsubmenu entry ") + std::to_string(i + 1), [i](PopupMenu::CheckState) { readbg() << "subsubmenu entry " << i + 1 << "\n"; }); } submenu.add_submenu("Going still deeper", subsubmenu); popmenu.add_submenu("More stuff", submenu); popmenu.execute(m_controls[1]->getXPosition(), m_controls[1]->getYPosition()); }; // Button 4 removes envelope points with value over 0.5 m_controls[4]->GenericNotifyCallback = [this, env](GenericNotifications) { env->remove_points_conditionally([](const envbreakpoint& pt) { return pt.get_y() > 0.5; }); m_envcontrol1->repaint(); }; m_combo1 = std::make_shared<WinComboBox>(this); m_combo1->addItem("Apple", -9001); m_combo1->addItem("Pear", 666); m_combo1->addItem("Kiwi", 42); m_combo1->addItem("Banana", 100); m_combo1->SelectedChangedCallback = [this](int index) { int user_id = m_combo1->userIDfromIndex(index); readbg() << "combo index " << index << " userid " << user_id << "\n"; }; add_control(m_combo1); m_combo1->setSelectedUserID(42); m_combo2 = std::make_shared<WinComboBox>(this); m_combo2->addItem("Item 1", 100); m_combo2->addItem("Item 2", 101); m_combo2->addItem("Item 3", 102); m_combo2->addItem("Item 4", 103); m_combo2->SelectedChangedCallback = [this](int index) { int user_id = m_combo2->userIDfromIndex(index); readbg() << "combo index " << index << " userid " << user_id << "\n"; }; add_control(m_combo2); m_combo2->setSelectedIndex(0); m_slider1 = std::make_shared<ReaSlider>(this, 0.5); //m_slider1->setValueConverter(std::make_shared<FFTSizesValueConverter>()); m_slider1->SliderValueCallback = [this](GenericNotifications, double x) { m_label1->setText(std::to_string(x)); m_progressbar1->setProgressValue(x); }; add_control(m_slider1); m_zoomscroll1 = std::make_shared<ZoomScrollBar>(this); add_control(m_zoomscroll1); m_zoomscroll1->RangeChangedCallback = [this](double t0, double t1) { m_envcontrol1->setViewTimeRange(t0, t1); }; m_progressbar1 = std::make_shared<ProgressControl>(this); m_progressbar1->setVisible(false); }
void ImportIconView::showContextMenuOnInfo(QContextMenuEvent* event, const CamItemInfo& /*info*/) { QList<CamItemInfo> selectedInfos = selectedCamItemInfosCurrentFirst(); QList<qlonglong> selectedItemIDs; foreach(const CamItemInfo& info, selectedInfos) { selectedItemIDs << info.id; } // -------------------------------------------------------- KMenu popmenu(this); ImportContextMenuHelper cmhelper(&popmenu); cmhelper.addAction("importui_fullscreen"); cmhelper.addAction("options_show_menubar"); cmhelper.addAction("import_zoomfit2window"); cmhelper.addSeparator(); // -------------------------------------------------------- cmhelper.addAction("importui_imagedownload"); cmhelper.addAction("importui_imagemarkasdownloaded"); cmhelper.addAction("importui_imagelock"); cmhelper.addAction("importui_delete"); cmhelper.addSeparator(); cmhelper.addAction("importui_item_view"); cmhelper.addServicesMenu(selectedUrls()); //TODO: cmhelper.addRotateMenu(selectedItemIDs); cmhelper.addSeparator(); // -------------------------------------------------------- cmhelper.addAction("importui_selectall"); cmhelper.addAction("importui_selectnone"); cmhelper.addAction("importui_selectinvert"); cmhelper.addSeparator(); // -------------------------------------------------------- //cmhelper.addAssignTagsMenu(selectedItemIDs); //cmhelper.addRemoveTagsMenu(selectedItemIDs); //cmhelper.addSeparator(); // -------------------------------------------------------- cmhelper.addLabelsAction(); //if (!d->faceMode) //{ // cmhelper.addGroupMenu(selectedItemIDs); //} // special action handling -------------------------------- //connect(&cmhelper, SIGNAL(signalAssignTag(int)), //this, SLOT(assignTagToSelected(int))); //TODO: Implement tag view for import tool. //connect(&cmhelper, SIGNAL(signalPopupTagsView()), //this, SIGNAL(signalPopupTagsView())); //connect(&cmhelper, SIGNAL(signalRemoveTag(int)), //this, SLOT(removeTagFromSelected(int))); //connect(&cmhelper, SIGNAL(signalGotoTag(int)), //this, SIGNAL(gotoTagAndImageRequested(int))); connect(&cmhelper, SIGNAL(signalAssignPickLabel(int)), this, SLOT(assignPickLabelToSelected(int))); connect(&cmhelper, SIGNAL(signalAssignColorLabel(int)), this, SLOT(assignColorLabelToSelected(int))); connect(&cmhelper, SIGNAL(signalAssignRating(int)), this, SLOT(assignRatingToSelected(int))); //connect(&cmhelper, SIGNAL(signalAddToExistingQueue(int)), //this, SLOT(insertSelectedToExistingQueue(int))); //FIXME: connect(&cmhelper, SIGNAL(signalCreateGroup()), //this, SLOT(createGroupFromSelection())); //connect(&cmhelper, SIGNAL(signalUngroup()), //this, SLOT(ungroupSelected())); //connect(&cmhelper, SIGNAL(signalRemoveFromGroup()), //this, SLOT(removeSelectedFromGroup())); // -------------------------------------------------------- cmhelper.exec(event->globalPos()); }
int main(int argc, char* argv[]) { // every ParaGUI application need an application-object PG_Application app(argv[0]); // let us escape with "ESC" app.SetEmergencyQuit(true); // every application needs a theme (the look & feel of the widgets) //app.LoadTheme("default"); app.LoadTheme("simple"); // we must initialize the screen where we want to draw on // 640 - screen width // 480 - screen height // 0 - use screen bitdepth // SDL_SWSURFACE - PG_ option to generate surface in system memory app.InitScreen(800, 600, 0, SDL_SWSURFACE); // ok - now we have a nice 640x480x16 window on the screen :) PG_Rect rect(0, 0, 80, 30); PG_Button myButton( NULL, // an optional parent widget for our button - NULL for no parent rect, // the screen position where the button should appear "Quit" // some textlabel for the button ); // this defines our callback handler for the message MSG_BUTTONCLICK, // we pass a pointer to the app object as userdata PG_MenuBar menubar(NULL, PG_Rect(100, 0, 400, 30)); PG_PopupMenu popmenu(NULL, 425, 140, "File"); popmenu.addMenuItem("Nail", 99, SigC::slot(handle_menu_click)). addMenuItem("Quit", ID_APP_EXIT, SigC::slot(handle_menu_click), &app); menubar.Add("File", &popmenu); menubar.Show(); myButton.sigClick.connect( SigC::slot(exit_handler), (PG_Pointer)&app); // now we have to make the button visible myButton.Show(); // Every ParaGUI application is event driven, so we need a loop where // we process all events (like mouse handling, keystrokes,...) // usually this is done with PG_Application::Run() PG_Rect sc_rect(50, 50, 100, 300); PG_ScrollBar myscroll(NULL, sc_rect, PG_ScrollBar::VERTICAL); myscroll.Show(); PG_Rect sc_rect2(200, 200, 300, 100); PG_ScrollBar myscroll2(NULL, sc_rect2, PG_ScrollBar::HORIZONTAL); myscroll2.SetRange(0, 100); myscroll2.SetPageSize(10); myscroll2.SetLineSize(5); myscroll2.Show(); // Attempt to get animation PlayField anim_test( // still no parent widget NULL, // a static function to create rects PG_Rect(260,120,120,50) ); anim_test.AddTimer(400); anim_test.Show(); PlayField2 anim_test2( NULL, PG_Rect(260, 300, 120, 100) ); anim_test2.AddTimer(40); anim_test2.AddTimer(20); anim_test2.Show(); app.Run(); // this function will only exit when the application was closed return 0; }