Ejemplo n.º 1
0
/**
 * Constructor
 * @param title :: The title
 * @param parent :: The parent widget
 * @param flags :: Window flags
 */
ScriptOutputDisplay::ScriptOutputDisplay(QWidget *parent)
    : QTextEdit(parent), m_copy(NULL), m_clear(NULL), m_save(NULL),
      m_origFontSize(8), m_zoomLevel(0) {
#ifdef __APPLE__
  // Make all fonts 4 points bigger on the Mac because otherwise they're tiny!
  m_zoomLevel += 4;
#endif

  // the control is readonly, but if you set it read only then ctrl+c for
  // copying does not work
  // this approach allows ctrl+c and disables user editing through the use of
  // the KeyPress handler
  // and disabling drag and drop
  // also the mouseMoveEventHandler prevents dragging out of the control
  // affecting the text.
  setReadOnly(false);
  this->setAcceptDrops(false);

  setLineWrapMode(QTextEdit::WidgetWidth);
  setLineWrapColumnOrWidth(105);
  setAutoFormatting(QTextEdit::AutoNone);
  // Change to fix width font so that table formatting isn't screwed up
  resetFont();

  setContextMenuPolicy(Qt::CustomContextMenu);
  connect(this, SIGNAL(customContextMenuRequested(const QPoint &)), this,
          SLOT(showContextMenu(const QPoint &)));

  initActions();
}
Ejemplo n.º 2
0
StatusBar::StatusBar()
{
    setFixedHeight(buttonSize());
    setSizeGripEnabled(false);

    my.timeButton = new QedTimeButton(this);
    my.timeButton->setFixedSize(QSize(buttonSize(), buttonSize()));
    my.timeButton->setWhatsThis(QApplication::translate("PmChart",
	"VCR state button, also used to display the time control window.",
	0, QApplication::UnicodeUTF8));
    my.timeFrame = new QToolButton(this);
    my.timeFrame->setMinimumSize(QSize(buttonSize(), buttonSize()));
    my.timeFrame->setSizePolicy(
			QSizePolicy::MinimumExpanding, QSizePolicy::Fixed);
    my.timeFrame->setWhatsThis(QApplication::translate("PmChart",
	"Unified time axis, displaying the current time position at the "
	"rightmost point, and either status information or the timeframe "
	"covering all Visible Points to the left",
	0, QApplication::UnicodeUTF8));

    delete layout();
    QHBoxLayout *box = new QHBoxLayout;
    box->setMargin(0);
    box->setSpacing(1);
    box->addWidget(my.timeButton);
    box->addWidget(my.timeFrame);
    setLayout(box);

    my.timeAxis = new TimeAxis(my.timeFrame);
    my.timeAxis->setFixedHeight(timeAxisHeight());
    my.gadgetLabel = new QLabel(my.timeFrame);
    my.gadgetLabel->hide();	// shown with gadget Tabs

    my.dateLabel = new QLabel(my.timeFrame);
    my.dateLabel->setIndent(8);
    my.dateLabel->setAlignment(Qt::AlignRight | Qt::AlignBottom);

    my.labelSpacer = new QSpacerItem(10, 0,
				QSizePolicy::Fixed, QSizePolicy::Minimum);
    my.rightSpacer = new QSpacerItem(0, 0,
				QSizePolicy::Fixed, QSizePolicy::Minimum);

    my.valueLabel = new QLabel(my.timeFrame);
    my.valueLabel->setIndent(8);
    my.valueLabel->setAlignment(Qt::AlignLeft | Qt::AlignBottom);

    my.grid = new QGridLayout;	// Grid of [5 x 3] cells
    my.grid->setMargin(0);
    my.grid->setSpacing(0);
    my.grid->addWidget(my.gadgetLabel, 0, 0, 1, 3);
    my.grid->addWidget(my.timeAxis, 0, 0, 1, 3);   // top two rows, all columns
    my.grid->addWidget(my.dateLabel, 2, 2, 1, 1);  // bottom row, last two cols
    my.grid->addItem(my.labelSpacer, 2, 1, 1, 1);  // bottom row, second column
    my.grid->addWidget(my.valueLabel, 2, 0, 1, 1); // bottom row, first column.
    my.grid->addItem(my.rightSpacer, 0, 4, 2, 1);  // all rows, in final column
    my.timeFrame->setLayout(my.grid);

    resetFont();
}
Ejemplo n.º 3
0
/**
 * Prepares the display for the next message
 * @param msgType :: One of the predefined message types
 */
void ScriptOutputDisplay::prepareForNewMessage(const MessageType msgType) {
  // Ensure the cursor is in the correct position. This affects the font
  // unfortunately
  moveCursor(QTextCursor::End);
  resetFont();
  // zoom(0);
  if (msgType == ScriptOutputDisplay::Error) {
    setTextColor(Qt::red);
  } else {
    setTextColor(Qt::black);
  }
}
Ejemplo n.º 4
0
NodeItem::NodeItem(QGraphicsItem* parent /* = nullptr */)
    : QGraphicsObject(parent)
    , m_emphasised(false)
{
    resetBackground();
    resetEmphasisBrush();
    resetBorderPen();
    resetSelectionPen();
    resetTextPen();
    resetFont();

    setFlag(QGraphicsItem::ItemIsMovable);
    setFlag(QGraphicsItem::ItemSendsScenePositionChanges);
    setFlag(QGraphicsItem::ItemIsSelectable);
    setPos(0, 0);
    setZValue(200.0f);
}
Ejemplo n.º 5
0
EdgeItem::EdgeItem(NodeItem* start /* = nullptr */,
                   NodeItem* end /* = nullptr */)
    : QGraphicsObject()
    , m_startNode(nullptr)
    , m_endNode(nullptr)
    , m_weight(0)
    , m_arrowhead(false)
    , m_emphasised(false)
{
    resetFont();
    resetEmphasisPen();

    setStartNode(start);
    setEndNode(end);
    setZValue(100.0f);

    setCacheMode(QGraphicsItem::NoCache);
    setAcceptedMouseButtons(Qt::NoButton);
    adjust();
}
Ejemplo n.º 6
0
void VCWidget::slotMenuCallback(int item)
{
	switch (item)
	{
	case KVCMenuEditCut:
		break;
	case KVCMenuEditCopy:
		break;
	case KVCMenuEditPaste:
		break;
	case KVCMenuEditDelete:
		scram();
		break;

	case KVCMenuEditRename:
		rename();
		break;

	case KVCMenuEditProperties:
		editProperties();
		break;

	case KVCMenuForegroundColor:
		chooseForegroundColor();
		break;

	case KVCMenuForegroundDefault:
		resetForegroundColor();
		break;

	case KVCMenuBackgroundColor:
		chooseBackgroundColor();
		break;
	
	case KVCMenuBackgroundImage:
		chooseBackgroundImage();
		break;
	
	case KVCMenuBackgroundDefault:
		resetBackgroundColor();
		break;

	case KVCMenuFont:
		chooseFont();
		break;

	case KVCMenuFontDefault:
		resetFont();
		break;

	case KVCMenuFrameSunken:
		setFrameStyle(KVCWidgetFrameStyleSunken);
		break;

	case KVCMenuFrameRaised:
		setFrameStyle(KVCWidgetFrameStyleRaised);
		break;

	case KVCMenuFrameNone:
		setFrameStyle(KVCWidgetFrameStyleNone);
		break;

	case KVCMenuStackingRaise:
		raise();
		break;

	case KVCMenuStackingLower:
		lower();
		break;

	default:
		break;
	}
}
Ejemplo n.º 7
0
ChatWidget::ChatWidget(QWidget *parent) :
	QWidget(parent), ui(new Ui::ChatWidget)
{
	ui->setupUi(this);

	newMessages = false;
	typing = false;
	peerStatus = 0;
	isChatLobby = false;
	firstShow = true;
	inChatCharFormatChanged = false;

	lastStatusSendTime = 0 ;

	connect(ui->sendButton, SIGNAL(clicked()), this, SLOT(sendChat()));
	connect(ui->addFileButton, SIGNAL(clicked()), this , SLOT(addExtraFile()));

	connect(ui->textboldButton, SIGNAL(clicked()), this, SLOT(setFont()));
	connect(ui->textunderlineButton, SIGNAL(clicked()), this, SLOT(setFont()));
	connect(ui->textitalicButton, SIGNAL(clicked()), this, SLOT(setFont()));
	connect(ui->attachPictureButton, SIGNAL(clicked()), this, SLOT(addExtraPicture()));
	connect(ui->colorButton, SIGNAL(clicked()), this, SLOT(chooseColor()));
	connect(ui->emoteiconButton, SIGNAL(clicked()), this, SLOT(smileyWidget()));
	connect(ui->actionSaveChatHistory, SIGNAL(triggered()), this, SLOT(fileSaveAs()));
	connect(ui->actionClearChatHistory, SIGNAL(triggered()), this, SLOT(clearChatHistory()));
	connect(ui->actionDeleteChatHistory, SIGNAL(triggered()), this, SLOT(deleteChatHistory()));
	connect(ui->actionMessageHistory, SIGNAL(triggered()), this, SLOT(messageHistory()));
	connect(ui->actionChooseFont, SIGNAL(triggered()), this, SLOT(chooseFont()));
	connect(ui->actionResetFont, SIGNAL(triggered()), this, SLOT(resetFont()));

	connect(ui->hashBox, SIGNAL(fileHashingFinished(QList<HashedFile>)), this, SLOT(fileHashingFinished(QList<HashedFile>)));

	connect(NotifyQt::getInstance(), SIGNAL(peerStatusChanged(const QString&, int)), this, SLOT(updateStatus(const QString&, int)));
	connect(NotifyQt::getInstance(), SIGNAL(peerHasNewCustomStateString(const QString&, const QString&)), this, SLOT(updatePeersCustomStateString(const QString&, const QString&)));

	connect(ui->textBrowser, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(contextMenuTextBrowser(QPoint)));

	connect(ui->chatTextEdit, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(contextMenu(QPoint)));
	// reset text and color after removing all characters from the QTextEdit and after calling QTextEdit::clear
	connect(ui->chatTextEdit, SIGNAL(currentCharFormatChanged(QTextCharFormat)), this, SLOT(chatCharFormatChanged()));

	ui->infoFrame->setVisible(false);
	ui->statusMessageLabel->hide();

	setAcceptDrops(true);
	ui->chatTextEdit->setAcceptDrops(false);
	ui->hashBox->setDropWidget(this);
	ui->hashBox->setAutoHide(true);

	QMenu *menu = new QMenu();
	menu->addAction(ui->actionChooseFont);
	menu->addAction(ui->actionResetFont);
	ui->fontButton->setMenu(menu);

	menu = new QMenu();
	menu->addAction(ui->actionClearChatHistory);
	menu->addAction(ui->actionDeleteChatHistory);
	menu->addAction(ui->actionSaveChatHistory);
	menu->addAction(ui->actionMessageHistory);
	ui->pushtoolsButton->setMenu(menu);

	ui->chatTextEdit->installEventFilter(this);

//#if QT_VERSION < 0x040700
	// embedded images are not supported before QT 4.7.0
	ui->attachPictureButton->setVisible(false);
//#endif

	resetStatusBar();
}
Ejemplo n.º 8
0
void AppEditMenu::setupMenu(QMenu *editMenu, QToolBar *toolbar)
{
    toolbar->addSeparator();

    editUndoAction=editMenu->addAction(IconUtil::getIcon("undo"), tr("&Undo"), this, SLOT(undo()), QKeySequence(QKeySequence::Undo));
    editUndoAction->setStatusTip(tr("Undo last edit action"));
    toolbar->addAction(editUndoAction);
    editRedoAction=editMenu->addAction(IconUtil::getIcon("redo"), tr("&Redo"), this, SLOT(redo()), QKeySequence(QKeySequence::Redo));
    editRedoAction->setStatusTip(tr("Redo last undone edit action"));
    toolbar->addAction(editRedoAction);

    editMenu->addSeparator();
    toolbar->addSeparator();

    editCutAction=editMenu->addAction(IconUtil::getIcon("editcut"), tr("Cu&t"), this, SLOT(cut()), QKeySequence(QKeySequence::Cut));
    editCutAction->setStatusTip(tr("Cut"));
    toolbar->addAction(editCutAction);
    editCopyAction=editMenu->addAction(IconUtil::getIcon("editcopy"), tr("&Copy"), this, SLOT(copy()), QKeySequence(QKeySequence::Copy));
    editCopyAction->setStatusTip(tr("Copy"));
    toolbar->addAction(editCopyAction);
    //editCopyAsAction=editMenu->addAction(IconUtil::getIcon("editcopy"), tr("Copy as"));
    //editCopyAsAction->setMenu(createCopyAsMenu(editMenu));
    editPasteAction=editMenu->addAction(IconUtil::getIcon("editpaste"), tr("&Paste"), this, SLOT(paste()), QKeySequence(QKeySequence::Paste));
    editPasteAction->setStatusTip(tr("Paste"));
    toolbar->addAction(editPasteAction);

    editMenu->addSeparator();

    editSelectAllAction=editMenu->addAction(IconUtil::getIcon("editselectall"), tr("Select &All"), this, SLOT(selectAll()), QKeySequence(QKeySequence::SelectAll));
    editSelectAllAction->setStatusTip(tr("Select All"));

    editMenu->addSeparator();
    toolbar->addSeparator();

    editAdvancedAction = editMenu->addAction(tr("Advanced"));
    createEditAdvancedMenu(toolbar);
    editAdvancedAction->setMenu(editAdvancedMenu);

    editMenu->addSeparator();

    editDescribeAction=editMenu->addAction(tr("Describe object"), this, SLOT(describeObject()), QKeySequence("F4"));

    editResolveAction=editMenu->addAction(tr("Object Menu"));
    createEditResolveMenu();
    editResolveAction->setMenu(editResolveMenu);

    editMenu->addSeparator();
    //toolbar->addSeparator();

    editIncreaseFontSize=editMenu->addAction(tr("Increase font size"), this, SLOT(increaseFont()), QKeySequence(QKeySequence::ZoomIn));
    editIncreaseFontSize->setStatusTip(tr("Increase font size"));

    editDecreaseFontSize=editMenu->addAction(tr("Decrease font size"), this, SLOT(decreaseFont()), QKeySequence(QKeySequence::ZoomOut));
    editDecreaseFontSize->setStatusTip(tr("Decrease font size"));

    editResetFontSize=editMenu->addAction(tr("Reset font size"), this, SLOT(resetFont()), QKeySequence(tr("Ctrl+0", "Edit|Reset font size")));
    editResetFontSize->setStatusTip(tr("Reset font size"));

    editMenu->addSeparator();
    toolbar->addSeparator();

    editFindAction=editMenu->addAction(IconUtil::getIcon("find"), tr("&Find..."), this, SLOT(showSearchWidget()), QKeySequence("Ctrl+F"));
    editFindAction->setStatusTip(tr("Find text"));
    toolbar->addAction(editFindAction);
    editFindPreviousAction=editMenu->addAction(IconUtil::getIcon("find_prev"), tr("Find p&revious"), this, SLOT(findPrevious()), QKeySequence("Shift+F3"));
    editFindPreviousAction->setStatusTip(tr("Find previous occurence of current search text"));
    toolbar->addAction(editFindPreviousAction);
    editFindNextAction=editMenu->addAction(IconUtil::getIcon("find_next"), tr("Find &next"), this, SLOT(findNext()), QKeySequence("F3"));
    editFindNextAction->setStatusTip(tr("Find next occurence of current search text"));
    toolbar->addAction(editFindNextAction);

    editMenu->addSeparator();

    editGoToLineAction=editMenu->addAction(IconUtil::getIcon("goto_line"), tr("&Go to line..."), this, SLOT(goToLine()), QKeySequence("Ctrl+G"));
    editGoToLineAction->setStatusTip(tr("Go to line"));


    connect(editResolveMenu, SIGNAL(aboutToShow()), this, SLOT(populateResolveMenu()));
}
Ejemplo n.º 9
0
MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::MainWindow)
{
	// open database connection
    db = QSqlDatabase::addDatabase("QSQLITE");
    db.setDatabaseName("/Users/jdoud/dev/brainstorm.sqlite");
	if(!db.open())
	{
		qDebug() << db.lastError();
		qFatal("Failed to connect.");
	}

	// setup UI
    ui->setupUi(this);
	ui->toolBar->addWidget(ui->comboFonts);
	ui->toolBar->addWidget(ui->comboFontSizes);
	ui->toolBar->addWidget(ui->comboColors);

	// set text editor defaults
	ui->textNote->document()->setIndentWidth(20);
	ui->textNote->setTabStopWidth(20);
	ui->textNote->setTabChangesFocus(false);
	ui->actionIncrease_Indent->setShortcut(Qt::Key_Tab);
	ui->actionDecrease_Indent->setShortcut(Qt::Key_Backtab);

	// setup comboColors
	QPixmap pix(16, 16);
	pix.fill(Qt::white);
	ui->comboColors->addItem(pix, "");
	pix.fill(Qt::black);
	ui->comboColors->addItem(pix, "");
	pix.fill(Qt::red);
	ui->comboColors->addItem(pix, "");
	pix.fill(Qt::blue);
	ui->comboColors->addItem(pix, "");
	pix.fill(Qt::darkGreen);
	ui->comboColors->addItem(pix, "");
	pix.fill(Qt::gray);
	ui->comboColors->addItem(pix, "");


	// create system tray icon
	createActions();
	createTrayIcon();

	// create models
    categoriesModel = new QSqlTableModel();
	categoriesModel->setTable("categories");
	categoriesModel->setSort(1, Qt::AscendingOrder);
	categoriesModel->select();
	ui->listCategories->setModel(categoriesModel);
	ui->listCategories->setModelColumn(1);

    notesModel = new QSqlTableModel();
	notesModel->setTable("notes");
	ui->listNotes->setModel(notesModel);
	ui->listNotes->setModelColumn(2);

    // set splitter size
    QList<int> sizes;
    sizes << 230 << 150;
    ui->splitterLists->setSizes(sizes);
    sizes.clear();
    sizes << 230 << 600;
    ui->splitterNote->setSizes(sizes);

    // connect File menu slots
    connect(ui->actionNew_Category, SIGNAL(triggered()), this, SLOT(newCategory()));
    connect(ui->actionRename_Category, SIGNAL(triggered()), this, SLOT(renameCategory()));
    connect(ui->actionDelete_Category, SIGNAL(triggered()), this, SLOT(deleteCategory()));
    connect(ui->actionNew_Note, SIGNAL(triggered()), this, SLOT(newNote()));
    connect(ui->actionRename_Note, SIGNAL(triggered()), this, SLOT(renameNote()));
    connect(ui->actionSave_Note, SIGNAL(triggered()), this, SLOT(saveNote()));
    connect(ui->actionDelete_Note, SIGNAL(triggered()), this, SLOT(deleteNote()));
    connect(ui->actionQuit, SIGNAL(triggered()), this, SLOT(quit()));
    // connect Edit menu slots	
    connect(ui->actionFind_Replace, SIGNAL(triggered()), this, SLOT(findAndReplace()));
    // connect Format menu slots
    connect(ui->actionBold, SIGNAL(triggered()), this, SLOT(bold()));
    connect(ui->actionItalic, SIGNAL(triggered()), this, SLOT(italic()));
    connect(ui->actionUnderline, SIGNAL(triggered()), this, SLOT(underline()));
    connect(ui->actionStrikethrough, SIGNAL(triggered()), this, SLOT(strikethrough()));
    connect(ui->actionBullet_List, SIGNAL(triggered()), this, SLOT(bulletList()));
    connect(ui->actionNumber_List, SIGNAL(triggered()), this, SLOT(numberList()));
    connect(ui->actionIncrease_Indent, SIGNAL(triggered()), this, SLOT(increaseIndent()));
    connect(ui->actionDecrease_Indent, SIGNAL(triggered()), this, SLOT(decreaseIndent()));
    connect(ui->actionShow_Colors, SIGNAL(triggered()), this, SLOT(showColors()));
    connect(ui->actionShow_Fonts, SIGNAL(triggered()), this, SLOT(showFonts()));
    connect(ui->actionIncrease_Font, SIGNAL(triggered()), this, SLOT(increaseFont()));
    connect(ui->actionDecrease_Font, SIGNAL(triggered()), this, SLOT(decreaseFont()));
    connect(ui->actionReset_Font, SIGNAL(triggered()), this, SLOT(resetFont()));
    connect(ui->actionAlign_Left, SIGNAL(triggered()), this, SLOT(alignLeft()));
    connect(ui->actionAlign_Center, SIGNAL(triggered()), this, SLOT(alignCenter()));
    connect(ui->actionAlign_Right, SIGNAL(triggered()), this, SLOT(alignRight()));
    connect(ui->actionAlign_Justify, SIGNAL(triggered()), this, SLOT(alignJustify()));
    // connect View menu slots
    connect(ui->actionHide_Window, SIGNAL(triggered()), this, SLOT(hide()));
    connect(ui->actionPrevious_Category, SIGNAL(triggered()), this, SLOT(previousCategory()));
    connect(ui->actionNext_Category, SIGNAL(triggered()), this, SLOT(nextCategory()));
    connect(ui->actionPrevious_Note, SIGNAL(triggered()), this, SLOT(previousNote()));
    connect(ui->actionNext_Note, SIGNAL(triggered()), this, SLOT(nextNote()));
    // connect Help menu slots
    connect(ui->actionAbout_Brainstorm, SIGNAL(triggered()), this, SLOT(aboutBrainstorm()));
    connect(ui->actionAbout_Qt, SIGNAL(triggered()), this, SLOT(aboutQt()));
	// connect application slots
	connect(ui->textNote, SIGNAL(cursorPositionChanged()), this, SLOT(updateMenus()));
	connect(ui->textNote, SIGNAL(currentCharFormatChanged(QTextCharFormat)), this, SLOT(updateMenus()));
    connect(ui->comboFonts, SIGNAL(activated(QString)), this, SLOT(setFont(QString)));
    connect(ui->comboFontSizes, SIGNAL(activated(QString)), this, SLOT(setFontSize(QString)));
    connect(ui->comboColors, SIGNAL(activated(int)), this, SLOT(setFontColor(int)));
	// connect category list slots
	connect(ui->listCategories->selectionModel(), SIGNAL(currentChanged(QModelIndex,QModelIndex)), this, SLOT(updateNoteList(QModelIndex)));
	// connect note list slots
	connect(ui->listNotes->selectionModel(), SIGNAL(currentChanged(QModelIndex,QModelIndex)), this, SLOT(updateNoteText(QModelIndex)));
	// connect text slots
	ui->textNote->installEventFilter((this));
	// connect system tray icon
    connect(trayIcon, SIGNAL(activated(QSystemTrayIcon::ActivationReason)), this, SLOT(iconActivated(QSystemTrayIcon::ActivationReason)));

	// initialize default data
	ui->listCategories->selectionModel()->setCurrentIndex(categoriesModel->index(0, 1), QItemSelectionModel::SelectCurrent);

}