Verified Commit d4b4f988 authored by ita1024's avatar ita1024

Improve the color system #88

parent ba67f24f
......@@ -2,6 +2,8 @@ Semantik 1.0.5
--------------
* Highlight code snippets in beamer presentations/pdflatex using Minted
* Fix drawing artifacts when switching diagrams
* Fix the inactive custom color buttons in semantik #88
* Add a color toolbar to semantik-d
Semantik 1.0.4
--------------
......
Manual positioning of diagram link labels
Source code snippets as data attachments
Arbitrary SVG shapes
Predefined diagram object colors
Z-index in diagrams
Crossing diagram arrows for the one with higher z-index
S5 default picture size?
......
......@@ -10,3 +10,11 @@ color_scheme::color_scheme()
m_oTextColor = QColor("#000000");
}
color_scheme& color_scheme::operator=(const color_scheme &i_o)
{
m_sName = i_o.m_sName;
m_oBorderColor = i_o.m_oBorderColor;
m_oInnerColor = i_o.m_oInnerColor;
m_oTextColor = i_o.m_oTextColor;
return *this;
}
......@@ -16,6 +16,7 @@ class color_scheme // :
QColor m_oInnerColor;
QColor m_oBorderColor;
QColor m_oTextColor;
color_scheme& operator=(const color_scheme &);
};
......
......@@ -1295,6 +1295,8 @@ sem_mediator::sem_mediator(QObject* i_oParent) : QObject(i_oParent)
m_sOutTemplate = "";
init_temp_dir();
m_bIsDiagram = false;
if (!QFile::exists(SEMANTIK_DIR "/templates/waf")) {
qDebug()<<"Access denied ^ô^";
Q_ASSERT(false);
......
......@@ -192,7 +192,7 @@ class sem_mediator: public QObject
QPixmap getThumb(int id);
bool load_picture(const QString&, int);
bool save_and_load_picture(const QUrl& i_sPath, int id);
bool m_bIsDiagram;
void generate_docs(const QString &i_oFile, const QString &i_sName, const QString &i_sLocation);
......
......@@ -47,7 +47,7 @@
#define PIPAD 20
canvas_view::canvas_view(QWidget *i_oWidget, sem_mediator *i_oControl) : QGraphicsView(i_oWidget)
canvas_view::canvas_view(QWidget *i_oWidget, sem_mediator *i_oControl, QMenu* i_oColorMenu) : QGraphicsView(i_oWidget)
{
m_oSemantikWindow = i_oWidget;
m_bDisableGradient = false;
......@@ -140,9 +140,9 @@ canvas_view::canvas_view(QWidget *i_oWidget, sem_mediator *i_oControl) : QGraphi
connect(fullAction, SIGNAL(triggered()), this, SLOT(toggle_fullscreen())); addAction(l_o);
m_oMenu->addAction(fullAction);
m_oColorMenu = m_oMenu->addMenu(trUtf8("Colors"));
//m_oDataMenu = m_oMenu->addMenu(trUtf8("Data type"));
m_oColorMenu = i_oColorMenu;
m_oMenu->addMenu(m_oColorMenu);
#define newAction(s, v, dest) dest = l_o = new QAction(s, this); \
connect(l_o, SIGNAL(triggered()), this, SLOT(slot_change_data())); \
......@@ -587,53 +587,6 @@ void canvas_view::notify_select(const QList<int>& unsel, const QList<int>& sel)
}
}
void canvas_view::sync_colors() {
semantik_win *l_o = (semantik_win*) m_oSemantikWindow;
l_o->m_oColorsToolBar->clear();
while (l_o->m_oColorGroup->actions().size() > m_oMediator->m_oColorSchemes.size()+1)
{
QAction* l_oA = l_o->m_oColorGroup->actions().takeFirst();
l_o->m_oColorsToolBar->removeAction(l_oA);
m_oColorMenu->removeAction(l_oA);
delete l_oA;
}
while (l_o->m_oColorGroup->actions().size() < m_oMediator->m_oColorSchemes.size()+1)
{
new QAction(QIcon(), trUtf8("Color"), l_o->m_oColorGroup);
}
l_o->m_oColorGroup->removeAction(l_o->m_oCustomColorAct);
l_o->m_oColorGroup->addAction(l_o->m_oCustomColorAct);
m_oColorMenu->removeAction(l_o->m_oCustomColorAct);
m_oColorMenu->addAction(l_o->m_oCustomColorAct);
for (int i=0; i<m_oMediator->m_oColorSchemes.size(); ++i)
{
color_scheme l_oScheme = m_oMediator->m_oColorSchemes[i];
QAction *l_oAction = l_o->m_oColorGroup->actions()[i];
QPixmap l_oPix(22, 22);
QPainter l_oP(&l_oPix);
l_oAction->setText(l_oScheme.m_sName);
l_oPix.fill(l_oScheme.m_oInnerColor);
//TODO pen ?
l_oP.drawRect(0, 0, 21, 21);
l_oAction->setIcon(QIcon(l_oPix));
}
// la première action est pour la couleur de la racine
for (int i=1; i<l_o->m_oColorGroup->actions().size(); ++i)
{
QAction *l_oAct = l_o->m_oColorGroup->actions()[i];
l_o->m_oColorsToolBar->addAction(l_oAct);
m_oColorMenu->addAction(l_oAct);
}
}
void canvas_view::notify_pic(int id)
{
qDebug()<<"canvas_view::notify_pic to be implemented";
......@@ -686,7 +639,10 @@ void canvas_view::change_colors(QAction* i_oAct)
if (i==l_o->m_oColorGroup->actions().size()-1)
{
l_oColor = QColorDialog::getColor(l_oColor, this);
if (!l_oColor.isValid()) return;
if (!l_oColor.isValid())
{
return;
}
}
break;
}
......@@ -694,6 +650,7 @@ void canvas_view::change_colors(QAction* i_oAct)
mem_color* col = new mem_color(m_oMediator);
col->newColor = l_iIdx;
col->m_oNewCustomColor.m_oInnerColor = l_oColor;
col->apply();
}
......
......@@ -22,7 +22,7 @@ class canvas_view : public QGraphicsView
{
Q_OBJECT
public:
canvas_view(QWidget *i_oWidget, sem_mediator* i_oControl);
canvas_view(QWidget *i_oWidget, sem_mediator* i_oControl, QMenu*);
void item_moved();
QMap<int, canvas_item*> m_oItems;
......@@ -141,7 +141,6 @@ class canvas_view : public QGraphicsView
void notify_change_data(int id);
void notify_export_doc();
void sync_flags();
void sync_colors();
void slot_change_data();
void reorganize();
......
......@@ -48,4 +48,7 @@
</MenuBar>
<ToolBar name="colorsToolBar" iconText="icononly" position="right"><text>Colors Toolbar</text>
<Action name="tool_select" />
</ToolBar>
</gui>
......@@ -206,11 +206,6 @@ box_view::box_view(QWidget *i_oWidget, sem_mediator *i_oControl) : QGraphicsView
connect(m_oDeleteAction, SIGNAL(triggered()), this, SLOT(slot_delete()));
addAction(m_oDeleteAction);
m_oColorAction = new QAction(QObject::trUtf8("Color..."), this);
connect(m_oColorAction, SIGNAL(triggered()), this, SLOT(slot_color()));
addAction(m_oColorAction);
m_oMoveUpAction = new QAction(QObject::trUtf8("Raise"), this);
m_oMoveUpAction->setShortcut(QObject::trUtf8("PgUp"));
connect(m_oMoveUpAction, SIGNAL(triggered()), this, SLOT(slot_move_up()));
......@@ -263,8 +258,6 @@ box_view::box_view(QWidget *i_oWidget, sem_mediator *i_oControl) : QGraphicsView
m_oCopyToClipboard = new QAction(QObject::trUtf8("Copy image to clipboard"), this);
connect(m_oCopyToClipboard, SIGNAL(triggered()), this, SLOT(slot_copy_picture()));
m_oColorAction->setEnabled(false);
m_oLastMovePoint = QPointF(-100, -100);
m_oCurrent = NULL;
......@@ -361,7 +354,7 @@ void box_view::init_menu()
//m_oMoveUpAction->setEnabled(false);
//m_oMoveDownAction->setEnabled(false);
m_oMenu->addSeparator();
m_oMenu->addAction(m_oColorAction);
m_oMenu->addMenu(m_oColorMenu);
m_oMenu->addAction(m_oPropertiesAction);
}
......@@ -668,7 +661,7 @@ void box_view::enable_menu_actions()
m_oAddItemAction->setEnabled(selected <= 1);
m_oDeleteAction->setEnabled(selected >= 1);
m_oColorAction->setEnabled(selected >= 1);
m_oColorMenu->setEnabled(selected >= 1);
m_oPropertiesAction->setEnabled(selected == 0 or (selected == 1 and dynamic_cast<editable*>(selection.at(0))));
......@@ -736,11 +729,12 @@ void box_view::change_colors(QAction* i_oAct)
QColor l_oColor;
static QColor selected_color;
for (int i=1; i < i_oAct->actionGroup()->actions().size(); ++i)
QList<QAction*> l_oActs = i_oAct->actionGroup()->actions();
for (int i=1; i < l_oActs.size(); ++i)
{
if (i_oAct->actionGroup()->actions()[i] == i_oAct)
if (l_oActs[i] == i_oAct)
{
if (i == i_oAct->actionGroup()->actions().size()-1)
if (i == l_oActs.size()-1)
{
selected_color = QColorDialog::getColor(selected_color, this);
if (!selected_color.isValid())
......@@ -752,7 +746,6 @@ void box_view::change_colors(QAction* i_oAct)
else
{
selected_color = l_oColor = m_oMediator->m_oColorSchemes[i].m_oInnerColor;
}
break;
}
......@@ -1802,6 +1795,8 @@ bool box_view::import_from_file(const QUrl& l_o)
mem_import_box *imp = new mem_import_box(m_oMediator, m_iId);
imp->init(tmp->m_oBoxes.values(), tmp->m_oLinks);
imp->m_iNewFont = tmp->m_oDiagramFont;
imp->m_oOldColorSchemes = m_oMediator->m_oColorSchemes;
imp->m_oNewColorSchemes = x->m_oColorSchemes;
imp->apply();
m_oCurrentUrl = l_o;
......
......@@ -49,6 +49,7 @@ class box_view : public QGraphicsView
QMenu* m_oAlignMenu;
QMenu* m_oSizeMenu;
QMenu* m_oFileMenu;
QMenu* m_oColorMenu;
QAction *m_oAddItemAction;
QAction *m_oAddLabel;
......
......@@ -39,6 +39,8 @@ diagram_document::diagram_document(QWidget *i_oParent) : QFrame(i_oParent)
void diagram_document::init()
{
m_oMediator->m_bIsDiagram = true;
connect(m_oMediator, SIGNAL(sig_add_item(int)), m_oDiagramView, SLOT(notify_add_item(int)));
connect(m_oMediator, SIGNAL(sig_select(const QList<int>&, const QList<int>&)), m_oDiagramView, SLOT(notify_select(const QList<int>&, const QList<int>&)));
......@@ -69,6 +71,9 @@ void diagram_document::init()
m_oMediator->m_oUndoStack.clear();
m_oMediator->m_oRedoStack.clear();
m_oMediator->init_colors();
m_oMediator->set_dirty(false);
}
......
......@@ -336,6 +336,10 @@ void mem_import_box::undo()
item->m_oLinks.append(k);
model->notify_link_box(m_iId, k);
}
if (model->m_bIsDiagram)
{
model->m_oColorSchemes = m_oOldColorSchemes;
}
undo_dirty();
}
......@@ -360,6 +364,10 @@ void mem_import_box::redo()
item->m_oLinks.append(k);
model->notify_link_box(m_iId, k);
}
if (model->m_bIsDiagram)
{
model->m_oColorSchemes = m_oNewColorSchemes;
}
redo_dirty();
}
......
......@@ -174,6 +174,8 @@ class mem_import_box : public mem_command {
QList<data_link*> old_links;
QFont m_iOldFont;
QFont m_iNewFont;
QList<color_scheme> m_oNewColorSchemes;
QList<color_scheme> m_oOldColorSchemes;
IType type() { return IMPORT_BOX; }
};
......
......@@ -38,6 +38,8 @@ semantik_d_win::semantik_d_win(QWidget *i_oParent) : KXmlGuiWindow(i_oParent)
setWindowIcon(QIcon("semantik"));
m_oColorMenu = new QMenu(trUtf8("Colors"), this);
m_oTabWidget = new KTabWidget(this);
m_oTabWidget->setCloseButtonEnabled(true);
m_oTabWidget->setAutomaticResizeTabs(true);
......@@ -83,6 +85,25 @@ semantik_d_win::semantik_d_win(QWidget *i_oParent) : KXmlGuiWindow(i_oParent)
setupGUI(QSize(1000, 800), Default, notr("semantik-dui.rc"));
m_oColorsToolBar = toolBar(notr("colorsToolBar"));
flag_scheme l_oScheme(this, notr("crsc-app-colors"), "");
m_oColorGroup = new QActionGroup(this);
for (int i = 0; i < 9; ++i)
{
QAction *l_oAct = new QAction(QIcon(), trUtf8("Color"), m_oColorGroup);
m_oColorGroup->addAction(l_oAct);
if (i != 0)
{
m_oColorsToolBar->addAction(l_oAct);
m_oColorMenu->addAction(l_oAct);
}
}
m_oCustomColorAct = new QAction(l_oScheme._icon(), trUtf8("Custom color"), m_oColorGroup);
m_oColorMenu->addAction(m_oCustomColorAct);
m_oColorsToolBar->addAction(m_oCustomColorAct);
m_oColorGroup->setExclusive(true);
read_config();
setAutoSaveSettings();
statusBar()->showMessage(trUtf8("This is Semantik-d"), 2000);
......@@ -90,11 +111,18 @@ semantik_d_win::semantik_d_win(QWidget *i_oParent) : KXmlGuiWindow(i_oParent)
connect(m_oFileTree, SIGNAL(url_selected(const QUrl&)), this, SLOT(slot_recent(const QUrl&)));
connect(this, SIGNAL(url_opened(const QUrl&)), this, SLOT(record_open_url(const QUrl&)));
m_oFileTree->m_oModel->expandToUrl(QUrl::fromLocalFile(QDir::homePath()));
}
void semantik_d_win::wire_actions()
{
//m_oColorGroup->disconnect();
if (m_oActiveDocument)
{
connect(m_oColorGroup, SIGNAL(triggered(QAction*)), m_oActiveDocument->m_oDiagramView, SLOT(change_colors(QAction*)));
}
QAction *l_oTmp = actionCollection()->action(KStandardAction::name(KStandardAction::Save));
l_oTmp->disconnect();
if (m_oActiveDocument)
......@@ -189,6 +217,7 @@ void semantik_d_win::slot_enable_undo(bool i_bUndo, bool i_bRedo)
void semantik_d_win::slot_add_tab()
{
m_oActiveDocument = new diagram_document(m_oTabWidget);
m_oActiveDocument->m_oDiagramView->m_oColorMenu = m_oColorMenu;
m_oActiveDocument->init();
int l_iIndex = m_oTabWidget->addTab(m_oActiveDocument, trUtf8("[Untitled]"));
m_oTabWidget->setCurrentIndex(l_iIndex);
......@@ -213,6 +242,7 @@ void semantik_d_win::slot_tab_changed(int i_iIndex)
{
emit url_opened(m_oActiveDocument->m_oDiagramView->m_oCurrentUrl);
}
sync_colors();
wire_actions();
}
......@@ -311,6 +341,7 @@ void semantik_d_win::slot_open()
// just open a new tab
diagram_document *l_oTmp = m_oActiveDocument;
m_oActiveDocument = new diagram_document(m_oTabWidget);
m_oActiveDocument->m_oDiagramView->m_oColorMenu = m_oColorMenu;
m_oActiveDocument->init();
if (m_oActiveDocument->m_oDiagramView->import_from_file(l_o))
{
......@@ -353,6 +384,7 @@ void semantik_d_win::slot_recent(const QUrl& i_oUrl)
diagram_document *l_oTmp = m_oActiveDocument;
m_oActiveDocument = new diagram_document(m_oTabWidget);
m_oActiveDocument->m_oDiagramView->m_oColorMenu = m_oColorMenu;
m_oActiveDocument->init();
if (m_oActiveDocument->m_oDiagramView->import_from_file(i_oUrl))
{
......@@ -420,3 +452,37 @@ void semantik_d_win::slot_export_fig_size()
}
}
void semantik_d_win::sync_colors()
{
if (m_oActiveDocument != NULL)
{
for (int i=0; i<m_oActiveDocument->m_oMediator->m_oColorSchemes.size(); ++i)
{
color_scheme l_oScheme = m_oActiveDocument->m_oMediator->m_oColorSchemes[i];
QAction *l_oAction = m_oColorGroup->actions()[i];
QPixmap l_oPix(22, 22);
QPainter l_oP(&l_oPix);
l_oAction->setText(l_oScheme.m_sName);
l_oPix.fill(l_oScheme.m_oInnerColor);
l_oP.drawRect(0, 0, 21, 21);
l_oAction->setIcon(QIcon(l_oPix));
}
QList<QAction*> l_oActs = m_oColorGroup->actions();
for (int i=1; i < l_oActs.size(); ++i)
{
l_oActs[i]->setEnabled(true);
}
}
else
{
QList<QAction*> l_oActs = m_oColorGroup->actions();
for (int i=1; i < l_oActs.size(); ++i)
{
l_oActs[i]->setEnabled(false);
}
}
}
......@@ -19,6 +19,7 @@ class QAction;
class QActionGroup;
class QListWidget;
class QMenu;
class QActionGroup;
class QTextEdit;
class KTabWidget;
class filetree;
......@@ -35,11 +36,15 @@ class semantik_d_win : public KXmlGuiWindow
diagram_document *m_oActiveDocument;
QAction *m_oUndoAct;
QAction *m_oRedoAct;
QAction *m_oCustomColorAct;
KRecentFilesAction* m_oRecentFilesAct;
KToolBar *m_oColorsToolBar;
KTabWidget *m_oTabWidget;
filetree *m_oFileTree;
QAction *m_oExportSizeAct;
QMenu *m_oColorMenu;
QActionGroup *m_oColorGroup;
void read_config();
void write_config();
......@@ -53,6 +58,7 @@ class semantik_d_win : public KXmlGuiWindow
void slot_enable_undo(bool, bool);
void slot_recent(const QUrl &);
void slot_export_fig_size();
void sync_colors();
void slot_properties();
......
......@@ -68,6 +68,7 @@ mem_color::mem_color(sem_mediator* mod) : mem_command(mod) {
foreach (data_item* t, model->m_oItems.values()) {
if (t->m_bSelected) {
prevColors[t->m_iId] = t->m_iColor;
m_oPrevCustomColors[t->m_iId] = t->m_oCustom;
}
}
}
......@@ -78,6 +79,7 @@ void mem_color::redo() {
{
data_item *t = model->m_oItems.value(i.key());
t->m_iColor = newColor;
t->m_oCustom = m_oNewCustomColor;
model->notify_repaint(i.key());
}
redo_dirty();
......@@ -85,10 +87,11 @@ void mem_color::redo() {
void mem_color::undo() {
QMap<int, int>::iterator i;
for (i = prevColors.begin(); i != prevColors.end(); ++i)
for (i = prevColors.begin(); i != prevColors.end(); ++i)
{
data_item *t = model->m_oItems.value(i.key());
t->m_iColor = i.value();
t->m_oCustom = m_oPrevCustomColors[i.key()];
model->notify_repaint(i.key());
}
undo_dirty();
......
......@@ -42,6 +42,8 @@ class mem_color : public mem_command {
void undo();
void redo();
QMap<int, int> prevColors;
QMap<int, color_scheme> m_oPrevCustomColors;
color_scheme m_oNewCustomColor;
int newColor;
IType type() { return COLOR; }
};
......
......@@ -994,7 +994,7 @@ msgid "Ctrl+G"
msgstr "Ctrl+G"
#: semantik.cpp:188
msgid "CustomColor"
msgid "Custom color"
msgstr "Vlastní barva"
#: semantik.cpp:211
......
......@@ -978,7 +978,7 @@ msgid "Ctrl+G"
msgstr "Strg+G"
#: semantik.cpp:188
msgid "CustomColor"
msgid "Custom color"
msgstr "Benutzerdefinierte Farbe"
#: semantik.cpp:211
......
......@@ -1003,7 +1003,7 @@ msgid "Ctrl+G"
msgstr ""
#: semantik.cpp:188
msgid "CustomColor"
msgid "Custom color"
msgstr "Προσαρμοσμένο χρώμα"
#: semantik.cpp:211
......
......@@ -951,7 +951,7 @@ msgid "Ctrl+G"
msgstr ""
#: semantik.cpp:188
msgid "CustomColor"
msgid "Custom color"
msgstr ""
#: semantik.cpp:211
......
......@@ -971,7 +971,7 @@ msgid "Ctrl+G"
msgstr ""
#: semantik.cpp:188
msgid "CustomColor"
msgid "Custom color"
msgstr ""
#: semantik.cpp:211
......
......@@ -970,7 +970,7 @@ msgid "Ctrl+G"
msgstr "Ctrl+G"
#: semantik.cpp:188
msgid "CustomColor"
msgid "Custom color"
msgstr "Другой цвет"
#: semantik.cpp:211
......
......@@ -957,7 +957,7 @@ msgid "Ctrl+G"
msgstr ""
#: semantik.cpp:188
msgid "CustomColor"
msgid "Custom color"
msgstr ""
#: semantik.cpp:211
......
......@@ -998,7 +998,7 @@ msgid "Ctrl+G"
msgstr ""
#: semantik.cpp:188
msgid "CustomColor"
msgid "Custom color"
msgstr "VlastnáFarba"
#: semantik.cpp:211
......
......@@ -141,10 +141,12 @@ semantik_win::semantik_win(QWidget *i_oParent) : KXmlGuiWindow(i_oParent)
connect(m_oMediator, SIGNAL(sig_message(const QString&, int)), this, SLOT(slot_message(const QString&, int)));
connect(m_oMediator, SIGNAL(update_title()), this, SLOT(update_title()));
m_oColorMenu = new QMenu(trUtf8("Colors"), this);
QFrame *fr = new QFrame(this);
fr->setLineWidth(0);
fr->setFrameStyle(QFrame::NoFrame);
m_oCanvas = new canvas_view(fr, m_oMediator);
m_oCanvas = new canvas_view(fr, m_oMediator, m_oColorMenu);
setCentralWidget(fr);
QGridLayout *ll = new QGridLayout(fr);
ll->addWidget(m_oCanvas);
......@@ -184,13 +186,6 @@ semantik_win::semantik_win(QWidget *i_oParent) : KXmlGuiWindow(i_oParent)
m_oGenerateAct->setShortcut(trUtf8("Ctrl+G"));
connect(m_oGenerateAct, SIGNAL(triggered(bool)), SLOT(slot_generate()));
flag_scheme l_oScheme(this, notr("crsc-app-colors"), "");
m_oColorGroup = new QActionGroup(this);
m_oCustomColorAct = new QAction(l_oScheme._icon(), trUtf8("CustomColor"), m_oColorGroup);
m_oColorGroup->setExclusive(true);
connect(m_oColorGroup, SIGNAL(triggered(QAction*)), m_oCanvas, SLOT(change_colors(QAction*)));
m_oFlagGroup = new QActionGroup(this);
m_oFlagGroup->setExclusive(false);
connect(m_oFlagGroup, SIGNAL(triggered(QAction*)), m_oCanvas, SLOT(change_flags(QAction*)));
......@@ -229,8 +224,8 @@ semantik_win::semantik_win(QWidget *i_oParent) : KXmlGuiWindow(i_oParent)
m_oDiagramView = new box_view(m_oDataView, m_oMediator);
m_oDiagramView->m_bShowFileMenu = true;
m_oDiagramView->m_oColorMenu = m_oColorMenu;
m_oDataView->addWidget(m_oDiagramView);
connect(m_oColorGroup, SIGNAL(triggered(QAction*)), m_oDiagramView, SLOT(change_colors(QAction*)));
connect(m_oDiagramView, SIGNAL(sig_message(const QString&, int)), this, SLOT(slot_message(const QString&, int)));
......@@ -262,15 +257,34 @@ semantik_win::semantik_win(QWidget *i_oParent) : KXmlGuiWindow(i_oParent)
actionCollection()->addAction(notr("show_dock_linear"), l_oDock->toggleViewAction());
l_oDock->setObjectName(notr("LinearDock"));
setupGUI(QSize(800, 800), Default, notr("semantikui.rc"));
m_oFlagsToolBar = toolBar(notr("flagsToolBar"));
m_oColorsToolBar = toolBar(notr("colorsToolBar"));
flag_scheme l_oScheme(this, notr("crsc-app-colors"), "");
m_oColorGroup = new QActionGroup(this);
for (int i = 0; i < 9; ++i)
{
QAction *l_oAct = new QAction(QIcon(), trUtf8("Color"), m_oColorGroup);
m_oColorGroup->addAction(l_oAct);
if (i != 0)
{
m_oColorsToolBar->addAction(l_oAct);
m_oColorMenu->addAction(l_oAct);
}
}
m_oCustomColorAct = new QAction(l_oScheme._icon(), trUtf8("Custom color"), m_oColorGroup);
m_oColorMenu->addAction(m_oCustomColorAct);
m_oColorsToolBar->addAction(m_oCustomColorAct);
m_oColorGroup->setExclusive(true);
connect(m_oMediator, SIGNAL(sync_colors()), this, SLOT(sync_colors()));
connect(m_oColorGroup, SIGNAL(triggered(QAction*)), m_oDiagramView, SLOT(change_colors(QAction*)));
connect(m_oColorGroup, SIGNAL(triggered(QAction*)), m_oCanvas, SLOT(change_colors(QAction*)));
m_oMediator->m_oCurrentUrl = QUrl();
update_title();
m_oColorsToolBar = toolBar(notr("colorsToolBar"));
m_oFlagsToolBar = toolBar(notr("flagsToolBar"));
linear_view* ln = m_oTree->m_oView;
connect(m_oMediator, SIGNAL(sig_preview()), m_oPreView, SLOT(notify_preview()));
connect(m_oMediator, SIGNAL(sig_add_item(int)), m_oCanvas, SLOT(notify_add_item(int)));
......@@ -317,8 +331,6 @@ semantik_win::semantik_win(QWidget *i_oParent) : KXmlGuiWindow(i_oParent)
connect(m_oMediator, SIGNAL(sig_move(const QList<int>&, const QList<QPointF>&)), m_oCanvas, SLOT(notify_move(const QList<int>&, const QList<QPointF>&)));
connect(m_oMediator, SIGNAL(sync_flags()), m_oCanvas, SLOT(sync_flags()));
connect(m_oMediator, SIGNAL(sync_colors()), m_oCanvas, SLOT(sync_colors()));
connect(m_oImageView, SIGNAL(sig_message(const QString&, int)), this, SLOT(slot_message(const QString&, int)));
connect(m_oMediator, SIGNAL(sig_open_map()), m_oCanvas, SLOT(notify_open_map()));
......@@ -641,3 +653,21 @@ void semantik_win::slot_enable_undo(bool undo, bool redo) {
m_oRedoAct->setEnabled(redo);
}
void semantik_win::sync_colors()
{
for (int i=0; i<m_oMediator->m_oColorSchemes.size(); ++i)
{
color_scheme l_oScheme = m_oMediator->m_oColorSchemes[i];
QAction *l_oAction = m_oColorGroup->actions()[i];
QPixmap l_oPix(22, 22);
QPainter l_oP(&l_oPix);
l_oAction->setText(l_oScheme.m_sName);
l_oPix.fill(l_oScheme.m_oInnerColor);
l_oP.drawRect(0, 0, 21, 21);
l_oAction->setIcon(QIcon(l_oPix));
}
}
......@@ -56,7 +56,6 @@ class semantik_win : public KXmlGuiWindow
linear_container *m_oTree;
sem_mediator *m_oMediator;
vars_view *m_oVarsView;
pre_view *m_oPreView;
text_view *m_oTextView;
......@@ -79,6 +78,7 @@ class semantik_win : public KXmlGuiWindow
KToolBar *m_oFlagsToolBar;
QMenu *m_oToolsMenu;
QMenu *m_oColorMenu;
QAction *m_oSelectAct;
QAction *m_oSortAct;
QAction *m_oScrollAct;
......@@ -101,7 +101,7 @@ class semantik_win : public KXmlGuiWindow
public slots:
void update_title();
void sync_colors();
void fit_zoom();
void slot_open();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment