コード例 #1
0
ファイル: gmailnotifier.cpp プロジェクト: Kalarel/leechcraft
	void GmailNotifier::sendMeNotification (const QString& title, const QString& msg, int num)
	{
		if (msg == LastMsg_)
			return;

		if (num && XmlSettingsManager::Instance ()->property ("ShowUnreadNumInTray").toBool ())
		{
			CheckCreateAction ();

			NotifierAction_->setText (tr ("%n new message(s)", 0, num));
			NotifierAction_->setToolTip (msg);

			auto font = qApp->font ();
			font.setBold (true);
			font.setItalic (true);

			const QIcon srcIcon (":/gmailnotifier/gmailicon.svg");
			QIcon result;
			for (auto sz : { 16, 22, 32, 48, 64, 96, 128, 192 })
			{
				const auto& px = srcIcon.pixmap (sz, sz);
				result.addPixmap (Util::DrawOverlayText (px, QString::number (num), font, QPen (Qt::black)));
			}
			NotifierAction_->setIcon (result);
		}

		LastMsg_ = msg;
		emit gotEntity (Util::MakeNotification (title, msg, PInfo_));
	}
コード例 #2
0
ファイル: kateattribute.cpp プロジェクト: Fat-Zer/tdelibs
KateAttribute& KateAttribute::operator+=(const KateAttribute& a)
{
  if (a.itemSet(Weight))
    setWeight(a.weight());

  if (a.itemSet(Italic))
    setItalic(a.italic());

  if (a.itemSet(Underline))
    setUnderline(a.underline());

  if (a.itemSet(Overline))
    setOverline(a.overline());

  if (a.itemSet(StrikeOut))
    setStrikeOut(a.strikeOut());

  if (a.itemSet(Outline))
    setOutline(a.outline());

  if (a.itemSet(TextColor))
    setTextColor(a.textColor());

  if (a.itemSet(SelectedTextColor))
    setSelectedTextColor(a.selectedTextColor());

  if (a.itemSet(BGColor))
    setBGColor(a.bgColor());

  if (a.itemSet(SelectedBGColor))
    setSelectedBGColor(a.selectedBGColor());

  return *this;
}
コード例 #3
0
ファイル: format.cpp プロジェクト: tazio/QtTail
Format::Format (QTextCharFormat tcf, QObject* parent):QObject (parent)
{
	setBackground( tcf.background().color() );
	setForeground( tcf.foreground().color() );
	setBold( tcf.fontWeight() >= QFont::Bold );
	setItalic( tcf.fontItalic() );
	setPoints ( tcf.fontPointSize() );
}
コード例 #4
0
QFont PluginListWidgetItemDelegate::subtitleFont(const QFont &baseFont) const
{
	auto retFont = baseFont;
	retFont.setItalic(true);
	retFont.setPointSize(baseFont.pointSize()-2);

	return retFont;
}
コード例 #5
0
ファイル: shapesidebar.cpp プロジェクト: h2so5/PaintField
void ShapeSideBar::onFontItalicChanged(bool italic)
{
	if (d->textLayer)
	{
		auto font = d->textLayer->font();
		font.setItalic(italic);
		layerScene()->setLayerProperty(d->textLayer, font, RoleFont, tr("Change Font Italic"));
	}
}
コード例 #6
0
ファイル: rzxtextedit.cpp プロジェクト: Fruneau/qRezix
void RzxTextEdit::setFormat(const Format& format)
{
	setFont(format.family);
	setSize(format.size);
	setBold(format.bold);
	setItalic(format.italic);
	setUnderline(format.underlined);
	setColor(format.color);
}
コード例 #7
0
void SignalListPresenter::OnDomainChanged(const Signal& newDomain)
{
	auto items = signalList->findItems(newDomain.name, Qt::MatchExactly);
	auto oldFont = items.at(0)->font();
	if (domain)
	{
		domain->setFont(oldFont);	
	}
	oldFont.setBold(true);
	oldFont.setItalic(true);
	items.at(0)->setFont(oldFont);
	domain = items.at(0);
}
コード例 #8
0
JFont::JFont(int face, int style, int size)
  : QFont(), metrics(*this)
{
  int qfont_size;
  QString qfont_family;
  switch (size)
  {
    case SIZE_SMALL:
      qfont_size = QFONT_SIZE_SMALL;
      break;
      
    default:
    case SIZE_MEDIUM:
      qfont_size = QFONT_SIZE_MEDIUM;
      break;
      
    case SIZE_LARGE:
      qfont_size = QFONT_SIZE_LARGE;
      break;
  }
  setPointSize(qfont_size);
  
  switch (face)
  {
    case FACE_SYSTEM:
      qfont_family = QFONT_FAMILY_SYSTEM;
      break;
    
    default:
    case FACE_PROPORTIONAL:
      qfont_family = QFONT_FAMILY_PROPORTIONAL;
      break;
      
    case FACE_MONOSPACE:
      qfont_family = QFONT_FAMILY_MONOSPACE;
      break;
  }
  setFamily(qfont_family);

  if (style & STYLE_BOLD)
    setBold(true);
  if (style & STYLE_ITALIC)
    setItalic(true);
  if (style & STYLE_UNDERLINED)
    setUnderline(true);
  
  metrics = QFontMetrics(*this, JApplication::desktop()->screen());
  
  id = attrs2id(face, style, size);
  cache[id] = this;
}
コード例 #9
0
int FontDisplay::qt_metacall(QMetaObject::Call _c, int _id, void **_a)
{
    _id = QLabel::qt_metacall(_c, _id, _a);
    if (_id < 0)
        return _id;
    if (_c == QMetaObject::InvokeMetaMethod) {
        switch (_id) {
        case 0: setText(*(QString*)_a[1]); break;
        case 1: setBold(*(bool*)_a[1]); break;
        case 2: setItalic(*(bool*)_a[1]); break;
        case 3: setPointSize(*(int*)_a[1]); break;
        }
        _id -= 4;
    }
    return _id;
}
コード例 #10
0
ファイル: proxy-combo-box.cpp プロジェクト: vogel/kadu
void ProxyComboBox::init()
{
    addBeforeAction(make_owned<QAction>(tr(" - No proxy - "), this));

    auto chain = make_owned<ModelChain>(this);
    m_model = m_injectedFactory->makeOwned<NetworkProxyModel>(chain);
    chain->setBaseModel(m_model);
    chain->addProxyModel(make_owned<NetworkProxyProxyModel>(this));
    setUpModel(NetworkProxyRole, chain);

    m_editProxyAction = make_owned<QAction>(tr("Edit proxy configuration..."), this);
    auto editProxyActionFont = m_editProxyAction->font();
    editProxyActionFont.setItalic(true);
    m_editProxyAction->setFont(editProxyActionFont);
    m_editProxyAction->setData(true);
    connect(m_editProxyAction, SIGNAL(triggered()), this, SLOT(editProxy()));

    addAfterAction(m_editProxyAction);
}
コード例 #11
0
void FontDescription::setTraitsMask(FontTraitsMask traitsMask)
{
    switch (traitsMask & FontWeightMask) {
    case FontWeight100Mask:
        setWeight(FontWeight100);
        break;
    case FontWeight200Mask:
        setWeight(FontWeight200);
        break;
    case FontWeight300Mask:
        setWeight(FontWeight300);
        break;
    case FontWeight400Mask:
        setWeight(FontWeight400);
        break;
    case FontWeight500Mask:
        setWeight(FontWeight500);
        break;
    case FontWeight600Mask:
        setWeight(FontWeight600);
        break;
    case FontWeight700Mask:
        setWeight(FontWeight700);
        break;
    case FontWeight800Mask:
        setWeight(FontWeight800);
        break;
    case FontWeight900Mask:
        setWeight(FontWeight900);
        break;
    default:
        ASSERT_NOT_REACHED();
    }
    setItalic((traitsMask & FontStyleItalicMask) ? FontItalicOn : FontItalicOff);
    setSmallCaps((traitsMask & FontVariantSmallCapsMask) ? FontSmallCapsOn : FontSmallCapsOff);
}
コード例 #12
0
ファイル: RichEdit.cpp プロジェクト: mmuszkow/wtwUpdate
	void RichEdit::addHtml(const wchar_t* html) {
		size_t i = 0, j, len = wcslen(html);
		FastStrBuff tmp;
		bool insideTag = false;

		while(i < len) {
			switch(html[i]) {
			case L'\r':
			case L'\n':
				break;
			case L'<':
				if(tmp.size() > 0) {
					addText(tmp.c_str());
					tmp.clear();
				}
				insideTag = true;
				break;
			case L'>':
				insideTag = false;
				if(tmp.equalIC(L"b"))
					setBold(true);
				else if(tmp.equalIC(L"/b"))
					setBold(false);
				else if(tmp.equalIC(L"i"))
					setItalic(true);
				else if(tmp.equalIC(L"/i"))
					setItalic(false);
				else if(tmp.equalIC(L"u"))
					setUnderline(true);
				else if(tmp.equalIC(L"/u"))
					setUnderline(false);
				else if(tmp.equalIC(L"br") || tmp.equalIC(L"br/") || tmp.equalIC(L"br /")) {
					addText(L"\r\n");
					setFontColor(_defaultCf.crTextColor);
				}
				else if(tmp.size() > 4) {
					std::wstring tag = tmp.firstChars(3);
					if(tag == L"img" || tag == L"IMG")
						handleImg(tmp.c_str());
				}
				tmp.clear();
				break;
			case L'&':
				if(insideTag) {
					tmp.push_back(html[i]); // it's tag, don't care
					break;
				}
				if(len > i + 3) {
					// &lt;
					if(html[i+1] == L'l' && html[i+2] == L't' && html[i+3] == L';')	{
						addText(tmp.c_str());
						tmp.clear();
						addText(L"<");
						i += 3;
						break;
					}
					// &gt;
					else if(html[i+1] == L'g' && html[i+2] == L't' && html[i+3] == L';') {
						addText(tmp.c_str());
						tmp.clear();
						addText(L">");
						i += 3;
						break;
					}
				}
				if(len > i + 4) {
					// &amp;
					if(html[i+1] == L'a' && html[i+2] == L'm' && html[i+3] == L'p' && html[i+4] == L';') {
						addText(tmp.c_str());
						tmp.clear();
						addText(L"&");
						i += 4;
						break;
					}
				}
				if(len > i + 5) {
					// &quot;
					if(html[i+1] == L'q' && html[i+2] == L'u' && html[i+3] == L'o' && html[i+4] == L't' && html[i+5] == L';') {
						addText(tmp.c_str());
						tmp.clear();
						addText(L"\"");
						i += 5;
						break;
					} 
					// &nbsp;
					else if(html[i+1] == L'n' && html[i+2] == L'b' && html[i+3] == L's' && html[i+4] == L'p' && html[i+5] == L';') {
						addText(tmp.c_str());
						tmp.clear();
						addText(L" ");
						i += 5;
						break;
					}
					// &apos;
					else if(html[i+1] == L'a' && html[i+2] == L'p' && html[i+3] == L'o' && html[i+4] == L's' && html[i+5] == L';') {
						addText(tmp.c_str());
						tmp.clear();
						addText(L"'");
						i += 5;
						break;
					}
				}
				// &#xxxx;
				if(len > i + 6 && html[i+1] == L'#' && html[i+6] == L';') {
					wchar_t hex[4];
					bool valid = true;
					for(j=0; j<4; j++) {
						hex[j] = html[i+j+2];
						if(hex[j] < L'0' || hex[j] > L'9') {
							valid = false;
							break;
						}
						hex[j] -= 0x30;
					}
					addText(tmp.c_str());
					tmp.clear();
					if(valid) {
						wchar_t letter[2] = {0,0};
						letter[0] = hex[0]*1000 + hex[1]*100 + hex[2]*10 + hex[3];
						addText(letter);
					}
					i += 6;
					break;
				}
				tmp.push_back(html[i]); // if & not for special char
				break;
			default:
				tmp.push_back(html[i]);
			}
			i++;
		}
		if(tmp.size() > 0)
			addText(tmp.c_str());
	}
コード例 #13
0
ファイル: pn_item_base.cpp プロジェクト: towazumi/pn
#include "pn_item_base.h"

#include <QFont>
#include "pn_connection_node.h"

QFont PnItemBase::s_font = []{
    auto font = QFont("consolas");
    font.setBold(true);
    font.setItalic(true);
    return font;
}();


PnItemBase::PnItemBase(const QRectF& rect, QGraphicsItem* parent)
        : QGraphicsRectItem(rect, parent)
{
    setFlags(QGraphicsItem::ItemIsMovable | QGraphicsItem::ItemIsSelectable | QGraphicsItem::ItemSendsGeometryChanges);
}

QVariant PnItemBase::itemChange(QGraphicsItem::GraphicsItemChange change, const QVariant &value)
{
    if (change == QGraphicsItem::ItemPositionChange)
    {
        for( auto node : nodes() )
        {
            if( node )
            {
                node->updatePosition();
            }
        }
    }
コード例 #14
0
ファイル: notepadwin.cpp プロジェクト: hronus/razor-qt
NotepadWin::NotepadWin(Notepad *notepad, SaveFunctionPointer sv, QWidget *parent) : QWidget(parent)
{
    pad = notepad;
    saveText = sv;
    layout = new QVBoxLayout(this);
    layout->setContentsMargins(0, 0, 0, 0);
    setLayout(layout);
    edit = new QTextEdit();
    layout->addWidget(edit);
    connect(edit, SIGNAL(textChanged()), this, SLOT(textChanged()));
    panel = new QWidget();
    panel->setFixedHeight(25);
    layout->addWidget(edit);
	/*QFile file("/home/nay/.razor/desktop/notepad.qss");
    file.open(QFile::ReadOnly);
    QString styleSheet = QLatin1String(file.readAll());
	setStyleSheet(styleSheet);
	file.close();*/
    panelLayout = new QHBoxLayout();
    layout->addLayout(panelLayout);
    bold = new QToolButton();
    bold->setText(QString("B"));
    bold->setIcon(XdgIcon::fromTheme("format-text-bold"));

    italic = new QToolButton();
    italic->setText(QString("I"));
    italic->setIcon(XdgIcon::fromTheme("format-text-italic"));

    underline = new QToolButton();
    underline->setText(QString("U"));
    underline->setIcon(XdgIcon::fromTheme("format-text-underline"));

    strikethrough = new QToolButton();
    strikethrough->setText(QString("S"));
    strikethrough->setIcon(XdgIcon::fromTheme("format-text-strikethrough"));


    leftSided = new QToolButton();
    leftSided->setText(QString("L"));
    leftSided->setIcon(XdgIcon::fromTheme("format-justify-left"));


    centered = new QToolButton();
    centered->setText(QString("C"));
    centered->setIcon(XdgIcon::fromTheme("format-justify-center"));

    rightSided = new QToolButton();
    rightSided->setText(QString("R"));
    rightSided->setIcon(XdgIcon::fromTheme("format-justify-right"));

    justified = new QToolButton();
    justified->setText(QString("J"));
    justified->setIcon(XdgIcon::fromTheme("format-justify-fill"));


    int btnWidth = 21;
    bold->setCheckable(true);
    italic->setCheckable(true);
    underline->setCheckable(true);
    strikethrough->setCheckable(true);
    leftSided->setCheckable(true);
    centered->setCheckable(true);
    rightSided->setCheckable(true);
    justified->setCheckable(true);
    bold->setFixedWidth(btnWidth);
    italic->setFixedWidth(btnWidth);
    underline->setFixedWidth(btnWidth);
    strikethrough->setFixedWidth(btnWidth);
    leftSided->setFixedWidth(btnWidth);
    centered->setFixedWidth(btnWidth);
    rightSided->setFixedWidth(btnWidth);
    justified->setFixedWidth(btnWidth);
    bold->setObjectName(QString("boldButton"));
    italic->setObjectName(QString("italicButton"));
    underline->setObjectName(QString("underlineButton"));
    strikethrough->setObjectName(QString("strikethroughButton"));
    leftSided->setObjectName(QString("leftSided"));
    centered->setObjectName(QString("centered"));
    rightSided->setObjectName(QString("rightSided"));
    justified->setObjectName(QString("justified"));
    
    panelLayout->addWidget(bold);
    panelLayout->addWidget(italic);
    panelLayout->addWidget(underline);
    panelLayout->addWidget(strikethrough);
    
    panelLayout->setSpacing(0);
    panelLayout->addWidget(leftSided);
    panelLayout->addWidget(centered);
    panelLayout->addWidget(rightSided);
    panelLayout->addWidget(justified);
    layout->setAlignment(panelLayout, Qt::AlignLeft);
    connect(bold, SIGNAL(clicked()), this, SLOT(setBold()));
    connect(italic, SIGNAL(clicked()), this, SLOT(setItalic()));
    connect(underline, SIGNAL(clicked()), this, SLOT(setUnderline()));
    connect(strikethrough, SIGNAL(clicked()), this, SLOT(setStrike()));

    connect(leftSided, SIGNAL(clicked()), this, SLOT(setLeftSided()));
    connect(centered, SIGNAL(clicked()), this, SLOT(setCentered()));
    connect(rightSided, SIGNAL(clicked()), this, SLOT(setRightSided()));
    connect(justified, SIGNAL(clicked()), this, SLOT(setJustified()));

    connect(edit, SIGNAL(selectionChanged()), this, SLOT(onSelectionChanged()));
    connect(edit, SIGNAL(cursorPositionChanged()), this, SLOT(onSelectionChanged()));
}
コード例 #15
0
ファイル: mainwindow.cpp プロジェクト: sherifff/TextEditor
MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::MainWindow)
{
    ui->setupUi(this);
//    QString s = QString::number(colors[1][0]);
//    ui->textEdit->append(s);
//    colors = new int*[12];
//    for(int i = 0; i < 12; ++i){
//        colors[i] = new int[3];
//    }
    connect(ui->italic,SIGNAL(clicked()),this,SLOT(setItalic()));
    connect(ui->underline,SIGNAL(clicked()),this,SLOT(setUnderline()));
    connect(ui->bold,SIGNAL(clicked()),this,SLOT(setBold()));
    connect(ui->sizebox,SIGNAL(currentIndexChanged(int)),this,SLOT(setSize(int)));
    connect(ui->alignLeft,SIGNAL(clicked()),this,SLOT(setAlignLeft()));
    connect(ui->alignCenter,SIGNAL(clicked()),this,SLOT(setAlignCenter()));
    connect(ui->alignRight,SIGNAL(clicked()),this,SLOT(setAlignRight()));
    connect(ui->justify,SIGNAL(clicked()),this,SLOT(setJustify()));
   // connect(ui->foregroundCombo,SIGNAL(clicked()),this,SLOT(colorHandle()));
    //connect(ui->backColorChooser,SIGNAL(clicked()),this,SLOT(backColorHandle()));
    connect(ui->fontComboBox,SIGNAL(currentFontChanged(QFont)),this,SLOT(setFont(QFont)));
    connect(ui->menuEdit,SIGNAL(triggered()),this,SLOT(enablePasteee()));
    connect(ui->menuEdit,SIGNAL(clicked()),this,SLOT(enablePasteee()));
    connect(ui->menuEdit,SIGNAL(hovered()),this,SLOT(enablePasteee()));
    connect(ui->actionUndo,SIGNAL(triggered()),this,SLOT(undo()));
    connect(ui->actionREdo,SIGNAL(triggered()),this,SLOT(redo()));
    connect(ui->actionCopy,SIGNAL(triggered()),this,SLOT(copy()));
    connect(ui->actionCut,SIGNAL(triggered()),this,SLOT(cut()));
    connect(ui->actionPaste_2,SIGNAL(triggered()),this,SLOT(paste()));
    connect(ui->actionLoad,SIGNAL(triggered()),this,SLOT(load()));
    connect(ui->actionSave,SIGNAL(triggered()),this,SLOT(save()));
    connect(ui->actionSelectAll,SIGNAL(triggered()),this,SLOT(selectAll()));
    connect(ui->actionExit,SIGNAL(triggered()),this,SLOT(exit()));
    QIcon *i0 = new QIcon(":/new/colors/0.png");
    QIcon *i1 = new QIcon(":/new/colors/1.png");
    QIcon *i2 = new QIcon(":/new/colors/2.png");
    QIcon *i3 = new QIcon(":/new/colors/3.png");
    QIcon *i4 = new QIcon(":/new/colors/4.png");
    QIcon *i5 = new QIcon(":/new/colors/5.png");
    QIcon *i6 = new QIcon(":/new/colors/6.png");
    QIcon *i7 = new QIcon(":/new/colors/7.png");
    QIcon *i8 = new QIcon(":/new/colors/8.png");
    QIcon *i9 = new QIcon(":/new/colors/9.png");
    QIcon *i10 = new QIcon(":/new/colors/10.png");
    QIcon *i11 = new QIcon(":/new/colors/11.png");
    QIcon *i12 = new QIcon(":/new/colors/12.png");
    QIcon *i13 = new QIcon(":/new/colors/13.png");
    QIcon *i14 = new QIcon(":/new/colors/14.png");
    QIcon *i15 = new QIcon(":/new/colors/15.png");
    QIcon *i16 = new QIcon(":/new/colors/16.png");
    ui->foregroundCombo->setItemIcon(0,*i0);
    ui->foregroundCombo->setItemIcon(1,*i1);
    ui->foregroundCombo->setItemIcon(2,*i2);
    ui->foregroundCombo->setItemIcon(3,*i3);
    ui->foregroundCombo->setItemIcon(4,*i4);
    ui->foregroundCombo->setItemIcon(5,*i5);
    ui->foregroundCombo->setItemIcon(6,*i6);
    ui->foregroundCombo->setItemIcon(7,*i7);
    ui->foregroundCombo->setItemIcon(8,*i8);
    ui->foregroundCombo->setItemIcon(9,*i9);
    ui->foregroundCombo->setItemIcon(10,*i10);
    ui->foregroundCombo->setItemIcon(11,*i11);
    ui->foregroundCombo->setItemIcon(12,*i12);
    ui->foregroundCombo->setItemIcon(13,*i13);
    ui->foregroundCombo->setItemIcon(14,*i14);
    ui->foregroundCombo->setItemIcon(15,*i15);
    ui->foregroundCombo->setItemIcon(16,*i16);
    //----------------------------------------------------
            ui->backgroundCombo->setItemIcon(0,*i16);
            ui->backgroundCombo->setItemIcon(1,*i0);
            ui->backgroundCombo->setItemIcon(2,*i1);
            ui->backgroundCombo->setItemIcon(3,*i2);
            ui->backgroundCombo->setItemIcon(4,*i3);
            ui->backgroundCombo->setItemIcon(5,*i4);
            ui->backgroundCombo->setItemIcon(6,*i5);
            ui->backgroundCombo->setItemIcon(7,*i6);
            ui->backgroundCombo->setItemIcon(8,*i7);
            ui->backgroundCombo->setItemIcon(9,*i8);
            ui->backgroundCombo->setItemIcon(10,*i9);
            ui->backgroundCombo->setItemIcon(11,*i10);
            ui->backgroundCombo->setItemIcon(12,*i11);
            ui->backgroundCombo->setItemIcon(13,*i12);
            ui->backgroundCombo->setItemIcon(14,*i13);
            ui->backgroundCombo->setItemIcon(15,*i14);
            ui->backgroundCombo->setItemIcon(16,*i15);

//    QPixmap pixmap3(":/Editing-Align-Left-icon.png");
//    QIcon leftIcon(pixmap3);
//    ui->alignLeft->setIcon(leftIcon);
//    ui->alignLeft->setIconSize(QSize(25,25));

    saved = false;
    foregroundColor=Qt::black;
    backgroundColor=Qt::white;
    QIcon *if0 = new QIcon(":/new/colors/0f.png");
    QIcon *ib0 = new QIcon(":/new/colors/16b.png");

    ui->forecolor->setIcon(*if0);
    ui->backcolor->setIcon(*ib0);
    fileName ="";
}
コード例 #16
0
ファイル: window.cpp プロジェクト: romcsmv/Rasp
Window::Window(QWidget *parent)
    : QMainWindow(parent)
    , ui(new Ui::Window)
    , calc_thread(new QThread(this))
    , calculator(new Calculator())
{
    calculator->moveToThread(calc_thread);
    calc_thread->start();

    ui->setupUi(this);

    {
        auto font = ui->plot->font();
        font.setPointSize(18);
        ui->plot->setFont(font);
        ui->plot->xAxis->setTickLabelFont(font);
        ui->plot->yAxis->setTickLabelFont(font);
        ui->plot->yAxis2->setTickLabelFont(font);
        font.setItalic(true);
        ui->plot->xAxis->setLabelFont(font);
        ui->plot->yAxis->setLabelFont(font);
        ui->plot->yAxis2->setLabelFont(font);
    }
    ui->plot->addGraph();
    ui->plot->addGraph(ui->plot->xAxis, ui->plot->yAxis2);
    ui->plot->yAxis2->setVisible(true);
    ui->plot->xAxis->setLabel("t");
    ui->plot->yAxis->setLabel("U");
    ui->plot->yAxis2->setLabel("I");
    connect(ui->plot->yAxis, static_cast<void(QCPAxis::*)(const QCPRange &, const QCPRange &)>(&QCPAxis::rangeChanged),  [this] (const QCPRange &newRange, const QCPRange &oldRange)
    {
        double scale_coef = ui->plot->yAxis2->range().size() / oldRange.size();

        double d_size = newRange.size() / oldRange.size();
        double d_center = (newRange.center() - oldRange.center()) * scale_coef;

        double new_size = ui->plot->yAxis2->range().size() * d_size;
        double new_center = ui->plot->yAxis2->range().center() + d_center;

        ui->plot->yAxis2->setRange(new_center - new_size/2, new_center + new_size/2);
    });

    for (int i=2; i < 5; i++)
    {
        ui->plot->addGraph();
    }
    ui->plot->addGraph(ui->plot->xAxis, ui->plot->yAxis2);

    ui->plot->graph(1)->setPen(QPen(QColor("blue")));
    ui->plot->graph(1)->setPen(QPen(QColor("red")));
    ui->plot->xAxis->setAutoTickCount(ui->x_axis_density->value());

    ui->plot->graph(2)->setPen(QPen(QColor("green")));
    ui->plot->graph(3)->setPen(QPen(QColor("green")));

    ui->plot->graph(4)->setPen(QPen(QBrush(QColor("lime")), 2));
    ui->plot->graph(5)->setPen(QPen(QBrush(QColor("orange")), 2));

    ui->plot->setInteraction(QCP::iRangeDrag);
    ui->plot->setInteraction(QCP::iRangeZoom);

    connect(this, SIGNAL(beginCalc()), calculator, SLOT(start()));
    connect(calculator, SIGNAL(progress(int,int)), this, SLOT(onProgress(int,int)));
    connect(calculator, SIGNAL(done()), this, SLOT(onDone()));
    connect(ui->btnRescale, SIGNAL(released()), this, SLOT(rescale()));
    connect(ui->allow_save_to_file, &QCheckBox::toggled, ui->output_filename, &QLineEdit::setEnabled);
    connect(ui->allow_save_to_file, &QCheckBox::toggled, calculator, &Calculator::setAllowOutToFile);

    connect(ui->slider_double, &DoubleSlider::valueChanged, this, &Window::onDoubleSliderMoved);
    connect(ui->slider_double, &DoubleSlider::altValueChanged, this, &Window::onDoubleSliderAltMoved);

    connect(ui->chck_dispersion_select, &QCheckBox::toggled, this, [this] (bool checked) {
        ui->chck_range_select->blockSignals(true);
        ui->chck_range_select->setChecked(false);
        ui->chck_range_select->blockSignals(false);

        if (checked)
        {
            select_from = ui->spin_dispersion_from;
            select_to = ui->spin_dispersion_to;
            ui->slider_double->show();
        }
        else
        {
            ui->slider_double->hide();
        }
    });

    connect(ui->chck_range_select, &QCheckBox::toggled, this, [this] (bool checked) {
        ui->chck_dispersion_select->blockSignals(true);
        ui->chck_dispersion_select->setChecked(false);
        ui->chck_dispersion_select->blockSignals(false);

        if (checked)
        {
            select_from = ui->spin_from;
            select_to = ui->spin_to;
            ui->slider_double->show();
        }
        else
        {
            ui->slider_double->hide();
        }
    });

    ui->chck_dispersion_select->setChecked(true);

    ui->allow_save_to_file->setChecked(false);
    ui->btnRescale->setIcon(qApp->style()->standardIcon(QStyle::SP_BrowserReload));
    ui->progressBar->hide();
}
コード例 #17
0
void *TextEdit::processEvent(Event *e)
{
    if (m_param == NULL)
        return NULL;
    if (e->type() == EventCheckState){
        CommandDef *cmd = (CommandDef*)(e->param());
        if (cmd->param != m_param)
            return NULL;
        switch (cmd->id){
        case CmdBgColor:
        case CmdFgColor:
        case CmdBold:
        case CmdItalic:
        case CmdUnderline:
        case CmdFont:
            if ((textFormat() == RichText) && !isReadOnly()){
                cmd->flags &= ~BTN_HIDE;
            }else{
                cmd->flags |= BTN_HIDE;
            }
            return e->param();
        default:
            return NULL;
        }
    }
    if (e->type() == EventCommandExec){
        CommandDef *cmd = (CommandDef*)(e->param());
        if (cmd->param != m_param)
            return NULL;
        switch (cmd->id){
        case CmdBgColor:{
                Event eWidget(EventCommandWidget, cmd);
                CToolButton *btnBg = (CToolButton*)(eWidget.process());
                if (btnBg){
                    ColorPopup *popup = new ColorPopup(this, background());
                    popup->move(CToolButton::popupPos(btnBg, popup));
                    connect(popup, SIGNAL(colorChanged(QColor)), this, SLOT(bgColorChanged(QColor)));
                    popup->show();
                }
                return e->param();
            }
        case CmdFgColor:{
                Event eWidget(EventCommandWidget, cmd);
                CToolButton *btnFg = (CToolButton*)(eWidget.process());
                if (btnFg){
                    ColorPopup *popup = new ColorPopup(this, foreground());
                    popup->move(CToolButton::popupPos(btnFg, popup));
                    connect(popup, SIGNAL(colorChanged(QColor)), this, SLOT(fgColorChanged(QColor)));
                    popup->show();
                }
                return e->param();
            }
        case CmdBold:
            m_bSelected = true;
            setBold((cmd->flags & COMMAND_CHECKED) != 0);
            return e->param();
        case CmdItalic:
            m_bSelected = true;
            setItalic((cmd->flags & COMMAND_CHECKED) != 0);
            return e->param();
        case CmdUnderline:
            m_bSelected = true;
            setUnderline((cmd->flags & COMMAND_CHECKED) != 0);
            return e->param();
        case CmdFont:{
#ifdef USE_KDE
                QFont f = font();
                if (KFontDialog::getFont(f, false, topLevelWidget()) != KFontDialog::Accepted)
                    break;
#else
                bool ok = false;
                QFont f = QFontDialog::getFont(&ok, font(), topLevelWidget());
                if (!ok)
                    break;
#endif
                m_bSelected = true;
                setCurrentFont(f);
                break;
            }
        default:
            return NULL;
        }
    }
    return NULL;
}
コード例 #18
0
ファイル: editor.cpp プロジェクト: amitch/tuxcards
// -------------------------------------------------------------------------------
void Editor::keyPressEvent( QKeyEvent* pKeyEv )
// -------------------------------------------------------------------------------
{
   if ( !pKeyEv )
      return;

   //std::cout<<"key = "<<pKeyEv->key();

   // If
   //   CTRL + S (save)  or
   //   ALT + left  cursor (history one back / previous entry) or
   //   ALT + right cursor (history one forward / next entry)
   //   CTRL + F (shortcut for "Searching")
   // is called, then ignore it.
   if( ( (pKeyEv->state() == Qt::ControlButton)  &&  (pKeyEv->key() == Qt::Key_S) ) ||
       ( (pKeyEv->state() == Qt::AltButton)      &&  (pKeyEv->key() == Qt::Key_Left) ) ||
       ( (pKeyEv->state() == Qt::AltButton)      &&  (pKeyEv->key() == Qt::Key_Right) ) ||
       ( (pKeyEv->state() == Qt::ControlButton)  &&  (pKeyEv->key() == Qt::Key_F) ) )
   {
      //std::cout<<" -> ignore"<<std::endl;
      pKeyEv->ignore();
   }
/*

   // if the shift button is down while pressing return or enter, insert a new paragraph
   else if  ( ( (pKeyEv->state() == Qt::ShiftButton ) || (pKeyEv->state() == Qt::ControlButton ) )
              &&
              ( (Qt::Key_Return == pKeyEv->key()) || (Qt::Key_Enter == pKeyEv->key()) )
            )
   {
      if ( LINEBREAK_MODERN == meLinebreakMode )
      {
         //std::cout<<" -> shift/ctrl + enter/return"<<std::endl;
         Q3TextEdit::keyPressEvent( new QKeyEvent( pKeyEv->type(),  Qt::Key_Return,
                                                  pKeyEv->ascii(), 0 ) );
      }
      else
      {
         Q3TextEdit::keyPressEvent( pKeyEv );
      }
   }
*/
   // Workaround Q3TextEdit's default Enter key behavior of adding a paragraph
   // Add control key pressed to it
   else if  ( (Qt::Key_Return == pKeyEv->key()) || (Qt::Key_Enter == pKeyEv->key()) )
   {
         Q3TextEdit::keyPressEvent( new QKeyEvent( pKeyEv->type(),  Qt::Key_Return,
                                                  pKeyEv->ascii(), Qt::ControlButton ) );
   }

   // CTRL + A -> select all
   else if ( (Qt::ControlButton == pKeyEv->state()) && (Qt::Key_A == pKeyEv->key()) )
   {
      selectAll();
   }

   // CTRL + B -> bold
   else if ( (Qt::ControlButton == pKeyEv->state()) && (Qt::Key_B == pKeyEv->key()) )
   {
      if ( Qt::RichText == textFormat() )
         setBold( !bold() );
   }

   // CTRL + I -> italic
   else if ( (Qt::ControlButton == pKeyEv->state()) && (Qt::Key_I == pKeyEv->key()) )
   {
      if ( Qt::RichText == textFormat() )
         setItalic( !italic() );
   }

   // CTRL + U -> underline
   else if ( (Qt::ControlButton == pKeyEv->state()) && (Qt::Key_U == pKeyEv->key()) )
   {
      if ( Qt::RichText == textFormat() )
         setUnderline( !underline() );
   }

   else
   {
      // otherwise call the super-method
      //std::cout<<std::endl;
      Q3TextEdit::keyPressEvent( pKeyEv );
   }
}