void ChronoShareGui::openFile() { // figure out who sent the signal QAction* pAction = qobject_cast<QAction*>(sender()); if (pAction->isEnabled()) { // we stored full path of the file in this toolTip field #ifdef Q_WS_MAC // we do some hack so we could show the file in Finder highlighted QStringList args; args << "-e"; args << "tell application \"Finder\""; args << "-e"; args << "activate"; args << "-e"; args << "select POSIX file \"" + pAction->toolTip() + "/" + pAction->text() + "\""; args << "-e"; args << "end tell"; QProcess::startDetached("osascript", args); #else // too bad qt couldn't do highlighting for Linux (or Mac) QDesktopServices::openUrl(QUrl("file:///" + pAction->toolTip())); #endif } }
bool RiuToolTipMenu::event(QEvent* e) { if (e->type() == QEvent::ToolTip) { QHelpEvent* he = dynamic_cast<QHelpEvent*>(e); QAction* act = actionAt(he->pos()); if (act) { // Remove ampersand as this is used to define shortcut key QString actionTextWithoutAmpersand = act->text().remove("&"); if (actionTextWithoutAmpersand != act->toolTip()) { QToolTip::showText(he->globalPos(), act->toolTip(), this); } return true; } } else if (e->type() == QEvent::Paint && QToolTip::isVisible()) { QToolTip::hideText(); } return QMenu::event(e); }
/*! \reimp */ QString QAccessibleWidget::actionText(int action, Text t, int child) const { if (action == DefaultAction) action = SetFocus; if (action > 0 && !child) { QAction *act = widget()->actions().value(action - 1); if (act) { switch (t) { case Name: return act->text(); case Description: return act->toolTip(); #ifndef QT_NO_SHORTCUT case Accelerator: return act->shortcut().toString(); #endif default: break; } } } return QAccessibleObject::actionText(action, t, child); }
KoGroupButton *addViewButton(KoGroupButton::GroupPosition pos, Kexi::ViewMode mode, QWidget *parent, const char *slot, const QString &text, QHBoxLayout *btnLyr) { if (!window->supportsViewMode(mode)) { return 0; } QAction *a = new KexiToggleViewModeAction(mode, q); toggleViewModeActions.insert(mode, a); KoGroupButton *btn = new KoGroupButton(pos, parent); toggleViewModeButtons.insert(mode, btn); connect(btn, SIGNAL(toggled(bool)), q, slot); btn->setToolButtonStyle(Qt::ToolButtonTextBesideIcon); btn->setText(text); btn->setIcon(a->icon()); QFont f(KGlobalSettings::toolBarFont()); f.setPixelSize(KexiUtils::smallFont().pixelSize()); btn->setFont(f); btn->setToolTip(a->toolTip()); btn->setWhatsThis(a->whatsThis()); btn->setCheckable(true); btn->setAutoRaise(true); btnLyr->addWidget(btn); return btn; }
QString QActionProto::toolTip() const { QAction *item = qscriptvalue_cast<QAction*>(thisObject()); if (item) return item->toolTip(); return QString(); }
// taken from libqtxdg: XdgMenuWidget bool XdgCachedMenu::event(QEvent* event) { if (event->type() == QEvent::MouseButtonPress) { QMouseEvent *e = static_cast<QMouseEvent*>(event); if (e->button() == Qt::LeftButton) mDragStartPosition = e->pos(); } else if (event->type() == QEvent::MouseMove) { QMouseEvent *e = static_cast<QMouseEvent*>(event); handleMouseMoveEvent(e); } else if(event->type() == QEvent::ToolTip) { QHelpEvent* helpEvent = static_cast<QHelpEvent*>(event); QAction* action = actionAt(helpEvent->pos()); if(action && action->menu() == NULL) QToolTip::showText(helpEvent->globalPos(), action->toolTip(), this); } return QMenu::event(event); }
ToolbarDialog::ToolbarDialog(QWidget* parent) : QDialog(parent),m_defaultToolBars() { setupUi(this); createDefaultToolBars(); // populate all available actions QList<QAction*> actions = parent->findChildren<QAction*>(QRegExp("action*")); QAction* action; foreach(action, actions) { if (action->actionGroup()->objectName() != "extraGroup") continue; QListWidgetItem* item = new QListWidgetItem(action->toolTip()); item->setIcon(action->icon()); item->setData(Qt::UserRole, QVariant::fromValue((QObject*)action)); listAllActions->addItem(item); } // Important to add special Separator listAllActions->addItem("Separator"); QList<QToolBar*> toolbars = parent->findChildren<QToolBar*>(); QToolBar* toolbar = NULL; int index = 0; foreach(toolbar, toolbars) { index = (int)(toolbar->iconSize().height()/10)-1; if (toolbar->objectName() != "keyToolBar") comboToolbars->addItem(toolbar->windowTitle(), QVariant::fromValue((QObject*)toolbar)); }
void ProxyAction::handleKeyChange(const QKeySequence &old) { QString oldTooltip(QString("<span style=\"color: gray; font-size: small\">%1</span>").arg(old.toString(QKeySequence::NativeText))); QList<QPointer<QAction> > actions(m_contextActions.values()); QAction *backendAction = 0; for (int n = 0; n < actions.count(); n++) { backendAction = actions.at(n); if (backendAction) { if (backendAction->toolTip().endsWith(oldTooltip)) { QString chopped(backendAction->toolTip()); chopped.chop(oldTooltip.length()); backendAction->setToolTip(chopped); } } } if (m_currentKey.isEmpty() && !m_defaultKey.isEmpty()) { m_currentKey = m_defaultKey; } m_action->setShortcut(m_currentKey); QString newTooltip(QString("<span style=\"color: gray; font-size: small\">%1</span>").arg(key().toString(QKeySequence::NativeText).toHtmlEscaped())); QString activeTooltip(m_activeAction ? m_activeAction->toolTip() : m_backup->toolTip()); if (m_action->shortcut().isEmpty()) { m_action->setToolTip(activeTooltip); } else { m_action->setToolTip(activeTooltip.trimmed() + " " + newTooltip); for (int n = 0; n < actions.count(); n++) { backendAction = actions.at(n); if (backendAction) { backendAction->setToolTip(backendAction->toolTip().trimmed() + " " + newTooltip); } } } }
void StatusBarToolButton::paintEvent(QPaintEvent* event) { if (mGroupPosition == NotGrouped) { QToolButton::paintEvent(event); return; } QStylePainter painter(this); QStyleOptionToolButton opt; initStyleOption(&opt); QStyleOptionToolButton panelOpt = opt; // Panel QRect& panelRect = panelOpt.rect; switch (mGroupPosition) { case GroupLeft: panelRect.setWidth(panelRect.width() * 2); break; case GroupCenter: panelRect.setLeft(panelRect.left() - panelRect.width()); panelRect.setWidth(panelRect.width() * 3); break; case GroupRight: panelRect.setLeft(panelRect.left() - panelRect.width()); break; case NotGrouped: Q_ASSERT(0); } painter.drawPrimitive(QStyle::PE_PanelButtonTool, panelOpt); // Separator const int y1 = opt.rect.top() + 6; const int y2 = opt.rect.bottom() - 6; if (mGroupPosition & GroupRight) { const int x = opt.rect.left(); painter.setPen(opt.palette.color(QPalette::Light)); painter.drawLine(x, y1, x, y2); } if (mGroupPosition & GroupLeft) { const int x = opt.rect.right(); painter.setPen(opt.palette.color(QPalette::Mid)); painter.drawLine(x, y1, x, y2); } // Text painter.drawControl(QStyle::CE_ToolButtonLabel, opt); // Filtering message on tooltip text for CJK to remove accelerators. // Quoting ktoolbar.cpp: // """ // CJK languages use more verbose accelerator marker: they add a Latin // letter in parenthesis, and put accelerator on that. Hence, the default // removal of ampersand only may not be enough there, instead the whole // parenthesis construct should be removed. Provide these filtering i18n // messages so that translators can use Transcript for custom removal. // """ if (!actions().isEmpty()) { QAction* action = actions().first(); setToolTip(i18nc("@info:tooltip of custom toolbar button", "%1", action->toolTip())); } }
bool MenuWithToolTips::event (QEvent * e) { const QHelpEvent *helpEvent = static_cast <QHelpEvent *>(e); if (helpEvent->type() == QEvent::ToolTip) { QAction* action = activeAction(); if(!action){ return false; } if(action->text() != action->toolTip()){ QToolTip::showText(helpEvent->globalPos(), action->toolTip()); } } else { QToolTip::hideText(); } return QMenu::event(e); }
QAction* getAction(Shortcut* s) { if (s == 0) return 0; if (s->action == 0) { QAction* a = new QAction(s->xml, 0); // mscore); s->action = a; a->setData(s->xml); if(!s->key.isEmpty()) a->setShortcut(s->key); else a->setShortcuts(s->standardKey); a->setShortcutContext(s->context); if (!s->help.isEmpty()) { a->setToolTip(s->help); a->setWhatsThis(s->help); } else { a->setToolTip(s->descr); a->setWhatsThis(s->descr); } if (s->standardKey != QKeySequence::UnknownKey) { QList<QKeySequence> kl = a->shortcuts(); if (!kl.isEmpty()) { QString s(a->toolTip()); s += " ("; for (int i = 0; i < kl.size(); ++i) { if (i) s += ","; s += kl[i].toString(QKeySequence::NativeText); } s += ")"; a->setToolTip(s); } } else if (!s->key.isEmpty()) { a->setToolTip(a->toolTip() + " (" + s->key.toString(QKeySequence::NativeText) + ")" ); } if (!s->text.isEmpty()) a->setText(s->text); if (s->icon != -1) a->setIcon(*icons[s->icon]); } return s->action; }
QCheckBox *OptionsPopup::createCheckboxForCommand(Id id) { QAction *action = ActionManager::command(id)->action(); QCheckBox *checkbox = new QCheckBox(action->text()); checkbox->setToolTip(action->toolTip()); checkbox->setChecked(action->isChecked()); checkbox->setEnabled(action->isEnabled()); checkbox->installEventFilter(this); // enter key handling QObject::connect(checkbox, &QCheckBox::clicked, action, &QAction::setChecked); QObject::connect(action, &QAction::changed, this, &OptionsPopup::actionChanged); m_checkboxMap.insert(action, checkbox); return checkbox; }
void WebView::adBlock() { QAction *action = qobject_cast<QAction *>(sender()); QString url = action->toolTip().replace("http://", ""); bool ok; QString text = QInputDialog::getText(this, tr("Ad Block"), tr("Check URL or pattern to block:"), QLineEdit::Normal, url, &ok); if (ok && !text.isEmpty()) { NetworkAccessManager* n = BrowserApplication::networkAccessManager(); n->blockAd( text ); } }
QAction* ControllableSplitter::getMoveLeftAction() { if (!mShiftSplitterLeft) { QAction* action = new QAction(QIcon(":/icons/open_icon_library/arrow-left-3.png"), QString("Show %1").arg(mRightName), this); action->setToolTip(QString("Show more %1").arg(mRightName)); action->setStatusTip(action->toolTip()); connect(action, &QAction::triggered, this, &ControllableSplitter::onMoveSplitterLeft); mShiftSplitterLeft = action; this->enableActions(); } return mShiftSplitterLeft; }
bool FullScreenBar::eventFilter(QObject* object, QEvent* event) { if (event->type() == QEvent::MouseMove) { QApplication::restoreOverrideCursor(); d->mAutoHideCursorTimer->start(); if (y() == 0) { if (d->shouldHide()) { slideOut(); } } else { QMouseEvent* mouseEvent = static_cast<QMouseEvent *>(event); if (mouseEvent->buttons() == 0 && d->slideInTriggerRect().contains(QCursor::pos())) { slideIn(); } } return false; } if (event->type() == QEvent::MouseButtonRelease) { // This can happen if user released the mouse after using a scrollbar // in the content (the bar does not hide while a button is down) if (y() == 0 && d->shouldHide()) { slideOut(); } return false; } // Filtering message on tooltip text for CJK to remove accelerators. // Quoting ktoolbar.cpp: // """ // CJK languages use more verbose accelerator marker: they add a Latin // letter in parenthesis, and put accelerator on that. Hence, the default // removal of ampersand only may not be enough there, instead the whole // parenthesis construct should be removed. Use KLocale's method to do this. // """ if (event->type() == QEvent::Show || event->type() == QEvent::Paint) { QToolButton* button = qobject_cast<QToolButton*>(object); if (button && !button->actions().isEmpty()) { QAction* action = button->actions().first(); QString toolTip = KGlobal::locale()->removeAcceleratorMarker(action->toolTip()); // Filtering message requested by translators (scripting). button->setToolTip(i18nc("@info:tooltip of custom toolbar button", "%1", toolTip)); } } return false; }
void KBookmarkMenu::addOpenInTabs() { if (!m_pOwner || !m_pOwner->supportsTabs() || !KAuthorized::authorizeKAction(QStringLiteral("bookmarks"))) { return; } QString title = tr("Open Folder in Tabs"); QAction *paOpenFolderInTabs = new QAction(title, this); paOpenFolderInTabs->setIcon(QIcon::fromTheme(QStringLiteral("tab-new"))); paOpenFolderInTabs->setToolTip(tr("Open all bookmarks in this folder as a new tab.")); paOpenFolderInTabs->setStatusTip(paOpenFolderInTabs->toolTip()); connect(paOpenFolderInTabs, &QAction::triggered, this, &KBookmarkMenu::slotOpenFolderInTabs); m_parentMenu->addAction(paOpenFolderInTabs); m_actions.append(paOpenFolderInTabs); }
void RecipeWidget::rightClick(QString tag) { QPoint pos = QCursor::pos(); QMenu menu; menu.addAction("delete"); //menu.addAction("test"); QAction* selection = menu.exec(pos); if (selection) { QString selectionStr = selection->toolTip(); if (selectionStr == "delete") { deleteTag(tag); } } }
void TopLevel::retranslateUi() { setPlainCaption( i18n( "System Monitor" ) ); mRefreshTabAction->setText(i18n("&Refresh Tab")); mNewWorksheetAction->setText(i18n( "&New Tab..." )); mInsertWorksheetAction->setText(i18n( "Import Tab Fr&om File..." )); mTabExportAction->setText( i18n( "Save Tab &As..." ) ); mTabRemoveAction->setText( i18n( "&Close Tab" ) ); mMonitorRemoteAction->setText( i18n( "Monitor &Remote Machine..." ) ); mHotNewWorksheetAction->setText( i18n( "&Download New Tabs..." ) ); mHotNewWorksheetUploadAction->setText( i18n( "&Upload Current Tab..." ) ); mConfigureSheetAction->setText( i18n( "Tab &Properties" ) ); if(mQuitAction) { QAction *tmpQuitAction = KStandardAction::quit( NULL, NULL, NULL ); mQuitAction->setText(tmpQuitAction->text()); mQuitAction->setWhatsThis(tmpQuitAction->whatsThis()); mQuitAction->setToolTip(tmpQuitAction->toolTip()); delete tmpQuitAction; } else mQuitAction = KStandardAction::quit( this, SLOT(close()), actionCollection() ); }
bool UIMenu::event(QEvent *pEvent) { /* Handle particular event-types: */ switch (pEvent->type()) { /* Tool-tip request handler: */ case QEvent::ToolTip: { /* Get current help-event: */ QHelpEvent *pHelpEvent = static_cast<QHelpEvent*>(pEvent); /* Get action which caused help-event: */ QAction *pAction = actionAt(pHelpEvent->pos()); /* If action present => show action's tool-tip if needed: */ if (pAction && m_fShowToolTips) QToolTip::showText(pHelpEvent->globalPos(), pAction->toolTip()); break; } default: break; } /* Base-class event-handler: */ return QMenu::event(pEvent); }
void MainWindow::loadComPorts() { ui->menuFile->clear(); m_comPorts = new QActionGroup(this); m_comPorts->setExclusive(true); QList<QextPortInfo> ports = QextSerialEnumerator::getPorts(); for (int i = 0; i < ports.size(); i++) { QString fullName; QString friendName = ports.at(i).friendName; QString name = ports.at(i).portName; if (name.contains("LPT")) { continue; } #ifdef Q_OS_WIN name.remove("\\\\.\\"); fullName = QString("%1").arg(friendName); #else #ifdef Q_OS_LINUX name.prepend("/dev/"); #endif if (friendName.size() > 0) { fullName = QString("%1 (%2)").arg(friendName) .arg(name); } else { QChar num = name.at(name.size() - 1); if (name.contains("ttyS")) { fullName = QString("Serial Port %1 (%2)").arg(num).arg(name); } else if (name.contains("ttyACM")) { fullName = QString("Serial ACM %1 (%2)").arg(num).arg(name); } else if (name.contains("ttyUSB")) { fullName = QString("Serial USB %1 (%2)").arg(num).arg(name); } } #endif QAction * com = new QAction(fullName, this); com->setToolTip(name); com->setCheckable(true); if (com->toolTip() == m_tty) { com->setChecked(true); } m_comPorts->addAction(com); } connect(m_comPorts, SIGNAL(triggered(QAction*)), this, SLOT(comAction_triggered(QAction*))); ui->menuFile->addActions(m_comPorts->actions()); ui->menuFile->addSeparator(); ui->menuFile->addAction(ui->actionRefresh); ui->menuFile->addSeparator(); ui->menuFile->addAction(ui->actionQuit); }
void DkCropToolBar::createLayout() { QList<QKeySequence> enterSc; enterSc.append(QKeySequence(Qt::Key_Enter)); enterSc.append(QKeySequence(Qt::Key_Return)); QAction* cropAction = new QAction(icons[crop_icon], tr("Crop (ENTER)"), this); cropAction->setShortcuts(enterSc); cropAction->setObjectName("cropAction"); QAction* cancelAction = new QAction(icons[cancel_icon], tr("Cancel (ESC)"), this); cancelAction->setShortcut(QKeySequence(Qt::Key_Escape)); cancelAction->setObjectName("cancelAction"); panAction = new QAction(icons[pan_icon], tr("Pan"), this); panAction->setShortcut(QKeySequence(Qt::Key_P)); panAction->setObjectName("panAction"); panAction->setCheckable(true); panAction->setChecked(false); QStringList ratios; ratios << "1:1" << "4:3" << "5:4" << "14:10" << "14:11" << "16:9" << "16:10"; ratios.prepend(tr("User Defined")); ratios.prepend(tr("No Aspect Ratio")); ratioBox = new QComboBox(this); ratioBox->addItems(ratios); ratioBox->setObjectName("ratioBox"); horValBox = new QDoubleSpinBox(this); horValBox->setObjectName("horValBox"); horValBox->setSpecialValueText(" "); horValBox->setToolTip(tr("Horizontal Constraint")); horValBox->setStatusTip(horValBox->toolTip()); QAction* swapAction = new QAction(QIcon(":/nomacs/img/swap.png"), tr("Swap"), this); swapAction->setObjectName("swapAction"); swapAction->setToolTip(tr("Swap Dimensions")); swapAction->setStatusTip(swapAction->toolTip()); verValBox = new QDoubleSpinBox(this); verValBox->setObjectName("verValBox"); verValBox->setSpecialValueText(" "); horValBox->setToolTip(tr("Vertical Constraint")); horValBox->setStatusTip(horValBox->toolTip()); angleBox = new QDoubleSpinBox(this); angleBox->setObjectName("angleBox"); angleBox->setSuffix("°"); angleBox->setMinimum(-180); angleBox->setMaximum(180); // background color bgCol = QColor(0,0,0,0); bgColButton = new QPushButton(this); bgColButton->setObjectName("bgColButton"); bgColButton->setStyleSheet("QPushButton {background-color: " + DkUtils::colorToString(bgCol) + "; border: 1px solid #888;}"); bgColButton->setToolTip(tr("Background Color")); bgColButton->setStatusTip(bgColButton->toolTip()); colorDialog = new QColorDialog(this); colorDialog->setObjectName("colorDialog"); colorDialog->setOption(QColorDialog::ShowAlphaChannel, true); // crop customization QStringList guides; guides << tr("Guides") << tr("Rule of Thirds") << tr("Grid"); guideBox = new QComboBox(this); guideBox->addItems(guides); guideBox->setObjectName("guideBox"); guideBox->setToolTip(tr("Show Guides in the Preview")); guideBox->setStatusTip(guideBox->toolTip()); invertAction = new QAction(icons[invert_icon], tr("Invert Crop Tool Color"), this); invertAction->setObjectName("invertAction"); invertAction->setCheckable(true); invertAction->setChecked(false); infoAction = new QAction(icons[info_icon], tr("Show Info"), this); infoAction->setObjectName("infoAction"); infoAction->setCheckable(true); infoAction->setChecked(false); addAction(cropAction); addAction(panAction); addAction(cancelAction); addSeparator(); addWidget(ratioBox); addWidget(horValBox); addAction(swapAction); addWidget(verValBox); addWidget(angleBox); addSeparator(); addWidget(bgColButton); addSeparator(); addWidget(guideBox); addAction(invertAction); addAction(infoAction); }
void QtWin::on_actionExamples_triggered() { QAction *action = (QAction *)QObject::sender(); if (action->toolTip().isEmpty()) return; openProject(action->toolTip().toAscii().data()); }
void cListWidget::navigate_to_clicked_folder(QListWidgetItem *current) { //creash protection //the clear() triggers a currentitemChanged and we receive //a bad null pointer if ( this->workLock == true ) return; this->workLock = true; //if this is a FILE -> wanna copy? if ( this->count() > 0 && this->children().count() > 0 ) { //fi is the COPY-SOURCE QFileInfo fi( current->toolTip() ); if ( fi.isFile() ) { //we're a file -> wanna copy? & return QMenu* m = new QMenu(); m->addAction( QIcon( ":/resources/img/" ), tr( "copy to /maps" ) ); m->setToolTip( this->projectFolder + "/maps/" ); QDir d( this->projectFolder + "/res/" ); QStringList dirs = d.entryList( QDir::NoFilter, QDir::Name ); for ( int i = 0; i < dirs.count(); i++ ) { if ( dirs.at(i) != "." && dirs.at(i) != ".." ) { m->addAction( QIcon( ":/resources/img/" ), tr( "copy to /res/" ) + dirs.at(i) ); m->actions().last()->setToolTip( this->projectFolder + "/res/" + dirs.at(i) ); } } QAction* a = m->exec( this->last_mouse_position ); if ( a != 0 ) { //check if the target file already exists in the pro folder //DESTINATION-FILE: QFile f( a->toolTip() + "/" + fi.fileName() ); //if-> ask for renameing or exit if ( f.exists() ) { QMessageBox msgBox; msgBox.setWindowTitle( tr( "File already exists" ) ); msgBox.setText( tr( "The file " ) + fi.fileName() + tr( " does already exist at the path\n" ) + a->toolTip() + "/" + fi.fileName() + tr( "\nDo you want to replace it?" ) ); msgBox.setStandardButtons(QMessageBox::Yes | QMessageBox::No); msgBox.setDefaultButton(QMessageBox::No); msgBox.setIcon(QMessageBox::Warning); if ( msgBox.exec() == QMessageBox::Yes ) { f.copy( fi.absoluteFilePath(), a->toolTip() + "/" + fi.fileName() ); emit this->copy_done( tr( "Successfully copied file " ) + fi.absoluteFilePath() + tr( " to " ) + a->toolTip() + "/" + fi.fileName() ); } } else { //straight copy f.copy( fi.absoluteFilePath(), a->toolTip() + "/" + fi.fileName() ); emit this->copy_done( tr( "Successfully copied file " ) + fi.absoluteFilePath() + tr( " to " ) + a->toolTip() + "/" + fi.fileName() ); } } this->clearSelection(); this->workLock = false; return; } } //else this is a folder an we navigate //applying new values if ( this->count() > 0 && this->children().count() > 0 ) { QDir dpath; dpath.cd( current->toolTip() ); this->absolute_path = dpath.absolutePath() ; dpath.cd("/"); } //rebuilding the gui //adding new widgets //adding folders this->navigate_to_our_folder(); //removing lock this->clearSelection(); this->workLock = false; }
ActionsDialog::ActionsDialog(QList<QAction *>& actions, MainWindow *parent) : QDialog(parent), Main(parent) { setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint); actionsTable = new QTableWidget(actions.count(), 2, this); QStringList hdr; hdr << tr("Description") << tr("Shortcut"); actionsTable->setHorizontalHeaderLabels(hdr); actionsTable->verticalHeader()->hide(); actionsTable->horizontalHeader()->setMinimumSectionSize(100); #ifdef QT5 #define setResizeMode setSectionResizeMode #endif actionsTable->horizontalHeader()->setResizeMode(0, QHeaderView::Stretch); actionsTable->horizontalHeader()->setResizeMode(1, QHeaderView::ResizeToContents); #undef setResizeMode //actionsTable->setColumnReadOnly(0, true); int row = 0; for (int i=0; i<actions.size(); ++i) { QAction *action = static_cast<QAction*>(actions.at(i)); QTableWidgetItem* it = new QTableWidgetItem(action->toolTip()); it->setFlags(0); actionsTable->setItem(row, 0, it); actionsTable->setItem(row, 1, new QTableWidgetItem(action->shortcut().toString())); actionsList.append(action); ++row; } QPushButton *importButton = new QPushButton(tr("&Import"), this); QPushButton *exportButton = new QPushButton(tr("&Export"), this); QPushButton *defaultButton = new QPushButton(tr("&Default"), this); QPushButton *okButton = new QPushButton(tr("&OK"), this); QPushButton *cancelButton = new QPushButton(tr("&Cancel"), this); connect(actionsTable, SIGNAL(currentCellChanged(int, int, int, int)), this, SLOT(recordAction(int, int))); connect(actionsTable, SIGNAL(cellChanged(int, int)), this, SLOT(validateAction(int, int))); connect(importButton, SIGNAL(clicked()), this, SLOT(importShortcuts())); connect(exportButton, SIGNAL(clicked()), this, SLOT(exportShortcuts())); connect(defaultButton, SIGNAL(clicked()), this, SLOT(resetToDefault())); connect(okButton, SIGNAL(clicked()), this, SLOT(accept())); connect(cancelButton, SIGNAL(clicked()), this, SLOT(reject())); QHBoxLayout *buttonLayout = new QHBoxLayout; buttonLayout->setSpacing(8); buttonLayout->addStretch(1); buttonLayout->addWidget(importButton); buttonLayout->addWidget(exportButton); buttonLayout->addWidget(defaultButton); buttonLayout->addWidget(okButton); buttonLayout->addWidget(cancelButton); QVBoxLayout *mainLayout = new QVBoxLayout(this); mainLayout->setMargin(8); mainLayout->setSpacing(8); mainLayout->addWidget(actionsTable); mainLayout->addLayout(buttonLayout); setWindowTitle(tr("Shortcut Editor")); cancelButton->setFocus(); }
void KnightsView::gameOver ( Color winner ) { qCDebug(LOG_KNIGHTS) << sender() << colorName ( winner ); QPointer<QDialog> dlg = new QDialog ( this ); QVBoxLayout *mainLayout = new QVBoxLayout; QWidget *mainWidget = new QWidget(this); dlg->setLayout(mainLayout); dlg->setWindowTitle ( i18n("Game over") ); mainLayout->addWidget(mainWidget); QDialogButtonBox *bBox = new QDialogButtonBox( QDialogButtonBox::Cancel|QDialogButtonBox::Ok|QDialogButtonBox::Apply ); KActionCollection* c = qobject_cast<KXmlGuiWindow*>( parentWidget() )->actionCollection(); Q_ASSERT(c); QMap<QDialogButtonBox::StandardButton, QByteArray> buttonsMap; buttonsMap[QDialogButtonBox::Ok] = KStandardGameAction::name ( KStandardGameAction::New ); buttonsMap[QDialogButtonBox::Apply] = KStandardGameAction::name ( KStandardGameAction::Save ); for ( QMap<QDialogButtonBox::StandardButton, QByteArray>::ConstIterator it = buttonsMap.constBegin(); it != buttonsMap.constEnd(); ++it ) { QAction* a = c->action ( QLatin1String ( it.value() ) ); Q_ASSERT(a); bBox->button ( it.key() )->setText ( a->text() ); bBox->button ( it.key() )->setIcon ( QIcon ( a->icon() ) ); bBox->button ( it.key() )->setToolTip ( a->toolTip() ); } connect( bBox, &QDialogButtonBox::accepted, dlg, &QDialog::accept ); connect( bBox, &QDialogButtonBox::rejected, dlg, &QDialog::reject ); connect( bBox->button (QDialogButtonBox::Apply), &QPushButton::clicked, static_cast<MainWindow *> (window()), &MainWindow::fileSave ); QLabel* label = new QLabel(this); if ( winner == NoColor ) label->setText ( i18n ( "The game ended in a draw" ) ); else { QString winnerName = Protocol::byColor ( winner )->playerName(); if ( winnerName == colorName(winner) ) { if ( winner == White ) { label->setText ( i18nc("White as in the player with white pieces", "The game ended with a victory for <em>White</em>") ); } else { label->setText ( i18nc("Black as in the player with black pieces", "The game ended with a victory for <em>Black</em>") ); } } else { if ( winner == White ) { label->setText ( i18nc("Player name, then <White as in the player with white pieces", "The game ended with a victory for <em>%1</em>, playing White", winnerName) ); } else { label->setText ( i18nc("Player name, then Black as in the player with black pieces", "The game ended with a victory for <em>%1</em>, playing Black", winnerName) ); } } } mainLayout->addWidget(label); mainLayout->addWidget(bBox); if ( dlg->exec() == QDialog::Accepted ) emit gameNew(); qCDebug(LOG_KNIGHTS) << Protocol::white(); qCDebug(LOG_KNIGHTS) << Protocol::black(); delete dlg; }
SignalFileBrowserWindow::SignalFileBrowserWindow(QWidget* parent) : QMainWindow(parent) { setWindowTitle(title); signalViewer = new SignalViewer(this); setCentralWidget(signalViewer); // Construct dock widgets. setDockNestingEnabled(true); QDockWidget* trackManagerDockWidget = new QDockWidget("Track Manager", this); trackManagerDockWidget->setObjectName("Track Manager QDockWidget"); trackManager = new TrackManager(this); trackManagerDockWidget->setWidget(trackManager); QDockWidget* eventManagerDockWidget = new QDockWidget("Event Manager", this); eventManagerDockWidget->setObjectName("Event Manager QDockWidget"); eventManager = new EventManager(this); eventManager->setReferences(signalViewer->getCanvas()); eventManagerDockWidget->setWidget(eventManager); QDockWidget* eventTypeDockWidget = new QDockWidget("EventType Manager", this); eventTypeDockWidget->setObjectName("EventType Manager QDockWidget"); eventTypeManager = new EventTypeManager(this); eventTypeDockWidget->setWidget(eventTypeManager); QDockWidget* montageManagerDockWidget = new QDockWidget("Montage Manager", this); montageManagerDockWidget->setObjectName("Montage Manager QDockWidget"); montageManager = new MontageManager(this); montageManagerDockWidget->setWidget(montageManager); addDockWidget(Qt::RightDockWidgetArea, trackManagerDockWidget); tabifyDockWidget(trackManagerDockWidget, eventManagerDockWidget); tabifyDockWidget(eventManagerDockWidget, eventTypeDockWidget); tabifyDockWidget(eventTypeDockWidget, montageManagerDockWidget); // Construct File actions. QAction* openFileAction = new QAction("&Open File", this); openFileAction->setShortcut(QKeySequence::Open); openFileAction->setToolTip("Open an existing file."); openFileAction->setStatusTip(openFileAction->toolTip()); connect(openFileAction, SIGNAL(triggered()), this, SLOT(openFile())); QAction* closeFileAction = new QAction("Close File", this); closeFileAction->setShortcut(QKeySequence::Close); closeFileAction->setToolTip("Close the currently opened file."); closeFileAction->setStatusTip(closeFileAction->toolTip()); connect(closeFileAction, SIGNAL(triggered()), this, SLOT(closeFile())); QAction* saveFileAction = new QAction("Save File", this); saveFileAction->setShortcut(QKeySequence::Save); saveFileAction->setToolTip("Save the currently opened file."); saveFileAction->setStatusTip(saveFileAction->toolTip()); connect(saveFileAction, SIGNAL(triggered()), this, SLOT(saveFile())); // Construct Zoom actions. QAction* horizontalZoomInAction = new QAction("Horizontal Zoom In", this); horizontalZoomInAction->setShortcut(QKeySequence("Alt++")); horizontalZoomInAction->setToolTip("Zoom in time line."); horizontalZoomInAction->setStatusTip(horizontalZoomInAction->toolTip()); connect(horizontalZoomInAction, SIGNAL(triggered()), this, SLOT(horizontalZoomIn())); QAction* horizontalZoomOutAction = new QAction("Horizontal Zoom Out", this); horizontalZoomOutAction->setShortcut(QKeySequence("Alt+-")); horizontalZoomOutAction->setToolTip("Zoom out time line."); horizontalZoomOutAction->setStatusTip(horizontalZoomOutAction->toolTip()); connect(horizontalZoomOutAction, SIGNAL(triggered()), this, SLOT(horizontalZoomOut())); QAction* verticalZoomInAction = new QAction("Vertical Zoom In", this); verticalZoomInAction->setShortcut(QKeySequence("Shift++")); verticalZoomInAction->setToolTip("Zoom in amplitudes of signals."); verticalZoomInAction->setStatusTip(verticalZoomInAction->toolTip()); connect(verticalZoomInAction, SIGNAL(triggered()), this, SLOT(verticalZoomIn())); QAction* verticalZoomOutAction = new QAction("Vertical Zoom Out", this); verticalZoomOutAction->setShortcut(QKeySequence("Shift+-")); verticalZoomOutAction->setToolTip("Zoom out amplitudes of signals."); verticalZoomOutAction->setStatusTip(verticalZoomOutAction->toolTip()); connect(verticalZoomOutAction, SIGNAL(triggered()), this, SLOT(verticalZoomOut())); // Construct Time Mode action group. timeModeActionGroup = new QActionGroup(this); QAction* timeModeAction0 = new QAction("Sample", this); timeModeAction0->setToolTip("Samples from the start."); timeModeAction0->setStatusTip(timeModeAction0->toolTip()); connect(timeModeAction0, SIGNAL(triggered()), this, SLOT(timeMode0())); timeModeAction0->setActionGroup(timeModeActionGroup); timeModeAction0->setCheckable(true); QAction* timeModeAction1 = new QAction("Offset", this); timeModeAction1->setToolTip("Time offset from the start."); timeModeAction1->setStatusTip(timeModeAction1->toolTip()); connect(timeModeAction1, SIGNAL(triggered()), this, SLOT(timeMode1())); timeModeAction1->setActionGroup(timeModeActionGroup); timeModeAction1->setCheckable(true); QAction* timeModeAction2 = new QAction("Real", this); timeModeAction2->setToolTip("Real time."); timeModeAction2->setStatusTip(timeModeAction2->toolTip()); connect(timeModeAction2, SIGNAL(triggered()), this, SLOT(timeMode2())); timeModeAction2->setActionGroup(timeModeActionGroup); timeModeAction2->setCheckable(true); // Construct Time Line Interval action group. timeLineIntervalActionGroup = new QActionGroup(this); QAction* timeLineOffAction = new QAction("Off", this); timeLineOffAction->setToolTip("Turn off the time lines."); timeLineOffAction->setStatusTip(timeLineOffAction->toolTip()); connect(timeLineOffAction, &QAction::triggered, [this] () { if (file != nullptr) { file->getInfoTable()->setTimeLineInterval(0); } }); setTimeLineIntervalAction = new QAction("Set", this); setTimeLineIntervalAction->setActionGroup(timeLineIntervalActionGroup); connect(setTimeLineIntervalAction, &QAction::triggered, [this] () { if (file != nullptr) { double value = file->getInfoTable()->getTimeLineInterval(); if (value == 0) { value = 1; } bool ok; value = QInputDialog::getDouble(this, "Set the interval", "Please, enter the value for the time line interval here:", value, 0, 1000*1000*1000, 2, &ok); if (ok) { file->getInfoTable()->setTimeLineInterval(value); } } }); // Tool bars. const int spacing = 3; // Construct File tool bar. QToolBar* fileToolBar = addToolBar("File Tool Bar"); fileToolBar->setObjectName("File QToolBar"); fileToolBar->layout()->setSpacing(spacing); fileToolBar->addAction(openFileAction); fileToolBar->addAction(closeFileAction); fileToolBar->addAction(saveFileAction); // Construct Filter tool bar. QToolBar* filterToolBar = addToolBar("Filter Tool Bar"); filterToolBar->setObjectName("Filter QToolBar"); filterToolBar->layout()->setSpacing(spacing); QLabel* label = new QLabel("LF:", this); label->setToolTip("Low-pass Filter frequency"); filterToolBar->addWidget(label); lowpassComboBox = new QComboBox(this); lowpassComboBox->setSizeAdjustPolicy(QComboBox::AdjustToContents); lowpassComboBox->setMaximumWidth(150); lowpassComboBox->setEditable(true); filterToolBar->addWidget(lowpassComboBox); label = new QLabel("HF:", this); label->setToolTip("High-pass Filter frequency"); filterToolBar->addWidget(label); highpassComboBox = new QComboBox(this); highpassComboBox->setSizeAdjustPolicy(QComboBox::AdjustToContents); highpassComboBox->setMaximumWidth(150); highpassComboBox->setEditable(true); filterToolBar->addWidget(highpassComboBox); notchCheckBox = new QCheckBox("Notch:", this); notchCheckBox->setToolTip("Notch Filter on/off"); notchCheckBox->setLayoutDirection(Qt::RightToLeft); filterToolBar->addWidget(notchCheckBox); // Construct Select tool bar. QToolBar* selectToolBar = addToolBar("Select Tool bar"); selectToolBar->setObjectName("Select QToolBar"); selectToolBar->layout()->setSpacing(spacing); selectToolBar->addWidget(new QLabel("Montage:", this)); montageComboBox = new QComboBox(this); montageComboBox->setSizeAdjustPolicy(QComboBox::AdjustToContents); montageComboBox->setMaximumWidth(200); selectToolBar->addWidget(montageComboBox); selectToolBar->addWidget(new QLabel("Event Type:", this)); eventTypeComboBox = new QComboBox(this); eventTypeComboBox->setSizeAdjustPolicy(QComboBox::AdjustToContents); eventTypeComboBox->setMaximumWidth(200); selectToolBar->addWidget(eventTypeComboBox); // Construct Zoom tool bar. QToolBar* zoomToolBar = addToolBar("Zoom Tool Bar"); zoomToolBar->setObjectName("Zoom QToolBar"); zoomToolBar->layout()->setSpacing(spacing); zoomToolBar->addAction(horizontalZoomInAction); zoomToolBar->addAction(horizontalZoomOutAction); zoomToolBar->addAction(verticalZoomInAction); zoomToolBar->addAction(verticalZoomOutAction); // Construct File menu. QMenu* fileMenu = menuBar()->addMenu("&File"); fileMenu->addAction(openFileAction); fileMenu->addAction(closeFileAction); fileMenu->addAction(saveFileAction); // Construct View menu. QMenu* viewMenu = menuBar()->addMenu("&View"); viewMenu->addAction(horizontalZoomInAction); viewMenu->addAction(horizontalZoomOutAction); viewMenu->addAction(verticalZoomInAction); viewMenu->addAction(verticalZoomOutAction); QMenu* timeModeMenu = new QMenu("Time Mode", this); timeModeMenu->addAction(timeModeAction0); timeModeMenu->addAction(timeModeAction1); timeModeMenu->addAction(timeModeAction2); viewMenu->addMenu(timeModeMenu); QMenu* timeLineIntervalMenu = new QMenu("Time Line Interval", this); timeLineIntervalMenu->addAction(timeLineOffAction); timeLineIntervalMenu->addAction(setTimeLineIntervalAction); viewMenu->addMenu(timeLineIntervalMenu); // Construct Window menu. QMenu* windowMenu = menuBar()->addMenu("&Window"); windowMenu->addAction(trackManagerDockWidget->toggleViewAction()); windowMenu->addAction(eventManagerDockWidget->toggleViewAction()); windowMenu->addAction(eventTypeDockWidget->toggleViewAction()); windowMenu->addAction(montageManagerDockWidget->toggleViewAction()); windowMenu->addSeparator(); windowMenu->addAction(fileToolBar->toggleViewAction()); windowMenu->addAction(filterToolBar->toggleViewAction()); windowMenu->addAction(selectToolBar->toggleViewAction()); windowMenu->addAction(zoomToolBar->toggleViewAction()); // Construct status bar. timeModeStatusLabel = new QLabel(this); timeModeStatusLabel->setContextMenuPolicy(Qt::ActionsContextMenu); timeModeStatusLabel->addAction(timeModeAction0); timeModeStatusLabel->addAction(timeModeAction1); timeModeStatusLabel->addAction(timeModeAction2); statusBar()->addPermanentWidget(timeModeStatusLabel); timeStatusLabel = new QLabel(this); timeStatusLabel->setContextMenuPolicy(Qt::ActionsContextMenu); timeStatusLabel->addAction(timeModeAction0); timeStatusLabel->addAction(timeModeAction1); timeStatusLabel->addAction(timeModeAction2); statusBar()->addPermanentWidget(timeStatusLabel); positionStatusLabel = new QLabel(this); positionStatusLabel->setContextMenuPolicy(Qt::ActionsContextMenu); positionStatusLabel->addAction(timeModeAction0); positionStatusLabel->addAction(timeModeAction1); positionStatusLabel->addAction(timeModeAction2); statusBar()->addPermanentWidget(positionStatusLabel); cursorStatusLabel = new QLabel(this); cursorStatusLabel->setContextMenuPolicy(Qt::ActionsContextMenu); cursorStatusLabel->addAction(timeModeAction0); cursorStatusLabel->addAction(timeModeAction1); cursorStatusLabel->addAction(timeModeAction2); statusBar()->addPermanentWidget(cursorStatusLabel); // Restore settings. restoreGeometry(PROGRAM_OPTIONS.settings("SignalFileBrowserWindow geometry").toByteArray()); restoreState(PROGRAM_OPTIONS.settings("SignalFileBrowserWindow state").toByteArray()); }
//BEGIN KateViewSpace KateViewSpace::KateViewSpace(KateViewManager *viewManager, QWidget *parent, const char *name) : QWidget(parent) , m_viewManager(viewManager) , m_isActiveSpace(false) { setObjectName(QString::fromLatin1(name)); QVBoxLayout *layout = new QVBoxLayout(this); layout->setSpacing(0); layout->setMargin(0); //BEGIN tab bar QHBoxLayout *hLayout = new QHBoxLayout(); hLayout->setSpacing(0); hLayout->setMargin(0); // add tab bar m_tabBar = new KateTabBar(this); connect(m_tabBar, &KateTabBar::currentChanged, this, &KateViewSpace::changeView); connect(m_tabBar, &KateTabBar::moreTabsRequested, this, &KateViewSpace::addTabs); connect(m_tabBar, &KateTabBar::lessTabsRequested, this, &KateViewSpace::removeTabs); connect(m_tabBar, &KateTabBar::closeTabRequested, this, &KateViewSpace::closeTabRequest, Qt::QueuedConnection); connect(m_tabBar, &KateTabBar::contextMenuRequest, this, &KateViewSpace::showContextMenu, Qt::QueuedConnection); connect(m_tabBar, &KateTabBar::newTabRequested, this, &KateViewSpace::createNewDocument); connect(m_tabBar, SIGNAL(activateViewSpaceRequested()), this, SLOT(makeActive())); hLayout->addWidget(m_tabBar); // add quick open m_quickOpen = new QToolButton(this); m_quickOpen->setAutoRaise(true); KAcceleratorManager::setNoAccel(m_quickOpen); m_quickOpen->installEventFilter(this); // on click, active this view space hLayout->addWidget(m_quickOpen); // forward tab bar quick open action to globa quick open action QAction * bridge = new QAction(QIcon::fromTheme(QStringLiteral("tab-duplicate")), i18nc("indicator for more documents", "+%1", 100), this); m_quickOpen->setDefaultAction(bridge); QAction * quickOpen = m_viewManager->mainWindow()->actionCollection()->action(QStringLiteral("view_quick_open")); Q_ASSERT(quickOpen); bridge->setToolTip(quickOpen->toolTip()); bridge->setWhatsThis(i18n("Click here to switch to the Quick Open view.")); connect(bridge, SIGNAL(triggered()), quickOpen, SLOT(trigger())); // add vertical split view space m_split = new QToolButton(this); m_split->setAutoRaise(true); m_split->setPopupMode(QToolButton::InstantPopup); m_split->setIcon(QIcon::fromTheme(QStringLiteral("view-split-left-right"))); m_split->addAction(m_viewManager->mainWindow()->actionCollection()->action(QStringLiteral("view_split_vert"))); m_split->addAction(m_viewManager->mainWindow()->actionCollection()->action(QStringLiteral("view_split_horiz"))); m_split->addAction(m_viewManager->mainWindow()->actionCollection()->action(QStringLiteral("view_close_current_space"))); m_split->addAction(m_viewManager->mainWindow()->actionCollection()->action(QStringLiteral("view_close_others"))); m_split->addAction(m_viewManager->mainWindow()->actionCollection()->action(QStringLiteral("view_hide_others"))); m_split->setWhatsThis(i18n("Control view space splitting")); m_split->installEventFilter(this); // on click, active this view space hLayout->addWidget(m_split); layout->addLayout(hLayout); //END tab bar stack = new QStackedWidget(this); stack->setFocus(); stack->setSizePolicy(QSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Expanding)); layout->addWidget(stack); m_group.clear(); // connect signal to hide/show statusbar connect(m_viewManager->mainWindow(), SIGNAL(statusBarToggled()), this, SLOT(statusBarToggled())); connect(m_viewManager->mainWindow(), SIGNAL(tabBarToggled()), this, SLOT(tabBarToggled())); // init the bars... statusBarToggled(); tabBarToggled(); // make sure we show correct number of hidden documents updateQuickOpen(); connect(KateApp::self()->documentManager(), SIGNAL(documentCreated(KTextEditor::Document*)), this, SLOT(updateQuickOpen())); connect(KateApp::self()->documentManager(), SIGNAL(documentsDeleted(const QList<KTextEditor::Document*>&)), this, SLOT(updateQuickOpen())); }