Changeset 6172 for trunk/qt-gui

Show
Ignore:
Timestamp:
04/27/08 22:21:04 (7 months ago)
Author:
flynd
Message:

Save mainwin position when saving settings or exiting licq. Not just when closing window.

Location:
trunk/qt-gui/src
Files:
2 modified

Legend:

Unmodified
Added
Removed
  • trunk/qt-gui/src/mainwin.cpp

    r6169 r6172  
    344344  licqSigMan = theSigMan; 
    345345  licqLogWindow = theLogWindow; 
    346   positionChanges = 0; 
     346  positionChanges = false; 
    347347  m_szUserMenuId = 0; 
    348348  m_nProtoNum = 0; 
     
    11211121 
    11221122  // Do this to save the new geometry 
    1123   positionChanges++; 
     1123  positionChanges = true; 
    11241124 
    11251125  // Resize the background pixmap and mask 
     
    11771177void CMainWindow::moveEvent(QMoveEvent* e) 
    11781178{ 
    1179   if(isVisible())  positionChanges++; 
     1179  if (isVisible()) 
     1180    positionChanges = true; 
    11801181 
    11811182  QWidget::moveEvent(e); 
     
    11841185void CMainWindow::closeEvent( QCloseEvent *e ) 
    11851186{ 
    1186 #if 0 
    1187     qDebug("closeEvent() visible %d", isVisible()); 
    1188     qDebug("geometry: x: %d y: %d, w: %d, h: %d", geometry().x(), geometry().y(), geometry().width(), geometry().height()); 
    1189     qDebug("x: %d, y: %d, w: %d, h: %d", x(), y(), size().width(), size().height()); 
    1190     qDebug(" toGlobal: x %d, y %d", mapToGlobal(QPoint(0,0)).x(), mapToGlobal(QPoint(0,0)).y()); 
    1191 #endif 
    1192  
    1193   if(isVisible() && positionChanges > 1) 
    1194   { 
    1195     // save window position and size 
    1196     char buf[MAX_FILENAME_LEN]; 
    1197     snprintf(buf, MAX_FILENAME_LEN, "%s/" QTGUI_CONFIGFILE, BASE_DIR); 
    1198     buf[MAX_FILENAME_LEN - 1] = '\0'; 
    1199     CIniFile licqConf(INI_FxALLOWxCREATE | INI_FxWARN); 
    1200     // need some more error checking here... 
    1201     licqConf.LoadFile(buf); 
    1202  
    1203     licqConf.SetSection("geometry"); 
    1204     // I'm not sure if we should really test for negative values... 
    1205     licqConf.WriteNum("x", static_cast<short>(x())); 
    1206     licqConf.WriteNum("y", static_cast<short>(y())); 
    1207     licqConf.WriteNum("h", (unsigned short)(size().height() < 0 ? 0 : (m_bInMiniMode ? m_nRealHeight : size().height()))); 
    1208     licqConf.WriteNum("w", (unsigned short)(size().width() < 0 ? 0 : size().width())); 
    1209  
    1210 #if 0 
    1211     licqConf.SetSection("floaties"); 
    1212     licqConf.WriteNum("Num", (unsigned short)CUserView::floaties->size()); 
    1213     unsigned short i = 0; 
    1214     char key[32]; 
    1215     for (; i < CUserView::floaties->size(); ) 
    1216     { 
    1217       CUserView* iter = CUserView::floaties->at(i); 
    1218       sprintf(key, "Floaty%d.Ppid", i); 
    1219       licqConf.WriteNum(key, static_cast<CUserViewItem*>(iter->firstChild())->ItemPPID()); 
    1220       sprintf(key, "Floaty%d.Uin", i); 
    1221       licqConf.WriteStr(key, static_cast<CUserViewItem*>(iter->firstChild())->ItemId()); 
    1222       sprintf(key, "Floaty%d.X", i); 
    1223       licqConf.WriteNum(key, (unsigned short)(iter->x() > 0 ? iter->x() : 0)); 
    1224       sprintf(key, "Floaty%d.Y", i); 
    1225       licqConf.WriteNum(key, (unsigned short)(iter->y() > 0 ? iter->y() : 0)); 
    1226       sprintf(key, "Floaty%d.W", i); 
    1227       licqConf.WriteNum(key, (unsigned short)iter->width()); 
    1228       i++; 
    1229     } 
    1230 #endif 
    1231  
    1232     licqConf.FlushFile(); 
    1233     licqConf.CloseFile(); 
    1234   } 
    1235  
    12361187  if (licqIcon != NULL) 
    12371188  { 
     
    29242875void CMainWindow::slot_shutdown() 
    29252876{ 
     2877  if (isVisible() && positionChanges) 
     2878  { 
     2879    // save window position and size 
     2880    char buf[MAX_FILENAME_LEN]; 
     2881    snprintf(buf, MAX_FILENAME_LEN, "%s/" QTGUI_CONFIGFILE, BASE_DIR); 
     2882    buf[MAX_FILENAME_LEN - 1] = '\0'; 
     2883    CIniFile licqConf(INI_FxALLOWxCREATE | INI_FxWARN); 
     2884    // need some more error checking here... 
     2885    licqConf.LoadFile(buf); 
     2886 
     2887    licqConf.SetSection("geometry"); 
     2888    // I'm not sure if we should really test for negative values... 
     2889    licqConf.WriteNum("x", static_cast<short>(x())); 
     2890    licqConf.WriteNum("y", static_cast<short>(y())); 
     2891    licqConf.WriteNum("h", (unsigned short)(size().height() < 0 ? 0 : (m_bInMiniMode ? m_nRealHeight : size().height()))); 
     2892    licqConf.WriteNum("w", (unsigned short)(size().width() < 0 ? 0 : size().width())); 
     2893 
     2894#if 0 
     2895    licqConf.SetSection("floaties"); 
     2896    licqConf.WriteNum("Num", (unsigned short)CUserView::floaties->size()); 
     2897    unsigned short i = 0; 
     2898    char key[32]; 
     2899    for (; i < CUserView::floaties->size(); ) 
     2900    { 
     2901      CUserView* iter = CUserView::floaties->at(i); 
     2902      sprintf(key, "Floaty%d.Ppid", i); 
     2903      licqConf.WriteNum(key, static_cast<CUserViewItem*>(iter->firstChild())->ItemPPID()); 
     2904      sprintf(key, "Floaty%d.Uin", i); 
     2905      licqConf.WriteStr(key, static_cast<CUserViewItem*>(iter->firstChild())->ItemId()); 
     2906      sprintf(key, "Floaty%d.X", i); 
     2907      licqConf.WriteNum(key, (unsigned short)(iter->x() > 0 ? iter->x() : 0)); 
     2908      sprintf(key, "Floaty%d.Y", i); 
     2909      licqConf.WriteNum(key, (unsigned short)(iter->y() > 0 ? iter->y() : 0)); 
     2910      sprintf(key, "Floaty%d.W", i); 
     2911      licqConf.WriteNum(key, (unsigned short)iter->width()); 
     2912      i++; 
     2913    } 
     2914#endif 
     2915 
     2916    licqConf.FlushFile(); 
     2917    licqConf.CloseFile(); 
     2918  } 
     2919 
    29262920  licqDaemon->Shutdown(); 
    29272921} 
     
    35543548  } 
    35553549 
     3550  licqConf.SetSection("geometry"); 
     3551  licqConf.WriteNum("x", static_cast<short>(x())); 
     3552  licqConf.WriteNum("y", static_cast<short>(y())); 
     3553  licqConf.WriteNum("h", (unsigned short)(size().height() < 0 ? 0 : (m_bInMiniMode ? m_nRealHeight : size().height()))); 
     3554  licqConf.WriteNum("w", (unsigned short)(size().width() < 0 ? 0 : size().width())); 
     3555 
    35563556  licqConf.SetSection("floaties"); 
    35573557  licqConf.WriteNum("Num", (unsigned short)CUserView::floaties->size()); 
  • trunk/qt-gui/src/mainwin.h

    r5944 r6172  
    261261          pmMSNOccupied, pmMSNPrivate, pmMSNAway, pmAIMOnline, pmAIMAway, 
    262262          pmAIMOffline, pmGPGKey, pmGPGKeyEnabled, pmGPGKeyDisabled; 
    263   unsigned int positionChanges; 
     263  bool positionChanges; 
    264264  int m_nProtoNum; 
    265265  char *m_szUserMenuId;