Changeset 6043
- Timestamp:
- 01/14/08 09:41:27 (10 months ago)
- Location:
- branches/qt-gui_qt4/src/core
- Files:
-
- 4 modified
-
licqgui.cpp (modified) (4 diffs)
-
licqgui.h (modified) (2 diffs)
-
mainwin.cpp (modified) (19 diffs)
-
mainwin.h (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/qt-gui_qt4/src/core/licqgui.cpp
r6001 r6043 240 240 241 241 // QLocale::system() uses LC_ALL, LC_NUMERIC and LANG (in that 242 // order) when det meningsystem locale. We want LC_MESSAGES instead242 // order) when determines system locale. We want LC_MESSAGES instead 243 243 // of LC_NUMERIC so we have to do it ourselves. 244 244 #ifdef Q_OS_UNIX … … 365 365 Config::Skin::active()->setFrameStyle(skinFrameStyle); 366 366 Config::Skin::active()->setFrameTransparent(skinFrameTransparent); 367 368 // Get saved position and size for mainwin369 licqConf.SetSection("geometry");370 unsigned short xPos, yPos, hVal, wVal;371 licqConf.ReadNum("x", xPos, 100);372 licqConf.ReadNum("y", yPos, 100);373 licqConf.ReadNum("h", hVal, 400);374 licqConf.ReadNum("w", wVal, 150);375 gLog.Info("%sGeometry configuration (%d, %d) (%d x %d)\n", L_INITxSTR,376 xPos, yPos, wVal, hVal);377 if (yPos > QApplication::desktop()->height() - 16)378 yPos = 0;379 if (xPos > QApplication::desktop()->width() - 16)380 xPos = 0;381 myMainwinRect.setRect(xPos, yPos, wVal, hVal);382 367 } 383 368 … … 415 400 void LicqGui::saveConfig() 416 401 { 417 // Tell the daemon to save it 's options402 // Tell the daemon to save its options 418 403 myLicqDaemon->SaveConf(); 419 404 … … 525 510 #endif /* defined(USE_SCRNSAVER) */ 526 511 527 myMainWindow = new MainWindow(myStartHidden , myMainwinRect);512 myMainWindow = new MainWindow(myStartHidden); 528 513 529 514 loadFloatiesConfig(); -
branches/qt-gui_qt4/src/core/licqgui.h
r5945 r6043 30 30 31 31 #include <QList> 32 #include <QRect>33 32 #include <QStringList> 34 33 #include <QTimer> … … 262 261 QString myIcons; 263 262 QString myExtendedIcons; 264 QRect myMainwinRect;265 263 266 264 bool myStartHidden; -
branches/qt-gui_qt4/src/core/mainwin.cpp
r6032 r6043 114 114 MainWindow* LicqQtGui::gMainWindow = NULL; 115 115 116 MainWindow::MainWindow(bool bStartHidden, Q Rect startRect, QWidget* parent)116 MainWindow::MainWindow(bool bStartHidden, QWidget* parent) 117 117 : QWidget(parent), 118 myInMiniMode(false), 119 myPositionChanges(0) 118 myInMiniMode(false) 120 119 { 121 120 Support::setWidgetProps(this, "MainWindow"); … … 123 122 gMainWindow = this; 124 123 125 connect(qApp, SIGNAL(aboutToQuit()), SLOT(slot_aboutToQuit())); 126 127 connect(Config::General::instance(), 128 SIGNAL(mainwinChanged()), SLOT(updateConfig())); 124 Config::General* conf = Config::General::instance(); 125 126 connect(conf, SIGNAL(mainwinChanged()), SLOT(updateConfig())); 129 127 connect(Config::ContactList::instance(), 130 128 SIGNAL(currentListChanged()), SLOT(updateCurrentGroup())); 131 132 myRealHeight = startRect.height();133 129 134 130 myCaption = "Licq"; … … 180 176 shortcut = new QShortcut(Qt::Key_Delete, this); 181 177 connect(shortcut, SIGNAL(activated()), SLOT(removeUserFromGroup())); 182 183 updateSkin(true);184 connect(Config::Skin::active(), SIGNAL(changed()), SLOT(updateSkin()));185 178 186 179 CreateUserView(); … … 225 218 SLOT(slot_protocolPlugin(unsigned long))); 226 219 220 if (conf->mainwinRect().isValid()) 221 setGeometry(conf->mainwinRect()); 222 else 223 { 224 myUserView->resize(myUserView->sizeHint()); 225 adjustSize(); 226 } 227 updateSkin(); 228 connect(Config::Skin::active(), SIGNAL(changed()), SLOT(updateSkin())); 229 227 230 updateStatus(); 228 231 updateEvents(); 229 232 updateGroups(true); 230 233 231 setGeometry(startRect); 232 setMiniMode(Config::General::instance()->miniMode()); 233 if (!Config::General::instance()->mainwinStartHidden() && !bStartHidden) 234 show(); 234 setMiniMode(conf->miniMode()); 235 setVisible(!conf->mainwinStartHidden() && !bStartHidden); 235 236 236 237 // verify we exist … … 329 330 } 330 331 331 void MainWindow::updateSkin( bool initial)332 void MainWindow::updateSkin() 332 333 { 333 334 Config::Skin* skin = Config::Skin::active(); 335 336 #define CLEAR(elem) \ 337 if ((elem) != NULL) \ 338 { \ 339 delete (elem); \ 340 (elem) = NULL; \ 341 } 334 342 335 343 // Set the background pixmap and mask … … 340 348 clearMask(); 341 349 342 // Group Combo Box343 myUserGroupsBox->applySkin(skin->cmbGroups);344 345 350 // System Button 346 if (mySystemButton != NULL) 347 delete mySystemButton; 348 if (myMenuBar != NULL) 349 delete myMenuBar; 350 351 if (!skin->frame.hasMenuBar) 352 { 353 mySystemButton = new SkinnableButton(skin->btnSys, tr("System"), this); 354 mySystemButton->setMenu(mySystemMenu); 355 myMenuBar = NULL; 356 } 357 else 351 CLEAR(mySystemButton); 352 CLEAR(myMenuBar); 353 354 if (skin->frame.hasMenuBar || 355 skin->btnSys.rect.isNull()) 358 356 { 359 357 #ifdef USE_KDE … … 367 365 myMenuBar->setMinimumWidth(mySystemMenu->width()); 368 366 myMenuBar->show(); 369 mySystemButton = NULL;370 367 skin->AdjustForMenuBar(myMenuBar->height()); 368 } 369 else 370 { 371 mySystemButton = new SkinnableButton(skin->btnSys, tr("System"), this); 372 mySystemButton->setMenu(mySystemMenu); 373 mySystemButton->show(); 371 374 } 372 375 373 376 unsigned minHeight = skin->frame.border.top + skin->frame.border.bottom; 374 377 setMinimumHeight(minHeight); 375 setMaximumHeight(Config::General::instance()->miniMode() ? minHeight : QWIDGETSIZE_MAX); 378 setMaximumHeight(Config::General::instance()->miniMode() ? 379 minHeight : QWIDGETSIZE_MAX); 380 381 // Group Combo Box 382 myUserGroupsBox->applySkin(skin->cmbGroups); 383 myUserGroupsBox->setVisible(!skin->cmbGroups.rect.isNull()); 376 384 377 385 // Message Label 378 delete myMessageField; 379 myMessageField = new SkinnableLabel(skin->lblMsg, mySystemMenu->getGroupMenu(), this); 380 connect(myMessageField, SIGNAL(doubleClicked()), LicqGui::instance(), SLOT(showNextEvent())); 381 myMessageField->setToolTip(tr("Right click - User groups\n" 382 "Double click - Show next message")); 386 CLEAR(myMessageField); 387 if (!skin->lblMsg.rect.isNull()) 388 { 389 myMessageField = new SkinnableLabel(skin->lblMsg, 390 mySystemMenu->getGroupMenu(), this); 391 connect(myMessageField, SIGNAL(doubleClicked()), 392 LicqGui::instance(), SLOT(showNextEvent())); 393 myMessageField->setToolTip(tr("Right click - User groups\n" 394 "Double click - Show next message")); 395 myMessageField->show(); 396 } 383 397 384 398 // Status Label 385 delete myStatusField; 386 myStatusField = new SkinnableLabel(skin->lblStatus, mySystemMenu->getStatusMenu(), this); 387 connect(myStatusField, SIGNAL(doubleClicked()), SLOT(showAwayMsgDlg())); 388 myStatusField->setToolTip(tr("Right click - Status menu\n" 389 "Double click - Set auto response")); 390 391 if (!initial) 392 { 393 resizeEvent(NULL); 394 395 if (mySystemButton != NULL) 396 { 397 if (skin->btnSys.rect.isNull()) 398 mySystemButton->hide(); 399 else 400 mySystemButton->show(); 401 } 402 if (myStatusField != NULL) 403 { 404 if (skin->lblStatus.rect.isNull()) 405 myStatusField->hide(); 406 else 407 myStatusField->show(); 408 } 409 if (myMessageField != NULL) 410 { 411 if (skin->lblMsg.rect.isNull()) 412 myMessageField->hide(); 413 else 414 myMessageField->show(); 415 } 416 if (myUserGroupsBox != NULL) 417 { 418 if (skin->cmbGroups.rect.isNull()) 419 myUserGroupsBox->hide(); 420 else 421 myUserGroupsBox->show(); 422 } 423 if (myMenuBar != NULL) 424 myMenuBar->show(); 425 updateEvents(); 426 updateStatus(); 427 } 399 CLEAR(myStatusField); 400 if (!skin->lblStatus.rect.isNull()) 401 { 402 myStatusField = new SkinnableLabel(skin->lblStatus, 403 mySystemMenu->getStatusMenu(), this); 404 connect(myStatusField, SIGNAL(doubleClicked()), SLOT(showAwayMsgDlg())); 405 myStatusField->setToolTip(tr("Right click - Status menu\n" 406 "Double click - Set auto response")); 407 myStatusField->show(); 408 } 409 410 #undef CLEAR 411 412 // update geometry and contents of the elements 413 resizeEvent(NULL); 414 updateEvents(); 415 updateStatus(); 428 416 } 429 417 … … 443 431 width() - skin->frameWidth(), height() - skin->frameHeight()); 444 432 445 if (!skin->frame.hasMenuBar)446 mySystemMenu->setGeometry(skin->btnSys.borderToRect(this));447 448 // Do this to save the new geometry449 myPositionChanges++;450 451 433 // Resize the background pixmap and mask 452 434 QPixmap pixmap = skin->mainwinPixmap(width(), height()); … … 461 443 setMask(mask); 462 444 463 /* Set geometry of our widgets 464 * Hide the widget if all position values are equal 465 * because this would result in a unusable 1-pixel widget */ 466 if (myUserGroupsBox != NULL) 467 { 468 if (skin->cmbGroups.rect.isNull()) 469 myUserGroupsBox->hide(); 470 else 471 myUserGroupsBox->setGeometry(skin->cmbGroups.borderToRect(this)); 472 } 473 if (myMessageField != NULL) 474 { 475 if (skin->lblMsg.rect.isNull()) 476 myMessageField->hide(); 477 else 478 myMessageField->setGeometry(skin->lblMsg.borderToRect(this)); 479 } 480 if (myStatusField != NULL) 481 { 482 if (skin->lblStatus.rect.isNull()) 483 myStatusField->hide(); 484 else 485 myStatusField->setGeometry(skin->lblStatus.borderToRect(this)); 486 } 487 if (mySystemButton != NULL) 488 { 489 if (skin->btnSys.rect.isNull()) 490 mySystemButton->hide(); 491 else 492 mySystemButton->setGeometry(skin->btnSys.borderToRect(this)); 493 } 494 } 495 496 void MainWindow::moveEvent(QMoveEvent* e) 497 { 445 #define UPDATE(wid, group) \ 446 if ((wid) != NULL) \ 447 (wid)->setGeometry(skin->group.borderToRect(this)); 448 449 // Set geometry of our widgets 450 UPDATE(myUserGroupsBox, cmbGroups); 451 UPDATE(myMessageField, lblMsg); 452 UPDATE(myStatusField, lblStatus); 453 UPDATE(mySystemButton, btnSys) 454 else 455 myMenuBar->resize(contentsRect().width(), myMenuBar->height()); 456 457 #undef UPDATE 458 498 459 if (isVisible()) 499 myPositionChanges++; 500 501 QWidget::moveEvent(e); 460 saveGeometry(); 461 } 462 463 void MainWindow::saveGeometry() 464 { 465 Config::General* conf = Config::General::instance(); 466 QRect geom = geometry(); 467 468 if (myInMiniMode) 469 geom.setHeight(conf->mainwinRect().height()); 470 471 conf->setMainwinRect(geom); 472 } 473 474 void MainWindow::moveEvent(QMoveEvent* /* e */) 475 { 476 saveGeometry(); 502 477 } 503 478 504 479 void MainWindow::closeEvent(QCloseEvent* e) 505 480 { 506 if (isVisible() && myPositionChanges > 1)507 {508 // save window position and size509 char buf[MAX_FILENAME_LEN];510 snprintf(buf, MAX_FILENAME_LEN, "%s%s", BASE_DIR, QTGUI_CONFIGFILE);511 buf[MAX_FILENAME_LEN - 1] = '\0';512 CIniFile licqConf(INI_FxALLOWxCREATE | INI_FxWARN);513 // need some more error checking here...514 licqConf.LoadFile(buf);515 516 licqConf.SetSection("geometry");517 licqConf.WriteNum("x", static_cast<short>(x()));518 licqConf.WriteNum("y", static_cast<short>(y()));519 licqConf.WriteNum("h", Config::General::instance()->miniMode() ?520 static_cast<short>(myRealHeight) :521 static_cast<short>(size().height()));522 licqConf.WriteNum("w", static_cast<short>(size().width()));523 524 licqConf.FlushFile();525 licqConf.CloseFile();526 }527 528 481 e->ignore(); 529 482 … … 725 678 unsigned short nNumUserEvents = ICQUser::getNumUserEvents() - nNumOwnerEvents; 726 679 727 myMessageField->setBold(false); 680 if (myMessageField != NULL) 681 myMessageField->setBold(false); 728 682 QString s, l; 729 683 … … 732 686 s = tr("SysMsg"); 733 687 l = tr("System Message"); 734 if (Config::General::instance()->boldOnMsg()) 688 if (Config::General::instance()->boldOnMsg() && 689 myMessageField != NULL) 735 690 myMessageField->setBold(true); 736 691 szCaption = "* " + myCaption; 737 // myMessageField->setPrependPixmap(IconManager->instance()->iconForEvent(ICQ_MDxSUB_MSG));738 692 } 739 693 else if (nNumUserEvents > 0) … … 741 695 s = tr("%1 msg%2").arg(nNumUserEvents).arg(nNumUserEvents == 1 ? tr(" ") : tr("s")); 742 696 l = tr("%1 message%2").arg(nNumUserEvents).arg(nNumUserEvents == 1 ? tr(" ") : tr("s")); 743 if (Config::General::instance()->boldOnMsg()) 697 if (Config::General::instance()->boldOnMsg() && 698 myMessageField != NULL) 744 699 myMessageField->setBold(true); 745 700 szCaption = "* " + myCaption; 746 // myMessagesField->setPrependPixmap(QPixmap());747 701 } 748 702 else … … 760 714 } 761 715 szCaption = myCaption; 762 // myMessageField->setPrependPixmap(QPixmap()); 763 } 764 if (myMessageField->fontMetrics().width(l) + myMessageField->margin() > myMessageField->width()) 765 myMessageField->setText(s); 766 else 767 myMessageField->setText(l); 768 myMessageField->update(); 716 } 717 769 718 setWindowTitle(szCaption); 719 720 if (myMessageField != NULL) 721 { 722 if (myMessageField->fontMetrics().width(l) + 723 myMessageField->margin() > myMessageField->width()) 724 myMessageField->setText(s); 725 else 726 myMessageField->setText(l); 727 myMessageField->update(); 728 } 770 729 771 730 if (LicqGui::instance()->dockIcon() != NULL) … … 802 761 803 762 // Update the msg label if necessary 804 if (Config::General::instance()->showGroupIfNoMsg() && 763 if (myMessageField != NULL && 764 Config::General::instance()->showGroupIfNoMsg() && 805 765 ICQUser::getNumUserEvents() == 0) 806 766 myMessageField->setText(myUserGroupsBox->currentText()); … … 841 801 void MainWindow::updateStatus(CICQSignal* s) 842 802 { 803 if (LicqGui::instance()->dockIcon() != NULL) 804 LicqGui::instance()->dockIcon()->updateIconStatus(); 805 806 if (myStatusField == NULL) 807 return; 808 843 809 Config::Skin* skin = Config::Skin::active(); 844 810 QColor theColor = skin->offlineColor; … … 939 905 myStatusField->setPalette(pal); 940 906 } 941 942 if (LicqGui::instance()->dockIcon() != NULL)943 LicqGui::instance()->dockIcon()->updateIconStatus();944 907 } 945 908 … … 963 926 } 964 927 965 void MainWindow::slot_aboutToQuit()966 {967 // Empty968 }969 970 928 void MainWindow::slot_logon() 971 929 { 972 930 updateStatus(); 973 //myStatusField->setEnabled(true);974 931 } 975 932 … … 1029 986 return; 1030 987 988 myInMiniMode = miniMode; 989 1031 990 if (miniMode) 1032 {1033 myRealHeight = height();1034 991 setMaximumHeight(minimumHeight()); 1035 }1036 992 else 1037 993 { 1038 994 setMaximumHeight(QWIDGETSIZE_MAX); 1039 resize(width(), myRealHeight); 1040 } 1041 1042 myInMiniMode = miniMode; 995 resize(width(), Config::General::instance()->mainwinRect().height()); 996 } 997 1043 998 if (myUserView != NULL) 1044 999 myUserView->setVisible(!miniMode); … … 1050 1005 1051 1006 #ifdef USE_KDE 1052 kdeIMInterface->removeProtocol(_nPPID);1007 kdeIMInterface->removeProtocol(_nPPID); 1053 1008 #endif 1054 1009 } -
branches/qt-gui_qt4/src/core/mainwin.h
r5824 r6043 76 76 77 77 public: 78 MainWindow(bool bStartHidden, Q Rect startRect, QWidget* parent = 0);78 MainWindow(bool bStartHidden, QWidget* parent = 0); 79 79 virtual ~MainWindow(); 80 80 … … 119 119 QString myCaption; 120 120 bool myInMiniMode; 121 unsigned int myPositionChanges;122 unsigned short myRealHeight;123 121 124 122 int myMouseX; … … 139 137 SkinnableComboBox* myUserGroupsBox; 140 138 139 void saveGeometry(); 140 141 141 private slots: 142 142 void updateConfig(); 143 void updateSkin( bool initial = false);143 void updateSkin(); 144 144 void updateEvents(); 145 145 void updateStatus(CICQSignal* = NULL); … … 151 151 void slot_doneOwnerFcn(ICQEvent*); 152 152 void slot_updateContactList(); 153 void slot_aboutToQuit();154 153 155 154 void addUser(QString id, unsigned long ppid);
