Logo Search packages:      
Sourcecode: kbib version File versions  Download package

kbibcheckkeydlg.cpp

/***************************************************************************
                          kbibcheckkeydlg.cpp  -  description
                             -------------------
    begin                : Sat Jul 5 2003
    copyright            : (C) 2003 by Thach Nguyen
    email                : thach@dragon.thach.com
 ***************************************************************************/

/***************************************************************************
 *                                                                         *
 *   This program is free software; you can redistribute it and/or modify  *
 *   it under the terms of the GNU General Public License as published by  *
 *   the Free Software Foundation; either version 2 of the License, or     *
 *   (at your option) any later version.                                   *
 *                                                                         *
 ***************************************************************************/

#include "kbibcheckkeydlg.h"
#include <qlabel.h>
#include <qvbox.h>
#include <qhbox.h>
#include <qpixmap.h>
#include <qlayout.h>
#include <qsimplerichtext.h>

#include <kapplication.h>
#include <kactivelabel.h>
#include <kiconloader.h>
#include <klocale.h>

KBibCheckKeyDlg::KBibCheckKeyDlg(QString msg, QWidget *parent, const char *name, WFlags f )
                : KDialogBase(Plain, i18n("Checking Key: Error"), User1|User2|User3|Cancel, User1, parent,name, f, false,
                              KGuiItem("Let KBib fix it"), KGuiItem("Let me fix it"), KGuiItem("Ignore") )
{
        userCode = 0;

        QPixmap ret = KApplication::kApplication()->iconLoader()->loadIcon("messagebox_critical", KIcon::NoGroup, KIcon::SizeMedium, KIcon::DefaultState, 0, true);

        //    QVBox *topcontents = new QVBox (this);
        //    topcontents->setSpacing(KDialog::spacingHint()*2);
        //    topcontents->setMargin(KDialog::marginHint());

        //    QWidget *contents = new QWidget(topcontents);

        //    QHBoxLayout * lay = new QHBoxLayout(contents);
        //    lay->setSpacing(KDialog::spacingHint()*2);


        //    QSplitter* vbox = new QSplitter(this);
        //    vbox->setOrientation(Horizontal);

        //    QLabel *lab1 = new QLabel(vbox);
        //    lab1->setPixmap(ret);
        //    lay->addWidget( lab1, 0, Qt::AlignCenter );
        //    lay->addSpacing(KDialog::spacingHint());



        QLabel* msgLabel = new QLabel(msg, this);
        //    this->setFixedWidth (400);
        msgLabel->setGeometry(QRect(40, 20, 360, 150 ));
        //    msgLabel->setText(msg);
        //    msgLabel->setFixedWidth (360);
        msgLabel->setMinimumWidth(360);
        msgLabel->adjustSize();

        //    lay->addWidget(msgLabel);




        int h = msgLabel->height();
        ;
        int w = msgLabel->width();

        //     this->setGeometry(QRect(200, 200, w + 100, h+100));
        this->setFixedSize(w+60, h+100);
        //  this->setFixedSize(400, 400);
        //  this->setMainWidget(topcontents);

        this->repaint();

        //   connect(this, SIGNAL(cancelClicked()), this, SLOT(slotCancelClick() ) );




        /*
         
          QVBox *topcontents = new QVBox (this);
          topcontents->setSpacing(KDialog::spacingHint()*2);
          topcontents->setMargin(KDialog::marginHint());
          QWidget *contents = new QWidget(topcontents);
          QHBoxLayout * lay = new QHBoxLayout(contents);
          lay->setSpacing(KDialog::spacingHint()*2);
         
          QLabel *label1 = new QLabel( contents);
          label1->setPixmap(ret);
          lay->addWidget( label1, 0, Qt::AlignCenter );
          lay->addSpacing(KDialog::spacingHint());
         
          int pref_width = 0;
          int pref_height = 0;
          // Calculate a proper size for the text.
          {
            QSimpleRichText rt(msg, this->font());
            int scr = QApplication::desktop()->screenNumber(this);
         
            pref_width = QApplication::desktop()->screenGeometry(scr).width() / 3;
            rt.setWidth(pref_width);
            int used_width = rt.widthUsed();
            pref_height = rt.height();
            if (used_width <= pref_width)
            {
               while(true)
                  {
                    int new_width = (used_width * 9) / 10;
                    rt.setWidth(new_width);
                   int new_height = rt.height();
                    if (new_height > pref_height)
                        break;
                    used_width = rt.widthUsed();
                    if (used_width > new_width)
                        break;
                  }
                  pref_width = used_width;
            }
            else
            {
              if (used_width > (pref_width *2))
                pref_width = pref_width *2;
              else
                pref_width = used_width;
            }
          }
          KActiveLabel *label2 = new KActiveLabel("This si a fdsa fds test \n mang trong kong nfsa hgj caiu gi", contents );
        //  QLabel *label2 = new QLabel(msg, contents);
          // We add 10 pixels extra to compensate for some KActiveLabel margins.
          // TODO: find out why this is 10.
        //  label2->setFixedSize(QSize(pref_width+10, pref_height));
          label2->setFixedSize(QSize(400, 400));
        //  label2->adjustSize();
          lay->addWidget( label2 );
         
         
          this->setMainWidget(topcontents);
          this->enableButtonSeparator(false);
          this->repaint();
        //  this->disableResize();
         
         
        */




}
KBibCheckKeyDlg::~KBibCheckKeyDlg()
{}

/** No descriptions */
00162 void KBibCheckKeyDlg::slotUser3( )
{
        this->hide();
        userCode = 3;
}
/** No descriptions */
00168 void KBibCheckKeyDlg::slotUser2( )
{
        this->hide();
        userCode = 2;
}
/** No descriptions */
00174 void KBibCheckKeyDlg::slotUser1( )
{
        this->hide();
        userCode = 1;
}
/** No descriptions */
00180 void KBibCheckKeyDlg::slotCancel()
{
        this->hide();
        userCode = 0;
}
/** No descriptions */
00186 int KBibCheckKeyDlg::getUserCode()
{
        return userCode;
}

Generated by  Doxygen 1.6.0   Back to index