Beispiel #1
0
void Paste::showOk()
{
    // Show ok icon like in DeviceNotifier
    setPopupIcon("dialog-ok");
    m_list->icon->setPixmap(KIcon("dialog-ok").pixmap(KIconLoader::SizeSmall,
                                                      KIconLoader::SizeSmall));
    QTimer::singleShot(2000, this, SLOT(resetIcon()));
}
Beispiel #2
0
void TextSymbol::scale(double factor)
{
	font_size = qRound(factor * font_size);
	framing_line_half_width = qRound(factor * framing_line_half_width);
	framing_shadow_x_offset = qRound(factor * framing_shadow_x_offset);
	framing_shadow_y_offset = qRound(factor * framing_shadow_y_offset);
	
	updateQFont();
	
	resetIcon();
}
Beispiel #3
0
void
ChatDialog::changeEvent(QEvent *e)
{
  switch(e->type()) {
  case QEvent::ActivationChange:
    if (isActiveWindow()) {
      emit resetIcon();
    }
    break;
  default:
    break;
  }
}
void StatusNotifierButton::newStatus(QString status)
{
    Status newStatus;
    if (status == QLatin1String("Passive"))
        newStatus = Passive;
    else if (status == QLatin1String("Active"))
        newStatus = Active;
    else
        newStatus = NeedsAttention;

    if (mStatus == newStatus)
        return;

    mStatus = newStatus;
    resetIcon();
}
StatusNotifierButton::StatusNotifierButton(QString service, QString objectPath, ILXQtPanelPlugin* plugin, QWidget *parent)
    : QToolButton(parent),
    mMenu(NULL),
    mStatus(Passive),
    mValid(true),
    mFallbackIcon(QIcon::fromTheme("application-x-executable")),
    mPlugin(plugin)
{
    interface = new org::kde::StatusNotifierItem(service, objectPath, QDBusConnection::sessionBus(), this);

    QString menuPath = interface->menu().path();
    if (!menuPath.isEmpty())
    {
        mMenu = (new DBusMenuImporter(service, interface->menu().path(), this))->menu();
        dynamic_cast<QObject &>(*mMenu).setParent(this);
        mMenu->setObjectName(QStringLiteral("StatusNotifierMenu"));
    }

    // HACK: sni-qt creates some invalid items (like one for konversarion 1.5)
    if (interface->title().isEmpty() && interface->id().isEmpty())
        mValid = false;

    if (mValid)
    {
        newToolTip();
        refetchIcon(Active);
        refetchIcon(Passive);
        refetchIcon(NeedsAttention);
        newStatus(interface->status());
        resetIcon();

        connect(interface, SIGNAL(NewIcon()), this, SLOT(newIcon()));
        connect(interface, SIGNAL(NewOverlayIcon()), this, SLOT(newOverlayIcon()));
        connect(interface, SIGNAL(NewAttentionIcon()), this, SLOT(newAttentionIcon()));
        connect(interface, SIGNAL(NewToolTip()), this, SLOT(newToolTip()));
        connect(interface, SIGNAL(NewStatus(QString)), this, SLOT(newStatus(QString)));
    }
}
Beispiel #6
0
void TextSymbol::colorDeleted(const MapColor* c)
{
	auto changes = 0;
	if (c == color)
	{
		color = nullptr;
		++changes;
	}
	if (c == framing_color)
	{
		framing_color = nullptr;
		++changes;
	}
	if (c == line_below_color)
	{
		line_below_color = nullptr;
		++changes;
	}
	if (changes)
	{
		resetIcon();
	}
}
void StatusNotifierButton::refetchIcon(Status status, const QString& themePath)
{
    QString nameProperty, pixmapProperty;
    if (status == Active)
    {
        nameProperty = QLatin1String("OverlayIconName");
        pixmapProperty = QLatin1String("OverlayIconPixmap");
    }
    else if (status == NeedsAttention)
    {
        nameProperty = QLatin1String("AttentionIconName");
        pixmapProperty = QLatin1String("AttentionIconPixmap");
    }
    else // status == Passive
    {
        nameProperty = QLatin1String("IconName");
        pixmapProperty = QLatin1String("IconPixmap");
    }

    interface->propertyGetAsync(nameProperty, [this, status, pixmapProperty, themePath] (QString iconName) {
        QIcon nextIcon;
        if (!iconName.isEmpty())
        {
            if (QIcon::hasThemeIcon(iconName))
                nextIcon = QIcon::fromTheme(iconName);
            else
            {
                QDir themeDir(themePath);
                if (themeDir.exists())
                {
                    if (themeDir.exists(iconName + ".png"))
                        nextIcon.addFile(themeDir.filePath(iconName + ".png"));

                    if (themeDir.cd("hicolor") || (themeDir.cd("icons") && themeDir.cd("hicolor")))
                    {
                        const QStringList sizes = themeDir.entryList(QDir::AllDirs | QDir::NoDotAndDotDot);
                        for (const QString &dir : sizes)
                        {
                            const QStringList dirs = QDir(themeDir.filePath(dir)).entryList(QDir::AllDirs | QDir::NoDotAndDotDot);
                            for (const QString &innerDir : dirs)
                            {
                                QString file = themeDir.absolutePath() + "/" + dir + "/" + innerDir + "/" + iconName + ".png";
                                if (QFile::exists(file))
                                    nextIcon.addFile(file);
                            }
                        }
                    }
                }
            }

            switch (status)
            {
                case Active:
                    mOverlayIcon = nextIcon;
                    break;
                case NeedsAttention:
                    mAttentionIcon = nextIcon;
                    break;
                case Passive:
                    mIcon = nextIcon;
                    break;
            }

            resetIcon();
        }
        else
        {
            interface->propertyGetAsync(pixmapProperty, [this, status, pixmapProperty] (IconPixmapList iconPixmaps) {
                if (iconPixmaps.empty())
                    return;

                QIcon nextIcon;

                for (IconPixmap iconPixmap: iconPixmaps)
                {
                    if (!iconPixmap.bytes.isNull())
                    {
                        QImage image((uchar*) iconPixmap.bytes.data(), iconPixmap.width,
                                     iconPixmap.height, QImage::Format_ARGB32);

                        const uchar *end = image.constBits() + image.byteCount();
                        uchar *dest = reinterpret_cast<uchar*>(iconPixmap.bytes.data());
                        for (const uchar *src = image.constBits(); src < end; src += 4, dest += 4)
                            qToUnaligned(qToBigEndian<quint32>(qFromUnaligned<quint32>(src)), dest);

                        nextIcon.addPixmap(QPixmap::fromImage(image));
                    }
                }

                switch (status)
                {
                    case Active:
                        mOverlayIcon = nextIcon;
                        break;
                    case NeedsAttention:
                        mAttentionIcon = nextIcon;
                        break;
                    case Passive:
                        mIcon = nextIcon;
                        break;
                }

                resetIcon();
            });
        }
    });
}
void StatusNotifierButton::newAttentionIcon()
{
    refetchIcon(NeedsAttention);
    resetIcon();
}
void StatusNotifierButton::newOverlayIcon()
{
    refetchIcon(Active);
    resetIcon();
}
void StatusNotifierButton::newIcon()
{
    refetchIcon(Passive);
    resetIcon();
}
Beispiel #11
0
QxCommandEditor::QxCommandEditor(QWidget* parent)
	: QxDialog(parent),
	  iconSelector_(new QxIconSelector(parent)),
	  command_(0)
{
	setWindowTitle(qApp->applicationName() + tr("- Edit Command"));
	
	QVBoxLayout* col = new QVBoxLayout;
	{
		QFormLayout* form = new QFormLayout;
		form->setFieldGrowthPolicy(QFormLayout::ExpandingFieldsGrow);
		{
			icon_ = new QToolButton(this);
			icon_->setText("...");
			icon_->setIconSize(QSize(24, 24));
			iconReset_ = new QToolButton(this);
			iconReset_->setText(tr("Reset"));
			connect(icon_, SIGNAL(clicked()), this, SLOT(loadIcon()));
			connect(iconReset_, SIGNAL(clicked()), this, SLOT(resetIcon()));
		
			QHBoxLayout* row = new QHBoxLayout;
			row->addWidget(icon_);
			row->addWidget(iconReset_);
			row->addStretch();
			form->addRow(tr("Icon"), row);
		}
		{
			noDescription_ = tr("<optional text>");
			description_ = new QLineEdit(this);
			description_->setText(noDescription_);
			form->addRow(tr("Description"), description_);
		}
		{
			modifier_ = new QComboBox(this);
			modifier_->addItem(tr("None"));
			modifier_->addItem(tr("Alt"), Qt::Key_Alt);
			modifier_->addItem(tr("Control"), Qt::Key_Control);
			modifier_->addItem(tr("Meta"), Qt::Key_Meta);
			keyGroup_ = new QComboBox(this);
			keyGroup_->addItem(tr("F1-F12"));
			keyGroup_->addItem(tr("0-9"));
			key_ = new QComboBox(this);
			connect(keyGroup_, SIGNAL(currentIndexChanged(int)), this, SLOT(updateKey(int)));
			updateKey(0);
			
			QHBoxLayout* row = new QHBoxLayout;
			row->addWidget(modifier_);
			row->addWidget(keyGroup_);
			row->addWidget(key_);
			row->addStretch();
			form->addRow(tr("Short key"), row);
		}
		{
			scriptLabel_ = new QLabel(tr("Script"), this);
			target_ = new QComboBox(this);
			target_->addItem(tr("Paste into current terminal"), QxCommand::ActiveTerminal);
			target_->addItem(tr("Paste into new terminal"), QxCommand::NewTerminal);
			// target_->addItem(tr("Paste into editor"), QxCommand::TextEditor);
			target_->addItem(tr("Open by default application"), QxCommand::WebBrowser);
			connect(target_, SIGNAL(currentIndexChanged(int)), this, SLOT(updateTarget(int)));
			QHBoxLayout* row = new QHBoxLayout;
			row->addWidget(target_);
			row->addStretch();
			form->addRow(scriptLabel_, row);
		}
		{
			autoSaveFile_ = new QCheckBox(tr("Automatically save current file"), this);
			autoOpenNextLink_ = new QCheckBox(tr("Automatically open next link"), this);
			QVBoxLayout* col = new QVBoxLayout();
			col->addWidget(autoSaveFile_);
			col->addWidget(autoOpenNextLink_);
			form->addRow(tr("Options"), col);
		}
		col->addLayout(form);
	}
	{
		QFrame* frame = new QFrame(this);
		frame->setFrameStyle(QFrame::Sunken|QFrame::StyledPanel);
		
		script_ = new EditWidget(frame);
		script_->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
		
		QHBoxLayout* cell = new QHBoxLayout;
		cell->setSpacing(0);
		cell->setMargin(0);
		cell->addWidget(script_);
		frame->setLayout(cell);
		
		QMenu* editMenu = script_->edit()->contextMenu();
		editMenu->addSeparator();
		QMenu* substMenu = editMenu->addMenu(tr("Insert $SUBST"));
		const char* substNames[] = {
			"$DIRPATH", "$DIRNAME",
			"$FILEPATH", "$FILENAME", "$FILEID", "$FILEEXT",
			"$TEXT", "$WORD", "$CURSOR_LINE", "$CURSOR_COLUMN", "$OFFSET"
		};
		for (int i = 0, n = sizeof(substNames) / sizeof(const char*); i < n; ++i)
			substMenu->addAction(substNames[i]);
		connect(substMenu, SIGNAL(triggered(QAction*)), this, SLOT(substTriggered(QAction*)));
		
		col->addWidget(frame);
	}
	{
		QDialogButtonBox* box = new QDialogButtonBox(
			QDialogButtonBox::Ok | QDialogButtonBox::Cancel
		);
		connect(box, SIGNAL(accepted()), this, SLOT(accept()));
		connect(box, SIGNAL(rejected()), this, SLOT(reject()));
		col->addWidget(box);
	}
	setLayout(col);
	
	// design HACK
	resize(parent->size() * 1.2);
	
	connect(this, SIGNAL(accepted()), this, SLOT(updateCommand()));
}