void OptionsTabPlugins::listPlugins()
{
	if ( !w )
		return;

	OptPluginsUI *d = (OptPluginsUI *)w;

	d->tw_Plugins->clear();

	PluginManager *pm=PluginManager::instance();

	QStringList plugins = pm->availablePlugins();
	plugins.sort();
	const QSize buttonSize = QSize(21,21);
	foreach ( const QString& plugin, plugins ){
		QIcon icon = pm->icon(plugin);
		bool enabled = pm->isEnabled(plugin);
		const QString path = pm->pathToPlugin(plugin);
		QString toolTip = tr("Plugin Path:\n%1").arg(path);
		Qt::CheckState state = enabled ? Qt::Checked : Qt::Unchecked;
		QTreeWidgetItem *item = new QTreeWidgetItem(d->tw_Plugins, QTreeWidgetItem::Type);
		item->setFlags(item->flags() | Qt::ItemIsUserCheckable);
		item->setText(C_NAME, plugin);
		item->setText(C_VERSION, pm->version(plugin));
		item->setTextAlignment(C_VERSION, Qt::AlignHCenter);
		item->setToolTip(C_NAME, toolTip);
		item->setCheckState(C_NAME, state);
		if ( !enabled ) {
			icon = QIcon(icon.pixmap(icon.availableSizes().at(0), QIcon::Disabled));
		}
		item->setIcon(C_NAME,icon);
		QString shortName = PluginManager::instance()->shortName(plugin);

		QToolButton *aboutbutton = new QToolButton(d->tw_Plugins);
		aboutbutton->setIcon(QIcon(IconsetFactory::iconPixmap("psi/info")));
		aboutbutton->resize(buttonSize);
		aboutbutton->setObjectName("ab_" + shortName);
		aboutbutton->setToolTip(tr("Show information about plugin"));
		connect(aboutbutton, SIGNAL(clicked()), this, SLOT(showPluginInfo()));
		d->tw_Plugins->setItemWidget(item, C_ABOUT, aboutbutton);

		QToolButton *settsbutton = new QToolButton(d->tw_Plugins);
		settsbutton->setIcon(QIcon(IconsetFactory::iconPixmap("psi/options")));
		settsbutton->resize(buttonSize);
		settsbutton->setObjectName("sb_" + shortName);
		settsbutton->setToolTip(tr("Open plugin settings dialog"));
		connect(settsbutton, SIGNAL(clicked()), this, SLOT(settingsClicked()));
		settsbutton->setEnabled(enabled);
		d->tw_Plugins->setItemWidget(item, C_SETTS, settsbutton);
	}
Esempio n. 2
0
			QToolButton* PackagesDelegate::GetUpdate (const QModelIndex& index) const
			{
				int row = index.row ();
				if (!Row2Update_.contains (row))
				{
					QAction *action = new QAction (Core::Instance ()
								.GetProxy ()->GetIcon ("update"),
							tr ("Update"),
							Viewport_);
					action->setCheckable (true);
					action->setProperty ("Role", "Update");
					connect (action,
							SIGNAL (triggered ()),
							this,
							SLOT (handleAction ()));

					QToolButton *toolButton = new QToolButton ();
					toolButton->resize (CActionsSize, CActionsSize);
					toolButton->setDefaultAction (action);
					Row2Update_ [row] = toolButton;
				}

				QToolButton *button = Row2Update_ [row];
				QAction *action = button->defaultAction ();

				bool upgradable = index.data (PackagesModel::PMRUpgradable).toBool ();
				action->setEnabled (upgradable);
				action->setData (index.data (PackagesModel::PMRPackageID));

				WasUpgradable_ [index] = upgradable;

				return button;
			}
Esempio n. 3
0
CColorPopup::CColorPopup (QWidget * parent, const char *name, Qt::WFlags f)
:QWidget (parent, name, f)
{
    colorShower = new QLabel (this, "color shower");
    colorShower->setFrameStyle (Q3Frame::WinPanel | Q3Frame::Sunken);
    colorShower->setLineWidth (2);
    colorShower->setMidLineWidth (1);
    colorShower->resize (37, 20);
    colorShower->setPaletteBackgroundColor (QColor (0, 0, 0));
    colorShower->move (5, 2);
    colorName = new Q3TextEdit (this);
    colorName->resize (55, 20);
    colorName->move (50, 2);
    colorName->setHScrollBarMode (Q3ScrollView::AlwaysOff);
    colorName->setVScrollBarMode (Q3ScrollView::AlwaysOff);
    
	QFont f1 ("Times", 8, QFont::Light);
    colorName->setFont (f1);
    colorName->clearFocus ();
    s = new CColorSwatches (this, "", ((CTools *) parent)->dad);
    s->resize (210, 125);
    s->move (2, 29);
    
	QToolButton * colordialog =new CToolButton (this, tr ("Open color dialog"));
    colordialog->move (180, 3);
    colordialog->resize (20, 20);
    colordialog->setIconSet (QIcon (QPixmap ("colordialogBut.png")));
    colordialog->setTextLabel (trUtf8 ("Open Color Dialog"));
    connect (colordialog, SIGNAL (clicked ()), this,SLOT (slotColordialog ()));

        //setFocusPolicy (QWidget::StrongFocus);
    setMouseTracking (true);
    mcursor = QPixmap ((const char **) eye_dropper_tool_xpm);
    setCursor (QCursor (mcursor, 1, 15));
}
Esempio n. 4
0
			QToolButton* PackagesDelegate::GetInstallRemove (const QModelIndex& index) const
			{
				int row = index.row ();
				if (!Row2InstallRemove_.contains (row))
				{
					QAction *action = new QAction (Viewport_);
					action->setCheckable (true);
					action->setProperty ("Role", "InstallRemove");
					connect (action,
							SIGNAL (triggered ()),
							this,
							SLOT (handleAction ()));

					QToolButton *toolButton = new QToolButton ();
					toolButton->resize (CActionsSize, CActionsSize);
					toolButton->setDefaultAction (action);
					Row2InstallRemove_ [row] = toolButton;
				}

				QToolButton *button = Row2InstallRemove_ [row];

				bool installed = index.data (PackagesModel::PMRInstalled).toBool ();
				QString label;
				QString iconName;
				if (installed)
				{
					label = tr ("Remove");
					iconName = "remove";
				}
				else
				{
					label = tr ("Install");
					iconName = "addjob";
				}

				QAction *action = button->defaultAction ();
				WasInstalled_ [index] = installed;

				action->setText (label);
				action->setIcon (Core::Instance ().GetProxy ()->GetIcon (iconName));
				action->setData (index.data (PackagesModel::PMRPackageID));
				action->setProperty ("Installed", index.data (PackagesModel::PMRInstalled));

				return button;
			}
Esempio n. 5
0
void ItemsViewDelegate::updateItemWidgets(const QList<QWidget*> widgets,
        const QStyleOptionViewItem &option,
        const QPersistentModelIndex &index) const
{
    const QSortFilterProxyModel * model = qobject_cast<const QSortFilterProxyModel*>(index.model());
    if (model == NULL) {
        return;
    }

    const ItemsModel * realmodel = qobject_cast<const ItemsModel*>(model->sourceModel());
    if (realmodel == NULL || !index.isValid()) {
        return;
    }

    // setup the install button
    int margin = option.fontMetrics.height() / 2;

    int right = option.rect.width();
    //int bottom = option.rect.height();

    QSize size(option.fontMetrics.height() * 7, widgets.at(kInstall)->sizeHint().height());

    QLabel * infoLabel = qobject_cast<QLabel*>(widgets.at(kLabel));
	infoLabel->setWordWrap(true);
    if (infoLabel != NULL) {
        if (realmodel->hasPreviewImages()) {
            // move the text right by kPreviewWidth + margin pixels to fit the preview
            infoLabel->move(kPreviewWidth + margin * 2, 0);
            infoLabel->resize(QSize(option.rect.width() - kPreviewWidth - (margin * 6) - size.width(), option.fontMetrics.height() * 7));
        } else {
            infoLabel->move(margin, 0);
            infoLabel->resize(QSize(option.rect.width() - (margin * 4) - size.width(), option.fontMetrics.height() * 7));
        }

        QString text = "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0//EN\" \"http://www.w3.org/TR/REC-html40/strict.dtd\">\n"
			"<html><head><meta name=\"qrichtext\" content=\"1\" /><style type=\"text/css\">p, li { white-space: pre-wrap; margin:0 0 0 0;}\n"
			"</style></head><body><p><b>" +
			index.data(ItemsModel::kNameRole).toString() + "</b></p>\n";

        QString summary = "<p>" + option.fontMetrics.elidedText(index.data(ItemsModel::kSummary).toString(),
		  Qt::ElideRight, infoLabel->width() * 3) + "</p>\n";
        text += summary;

        QString authorName = index.data(ItemsModel::kAuthorName).toString();
        QString email = index.data(ItemsModel::kAuthorEmail).toString();
        if (!authorName.isEmpty()) {
            if (email.isEmpty()) {
                text += "<p><i>" + authorName + "</i></p>\n";
            } else {
                text += "<p><i>" + authorName + "</i> <a href=\"mailto:" + email + "\">" + email + "</a></p>\n";
            }
        }

        unsigned int downloads = index.data(ItemsModel::kDownloads).toUInt();
        text += downloads == 0 ? i18n("<p>No Downloads</p>") : i18n("<p>Downloads: %1</p>\n", downloads);

		text += "</body></html>";
        text.replace("[b]", "<b>");
        text.replace("[/b]", "</b>");
        text.replace("[i]", "<i>");
        text.replace("[/i]", "</i>");
        text.replace("[u]", "<i>");
        text.replace("[/u]", "</i>");
        text.remove("[url]");
        text.remove("[/url]");
        text.replace("\\\'", "\'");
        infoLabel->setText(text.simplified());
    }

    QToolButton * button = qobject_cast<QToolButton*>(widgets.at(kInstall));
    if (button != NULL) {
        Entry::Status status = Entry::Status(model->data(index, ItemsModel::kStatus).toUInt());
        //if (!button->menu()) {
        //    button->setMenu(InstallMenu(button, status));
        //    button->setIconSize(QSize(16, 16));
            button->resize(size);
        //}
        button->move(right - button->width() - margin, option.rect.height() / 2 - button->height());
        button->setToolButtonStyle(Qt::ToolButtonTextBesideIcon);
        //button->setPopupMode(QToolButton::MenuButtonPopup);

        // validate our assumptions
        //Q_ASSERT(button->menu());
        //Q_ASSERT(button->menu()->actions().count() == 2);

        // get the two actions
        //QAction * action_install = button->menu()->actions()[0];
        //QAction * action_uninstall = button->menu()->actions()[1];
        switch (status) {
        case Entry::Installed:
            button->setText(i18n("Uninstall"));
            //action_install->setVisible(false);
            //action_uninstall->setVisible(true);
            button->setIcon(QIcon(m_statusicons[Entry::Deleted]));
            break;
        case Entry::Updateable:
            button->setText(i18n("Update"));
            //action_uninstall->setVisible(false);
            //action_install->setText(i18n("Update"));
            //action_install->setVisible(true);
            //action_install->setIcon(QIcon(m_statusicons[Entry::Updateable]));
            button->setIcon(QIcon(m_statusicons[Entry::Updateable]));
            break;
        case Entry::Deleted:
            /// @todo Set different button text when string freeze is over? "Install again"
            button->setText(i18n("Install"));
            //action_uninstall->setVisible(false);
            //action_install->setText(i18n("Install"));
            //action_install->setVisible(true);
            //action_install->setIcon(QIcon(m_statusicons[Entry::Installed]));
            button->setIcon(QIcon(m_statusicons[Entry::Installed]));
            break;
        default:
            button->setText(i18n("Install"));
            //action_uninstall->setVisible(false);
            //action_install->setVisible(true);
            //action_install->setIcon(QIcon(m_statusicons[Entry::Installed]));
            button->setIcon(QIcon(m_statusicons[Entry::Installed]));
        }
    }

    QLabel * ratingLabel = qobject_cast<QLabel*>(widgets.at(kRating));
    if (ratingLabel != NULL) {
        ratingLabel->setText(i18n("Rating: %1", model->data(index, ItemsModel::kRating).toString()));

        // put the rating label below the install button
        ratingLabel->move(right - button->width() - margin, option.rect.height() / 2 + button->height()/2);
        ratingLabel->resize(size);
    }
}