void CellMLAnnotationViewMetadataEditDetailsWidget::updateItemsGui(const Items &pItems, const QString &pErrorMsg, const bool &pLookupTerm) { Q_ASSERT(mItemsScrollArea); // Prevent ourselves from being updated (to avoid any flickering) setUpdatesEnabled(false); // Keep track of some information mItems = pItems; mErrorMsg = pErrorMsg; mLookupTerm = pLookupTerm; // Create a new widget and layout QWidget *newGridWidget = new QWidget(mItemsScrollArea); QGridLayout *newGridLayout = new QGridLayout(newGridWidget); newGridWidget->setLayout(newGridLayout); // Populate our new layout, but only if there is at least one item if (pItems.count()) { // Create labels to act as headers newGridLayout->addWidget(Core::newLabel(tr("Name"), 1.25, true, false, Qt::AlignCenter, newGridWidget), 0, 0); newGridLayout->addWidget(Core::newLabel(tr("Resource"), 1.25, true, false, Qt::AlignCenter, newGridWidget), 0, 1); newGridLayout->addWidget(Core::newLabel(tr("Id"), 1.25, true, false, Qt::AlignCenter, newGridWidget), 0, 2); // Number of terms newGridLayout->addWidget(Core::newLabel((pItems.count() == 1)? tr("(1 term)"): tr("(%1 terms)").arg(QString::number(pItems.count())), 1.0, false, true, Qt::AlignCenter, newGridWidget), 0, 3); // Add the items int row = 0; foreach (const Item &item, pItems) { // Name newGridLayout->addWidget(Core::newLabel(item.name, 1.0, false, false, Qt::AlignCenter, newGridWidget), ++row, 0); // Resource QString itemInformation = item.resource+"|"+item.id; QLabel *resourceLabel = Core::newLabel("<a href=\""+itemInformation+"\">"+item.resource+"</a>", 1.0, false, false, Qt::AlignCenter, newGridWidget); resourceLabel->setAccessibleDescription("http://identifiers.org/"+item.resource+"/?redirect=true"); resourceLabel->setContextMenuPolicy(Qt::CustomContextMenu); connect(resourceLabel, SIGNAL(customContextMenuRequested(const QPoint &)), this, SLOT(showCustomContextMenu(const QPoint &))); connect(resourceLabel, SIGNAL(linkActivated(const QString &)), this, SLOT(lookupResource(const QString &))); newGridLayout->addWidget(resourceLabel, row, 1); // Id QLabel *idLabel = Core::newLabel("<a href=\""+itemInformation+"\">"+item.id+"</a>", 1.0, false, false, Qt::AlignCenter, newGridWidget); idLabel->setAccessibleDescription("http://identifiers.org/"+item.resource+"/"+item.id+"/?profile=most_reliable&redirect=true"); idLabel->setContextMenuPolicy(Qt::CustomContextMenu); connect(idLabel, SIGNAL(customContextMenuRequested(const QPoint &)), this, SLOT(showCustomContextMenu(const QPoint &))); connect(idLabel, SIGNAL(linkActivated(const QString &)), this, SLOT(lookupId(const QString &))); newGridLayout->addWidget(idLabel, row, 2); // Add button QPushButton *addButton = new QPushButton(newGridWidget); // Note #1: ideally, we could assign a QAction to our // QPushButton, but this cannot be done, so... we // assign a few properties by hand... // Note #2: to use a QToolButton would allow us to assign a // QAction to it, but a QToolButton doesn't look quite // the same as a QPushButton on some platforms, so... addButton->setIcon(QIcon(":/oxygen/actions/list-add.png")); addButton->setStatusTip(tr("Add the term")); addButton->setToolTip(tr("Add")); addButton->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed); mItemsMapping.insert(addButton, item); connect(addButton, SIGNAL(clicked()), this, SLOT(addRetrievedTerm())); newGridLayout->addWidget(addButton, row, 3, Qt::AlignCenter); }
QtLoginWindow::QtLoginWindow(UIEventStream* uiEventStream, SettingsProvider* settings, TimerFactory* timerFactory) : QMainWindow(), settings_(settings), timerFactory_(timerFactory) { uiEventStream_ = uiEventStream; setWindowTitle("Swift"); #ifndef Q_OS_MAC #ifdef Q_OS_WIN32 setWindowIcon(QIcon(":/logo-icon-16-win.png")); #else setWindowIcon(QIcon(":/logo-icon-16.png")); #endif #endif QtUtilities::setX11Resource(this, "Main"); setAccessibleName(tr("Swift Login Window")); //setAccessibleDescription(tr("This window is used for providing credentials to log into your XMPP service")); resize(200, 500); setContentsMargins(0,0,0,0); QWidget *centralWidget = new QWidget(this); setCentralWidget(centralWidget); QBoxLayout *topLayout = new QBoxLayout(QBoxLayout::TopToBottom, centralWidget); stack_ = new QStackedWidget(centralWidget); topLayout->addWidget(stack_); topLayout->setMargin(0); loginWidgetWrapper_ = new QWidget(this); loginWidgetWrapper_->setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding)); QBoxLayout *layout = new QBoxLayout(QBoxLayout::TopToBottom, loginWidgetWrapper_); layout->addStretch(2); QLabel* logo = new QLabel(this); QIcon swiftWithTextLogo = QIcon(":/logo-shaded-text.png"); logo->setPixmap(swiftWithTextLogo.pixmap(QSize(192,192))); QWidget *logoWidget = new QWidget(this); QHBoxLayout *logoLayout = new QHBoxLayout(); logoLayout->setMargin(0); logoLayout->addStretch(0); logoLayout->addWidget(logo); logoLayout->addStretch(0); logoWidget->setLayout(logoLayout); layout->addWidget(logoWidget); layout->addStretch(2); QLabel* jidLabel = new QLabel(this); jidLabel->setText("<font size='-1'>" + tr("User address:") + "</font>"); layout->addWidget(jidLabel); username_ = new QComboBox(this); username_->setEditable(true); username_->setWhatsThis(tr("User address - looks like [email protected]")); username_->setToolTip(tr("User address - looks like [email protected]")); username_->view()->installEventFilter(this); username_->setAccessibleName(tr("User address (of the form [email protected])")); username_->setAccessibleDescription(tr("This is the user address that you'll be using to log in with")); layout->addWidget(username_); QLabel* jidHintLabel = new QLabel(this); jidHintLabel->setText("<font size='-1' color='grey' >" + tr("Example: [email protected]") + "</font>"); jidHintLabel->setAlignment(Qt::AlignRight); layout->addWidget(jidHintLabel); QLabel* passwordLabel = new QLabel(); passwordLabel->setText("<font size='-1'>" + tr("Password:"******"</font>"); passwordLabel->setAccessibleName(tr("User password")); passwordLabel->setAccessibleDescription(tr("This is the password you'll use to log in to the XMPP service")); layout->addWidget(passwordLabel); QWidget* w = new QWidget(this); w->setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding)); layout->addWidget(w); QHBoxLayout* credentialsLayout = new QHBoxLayout(w); credentialsLayout->setMargin(0); credentialsLayout->setSpacing(3); password_ = new QLineEdit(this); password_->setEchoMode(QLineEdit::Password); connect(password_, SIGNAL(returnPressed()), this, SLOT(loginClicked())); connect(username_->lineEdit(), SIGNAL(returnPressed()), password_, SLOT(setFocus())); connect(username_, SIGNAL(editTextChanged(const QString&)), this, SLOT(handleUsernameTextChanged())); credentialsLayout->addWidget(password_); certificateButton_ = new QToolButton(this); certificateButton_->setCheckable(true); certificateButton_->setIcon(QIcon(":/icons/certificate.png")); certificateButton_->setToolTip(tr("Click if you have a personal certificate used for login to the service.")); certificateButton_->setWhatsThis(tr("Click if you have a personal certificate used for login to the service.")); certificateButton_->setAccessibleName(tr("Login with certificate")); certificateButton_->setAccessibleDescription(tr("Click if you have a personal certificate used for login to the service.")); credentialsLayout->addWidget(certificateButton_); connect(certificateButton_, SIGNAL(clicked(bool)), SLOT(handleCertficateChecked(bool))); loginButton_ = new QPushButton(this); loginButton_->setText(tr("Connect")); loginButton_->setAutoDefault(true); loginButton_->setDefault(true); loginButton_->setAccessibleName(tr("Connect now")); layout->addWidget(loginButton_); QLabel* connectionOptionsLabel = new QLabel(this); connectionOptionsLabel->setText("<a href=\"#\"><font size='-1'>" + QObject::tr("Connection Options") + "</font></a>"); connectionOptionsLabel->setTextFormat(Qt::RichText); connectionOptionsLabel->setAlignment(Qt::AlignRight|Qt::AlignVCenter); layout->addWidget(connectionOptionsLabel); connect(connectionOptionsLabel, SIGNAL(linkActivated(const QString&)), SLOT(handleOpenConnectionOptions())); message_ = new QLabel(this); message_->setTextFormat(Qt::RichText); message_->setWordWrap(true); layout->addWidget(message_); layout->addStretch(2); remember_ = new QCheckBox(tr("Remember Password?"), this); layout->addWidget(remember_); loginAutomatically_ = new QCheckBox(tr("Login Automatically?"), this); layout->addWidget(loginAutomatically_); connect(loginButton_, SIGNAL(clicked()), SLOT(loginClicked())); stack_->addWidget(loginWidgetWrapper_); #ifdef SWIFTEN_PLATFORM_MACOSX menuBar_ = new QMenuBar(nullptr); #else menuBar_ = menuBar(); #endif QApplication::setQuitOnLastWindowClosed(false); swiftMenu_ = new QMenu(tr("&Swift"), this); #ifdef SWIFTEN_PLATFORM_MACOSX generalMenu_ = new QMenu(tr("&General"), this); #else generalMenu_ = swiftMenu_; #endif #ifdef SWIFTEN_PLATFORM_MACOSX QAction* aboutAction = new QAction(QString("&About %1").arg("Swift"), this); #else QAction* aboutAction = new QAction(QString(tr("&About %1")).arg("Swift"), this); #endif connect(aboutAction, SIGNAL(triggered()), SLOT(handleAbout())); swiftMenu_->addAction(aboutAction); xmlConsoleAction_ = new QAction(tr("&Show Debug Console"), this); connect(xmlConsoleAction_, SIGNAL(triggered()), SLOT(handleShowXMLConsole())); generalMenu_->addAction(xmlConsoleAction_); #ifdef SWIFT_EXPERIMENTAL_FT fileTransferOverviewAction_ = new QAction(tr("Show &File Transfer Overview"), this); connect(fileTransferOverviewAction_, SIGNAL(triggered()), SLOT(handleShowFileTransferOverview())); generalMenu_->addAction(fileTransferOverviewAction_); #endif highlightEditorAction_ = new QAction(tr("&Edit Highlight Rules"), this); connect(highlightEditorAction_, SIGNAL(triggered()), SLOT(handleShowHighlightEditor())); generalMenu_->addAction(highlightEditorAction_); toggleSoundsAction_ = new QAction(tr("&Play Sounds"), this); toggleSoundsAction_->setCheckable(true); toggleSoundsAction_->setChecked(settings_->getSetting(SettingConstants::PLAY_SOUNDS)); connect(toggleSoundsAction_, SIGNAL(toggled(bool)), SLOT(handleToggleSounds(bool))); generalMenu_->addAction(toggleSoundsAction_); toggleNotificationsAction_ = new QAction(tr("Display Pop-up &Notifications"), this); toggleNotificationsAction_->setCheckable(true); toggleNotificationsAction_->setChecked(settings_->getSetting(SettingConstants::SHOW_NOTIFICATIONS)); connect(toggleNotificationsAction_, SIGNAL(toggled(bool)), SLOT(handleToggleNotifications(bool))); #ifndef SWIFTEN_PLATFORM_MACOSX swiftMenu_->addSeparator(); #endif #ifdef SWIFTEN_PLATFORM_MACOSX QAction* quitAction = new QAction("&Quit", this); #else QAction* quitAction = new QAction(tr("&Quit"), this); #endif connect(quitAction, SIGNAL(triggered()), SLOT(handleQuit())); swiftMenu_->addAction(quitAction); setInitialMenus(); settings_->onSettingChanged.connect(boost::bind(&QtLoginWindow::handleSettingChanged, this, _1)); bool eagle = settings_->getSetting(SettingConstants::FORGET_PASSWORDS); remember_->setEnabled(!eagle); loginAutomatically_->setEnabled(!eagle); xmlConsoleAction_->setEnabled(!eagle); if (eagle) { remember_->setChecked(false); loginAutomatically_->setChecked(false); } #ifdef SWIFTEN_PLATFORM_MACOSX // Temporary workaround for case 501. Could be that this code is still // needed when Qt provides a proper fix qApp->installEventFilter(this); #endif this->show(); }