ContactListDragView::ContactListDragView(QWidget* parent) : ContactListView(parent) , backedUpSelection_(0) , backedUpVerticalScrollBarValue_(-1) , removeAction_(0) , dropIndicatorRect_(QRect()) , dropIndicatorPosition_(QAbstractItemView::OnViewport) , keyboardModifiers_(Qt::NoModifier) , dirty_(false) , pressedIndex_(0) , pressedIndexWasSelected_(false) , viewportMenu_(0) { removeAction_ = new IconAction("", "psi/remove", QString(), ShortcutManager::instance()->shortcuts("contactlist.delete"), this, "act_remove"); connect(removeAction_, SIGNAL(activated()), SLOT(removeSelection())); addAction(removeAction_); connect(this, SIGNAL(entered(const QModelIndex&)), SLOT(updateCursorMouseHover(const QModelIndex&))); connect(this, SIGNAL(clicked(const QModelIndex&)), SLOT(itemClicked(const QModelIndex&))); connect(this, SIGNAL(viewportEntered()), SLOT(updateCursorMouseHover())); setSelectionMode(ExtendedSelection); viewport()->installEventFilter(this); setDragEnabled(true); setAcceptDrops(true); setDropIndicatorShown(false); // we're painting it by ourselves // There are crashes related to this in Qt 4.2.3. Disabling for now. // #ifndef Q_WS_X11 // setAnimated(true); // #endif }
void SimpleList::do_connections() { connect(ui->tableViewFM, SIGNAL(clicked(QModelIndex)), this, SLOT(onRowClicked(QModelIndex))); connect(ui->tableViewFM, SIGNAL(doubleClicked(QModelIndex)), this, SLOT(onOpenItem(QModelIndex))); connect(m_model, SIGNAL(pathChanged(QString)), this, SLOT(onPathChanged(QString))); connect(ui->toolButtonUp, SIGNAL(clicked()), m_model, SLOT(cdUp())); connect(ui->toolButtonBack, SIGNAL(clicked()), m_model, SLOT(goBack())); connect(ui->actionCopy, SIGNAL(triggered()), m_model, SLOT(copySelection())); connect(ui->actionCut, SIGNAL(triggered()), m_model, SLOT(cutSelection())); connect(ui->actionDelete, SIGNAL(triggered()), m_model, SLOT(removeSelection())); connect(ui->actionPaste, SIGNAL(triggered()), m_model, SLOT(paste())); connect(ui->actionMoveToTrash,SIGNAL(triggered()), m_model, SLOT(moveSelectionToTrash())); connect(ui->actionTerminnal, SIGNAL(triggered()), this, SLOT(onOpenTerminal())); connect(ui->actionRestoreFromTrash, SIGNAL(triggered()), m_model, SLOT(restoreSelectionFromTrash())); connect(ui->checkBoxShowDirs, SIGNAL(clicked(bool)), m_model, SLOT(setShowDirectories(bool))); connect(ui->checkBoxShowHidden, SIGNAL(clicked(bool)), m_model, SLOT(setShowHiddenFiles(bool))); connect(ui->checkBoxExtFsWatcher, SIGNAL(clicked(bool)), m_model, SLOT(setEnabledExternalFSWatcher(bool))); connect(ui->checkBoxShowMediaInfo, SIGNAL(clicked(bool)),m_model, SLOT(setReadsMediaMetadata(bool))); connect(ui->checkBoxMultiSelection,SIGNAL(clicked(bool)), m_selection, SLOT(setMultiSelection(bool))); connect(ui->comboBoxPath, SIGNAL(activated(int)), this, SLOT(onPathChoosedFromList(int))); connect(ui->comboBoxPath->lineEdit(), SIGNAL(returnPressed()), this, SLOT(onPathComboEdited())); connect(ui->tableViewFM->horizontalHeader(), SIGNAL(sortIndicatorChanged(int,Qt::SortOrder)), this, SLOT(onSetSort(int,Qt::SortOrder))); connect(m_model, SIGNAL(progress(int,int,int)), this, SLOT(onProgress(int,int,int))); connect(m_model, SIGNAL(clipboardChanged()), this, SLOT(onClipboardChanged())); connect(m_model, SIGNAL(error(QString,QString)), this, SLOT(onError(QString,QString))); connect(m_model, SIGNAL(awaitingResultsChanged()), this, SLOT(onStatusChanged())); connect(m_selection, SIGNAL(selectionChanged(int)), this, SLOT(onSelectionChanged(int))); connect(ui->listViewPlaces, SIGNAL(clicked(QModelIndex)), this, SLOT(onPlacesClicked(QModelIndex))); connect(m_pbar, SIGNAL(cancel()), this, SLOT(onCancelAction())); }
MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow) { ui->setupUi(this); QAction* aRemove = ui->actionRemove_Playlist_Selection; QAction* aClear = ui->actionClear_Playlist; connect(aRemove, SIGNAL(triggered()), ui->player->playlist(), SLOT(removeSelection())); connect(aClear, SIGNAL(triggered()), ui->player->playlist(), SLOT(clear())); connect(ui->player->inner_player(), SIGNAL(metaDataChanged(QString,QVariant)), SLOT(metadataChanged(QString,QVariant))); }
void SelectableGeometryFeatures::deleteVertex(Vertex *vertex) { VertexPath *ownerPath = vertex->ownerPath; removeSelection(vertex); if (ownerPath != NULL) { removeVertexFromPath(vertex); } vector<Vertex *>::iterator it = std::remove(mPoints.begin(), mPoints.end(), vertex); mPoints.erase(it, mPoints.end()); delete_safe (vertex); }
KornSubjectsDlg::KornSubjectsDlg(QWidget *parent) : KDialogBase(parent, "urldialog", true, "test", Close, Close, true), _mailDrop(new QPtrList< KMailDrop >), _subjects(0), _delete(0), mailDlg(0), _canDeleteMaildrop(true) { _loadSubjectsCanceled = false; setModal(true); // The dialog contains a list view and several buttons. // Two box layouts hol dthem. QWidget *page = new QWidget(this); setMainWidget(page); invertSelButton = new KPushButton(i18n("&Invert Selection"), page); clearSelButton = new KPushButton(i18n("&Remove Selection"), page); deleteButton = new KPushButton(i18n("&Delete"), page); showButton = new KPushButton(i18n("&Show"), page); deleteButton->setEnabled(false); showButton->setEnabled(false); QVBoxLayout *topLayout = new QVBoxLayout(page, 0, spacingHint()); QHBoxLayout *buttons = new QHBoxLayout(); _list = new KListView(page); topLayout->addWidget(_list, 10); topLayout->addLayout(buttons, 0); buttons->addWidget(invertSelButton, 0); buttons->addWidget(clearSelButton, 0); buttons->addWidget(deleteButton, 0); buttons->addWidget(showButton, 0); buttons->addStretch(10); // feed the list view with its colums _list->setSelectionMode(QListView::Multi); _list->addColumn(i18n("From")); _list->addColumn(i18n("Subject")); _list->addColumn(i18n("Date")); _list->addColumn(i18n("Size (Bytes)")); // column 3 contains a number (change alignment) _list->setColumnAlignment(3, Qt::AlignRight); _list->setItemMargin(3); // connect the selection changed and double click events of the list view connect(_list, SIGNAL(selectionChanged()), this, SLOT(listSelectionChanged())); connect(_list, SIGNAL(executed(QListViewItem *)), this, SLOT(doubleClicked(QListViewItem *))); // connect the buttons connect(invertSelButton, SIGNAL(clicked()), this, SLOT(invertSelection())); connect(clearSelButton, SIGNAL(clicked()), this, SLOT(removeSelection())); connect(showButton, SIGNAL(clicked()), this, SLOT(showMessage())); connect(deleteButton, SIGNAL(clicked()), this, SLOT(deleteMessage())); setInitialSize(QSize(QApplication::desktop()->width(), QApplication::desktop()->height())); }
void SelectableGeometryFeatures::deletePath(SelectableGeometryFeatures::VertexPath *path) { if (path->isSelected()) { removeSelection(path); } for (unsigned i = 0; i < path->vertexes.size(); i++) { path->vertexes[i]->ownerPath = NULL; } vector<VertexPath *>::iterator it = std::remove(mPaths.begin(), mPaths.end(), path); mPaths.erase(it, mPaths.end()); delete path; }
void ControllerAnnotations::keyPressEvent(QKeyEvent *event) { auto model = static_cast<Annotations*>(getModel()); actionQueued = ActionQueued::None; bool handled = true; if (event->modifiers()&Qt::AltModifier) { switch (event->key()) { case Qt::Key::Key_A: actionQueued = ActionQueued::CreateArrow; break; case Qt::Key::Key_L: actionQueued = ActionQueued::CreateLabel; break; case Qt::Key::Key_R: actionQueued = ActionQueued::CreateRect; break; case Qt::Key::Key_E: actionQueued = ActionQueued::CreateEllipse; break; case Qt::Key::Key_Delete: // Remove existing selected annotation at current frame. if (model->removeSelection()) { updateView(); } else handled = false; break; case Qt::Key::Key_Q: if (!model->updateSelectionStartFrame()) handled = false; break; case Qt::Key::Key_W: if (!model->updateSelectionEndFrame()) handled = false; break; default: handled = false; break; } } if (handled) event->accept(); }
QgsPresetColorRampWidget::QgsPresetColorRampWidget( const QgsPresetSchemeColorRamp& ramp, QWidget* parent ) : QgsPanelWidget( parent ) , mRamp( ramp ) { setupUi( this ); mTreeColors->setScheme( &mRamp ); connect( mButtonCopyColors, SIGNAL( clicked() ), mTreeColors, SLOT( copyColors() ) ); connect( mButtonRemoveColor, SIGNAL( clicked() ), mTreeColors, SLOT( removeSelection() ) ); connect( mButtonPasteColors, SIGNAL( clicked() ), mTreeColors, SLOT( pasteColors() ) ); connect( mButtonImportColors, SIGNAL( clicked( bool ) ), mTreeColors, SLOT( showImportColorsDialog() ) ); connect( mButtonExportColors, SIGNAL( clicked( bool ) ), mTreeColors, SLOT( showExportColorsDialog() ) ); connect( mTreeColors->model(), SIGNAL( dataChanged( QModelIndex, QModelIndex, QVector<int> ) ), this, SLOT( schemeChanged() ) ); connect( mTreeColors->model(), SIGNAL( rowsRemoved( QModelIndex, int, int ) ), this, SLOT( schemeChanged() ) ); updatePreview(); }
void Presenter::fillContextMenu( QMenu& menu, const QPoint& pos, const QPointF& scenepos) { menu.addSeparator(); auto removeAct = new QAction{tr("Remove"), this}; connect(removeAct, &QAction::triggered, [&] () { removeSelection(); }); auto typeMenu = menu.addMenu(tr("Type")); for(const auto& seg : m_curveSegments) { auto act = typeMenu->addAction(seg.prettyName()); connect(act, &QAction::triggered, this, [this,key=seg.concreteFactoryKey()] () { updateSegmentsType(key); }); } auto lockAction = new QAction{tr("Lock between points"), this}; connect(lockAction, &QAction::toggled, this, [&] (bool b) { m_editionSettings.setLockBetweenPoints(b); }); lockAction->setCheckable(true); lockAction->setChecked(m_editionSettings.lockBetweenPoints()); auto suppressAction = new QAction{tr("Suppress on overlap"), this}; connect(suppressAction, &QAction::toggled, this, [&] (bool b) { m_editionSettings.setSuppressOnOverlap(b); }); suppressAction->setCheckable(true); suppressAction->setChecked(m_editionSettings.suppressOnOverlap()); menu.addAction(removeAct); menu.addAction(lockAction); menu.addAction(suppressAction); }
void KJotsEdit::setEntry (KJotsPage *entry) { //tell the old entry to take a hike if ( m_entry ) { m_entry->setEditor(0); } //load up the new entry (assuming there is one) if ( entry ) { m_entry = entry; setText(entry->body()); removeSelection(); repaint(); setEnabled(true); setFocus(); entry->setEditor(this); } else { clear(); } m_entry = entry; }
// ============================================================= PythonSettings::PythonSettings(QWidget* parent, const char* name) : QWidget(parent), Ui_PythonSettingsData(), PreferencesEntry() { setINIFileSectionName("PYTHON"); setupUi(this); setObjectName(name); // signals and slots connections connect( choose_button, SIGNAL( clicked() ), this, SLOT( fileSelected() ) ); connect( clear_button, SIGNAL( clicked() ), this, SLOT( clearStartupScript() ) ); connect( font_button, SIGNAL( clicked() ), this, SLOT( selectFont() ) ); connect(new_button, SIGNAL(pressed()), table, SLOT(addEmptyRow())); connect(remove_button, SIGNAL(pressed()), table, SLOT(removeSelection())); registerWidgetForHelpSystem_(widget_stack->widget(0), "pythonInterpreter.html#startup_script"); registerWidgetForHelpSystem_(widget_stack->widget(1), "pythonInterpreter.html#create_hotkeys"); setWidgetStackName("Python"); setWidgetStack(widget_stack); registerWidgets_(); }
void AudioDeviceComboBox::AudioRescan() { AudioOutput::ADCVect &vect = m_parent->AudioDeviceVect(); AudioOutput::ADCVect::const_iterator it; if (vect.empty()) return; QString value = getValue(); clearSelections(); resetMaxCount(vect.size()); bool found = false; for (it = vect.begin(); it != vect.end(); it++) addSelection(it->name, it->name, value == it->name ? (found = true) : false); if (!found) { resetMaxCount(vect.size()+1); addSelection(value, value, true); } // For some reason, it adds an empty entry, remove it removeSelection(QString::null); }
void MsgView::messageRead(ICQMessage *msg) { QString pat; pat.sprintf("<a href=\"msg://%lu.%lu", msg->getUin(), msg->Id); for (int i = 0; i < paragraphs();){ if (text(i).find(pat) < 0){ for (i++; i < paragraphs(); i++) if (text(i).find("<a href=\"msg://") >= 0) break; continue; } int paraFrom, indexFrom; int paraTo, indexTo; getSelection(¶From, &indexFrom, ¶To, &indexTo); setSelection(i, 0, i, 0xFFFF); setBold(false); if ((paraFrom == -1) && (paraTo == -1)){ removeSelection(); scrollToBottom(); }else{ setSelection(paraFrom, indexFrom, paraTo, indexTo); } break; } }
//自定义 右键菜单 void MusicList::contextMenuEvent(QContextMenuEvent *event) { //播放列表右键菜单 if (this->currentItem() == this->topLevelItem(0)) { QMenu menu_rootDir; menu_rootDir.addAction(tr("清空所有列表"), this, SLOT(clearAll())); menu_rootDir.exec(event ->globalPos()); return; } for (int i=0; i<this->topLevelItemCount(); i++) { if (this->currentItem() == this->topLevelItem(i)) { //创建节点菜单 QMenu menu_rootDir; menu_rootDir.addAction(tr("删除"), this, SLOT(remove_rootDir())); menu_rootDir.addAction(tr("重命名"), this, SLOT(renameToplevel(QTreeWidgetItem *item))); menu_rootDir.addAction(tr("清空所有列表"), this, SLOT(clearAll())); menu_rootDir.exec(event ->globalPos()); return; } } //音乐右键菜单 QStringList otherToplevel; // 选中列表外的其他列表(用于添加到其他列表) QString activedToplevel = this->topLevelItem(get_current_rootDir())->text(0); // 被右键选中的列表的名字 for(int i=0; i<this->topLevelItemCount(); i++) // 遍历选中之外的其他列表的名字 { QString toplevelText = this->topLevelItem(i)->text(0); if (toplevelText == activedToplevel) { continue; } otherToplevel.append(toplevelText); } //创建二级菜单 QMenu menu_child; menu_child.setIcon(QIcon(":/Images/menu_add.png")); menu_child.setTitle(tr("添加到...")); for (int i=0; i<this->topLevelItemCount(); ++i) { if (this->topLevelItem(i) != this->topLevelItem(get_current_rootDir())) { menu_child.addAction(musicMenuActionList[i]); } } connect(&menu_child, SIGNAL(triggered(QAction*)), this, SLOT(add_otherMusicList(QAction*))); // for (int i=0; i<otherToplevel.count(); i++) // { // menu_child.addAction(otherToplevel.at(i), this, SLOT(add_otherMusicList())); // } //创建项目菜单 QMenu menu_item; menu_item.addAction(QIcon(":/Images/menu_play.png"), tr("立即播放"), this, SLOT(rightBtnPlay())); menu_item.addMenu(&menu_child); menu_item.addAction(QIcon(":/Images/miniWindow_hover.png"), tr("移出列表"), this, SLOT(removeSelection())); menu_item.addAction(QIcon(":/Images/closeWindow_hover.png"), tr("删除歌曲及文件"), this, SLOT(deleteSelection())); menu_item.addAction(QIcon(":/Images/menu_clear.png"), tr("清空本列表"), this, SLOT(clearSelf())); menu_item.exec(event ->globalPos()); return; }
void MainWindow::on_pushButtonRemove_clicked() { removeSelection(); }
void ControllerAnnotations::receiveDeleteSelectedAnnotation(){ auto model = static_cast<Annotations*>(getModel()); if (model->removeSelection()){ updateView(); } }
void *MsgViewBase::processEvent(Event *e) { if (e->type() == EventRewriteMessage){ Message *msg = (Message*)(e->param()); if (msg->contact() != m_id) return NULL; unsigned i; for (i = 0; i < (unsigned)paragraphs(); i++){ QString s = text(i); int n = s.find(MSG_ANCHOR); if (n < 0) continue; s = s.mid(n + strlen(MSG_ANCHOR)); n = s.find("\""); if (n < 0) continue; string client; if ((messageId(s.left(n), client) == msg->id()) && (client == msg->client())) break; } if (i >= (unsigned)paragraphs()) return NULL; reload(); return NULL; } if (e->type() == EventCutHistory){ CutHistory *ch = (CutHistory*)(e->param()); if (ch->contact != m_id) return NULL; bool bDelete = false; vector<unsigned> start_pos; vector<unsigned> end_pos; for (unsigned i = 0; i < (unsigned)paragraphs(); i++){ QString s = text(i); int n = s.find(MSG_ANCHOR); if (n < 0) continue; s = s.mid(n + strlen(MSG_ANCHOR)); n = s.find("\""); if (n < 0) continue; string client; unsigned id = messageId(s.left(n), client); log(L_DEBUG, "> %u %u %s - %u %u %u", i, id, client.c_str(), ch->from, ch->size, ch->from + ch->size); if ((client == ch->client) && (id >= ch->from) && (id < ch->from + ch->size)){ log(L_DEBUG, "Delete!"); if (!bDelete){ bDelete = true; start_pos.push_back(i); } }else{ if (bDelete){ bDelete = false; end_pos.push_back(i); } } } if (bDelete) end_pos.push_back(paragraphs()); if (start_pos.size()){ int paraFrom, indexFrom; int paraTo, indexTo; getSelection(¶From, &indexFrom, ¶To, &indexTo); QPoint p = QPoint(0, 0); p = mapToGlobal(p); p = viewport()->mapFromGlobal(p); int x, y; viewportToContents(p.x(), p.y(), x, y); int para; int pos = charAt(QPoint(x, y), ¶); setReadOnly(false); for (unsigned i = 0; i < start_pos.size(); i++){ setSelection(start_pos[i], 0, end_pos[i], 0); removeSelectedText(); if ((unsigned)pos >= start_pos[i]) pos = end_pos[i] - start_pos[i]; } if ((paraFrom == -1) && (paraTo == -1)){ if (pos == -1){ scrollToBottom(); }else{ setCursorPosition(para, pos); ensureCursorVisible(); } }else{ setSelection(paraFrom, indexFrom, paraTo, indexTo); } setReadOnly(true); repaint(); } m_cut.push_back(*ch); return NULL; } if (e->type() == EventMessageDeleted){ Message *msg = (Message*)(e->param()); if (msg->contact() != m_id) return NULL; for (unsigned i = 0; i < (unsigned)paragraphs(); i++){ QString s = text(i); int n = s.find(MSG_ANCHOR); if (n < 0) continue; s = s.mid(n + strlen(MSG_ANCHOR)); n = s.find("\""); if (n < 0) continue; string client; if ((messageId(s.left(n), client) != msg->id()) || (client != msg->client())) continue; unsigned j; for (j = i + 1; j < (unsigned)paragraphs(); j++){ QString s = text(j); if (s.find(MSG_ANCHOR) >= 0) break; } int paraFrom, indexFrom; int paraTo, indexTo; getSelection(¶From, &indexFrom, ¶To, &indexTo); setSelection(i, 0, j - 1, 0xFFFF); setReadOnly(false); removeSelectedText(); setReadOnly(true); if ((paraFrom == -1) && (paraTo == -1)){ scrollToBottom(); }else{ setSelection(paraFrom, indexFrom, paraTo, indexTo); } break; } return NULL; } if (e->type() == EventMessageRead){ Message *msg = (Message*)(e->param()); if (msg->contact() != m_id) return NULL; for (unsigned i = 0; i < (unsigned)paragraphs(); i++){ QString s = text(i); int n = s.find(MSG_ANCHOR); if (n < 0) continue; s = s.mid(n + strlen(MSG_ANCHOR)); n = s.find("\""); if (n < 0) continue; string client; if ((messageId(s.left(n), client) != msg->id()) || (client != msg->client())) continue; int paraFrom, indexFrom; int paraTo, indexTo; getSelection(¶From, &indexFrom, ¶To, &indexTo); setSelection(i, 0, i, 0xFFFF); setBold(false); if ((paraFrom == -1) && (paraTo == -1)){ removeSelection(); scrollToBottom(); }else{ setSelection(paraFrom, indexFrom, paraTo, indexTo); } break; } return NULL; } if (e->type() == EventHistoryConfig){ unsigned id = (unsigned)(e->param()); if (id && (id != m_id)) return NULL; reload(); } if (e->type() == EventHistoryColors) setColors(); if (e->type() == EventCheckState){ CommandDef *cmd = (CommandDef*)(e->param()); if ((cmd->param != this) || (cmd->menu_id != MenuMsgView)) return NULL; Message *msg; switch (cmd->id){ case CmdCopy: cmd->flags &= ~(COMMAND_DISABLED | COMMAND_CHECKED); if (!hasSelectedText()) cmd->flags |= COMMAND_DISABLED; return e->param(); case CmdMsgOpen: msg = currentMessage(); if (msg){ unsigned type = msg->baseType(); delete msg; CommandDef *def = CorePlugin::m_plugin->messageTypes.find(type); if (def == NULL) return NULL; cmd->icon = def->icon; cmd->flags &= ~COMMAND_CHECKED; return e->param(); } return NULL; case CmdMsgSpecial: msg = currentMessage(); if (msg){ Event eMenu(EventGetMenuDef, (void*)MenuMsgCommand); CommandsDef *cmdsMsg = (CommandsDef*)(eMenu.process()); unsigned n = 0; MessageDef *mdef = NULL; unsigned type = msg->baseType(); const CommandDef *cmdsSpecial = NULL; CommandDef *msgCmd = CorePlugin::m_plugin->messageTypes.find(type); if (msgCmd) mdef = (MessageDef*)(msgCmd->param); if (mdef){ if (msg->getFlags() & MESSAGE_RECEIVED){ cmdsSpecial = mdef->cmdReceived; }else{ cmdsSpecial = mdef->cmdSent; } if (cmdsSpecial) for (const CommandDef *d = cmdsSpecial; d->text; d++) n++; } { CommandsList it(*cmdsMsg, true); while (++it) n++; } if (n == 0) return NULL; n++; CommandDef *cmds = new CommandDef[n]; memset(cmds, 0, sizeof(CommandDef) * n); n = 0; if (cmdsSpecial){ for (const CommandDef *d = cmdsSpecial; d->text; d++){ cmds[n] = *d; cmds[n].id = CmdMsgSpecial + n; n++; } } CommandDef *c; CommandsList it(*cmdsMsg, true); while ((c = ++it) != NULL){ CommandDef cmd = *c; cmd.menu_id = MenuMsgCommand; cmd.param = msg; Event e(EventCheckState, &cmd); if (!e.process()) continue; cmd.flags &= ~COMMAND_CHECK_STATE; cmds[n++] = cmd; } cmd->param = cmds; cmd->flags |= COMMAND_RECURSIVE; delete msg; return e->param(); } return NULL; } } if (e->type() == EventCommandExec){ CommandDef *cmd = (CommandDef*)(e->param()); if ((cmd->param != this) || (cmd->menu_id != MenuMsgView)) return NULL; Message *msg; switch (cmd->id){ case CmdCutHistory: msg = currentMessage(); if (msg){ History::cut(msg, 0, 0); delete msg; return e->param(); } return NULL; case CmdDeleteMessage: msg = currentMessage(); if (msg){ History::del(msg); delete msg; return e->param(); } return NULL; case CmdCopy: copy(); return e->param(); case CmdMsgOpen: msg = currentMessage(); if (msg){ msg->setFlags(msg->getFlags() | MESSAGE_OPEN); Event eOpen(EventOpenMessage, msg); eOpen.process(); delete msg; return e->param(); } return NULL; default: msg = currentMessage(); if (msg){ if (cmd->id >= CmdMsgSpecial){ MessageDef *mdef = NULL; unsigned type = msg->baseType(); CommandDef *msgCmd = CorePlugin::m_plugin->messageTypes.find(type); if (msgCmd) mdef = (MessageDef*)(msgCmd->param); const CommandDef *cmds = NULL; if (mdef){ if (msg->getFlags() & MESSAGE_RECEIVED){ cmds = mdef->cmdReceived; }else{ cmds = mdef->cmdSent; } } if (cmds){ unsigned n = cmd->id - CmdMsgSpecial; for (const CommandDef *d = cmds; d->text; d++){ if (n-- == 0){ CommandDef cmd = *d; cmd.param = msg; Event eCmd(EventCommandExec, &cmd); eCmd.process(); return e->param(); } } } } Command c; c->id = cmd->id; c->menu_id = MenuMsgCommand; c->param = msg; Event e(EventCommandExec, c); void *res = e.process(); delete msg; return res; } return NULL; } } return NULL; }
QgsCompoundColorWidget::QgsCompoundColorWidget( QWidget *parent, const QColor& color, Layout widgetLayout ) : QgsPanelWidget( parent ) , mAllowAlpha( true ) , mLastCustomColorIndex( 0 ) , mPickingColor( false ) { setupUi( this ); if ( widgetLayout == LayoutVertical ) { // shuffle stuff around QVBoxLayout* newLayout = new QVBoxLayout(); newLayout->addWidget( mTabWidget ); newLayout->addWidget( mSlidersWidget ); newLayout->addWidget( mPreviewWidget ); newLayout->addWidget( mSwatchesWidget ); delete layout(); setLayout( newLayout ); } QSettings settings; mSchemeList->header()->hide(); mSchemeList->setColumnWidth( 0, 44 ); //get schemes with ShowInColorDialog set refreshSchemeComboBox(); QList<QgsColorScheme *> schemeList = QgsColorSchemeRegistry::instance()->schemes( QgsColorScheme::ShowInColorDialog ); //choose a reasonable starting scheme int activeScheme = settings.value( "/Windows/ColorDialog/activeScheme", 0 ).toInt(); activeScheme = activeScheme >= mSchemeComboBox->count() ? 0 : activeScheme; mSchemeList->setScheme( schemeList.at( activeScheme ) ); mSchemeComboBox->setCurrentIndex( activeScheme ); updateActionsForCurrentScheme(); //listen out for selection changes in list, so we can enable/disable the copy colors option connect( mSchemeList->selectionModel(), SIGNAL( selectionChanged( QItemSelection, QItemSelection ) ), this, SLOT( listSelectionChanged( QItemSelection, QItemSelection ) ) ); //copy action defaults to disabled mActionCopyColors->setEnabled( false ); connect( mActionCopyColors, SIGNAL( triggered() ), mSchemeList, SLOT( copyColors() ) ); connect( mActionPasteColors, SIGNAL( triggered() ), mSchemeList, SLOT( pasteColors() ) ); connect( mActionExportColors, SIGNAL( triggered() ), this, SLOT( exportColors() ) ); connect( mActionImportColors, SIGNAL( triggered() ), this, SLOT( importColors() ) ); connect( mActionImportPalette, SIGNAL( triggered() ), this, SLOT( importPalette() ) ); connect( mActionRemovePalette, SIGNAL( triggered() ), this, SLOT( removePalette() ) ); connect( mActionNewPalette, SIGNAL( triggered() ), this, SLOT( newPalette() ) ); connect( mRemoveColorsFromSchemeButton, SIGNAL( clicked() ), mSchemeList, SLOT( removeSelection() ) ); QMenu* schemeMenu = new QMenu( mSchemeToolButton ); schemeMenu->addAction( mActionCopyColors ); schemeMenu->addAction( mActionPasteColors ); schemeMenu->addSeparator(); schemeMenu->addAction( mActionImportColors ); schemeMenu->addAction( mActionExportColors ); schemeMenu->addSeparator(); schemeMenu->addAction( mActionNewPalette ); schemeMenu->addAction( mActionImportPalette ); schemeMenu->addAction( mActionRemovePalette ); schemeMenu->addAction( mActionShowInButtons ); mSchemeToolButton->setMenu( schemeMenu ); connect( mSchemeComboBox, SIGNAL( currentIndexChanged( int ) ), this, SLOT( schemeIndexChanged( int ) ) ); connect( mSchemeList, SIGNAL( colorSelected( QColor ) ), this, SLOT( setColor( QColor ) ) ); mOldColorLabel->hide(); mVerticalRamp->setOrientation( QgsColorRampWidget::Vertical ); mVerticalRamp->setInteriorMargin( 2 ); mVerticalRamp->setShowFrame( true ); mRedSlider->setComponent( QgsColorWidget::Red ); mGreenSlider->setComponent( QgsColorWidget::Green ); mBlueSlider->setComponent( QgsColorWidget::Blue ); mHueSlider->setComponent( QgsColorWidget::Hue ); mSaturationSlider->setComponent( QgsColorWidget::Saturation ); mValueSlider->setComponent( QgsColorWidget::Value ); mAlphaSlider->setComponent( QgsColorWidget::Alpha ); mSwatchButton1->setShowMenu( false ); mSwatchButton1->setBehaviour( QgsColorButton::SignalOnly ); mSwatchButton2->setShowMenu( false ); mSwatchButton2->setBehaviour( QgsColorButton::SignalOnly ); mSwatchButton3->setShowMenu( false ); mSwatchButton3->setBehaviour( QgsColorButton::SignalOnly ); mSwatchButton4->setShowMenu( false ); mSwatchButton4->setBehaviour( QgsColorButton::SignalOnly ); mSwatchButton5->setShowMenu( false ); mSwatchButton5->setBehaviour( QgsColorButton::SignalOnly ); mSwatchButton6->setShowMenu( false ); mSwatchButton6->setBehaviour( QgsColorButton::SignalOnly ); mSwatchButton7->setShowMenu( false ); mSwatchButton7->setBehaviour( QgsColorButton::SignalOnly ); mSwatchButton8->setShowMenu( false ); mSwatchButton8->setBehaviour( QgsColorButton::SignalOnly ); mSwatchButton9->setShowMenu( false ); mSwatchButton9->setBehaviour( QgsColorButton::SignalOnly ); mSwatchButton10->setShowMenu( false ); mSwatchButton10->setBehaviour( QgsColorButton::SignalOnly ); mSwatchButton11->setShowMenu( false ); mSwatchButton11->setBehaviour( QgsColorButton::SignalOnly ); mSwatchButton12->setShowMenu( false ); mSwatchButton12->setBehaviour( QgsColorButton::SignalOnly ); mSwatchButton13->setShowMenu( false ); mSwatchButton13->setBehaviour( QgsColorButton::SignalOnly ); mSwatchButton14->setShowMenu( false ); mSwatchButton14->setBehaviour( QgsColorButton::SignalOnly ); mSwatchButton15->setShowMenu( false ); mSwatchButton15->setBehaviour( QgsColorButton::SignalOnly ); mSwatchButton16->setShowMenu( false ); mSwatchButton16->setBehaviour( QgsColorButton::SignalOnly ); //restore custom colors mSwatchButton1->setColor( settings.value( "/Windows/ColorDialog/customColor1", QVariant( QColor() ) ).value<QColor>() ); mSwatchButton2->setColor( settings.value( "/Windows/ColorDialog/customColor2", QVariant( QColor() ) ).value<QColor>() ); mSwatchButton3->setColor( settings.value( "/Windows/ColorDialog/customColor3", QVariant( QColor() ) ).value<QColor>() ); mSwatchButton4->setColor( settings.value( "/Windows/ColorDialog/customColor4", QVariant( QColor() ) ).value<QColor>() ); mSwatchButton5->setColor( settings.value( "/Windows/ColorDialog/customColor5", QVariant( QColor() ) ).value<QColor>() ); mSwatchButton6->setColor( settings.value( "/Windows/ColorDialog/customColor6", QVariant( QColor() ) ).value<QColor>() ); mSwatchButton7->setColor( settings.value( "/Windows/ColorDialog/customColor7", QVariant( QColor() ) ).value<QColor>() ); mSwatchButton8->setColor( settings.value( "/Windows/ColorDialog/customColor8", QVariant( QColor() ) ).value<QColor>() ); mSwatchButton9->setColor( settings.value( "/Windows/ColorDialog/customColor9", QVariant( QColor() ) ).value<QColor>() ); mSwatchButton10->setColor( settings.value( "/Windows/ColorDialog/customColor10", QVariant( QColor() ) ).value<QColor>() ); mSwatchButton11->setColor( settings.value( "/Windows/ColorDialog/customColor11", QVariant( QColor() ) ).value<QColor>() ); mSwatchButton12->setColor( settings.value( "/Windows/ColorDialog/customColor12", QVariant( QColor() ) ).value<QColor>() ); mSwatchButton13->setColor( settings.value( "/Windows/ColorDialog/customColor13", QVariant( QColor() ) ).value<QColor>() ); mSwatchButton14->setColor( settings.value( "/Windows/ColorDialog/customColor14", QVariant( QColor() ) ).value<QColor>() ); mSwatchButton15->setColor( settings.value( "/Windows/ColorDialog/customColor15", QVariant( QColor() ) ).value<QColor>() ); mSwatchButton16->setColor( settings.value( "/Windows/ColorDialog/customColor16", QVariant( QColor() ) ).value<QColor>() ); //restore sample radius mSpinBoxRadius->setValue( settings.value( "/Windows/ColorDialog/sampleRadius", 1 ).toInt() ); mSamplePreview->setColor( QColor() ); if ( color.isValid() ) { setColor( color ); } //restore active component radio button int activeRadio = settings.value( "/Windows/ColorDialog/activeComponent", 2 ).toInt(); switch ( activeRadio ) { case 0: mHueRadio->setChecked( true ); break; case 1: mSaturationRadio->setChecked( true ); break; case 2: mValueRadio->setChecked( true ); break; case 3: mRedRadio->setChecked( true ); break; case 4: mGreenRadio->setChecked( true ); break; case 5: mBlueRadio->setChecked( true ); break; } int currentTab = settings.value( "/Windows/ColorDialog/activeTab", 0 ).toInt(); mTabWidget->setCurrentIndex( currentTab ); #ifdef Q_OS_MAC //disable color picker tab for OSX, as it is impossible to grab the mouse under OSX //see note for QWidget::grabMouse() re OSX Cocoa //http://qt-project.org/doc/qt-4.8/qwidget.html#grabMouse mTabWidget->removeTab( 3 ); #endif //setup connections connect( mColorBox, SIGNAL( colorChanged( QColor ) ), this, SLOT( setColor( QColor ) ) ); connect( mColorWheel, SIGNAL( colorChanged( QColor ) ), this, SLOT( setColor( QColor ) ) ); connect( mColorText, SIGNAL( colorChanged( QColor ) ), this, SLOT( setColor( QColor ) ) ); connect( mVerticalRamp, SIGNAL( colorChanged( QColor ) ), this, SLOT( setColor( QColor ) ) ); connect( mRedSlider, SIGNAL( colorChanged( QColor ) ), this, SLOT( setColor( QColor ) ) ); connect( mGreenSlider, SIGNAL( colorChanged( QColor ) ), this, SLOT( setColor( QColor ) ) ); connect( mBlueSlider, SIGNAL( colorChanged( QColor ) ), this, SLOT( setColor( QColor ) ) ); connect( mHueSlider, SIGNAL( colorChanged( QColor ) ), this, SLOT( setColor( QColor ) ) ); connect( mValueSlider, SIGNAL( colorChanged( QColor ) ), this, SLOT( setColor( QColor ) ) ); connect( mSaturationSlider, SIGNAL( colorChanged( QColor ) ), this, SLOT( setColor( QColor ) ) ); connect( mAlphaSlider, SIGNAL( colorChanged( QColor ) ), this, SLOT( setColor( QColor ) ) ); connect( mColorPreview, SIGNAL( colorChanged( QColor ) ), this, SLOT( setColor( QColor ) ) ); connect( mSwatchButton1, SIGNAL( colorClicked( QColor ) ), this, SLOT( setColor( QColor ) ) ); connect( mSwatchButton2, SIGNAL( colorClicked( QColor ) ), this, SLOT( setColor( QColor ) ) ); connect( mSwatchButton3, SIGNAL( colorClicked( QColor ) ), this, SLOT( setColor( QColor ) ) ); connect( mSwatchButton4, SIGNAL( colorClicked( QColor ) ), this, SLOT( setColor( QColor ) ) ); connect( mSwatchButton5, SIGNAL( colorClicked( QColor ) ), this, SLOT( setColor( QColor ) ) ); connect( mSwatchButton6, SIGNAL( colorClicked( QColor ) ), this, SLOT( setColor( QColor ) ) ); connect( mSwatchButton7, SIGNAL( colorClicked( QColor ) ), this, SLOT( setColor( QColor ) ) ); connect( mSwatchButton8, SIGNAL( colorClicked( QColor ) ), this, SLOT( setColor( QColor ) ) ); connect( mSwatchButton9, SIGNAL( colorClicked( QColor ) ), this, SLOT( setColor( QColor ) ) ); connect( mSwatchButton10, SIGNAL( colorClicked( QColor ) ), this, SLOT( setColor( QColor ) ) ); connect( mSwatchButton11, SIGNAL( colorClicked( QColor ) ), this, SLOT( setColor( QColor ) ) ); connect( mSwatchButton12, SIGNAL( colorClicked( QColor ) ), this, SLOT( setColor( QColor ) ) ); connect( mSwatchButton13, SIGNAL( colorClicked( QColor ) ), this, SLOT( setColor( QColor ) ) ); connect( mSwatchButton14, SIGNAL( colorClicked( QColor ) ), this, SLOT( setColor( QColor ) ) ); connect( mSwatchButton15, SIGNAL( colorClicked( QColor ) ), this, SLOT( setColor( QColor ) ) ); connect( mSwatchButton16, SIGNAL( colorClicked( QColor ) ), this, SLOT( setColor( QColor ) ) ); }
QList<PopupDropperAction*> Playlist::ViewCommon::actionsFor( QWidget *parent, const QModelIndex *index, bool coverActions ) { QList<PopupDropperAction*> actions; Meta::TrackPtr track = index->data( Playlist::TrackRole ).value< Meta::TrackPtr >(); PopupDropperAction *separator = new PopupDropperAction( parent ); separator->setSeparator( true ); const bool isCurrentTrack = index->data( Playlist::ActiveTrackRole ).toBool(); PopupDropperAction *stopAction = new PopupDropperAction( KIcon( "media-playback-stop-amarok" ), i18n( "Stop Playing After This Track" ), parent ); QObject::connect( stopAction, SIGNAL( triggered() ), parent, SLOT( stopAfterTrack() ) ); actions << stopAction; actions << separator; const bool isQueued = index->data( Playlist::StateRole ).toInt() & Item::Queued; const QString queueText = !isQueued ? i18n( "Queue Track" ) : i18n( "Dequeue Track" ); PopupDropperAction *queueAction = new PopupDropperAction( KIcon( "media-track-queue-amarok" ), queueText, parent ); if( isQueued ) QObject::connect( queueAction, SIGNAL( triggered() ), parent, SLOT( dequeueSelection() ) ); else QObject::connect( queueAction, SIGNAL( triggered() ), parent, SLOT( queueSelection() ) ); actions << queueAction; actions << separator; PopupDropperAction *removeAction = new PopupDropperAction( KIcon( "media-track-remove-amarok" ), i18n( "Remove From Playlist" ), parent ); QObject::connect( removeAction, SIGNAL( triggered() ), parent, SLOT( removeSelection() ) ); actions << removeAction; actions << separator; //lets see if parent is the currently playing tracks, and if it has CurrentTrackActionsCapability if( isCurrentTrack ) { QList<QAction*> globalCurrentTrackActions = The::globalCurrentTrackActions()->actions(); foreach( QAction *action, globalCurrentTrackActions ) actions << PopupDropperAction::from( action ); if ( track->hasCapabilityInterface( Meta::Capability::CurrentTrackActions ) ) { Meta::CurrentTrackActionsCapability *cac = track->create<Meta::CurrentTrackActionsCapability>(); if ( cac ) { QList<PopupDropperAction *> actions = cac->customActions(); foreach( PopupDropperAction *action, actions ) actions << action; } delete cac; } } actions << separator; if ( coverActions ) { Meta::AlbumPtr album = track->album(); if ( album ) { Meta::CustomActionsCapability *cac = album->create<Meta::CustomActionsCapability>(); if ( cac ) { QList<PopupDropperAction *> customActions = cac->customActions(); foreach( PopupDropperAction *customAction, customActions ) actions << customAction; } delete cac; } } actions << separator; const bool isMultiSource = index->data( Playlist::MultiSourceRole ).toBool(); if( isMultiSource ) { PopupDropperAction *selectSourceAction = new PopupDropperAction( KIcon( "media-playlist-repeat" ), i18n( "Select Source" ), parent ); QObject::connect( selectSourceAction, SIGNAL( triggered() ), parent, SLOT( selectSource() ) ); actions << selectSourceAction; } PopupDropperAction *editAction = new PopupDropperAction( KIcon( "media-track-edit-amarok" ), i18n( "Edit Track Details" ), parent ); QObject::connect( editAction, SIGNAL( triggered() ), parent, SLOT( editTrackInformation() ) ); actions << editAction; return actions; }
QgsColorDialogV2::QgsColorDialogV2( QWidget *parent, Qt::WindowFlags fl, const QColor& color ) : QDialog( parent, fl ) , mPreviousColor( color ) , mAllowAlpha( true ) , mLastCustomColorIndex( 0 ) , mPickingColor( false ) { setupUi( this ); QSettings settings; restoreGeometry( settings.value( "/Windows/ColorDialog/geometry" ).toByteArray() ); mSchemeList->header()->hide(); mSchemeList->setColumnWidth( 0, 44 ); //get schemes with ShowInColorDialog set refreshSchemeComboBox(); QList<QgsColorScheme *> schemeList = QgsColorSchemeRegistry::instance()->schemes( QgsColorScheme::ShowInColorDialog ); //choose a reasonable starting scheme int activeScheme = settings.value( "/Windows/ColorDialog/activeScheme", 0 ).toInt(); activeScheme = activeScheme >= mSchemeComboBox->count() ? 0 : activeScheme; mSchemeList->setScheme( schemeList.at( activeScheme ) ); mSchemeComboBox->setCurrentIndex( activeScheme ); mActionImportColors->setEnabled( schemeList.at( activeScheme )->isEditable() ); mActionPasteColors->setEnabled( schemeList.at( activeScheme )->isEditable() ); mAddColorToSchemeButton->setEnabled( schemeList.at( activeScheme )->isEditable() ); mRemoveColorsFromSchemeButton->setEnabled( schemeList.at( activeScheme )->isEditable() ); QgsUserColorScheme* userScheme = dynamic_cast<QgsUserColorScheme*>( schemeList.at( activeScheme ) ); mActionRemovePalette->setEnabled( userScheme ? true : false ); //listen out for selection changes in list, so we can enable/disable the copy colors option connect( mSchemeList->selectionModel(), SIGNAL( selectionChanged( QItemSelection, QItemSelection ) ), this, SLOT( listSelectionChanged( QItemSelection, QItemSelection ) ) ); //copy action defaults to disabled mActionCopyColors->setEnabled( false ); connect( mActionCopyColors, SIGNAL( triggered() ), mSchemeList, SLOT( copyColors() ) ); connect( mActionPasteColors, SIGNAL( triggered() ), mSchemeList, SLOT( pasteColors() ) ); connect( mActionExportColors, SIGNAL( triggered() ), this, SLOT( exportColors() ) ); connect( mActionImportColors, SIGNAL( triggered() ), this, SLOT( importColors() ) ); connect( mActionImportPalette, SIGNAL( triggered() ), this, SLOT( importPalette() ) ); connect( mActionRemovePalette, SIGNAL( triggered() ), this, SLOT( removePalette() ) ); connect( mActionNewPalette, SIGNAL( triggered() ), this, SLOT( newPalette() ) ); connect( mRemoveColorsFromSchemeButton, SIGNAL( clicked() ), mSchemeList, SLOT( removeSelection() ) ); QMenu* schemeMenu = new QMenu( mSchemeToolButton ); schemeMenu->addAction( mActionCopyColors ); schemeMenu->addAction( mActionPasteColors ); schemeMenu->addSeparator(); schemeMenu->addAction( mActionImportColors ); schemeMenu->addAction( mActionExportColors ); schemeMenu->addSeparator(); schemeMenu->addAction( mActionNewPalette ); schemeMenu->addAction( mActionImportPalette ); schemeMenu->addAction( mActionRemovePalette ); mSchemeToolButton->setMenu( schemeMenu ); connect( mSchemeComboBox, SIGNAL( currentIndexChanged( int ) ), this, SLOT( schemeIndexChanged( int ) ) ); connect( mSchemeList, SIGNAL( colorSelected( QColor ) ), this, SLOT( setColor( QColor ) ) ); if ( mPreviousColor.isValid() ) { QPushButton* resetButton = new QPushButton( tr( "Reset" ) ); mButtonBox->addButton( resetButton, QDialogButtonBox::ResetRole ); } else { mOldColorLabel->hide(); } mVerticalRamp->setOrientation( QgsColorRampWidget::Vertical ); mVerticalRamp->setInteriorMargin( 2 ); mVerticalRamp->setShowFrame( true ); mRedSlider->setComponent( QgsColorWidget::Red ); mGreenSlider->setComponent( QgsColorWidget::Green ); mBlueSlider->setComponent( QgsColorWidget::Blue ); mHueSlider->setComponent( QgsColorWidget::Hue ); mSaturationSlider->setComponent( QgsColorWidget::Saturation ); mValueSlider->setComponent( QgsColorWidget::Value ); mAlphaSlider->setComponent( QgsColorWidget::Alpha ); mSwatchButton1->setShowMenu( false ); mSwatchButton1->setBehaviour( QgsColorButtonV2::SignalOnly ); mSwatchButton2->setShowMenu( false ); mSwatchButton2->setBehaviour( QgsColorButtonV2::SignalOnly ); mSwatchButton3->setShowMenu( false ); mSwatchButton3->setBehaviour( QgsColorButtonV2::SignalOnly ); mSwatchButton4->setShowMenu( false ); mSwatchButton4->setBehaviour( QgsColorButtonV2::SignalOnly ); mSwatchButton5->setShowMenu( false ); mSwatchButton5->setBehaviour( QgsColorButtonV2::SignalOnly ); mSwatchButton6->setShowMenu( false ); mSwatchButton6->setBehaviour( QgsColorButtonV2::SignalOnly ); mSwatchButton7->setShowMenu( false ); mSwatchButton7->setBehaviour( QgsColorButtonV2::SignalOnly ); mSwatchButton8->setShowMenu( false ); mSwatchButton8->setBehaviour( QgsColorButtonV2::SignalOnly ); mSwatchButton9->setShowMenu( false ); mSwatchButton9->setBehaviour( QgsColorButtonV2::SignalOnly ); mSwatchButton10->setShowMenu( false ); mSwatchButton10->setBehaviour( QgsColorButtonV2::SignalOnly ); mSwatchButton11->setShowMenu( false ); mSwatchButton11->setBehaviour( QgsColorButtonV2::SignalOnly ); mSwatchButton12->setShowMenu( false ); mSwatchButton12->setBehaviour( QgsColorButtonV2::SignalOnly ); mSwatchButton13->setShowMenu( false ); mSwatchButton13->setBehaviour( QgsColorButtonV2::SignalOnly ); mSwatchButton14->setShowMenu( false ); mSwatchButton14->setBehaviour( QgsColorButtonV2::SignalOnly ); mSwatchButton15->setShowMenu( false ); mSwatchButton15->setBehaviour( QgsColorButtonV2::SignalOnly ); mSwatchButton16->setShowMenu( false ); mSwatchButton16->setBehaviour( QgsColorButtonV2::SignalOnly ); //restore custom colors mSwatchButton1->setColor( settings.value( "/Windows/ColorDialog/customColor1", QVariant( QColor() ) ).value<QColor>() ); mSwatchButton2->setColor( settings.value( "/Windows/ColorDialog/customColor2", QVariant( QColor() ) ).value<QColor>() ); mSwatchButton3->setColor( settings.value( "/Windows/ColorDialog/customColor3", QVariant( QColor() ) ).value<QColor>() ); mSwatchButton4->setColor( settings.value( "/Windows/ColorDialog/customColor4", QVariant( QColor() ) ).value<QColor>() ); mSwatchButton5->setColor( settings.value( "/Windows/ColorDialog/customColor5", QVariant( QColor() ) ).value<QColor>() ); mSwatchButton6->setColor( settings.value( "/Windows/ColorDialog/customColor6", QVariant( QColor() ) ).value<QColor>() ); mSwatchButton7->setColor( settings.value( "/Windows/ColorDialog/customColor7", QVariant( QColor() ) ).value<QColor>() ); mSwatchButton8->setColor( settings.value( "/Windows/ColorDialog/customColor8", QVariant( QColor() ) ).value<QColor>() ); mSwatchButton9->setColor( settings.value( "/Windows/ColorDialog/customColor9", QVariant( QColor() ) ).value<QColor>() ); mSwatchButton10->setColor( settings.value( "/Windows/ColorDialog/customColor10", QVariant( QColor() ) ).value<QColor>() ); mSwatchButton11->setColor( settings.value( "/Windows/ColorDialog/customColor11", QVariant( QColor() ) ).value<QColor>() ); mSwatchButton12->setColor( settings.value( "/Windows/ColorDialog/customColor12", QVariant( QColor() ) ).value<QColor>() ); mSwatchButton13->setColor( settings.value( "/Windows/ColorDialog/customColor13", QVariant( QColor() ) ).value<QColor>() ); mSwatchButton14->setColor( settings.value( "/Windows/ColorDialog/customColor14", QVariant( QColor() ) ).value<QColor>() ); mSwatchButton15->setColor( settings.value( "/Windows/ColorDialog/customColor15", QVariant( QColor() ) ).value<QColor>() ); mSwatchButton16->setColor( settings.value( "/Windows/ColorDialog/customColor16", QVariant( QColor() ) ).value<QColor>() ); //restore sample radius mSpinBoxRadius->setValue( settings.value( "/Windows/ColorDialog/sampleRadius", 1 ).toInt() ); mSamplePreview->setColor( QColor() ); if ( color.isValid() ) { setColor( color ); mColorPreview->setColor2( color ); } //restore active component radio button int activeRadio = settings.value( "/Windows/ColorDialog/activeComponent", 2 ).toInt(); switch ( activeRadio ) { case 0: mHueRadio->setChecked( true ); break; case 1: mSaturationRadio->setChecked( true ); break; case 2: mValueRadio->setChecked( true ); break; case 3: mRedRadio->setChecked( true ); break; case 4: mGreenRadio->setChecked( true ); break; case 5: mBlueRadio->setChecked( true ); break; } int currentTab = settings.value( "/Windows/ColorDialog/activeTab", 0 ).toInt(); mTabWidget->setCurrentIndex( currentTab ); //setup connections connect( mColorBox, SIGNAL( colorChanged( QColor ) ), this, SLOT( setColor( QColor ) ) ); connect( mColorWheel, SIGNAL( colorChanged( QColor ) ), this, SLOT( setColor( QColor ) ) ); connect( mColorText, SIGNAL( colorChanged( QColor ) ), this, SLOT( setColor( QColor ) ) ); connect( mVerticalRamp, SIGNAL( colorChanged( QColor ) ), this, SLOT( setColor( QColor ) ) ); connect( mRedSlider, SIGNAL( colorChanged( QColor ) ), this, SLOT( setColor( QColor ) ) ); connect( mGreenSlider, SIGNAL( colorChanged( QColor ) ), this, SLOT( setColor( QColor ) ) ); connect( mBlueSlider, SIGNAL( colorChanged( QColor ) ), this, SLOT( setColor( QColor ) ) ); connect( mHueSlider, SIGNAL( colorChanged( QColor ) ), this, SLOT( setColor( QColor ) ) ); connect( mValueSlider, SIGNAL( colorChanged( QColor ) ), this, SLOT( setColor( QColor ) ) ); connect( mSaturationSlider, SIGNAL( colorChanged( QColor ) ), this, SLOT( setColor( QColor ) ) ); connect( mAlphaSlider, SIGNAL( colorChanged( QColor ) ), this, SLOT( setColor( QColor ) ) ); connect( mColorPreview, SIGNAL( colorChanged( QColor ) ), this, SLOT( setColor( QColor ) ) ); connect( mSwatchButton1, SIGNAL( colorClicked( QColor ) ), this, SLOT( setColor( QColor ) ) ); connect( mSwatchButton2, SIGNAL( colorClicked( QColor ) ), this, SLOT( setColor( QColor ) ) ); connect( mSwatchButton3, SIGNAL( colorClicked( QColor ) ), this, SLOT( setColor( QColor ) ) ); connect( mSwatchButton4, SIGNAL( colorClicked( QColor ) ), this, SLOT( setColor( QColor ) ) ); connect( mSwatchButton5, SIGNAL( colorClicked( QColor ) ), this, SLOT( setColor( QColor ) ) ); connect( mSwatchButton6, SIGNAL( colorClicked( QColor ) ), this, SLOT( setColor( QColor ) ) ); connect( mSwatchButton7, SIGNAL( colorClicked( QColor ) ), this, SLOT( setColor( QColor ) ) ); connect( mSwatchButton8, SIGNAL( colorClicked( QColor ) ), this, SLOT( setColor( QColor ) ) ); connect( mSwatchButton9, SIGNAL( colorClicked( QColor ) ), this, SLOT( setColor( QColor ) ) ); connect( mSwatchButton10, SIGNAL( colorClicked( QColor ) ), this, SLOT( setColor( QColor ) ) ); connect( mSwatchButton11, SIGNAL( colorClicked( QColor ) ), this, SLOT( setColor( QColor ) ) ); connect( mSwatchButton12, SIGNAL( colorClicked( QColor ) ), this, SLOT( setColor( QColor ) ) ); connect( mSwatchButton13, SIGNAL( colorClicked( QColor ) ), this, SLOT( setColor( QColor ) ) ); connect( mSwatchButton14, SIGNAL( colorClicked( QColor ) ), this, SLOT( setColor( QColor ) ) ); connect( mSwatchButton15, SIGNAL( colorClicked( QColor ) ), this, SLOT( setColor( QColor ) ) ); connect( mSwatchButton16, SIGNAL( colorClicked( QColor ) ), this, SLOT( setColor( QColor ) ) ); }
//彻底删除 void MusicList::deleteSelection() { removeSelection(true); }
void KreTextEdit::keyPressEvent( QKeyEvent *e ) { // Filter key-events if completion mode is not set to CompletionNone KeyBindingMap keys = getKeyBindings(); KShortcut cut; bool noModifier = ( e->modifiers() == Qt::NoModifier || e->modifiers() == Qt::ShiftModifier ); if ( noModifier ) { QString keycode = e->text(); if ( !keycode.isEmpty() && keycode.unicode() ->isPrint() ) { KTextEdit::keyPressEvent ( e ); tryCompletion(); e->accept(); return ; } } // Handles completion if ( keys[ TextCompletion ].isEmpty() ) cut = KStandardShortcut::shortcut( KStandardShortcut::TextCompletion ); else cut = keys[ TextCompletion ]; //using just the standard Ctrl+E isn't user-friendly enough for Grandma... if ( completing && ( cut.contains( e->key() ) || e->key() == Qt::Key_Enter || e->key() == Qt::Key_Return ) ) { #if 0 int paraFrom, indexFrom, paraTo, indexTo; getSelection ( ¶From, &indexFrom, ¶To, &indexTo ); removeSelection(); setCursorPosition( paraTo, indexTo ); completing = false; return ; #endif } // handle rotation // Handles previous match if ( keys[ PrevCompletionMatch ].isEmpty() ) cut = KStandardShortcut::shortcut( KStandardShortcut::PrevCompletion ); else cut = keys[ PrevCompletionMatch ]; if ( cut.contains( e->key() ) ) { rotateText( KCompletionBase::PrevCompletionMatch ); return ; } // Handles next match if ( keys[ NextCompletionMatch ].isEmpty() ) cut = KStandardShortcut::shortcut( KStandardShortcut::NextCompletion ); else cut = keys[ NextCompletionMatch ]; if ( cut.contains( e->key() ) ) { rotateText( KCompletionBase::NextCompletionMatch ); return ; } //any other key events will end any text completion execpt for modifiers switch ( e->key() ) { case Qt::Key_Shift: case Qt::Key_Control: case Qt::Key_Alt: case Qt::Key_Meta: break; default: completing = false; break; } // Let KTextEdit handle any other keys events. KTextEdit::keyPressEvent ( e ); }
void *MsgViewBase::processEvent(Event *e) { if (e->type() == EventMessageRead){ Message *msg = (Message*)(e->param()); if (msg->contact() != m_id) return NULL; for (unsigned i = 0; i < (unsigned)paragraphs(); i++){ QString s = text(i); int n = s.find(MSG_HREF); if (n < 0) continue; s = s.mid(n + strlen(MSG_HREF)); n = s.find("\""); if (n < 0) continue; s = s.left(n); unsigned id = atol(getToken(s, ',').latin1()); if (id != msg->id()) continue; getToken(s, ','); if (s != msg->client()) continue; int paraFrom, indexFrom; int paraTo, indexTo; getSelection(¶From, &indexFrom, ¶To, &indexTo); setSelection(i, 0, i, 0xFFFF); setBold(false); if ((paraFrom == -1) && (paraTo == -1)){ removeSelection(); scrollToBottom(); }else{ setSelection(paraFrom, indexFrom, paraTo, indexTo); } break; } return NULL; } if (e->type() == EventHistoryConfig){ unsigned id = (unsigned)(e->param()); if (id && (id != m_id)) return NULL; QString t; for (unsigned i = 0; i < (unsigned)paragraphs(); i++){ QString s = text(i); int n = s.find(MSG_HREF); if (n < 0) continue; s = s.mid(n + strlen(MSG_HREF)); n = s.find("\""); if (n < 0) continue; s = s.left(n); unsigned id = atol(getToken(s, ',').latin1()); getToken(s, ','); Message *msg = History::load(id, s.utf8(), m_id); if (msg == NULL) continue; t += messageText(msg); delete msg; } QPoint p = QPoint(0, height()); p = mapToGlobal(p); p = viewport()->mapFromGlobal(p); int x, y; viewportToContents(p.x(), p.y(), x, y); int para; int pos = charAt(QPoint(x, y), ¶); setText(t); setBackground(0); if (pos == -1){ scrollToBottom(); }else{ setCursorPosition(para, pos); ensureCursorVisible(); } } if (e->type() == EventCheckState){ CommandDef *cmd = (CommandDef*)(e->param()); if ((cmd->param != this) || (cmd->menu_id != MenuMsgView)) return NULL; Message *msg; switch (cmd->id){ case CmdCopy: cmd->flags &= ~(COMMAND_DISABLED | COMMAND_CHECKED); if (!hasSelectedText()) cmd->flags |= COMMAND_DISABLED; return e->param(); case CmdMsgOpen: msg = currentMessage(); if (msg){ unsigned type = msg->type(); delete msg; for (;;){ CommandDef *def = CorePlugin::m_plugin->messageTypes.find(type); if (def == NULL){ return NULL; } MessageDef *mdef = (MessageDef*)(def->param); if (mdef->base_type){ type = mdef->base_type; continue; } cmd->icon = def->icon; cmd->flags &= ~COMMAND_CHECKED; return e->param(); } } return NULL; case CmdMsgSpecial: msg = currentMessage(); if (msg){ Event eMenu(EventGetMenuDef, (void*)MenuMsgCommand); CommandsDef *cmdsMsg = (CommandsDef*)(eMenu.process()); unsigned n = 0; MessageDef *mdef = NULL; if (msg->getFlags() & MESSAGE_RECEIVED){ unsigned type = msg->type(); for (;;){ CommandDef *msgCmd = CorePlugin::m_plugin->messageTypes.find(type); if (msgCmd == NULL) break; mdef = (MessageDef*)(msgCmd->param); if (mdef->base_type == 0) break; type = mdef->base_type; } } if (mdef && mdef->cmd){ for (const CommandDef *d = mdef->cmd; d->text; d++) n++; } { CommandsList it(*cmdsMsg, true); while (++it) n++; } if (n == 0) return NULL; n++; CommandDef *cmds = new CommandDef[n]; memset(cmds, 0, sizeof(CommandDef) * n); n = 0; if (mdef && mdef->cmd){ for (const CommandDef *d = mdef->cmd; d->text; d++){ cmds[n] = *d; cmds[n].id = CmdMsgSpecial + n; n++; } } CommandDef *c; CommandsList it(*cmdsMsg, true); while ((c = ++it) != NULL){ CommandDef cmd = *c; cmd.menu_id = MenuMsgCommand; cmd.param = msg; Event e(EventCheckState, &cmd); if (!e.process()) continue; cmd.flags &= ~COMMAND_CHECK_STATE; cmds[n++] = cmd; } cmd->param = cmds; cmd->flags |= COMMAND_RECURSIVE; delete msg; return e->param(); } return NULL; } } if (e->type() == EventCommandExec){ CommandDef *cmd = (CommandDef*)(e->param()); if ((cmd->param != this) || (cmd->menu_id != MenuMsgView)) return NULL; Message *msg; switch (cmd->id){ case CmdCopy: copy(); return e->param(); case CmdMsgOpen: msg = currentMessage(); if (msg){ Event eOpen(EventOpenMessage, msg); eOpen.process(); delete msg; return e->param(); } return NULL; default: msg = currentMessage(); if (msg){ if (cmd->id >= CmdMsgSpecial){ MessageDef *mdef = NULL; unsigned type = msg->type(); for (;;){ CommandDef *msgCmd = CorePlugin::m_plugin->messageTypes.find(type); if (msgCmd == NULL) break; mdef = (MessageDef*)(msgCmd->param); if (mdef->base_type == 0) break; type = mdef->base_type; } if (mdef && mdef->cmd){ unsigned n = cmd->id - CmdMsgSpecial; for (const CommandDef *d = mdef->cmd; d->text; d++){ if (n-- == 0){ CommandDef cmd = *d; cmd.param = msg; Event eCmd(EventCommandExec, &cmd); eCmd.process(); return e->param(); } } } } Command c; c->id = cmd->id; c->menu_id = MenuMsgCommand; c->param = msg; Event e(EventCommandExec, c); void *res = e.process(); delete msg; return res; } return NULL; } } return NULL; }
void CurvePresenter::setupContextMenu() { m_contextMenu = new QMenu; auto selectAct = new QAction{tr("Select"), this}; selectAct->setCheckable(true); selectAct->setChecked(false); connect(selectAct, &QAction::toggled, this, [&] (bool b) { if(b) m_sm->changeTool(int(Curve::Tool::Selection)); else m_sm->changeTool(int(Curve::Tool::Move)); }); auto removeAct = new QAction{tr("Remove"), this}; removeAct->setData(2); // Small identifier for segments actions... auto typeMenu = m_contextMenu->addMenu(tr("Type")); for(const auto& seg : SingletonCurveSegmentList::instance().nameList()) { auto act = typeMenu->addAction(seg); act->setData(1); } auto lockAction = new QAction{tr("Lock between points"), this}; connect(lockAction, &QAction::toggled, this, [&] (bool b) { setLockBetweenPoints(b); }); lockAction->setCheckable(true); lockAction->setChecked(true); auto suppressAction = new QAction{tr("Suppress on overlap"), this}; connect(suppressAction, &QAction::toggled, this, [&] (bool b) { setSuppressOnOverlap(b); }); suppressAction->setCheckable(true); suppressAction->setChecked(false); m_contextMenu->addAction(selectAct); m_contextMenu->addAction(removeAct); m_contextMenu->addAction(lockAction); m_contextMenu->addAction(suppressAction); connect(m_view, &CurveView::contextMenuRequested, this, [&] (const QPoint& pt) { auto act = m_contextMenu->exec(pt, nullptr); m_contextMenu->close(); if(!act) { return; } else if(act->data().value<int>() == 1) { updateSegmentsType(act->text()); } else if(act->data().value<int>() == 2) { removeSelection(); } }); }