adding status icons

master
Denes Matetelki 14 years ago
parent 8feb503d7a
commit 6bdf817793

@ -207,6 +207,17 @@ void GraphWidget::writeContentToPngFile(const QString &fileName)
m_parent->statusBarMsg(tr("MindMap exported as ") + fileName); m_parent->statusBarMsg(tr("MindMap exported as ") + fileName);
} }
void GraphWidget::insertPicture(const QString &picture)
{
if (!m_activeNode)
{
m_parent->statusBarMsg(tr("No active node."));
return;
}
m_activeNode->insertPicture(picture);
}
void GraphWidget::keyPressEvent(QKeyEvent *event) void GraphWidget::keyPressEvent(QKeyEvent *event)
{ {
// esc leaves node editing mode // esc leaves node editing mode

@ -32,6 +32,8 @@ public:
void writeContentToXmlFile(const QString &fileName); void writeContentToXmlFile(const QString &fileName);
void writeContentToPngFile(const QString &fileName); void writeContentToPngFile(const QString &fileName);
void insertPicture(const QString &picture);
protected: protected:
void keyPressEvent(QKeyEvent *event); void keyPressEvent(QKeyEvent *event);

@ -40,29 +40,42 @@ MainWindow::MainWindow(QWidget *parent) :
// why can't I do this with qtcreator? // why can't I do this with qtcreator?
/// @bug or a feature? no underline here /// @bug or a feature? no underline here
/// @todo solve the shorcuts
m_doIt = new QAction(QIcon(":/user-trash-full.svg"), "&Do it", this);
// m_doIt->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_T));
m_ui->mainToolBar->addAction(m_doIt);
connect(m_doIt, SIGNAL(activated()), this, SLOT(insertPicture()));
m_trash = new QAction(QIcon(":/user-trash-full.svg"), "&Trash it", this); m_trash = new QAction(QIcon(":/user-trash-full.svg"), "&Trash it", this);
m_trash->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_T)); m_trash->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_T));
m_ui->mainToolBar->addAction(m_trash); m_ui->mainToolBar->addAction(m_trash);
connect(m_trash, SIGNAL(activated()), this, SLOT(insertPicture()));
m_info = new QAction(QIcon(":/folder.svg"), "&Reference it", this); m_info = new QAction(QIcon(":/folder.svg"), "&Reference it", this);
m_info->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_R)); m_info->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_R));
m_ui->mainToolBar->addAction(m_info); m_ui->mainToolBar->addAction(m_info);
connect(m_info, SIGNAL(activated()), this, SLOT(insertPicture()));
m_blocked = new QAction(QIcon(":/dialog-warning.svg"), tr("&Blocked"), this); m_blocked = new QAction(QIcon(":/dialog-warning.svg"), tr("&Blocked"), this);
m_blocked->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_B)); m_blocked->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_B));
m_ui->mainToolBar->addAction(m_blocked); m_ui->mainToolBar->addAction(m_blocked);
connect(m_blocked, SIGNAL(activated()), this, SLOT(insertPicture()));
m_question = new QAction(QIcon(":/help-browser.svg"), tr("&What shall be done?"), this); m_question = new QAction(QIcon(":/help-browser.svg"), tr("&What is it?"), this);
// m_question->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_Q)); // m_question->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_Q));
m_ui->mainToolBar->addAction(m_question); m_ui->mainToolBar->addAction(m_question);
connect(m_question, SIGNAL(activated()), this, SLOT(insertPicture()));
m_postpone = new QAction(QIcon(":/x-office-calendar.svg"), tr("&Postpone it"), this); m_postpone = new QAction(QIcon(":/x-office-calendar.svg"), tr("&Postpone it"), this);
m_postpone->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_P)); m_postpone->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_P));
m_ui->mainToolBar->addAction(m_postpone); m_ui->mainToolBar->addAction(m_postpone);
connect(m_postpone, SIGNAL(activated()), this, SLOT(insertPicture()));
m_delegate = new QAction(QIcon(":/system-users.svg"), tr("&Delegate it"), this); m_delegate = new QAction(QIcon(":/system-users.svg"), tr("&Delegate it"), this);
m_delegate->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_D)); m_delegate->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_D));
m_ui->mainToolBar->addAction(m_delegate); m_ui->mainToolBar->addAction(m_delegate);
connect(m_delegate, SIGNAL(activated()), this, SLOT(insertPicture()));
m_ui->mainToolBar->setToolButtonStyle(Qt::ToolButtonTextUnderIcon); m_ui->mainToolBar->setToolButtonStyle(Qt::ToolButtonTextUnderIcon);
} }
@ -317,6 +330,47 @@ void MainWindow::about()
msgBox.exec(); msgBox.exec();
} }
void MainWindow::insertPicture()
{
QAction *sender = dynamic_cast<QAction*>(QObject::sender());
/// @note Why QIcon does not store it's fileName? It would be easier:
// m_graphicsView->insertPicture(
// dynamic_cast<QAction*>(QObject::sender())->icon().name());
if (sender == m_doIt)
{
m_graphicsView->insertPicture(":/user-trash-full.svg");
}
else if (sender == m_trash)
{
m_graphicsView->insertPicture(":/user-trash-full.svg");
}
else if (sender == m_info)
{
m_graphicsView->insertPicture(":/folder.svg");
}
else if (sender == m_blocked)
{
m_graphicsView->insertPicture(":/dialog-warning.svg");
}
else if (sender == m_question)
{
m_graphicsView->insertPicture(":/help-browser.svg");
}
else if (sender == m_postpone)
{
m_graphicsView->insertPicture(":/x-office-calendar.svg");
}
else if (sender == m_delegate)
{
m_graphicsView->insertPicture(":/system-users.svg");
}
else
{
return;
}
}
void MainWindow::closeEvent(QCloseEvent * event) void MainWindow::closeEvent(QCloseEvent * event)
{ {
m_contentChanged && !closeFile() ? event->ignore() : event->accept(); m_contentChanged && !closeFile() ? event->ignore() : event->accept();

@ -34,6 +34,8 @@ public slots:
void keys(); void keys();
void about(); void about();
void insertPicture();
protected: protected:
void closeEvent(QCloseEvent * event); void closeEvent(QCloseEvent * event);
@ -46,6 +48,7 @@ private:
QString m_fileName; QString m_fileName;
bool m_contentChanged; bool m_contentChanged;
QAction *m_doIt;
QAction *m_trash; QAction *m_trash;
QAction *m_info; QAction *m_info;
QAction *m_blocked; QAction *m_blocked;

@ -152,6 +152,22 @@ void Node::showNumber(const int &number,
update(); update();
} }
void Node::insertPicture(const QString &picture, const int &pos)
{
QTextCursor c = textCursor();
if (pos)
{
c.setPosition(pos);
}
c.insertHtml(QString("<img src=").append(picture).
append(" width=15 height=15></img>"));
m_graph->contentChanged();
foreach (EdgeElement element, m_edgeList) element.edge->adjust();
}
double Node::calculateBiggestAngle() double Node::calculateBiggestAngle()
{ {
if (m_edgeList.empty()) if (m_edgeList.empty())

@ -33,6 +33,7 @@ public:
void showNumber(const int &number, const bool& show = true, void showNumber(const int &number, const bool& show = true,
const bool &numberIsSpecial = false); const bool &numberIsSpecial = false);
void insertPicture(const QString &picture, const int &pos = 0);
double calculateBiggestAngle(); double calculateBiggestAngle();
// changing visibility from prot to pub // changing visibility from prot to pub

@ -6,7 +6,10 @@
QT += core gui svg xml QT += core gui svg xml
CONFIG += warn_on
TARGET = qtmindmap TARGET = qtmindmap
TEMPLATE = app TEMPLATE = app

Loading…
Cancel
Save