src/gui.cpp

changeset 322
5e701c3c3d8e
parent 321
48e429bfd58c
child 324
31c6e53e1e4e
equal deleted inserted replaced
321:48e429bfd58c 322:5e701c3c3d8e
43 #include "misc.h" 43 #include "misc.h"
44 #include "colors.h" 44 #include "colors.h"
45 #include "history.h" 45 #include "history.h"
46 #include "widgets.h" 46 #include "widgets.h"
47 #include "addObjectDialog.h" 47 #include "addObjectDialog.h"
48 #include "msglog.h"
48 #include "config.h" 49 #include "config.h"
49 50
50 actionmeta g_actionMeta[MAX_ACTIONS]; 51 actionmeta g_actionMeta[MAX_ACTIONS];
51 static ushort g_metacursor = 0; 52 static ushort g_metacursor = 0;
52 53
76 m_objList = new ObjectList; 77 m_objList = new ObjectList;
77 m_objList->setSelectionMode (QListWidget::ExtendedSelection); 78 m_objList->setSelectionMode (QListWidget::ExtendedSelection);
78 m_objList->setAlternatingRowColors (true); 79 m_objList->setAlternatingRowColors (true);
79 connect (m_objList, SIGNAL (itemSelectionChanged ()), this, SLOT (slot_selectionChanged ())); 80 connect (m_objList, SIGNAL (itemSelectionChanged ()), this, SLOT (slot_selectionChanged ()));
80 connect (m_objList, SIGNAL (itemDoubleClicked (QListWidgetItem*)), this, SLOT (slot_editObject (QListWidgetItem*))); 81 connect (m_objList, SIGNAL (itemDoubleClicked (QListWidgetItem*)), this, SLOT (slot_editObject (QListWidgetItem*)));
82
83 m_msglog = new MessageManager;
84 m_msglog->setRenderer( R() );
85 m_renderer->setMessageLog( m_msglog );
81 86
82 m_splitter = new QSplitter; 87 m_splitter = new QSplitter;
83 m_splitter->addWidget (m_renderer); 88 m_splitter->addWidget (m_renderer);
84 m_splitter->addWidget (m_objList); 89 m_splitter->addWidget (m_objList);
85 setCentralWidget (m_splitter); 90 setCentralWidget (m_splitter);
560 break; 565 break;
561 } 566 }
562 } 567 }
563 568
564 if (!meta) { 569 if (!meta) {
565 logf (LOG_Warning, "unknown signal sender %p!\n", qAct); 570 log ("Warning: unknown signal sender %p!\n", qAct);
566 return; 571 return;
567 } 572 }
568 573
569 // We have the meta, now call the handler. 574 // We have the meta, now call the handler.
570 (*meta->handler) (); 575 (*meta->handler) ();
1041 { 1046 {
1042 f->setName (path); 1047 f->setName (path);
1043 1048
1044 if( f == g_curfile ) 1049 if( f == g_curfile )
1045 g_win->updateTitle (); 1050 g_win->updateTitle ();
1051
1052 log( "Saved to %1.", path );
1046 } 1053 }
1047 else 1054 else
1048 { 1055 {
1049 setlocale( LC_ALL, "C" ); 1056 setlocale( LC_ALL, "C" );
1050 1057
1064 if( dlg.clickedButton () == saveAsBtn ) 1071 if( dlg.clickedButton () == saveAsBtn )
1065 save (f, true); // yay recursion! 1072 save (f, true); // yay recursion!
1066 } 1073 }
1067 } 1074 }
1068 1075
1076 void ForgeWindow::addMessage( str msg )
1077 {
1078 m_msglog->addLine( msg );
1079 }
1080
1069 // ============================================================================ 1081 // ============================================================================
1070 void ObjectList::contextMenuEvent (QContextMenuEvent* ev) { 1082 void ObjectList::contextMenuEvent (QContextMenuEvent* ev) {
1071 g_win->spawnContextMenu (ev->globalPos ()); 1083 g_win->spawnContextMenu (ev->globalPos ());
1072 } 1084 }
1073 1085
1090 1102
1091 // ============================================================================= 1103 // =============================================================================
1092 void critical (str msg) { 1104 void critical (str msg) {
1093 QMessageBox::critical (g_win, QObject::tr( "Error" ), msg, 1105 QMessageBox::critical (g_win, QObject::tr( "Error" ), msg,
1094 (QMessageBox::Close), QMessageBox::Close); 1106 (QMessageBox::Close), QMessageBox::Close);
1095 }
1096
1097 // =============================================================================
1098 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
1099 // =============================================================================
1100 // Print to message log
1101 // TODO: I don't think that the message log being a widget in the window
1102 // is a very good idea... maybe this should log into the renderer? Or into
1103 // another dialog that can be popped up?
1104 void ForgeWindow::logVA (LogType type, const char* fmtstr, va_list va) {
1105 (void) type;
1106 (void) fmtstr;
1107 (void) va;
1108 } 1107 }
1109 1108
1110 // ============================================================================= 1109 // =============================================================================
1111 QAction* findAction (str name) { 1110 QAction* findAction (str name) {
1112 for (actionmeta& meta : g_actionMeta) { 1111 for (actionmeta& meta : g_actionMeta) {

mercurial