void StyleDialog::drawButtons() { QPixmap pxm(16,14); QMap<QPushButton*, QColor>::iterator it; for (it = colors.begin(); it != colors.end(); ++it) { pxm.fill(it.value()); it.key()->setIcon(pxm); } }
void PeersDialog::setColor() { bool ok; QRgb color = QColorDialog::getRgba(ui.lineEdit->textColor().rgba(), &ok, this); if (ok) { _currentColor = QColor(color); QPixmap pxm(16,16); pxm.fill(_currentColor); ui.colorChatButton->setIcon(pxm); } setFont(); }
/** * Add an item to the GensColorComboBox. * @param color Color. * @param text Text. */ void GensColorComboBox::addItem(const QColor& color, const QString& text) { // Create the icon for this item. // Currently uses the QComboBox's preset icon size. QSize size = this->iconSize(); QPixmap pxm(size); pxm.fill(color); // Draw a black rectangle outline. // TODO: Use a darkened version of the color like Mac OS X's NSColorWell? QPainter painter(&pxm); painter.setPen(QColor(Qt::black)); painter.drawRect(0, 0, size.width()-1, size.height()-1); // Convert the QPixmap to a QIcon and add the item. QIcon icon(pxm); super::addItem(icon, text, color); }
QPixmap qt_glue_widget_rep::render () { QSize s = QSize (w/PIXEL, h/PIXEL); QPixmap pxm(s); //cout << "glue (" << s.width() << "," << s.height() << ")\n"; pxm.fill (Qt::transparent); QPaintDevice *pd = static_cast<QPaintDevice*>(&pxm); if (pd && !pxm.isNull()) { qt_renderer_rep *ren = the_qt_renderer(); ren->begin (pd); rectangle r = rectangle (0, 0, s.width(), s.height()); ren->set_origin(0,0); ren->encode (r->x1, r->y1); ren->encode (r->x2, r->y2); ren->set_clipping (r->x1, r->y2, r->x2, r->y1); if (col == "") { // do nothing } else { if (is_atomic (col)) { color c= named_color (col->label); ren->set_background (c); ren->set_color (c); ren->fill (r->x1, r->y2, r->x2, r->y1); } else { ren->set_shrinking_factor (5); int old_a; tree old_bg= ren->get_background_pattern (old_a); ren->set_background_pattern (col); ren->clear_pattern (5*r->x1, 5*r->y2, 5*r->x2, 5*r->y1); ren->set_background_pattern (old_bg, old_a); ren->set_shrinking_factor (1); } } ren->end(); } return pxm; }
/** * Main. Creates Application window. * * Cleaning up #defines. */ int main(int argc, char** argv) { RS_DEBUG->setLevel(RS_Debug::D_WARNING); RS_DEBUG->print("param 0: %s", argv[0]); QCoreApplication::setApplicationName(XSTR(QC_APPNAME)); #if QT_VERSION < 0x040400 /* No such property in Qt 4.3 */ #else QCoreApplication::setApplicationVersion(XSTR(QC_VERSION)); #endif QApplication app(argc, argv); // for image mime resources from png files // TODO: kinda dirty to call that explicitly // QINITIMAGES_LIBRECAD(); #ifdef RS_SCRIPTING // qInitImages_librecad(); #endif for (int i=0; i<app.argc(); i++) { if (QString("--debug") == app.argv()[i]) { RS_DEBUG->setLevel(RS_Debug::D_DEBUGGING); } } QFileInfo prgInfo( QFile::decodeName(argv[0]) ); QString prgDir(prgInfo.absolutePath()); RS_SETTINGS->init(XSTR(QC_COMPANYKEY), XSTR(QC_APPKEY)); RS_SYSTEM->init(XSTR(QC_APPNAME), XSTR(QC_VERSION), XSTR(QC_APPDIR), prgDir); RS_FileIO::instance()->registerFilter(&( RS_FilterLFF::createFilter)); RS_FileIO::instance()->registerFilter( &(RS_FilterDXFRW::createFilter)); RS_FileIO::instance()->registerFilter( &(RS_FilterCXF::createFilter)); RS_FileIO::instance()->registerFilter( &(RS_FilterJWW::createFilter)); RS_FileIO::instance()->registerFilter( &(RS_FilterDXF1::createFilter)); // parse command line arguments that might not need a launched program: QStringList fileList = handleArgs(argc, argv); QString lang; QString langCmd; QString unit; RS_SETTINGS->beginGroup("/Defaults"); #ifndef QC_PREDEFINED_UNIT unit = RS_SETTINGS->readEntry("/Unit", "Invalid"); #else unit = RS_SETTINGS->readEntry("/Unit", QC_PREDEFINED_UNIT); #endif RS_SETTINGS->endGroup(); // show initial config dialog: if (unit=="Invalid") { RS_DEBUG->print("main: show initial config dialog.."); QG_DlgInitial di(NULL); di.setText("<font size=\"+1\"><b>Welcome to " XSTR(QC_APPNAME) "</b></font>" "<br>" "Please choose the unit you want to use for new drawings and your " "preferred language.<br>" "You can changes these settings later in the " "Options Dialog of " XSTR(QC_APPNAME) "."); QPixmap pxm(":/main/intro_librecad.png"); di.setPixmap(pxm); if (di.exec()) { RS_SETTINGS->beginGroup("/Defaults"); unit = RS_SETTINGS->readEntry("/Unit", "None"); RS_SETTINGS->endGroup(); } RS_DEBUG->print("main: show initial config dialog: OK"); } #ifdef QSPLASHSCREEN_H RS_DEBUG->print("main: splashscreen.."); QPixmap* pixmap = new QPixmap(":/main/splash_librecad.png"); # endif RS_DEBUG->print("main: init fontlist.."); RS_FONTLIST->init(); RS_DEBUG->print("main: init fontlist: OK"); RS_DEBUG->print("main: init patternlist.."); RS_PATTERNLIST->init(); RS_DEBUG->print("main: init patternlist: OK"); RS_DEBUG->print("main: init scriptlist.."); RS_SCRIPTLIST->init(); RS_DEBUG->print("main: init scriptlist: OK"); RS_DEBUG->print("main: loading translation.."); RS_SETTINGS->beginGroup("/Appearance"); #ifdef QC_PREDEFINED_LOCALE lang = RS_SETTINGS->readEntry("/Language", ""); if (lang.isEmpty()) { lang=QC_PREDEFINED_LOCALE; RS_SETTINGS->writeEntry("/Language", lang); } langCmd = RS_SETTINGS->readEntry("/LanguageCmd", ""); if (langCmd.isEmpty()) { langCmd=QC_PREDEFINED_LOCALE; RS_SETTINGS->writeEntry("/LanguageCmd", langCmd); } #else lang = RS_SETTINGS->readEntry("/Language", "en"); langCmd = RS_SETTINGS->readEntry("/LanguageCmd", "en"); #endif RS_SETTINGS->endGroup(); RS_SYSTEM->loadTranslation(lang, langCmd); RS_DEBUG->print("main: loading translation: OK"); #ifdef QSPLASHSCREEN_H splash = new QSplashScreen(*pixmap); splash->show(); splash->showMessage(QObject::tr("Loading.."), Qt::AlignRight|Qt::AlignBottom, QC_SPLASH_TXTCOL); RS_DEBUG->print("main: splashscreen: OK"); #endif //QApplication::setStyle(new QWindowsStyle()); //QApplication::setStyle(new QPlatinumStyle()); #ifdef QC_BUILTIN_STYLE //js: RS_DEBUG->print("main: applying built in style.."); applyBuiltinStyle(); #endif RS_DEBUG->print("main: creating main window.."); QC_ApplicationWindow * appWin = new QC_ApplicationWindow(); RS_DEBUG->print("main: setting caption"); appWin->setWindowTitle(XSTR(QC_APPNAME)); RS_DEBUG->print("main: show main window"); appWin->show(); RS_DEBUG->print("main: set focus"); appWin->setFocus(); RS_DEBUG->print("main: creating main window: OK"); #ifdef QSPLASHSCREEN_H if (splash) { RS_DEBUG->print("main: updating splash.."); splash->showMessage(QObject::tr("Loading..."), Qt::AlignRight|Qt::AlignBottom, QC_SPLASH_TXTCOL); RS_DEBUG->print("main: processing events"); qApp->processEvents(); RS_DEBUG->print("main: updating splash: OK"); } #endif // Set LC_NUMERIC so that enetring numeric values uses . as teh decimal seperator setlocale(LC_NUMERIC, "C"); RS_DEBUG->print("main: loading files.."); bool files_loaded = false; for (QStringList::Iterator it = fileList.begin(); it != fileList.end(); ++it ) { #ifdef QSPLASHSCREEN_H if (splash) { splash->showMessage(QObject::tr("Loading File %1..") .arg(QDir::toNativeSeparators(*it)), Qt::AlignRight|Qt::AlignBottom, QC_SPLASH_TXTCOL); qApp->processEvents(); } #endif appWin->slotFileOpen(*it, RS2::FormatUnknown); files_loaded = true; } RS_DEBUG->print("main: loading files: OK"); #ifdef QSPLASHSCREEN_H # ifndef QC_DELAYED_SPLASH_SCREEN if (splash) { splash->finish(appWin); delete splash; splash = 0; } # endif delete pixmap; #endif //app.connect(&app, SIGNAL(lastWindowClosed()), &app, SLOT(quit())); RS_DEBUG->print("main: app.exec()"); if (!files_loaded) { appWin->slotFileNewNew(); } appWin->slotRunStartScript(); int r = app.exec(); RS_DEBUG->print("main: Temporary disabled delete appWin"); // delete appWin; RS_DEBUG->print("main: finished"); return r; }
/** * Main. Creates Application window. */ int main(int argc, char** argv) { RS_DEBUG->setLevel(RS_Debug::D_WARNING); QApplication app(argc, argv); QCoreApplication::setOrganizationName("LibreCAD"); QCoreApplication::setApplicationName("LibreCAD"); QCoreApplication::setApplicationVersion(XSTR(LC_VERSION)); QSettings settings; bool first_load = settings.value("Startup/FirstLoad", 1).toBool(); const QString lpDebugSwitch0("-d"),lpDebugSwitch1("--debug") ; const QString help0("-h"), help1("--help"); bool allowOptions=true; QList<int> argClean; for (int i=0; i<argc; i++) { QString argstr(argv[i]); if(allowOptions&&QString::compare("--", argstr)==0) { allowOptions=false; continue; } if (allowOptions && (help0.compare(argstr, Qt::CaseInsensitive)==0 || help1.compare(argstr, Qt::CaseInsensitive)==0 )) { qDebug()<<"librecad::usage: <options> <dxf file>"; qDebug()<<"-h, --help\tdisplay this message"; qDebug()<<""; qDebug()<<" --help\tdisplay this message"; qDebug()<<"-d, --debug <level>"; RS_DEBUG->print( RS_Debug::D_NOTHING, "possible debug levels:"); RS_DEBUG->print( RS_Debug::D_NOTHING, " %d Nothing", RS_Debug::D_NOTHING); RS_DEBUG->print( RS_Debug::D_NOTHING, " %d Critical", RS_Debug::D_CRITICAL); RS_DEBUG->print( RS_Debug::D_NOTHING, " %d Error", RS_Debug::D_ERROR); RS_DEBUG->print( RS_Debug::D_NOTHING, " %d Warning", RS_Debug::D_WARNING); RS_DEBUG->print( RS_Debug::D_NOTHING, " %d Notice", RS_Debug::D_NOTICE); RS_DEBUG->print( RS_Debug::D_NOTHING, " %d Informational", RS_Debug::D_INFORMATIONAL); RS_DEBUG->print( RS_Debug::D_NOTHING, " %d Debugging", RS_Debug::D_DEBUGGING); exit(0); } if ( allowOptions&& (argstr.startsWith(lpDebugSwitch0, Qt::CaseInsensitive) || argstr.startsWith(lpDebugSwitch1, Qt::CaseInsensitive) )) { argClean<<i; // to control the level of debugging output use --debug with level 0-6, e.g. --debug3 // for a list of debug levels use --debug? // if no level follows, the debugging level is set argstr.remove(QRegExp("^"+lpDebugSwitch0)); argstr.remove(QRegExp("^"+lpDebugSwitch1)); char level; if(argstr.size()==0) { if(i+1<argc) { if(QRegExp("\\d*").exactMatch(argv[i+1])) { ++i; qDebug()<<"reading "<<argv[i]<<" as debugging level"; level=argv[i][0]; argClean<<i; } else level='3'; } else level='3'; //default to D_WARNING } else level=argstr.toStdString()[0]; switch(level) { case '?' : RS_DEBUG->print( RS_Debug::D_NOTHING, "possible debug levels:"); RS_DEBUG->print( RS_Debug::D_NOTHING, " %d Nothing", RS_Debug::D_NOTHING); RS_DEBUG->print( RS_Debug::D_NOTHING, " %d Critical", RS_Debug::D_CRITICAL); RS_DEBUG->print( RS_Debug::D_NOTHING, " %d Error", RS_Debug::D_ERROR); RS_DEBUG->print( RS_Debug::D_NOTHING, " %d Warning", RS_Debug::D_WARNING); RS_DEBUG->print( RS_Debug::D_NOTHING, " %d Notice", RS_Debug::D_NOTICE); RS_DEBUG->print( RS_Debug::D_NOTHING, " %d Informational", RS_Debug::D_INFORMATIONAL); RS_DEBUG->print( RS_Debug::D_NOTHING, " %d Debugging", RS_Debug::D_DEBUGGING); return 0; case '0' + RS_Debug::D_NOTHING : RS_DEBUG->setLevel( RS_Debug::D_NOTHING); ++i; break; case '0' + RS_Debug::D_CRITICAL : RS_DEBUG->setLevel( RS_Debug::D_CRITICAL); ++i; break; case '0' + RS_Debug::D_ERROR : RS_DEBUG->setLevel( RS_Debug::D_ERROR); ++i; break; case '0' + RS_Debug::D_WARNING : RS_DEBUG->setLevel( RS_Debug::D_WARNING); ++i; break; case '0' + RS_Debug::D_NOTICE : RS_DEBUG->setLevel( RS_Debug::D_NOTICE); ++i; break; case '0' + RS_Debug::D_INFORMATIONAL : RS_DEBUG->setLevel( RS_Debug::D_INFORMATIONAL); ++i; break; case '0' + RS_Debug::D_DEBUGGING : RS_DEBUG->setLevel( RS_Debug::D_DEBUGGING); ++i; break; default : RS_DEBUG->setLevel(RS_Debug::D_DEBUGGING); break; } } } RS_DEBUG->print("param 0: %s", argv[0]); QFileInfo prgInfo( QFile::decodeName(argv[0]) ); QString prgDir(prgInfo.absolutePath()); RS_SETTINGS->init(app.organizationName(), app.applicationName()); RS_SYSTEM->init(app.applicationName(), app.applicationVersion(), XSTR(QC_APPDIR), prgDir); // parse command line arguments that might not need a launched program: QStringList fileList = handleArgs(argc, argv, argClean); QString unit = settings.value("Defaults/Unit", "Invalid").toString(); // show initial config dialog: if (first_load) { RS_DEBUG->print("main: show initial config dialog.."); QG_DlgInitial di(nullptr); QPixmap pxm(":/main/intro_librecad.png"); di.setPixmap(pxm); if (di.exec()) { RS_SETTINGS->beginGroup("/Defaults"); unit = RS_SETTINGS->readEntry("/Unit", "None"); RS_SETTINGS->endGroup(); } RS_DEBUG->print("main: show initial config dialog: OK"); } auto splash = new QSplashScreen; bool show_splash = settings.value("Startup/ShowSplash", 1).toBool(); if (show_splash) { QPixmap pixmap(":/main/splash_librecad.png"); splash->setPixmap(pixmap); splash->setAttribute(Qt::WA_DeleteOnClose); splash->show(); splash->showMessage(QObject::tr("Loading.."), Qt::AlignRight|Qt::AlignBottom, Qt::black); app.processEvents(); RS_DEBUG->print("main: splashscreen: OK"); } RS_DEBUG->print("main: init fontlist.."); RS_FONTLIST->init(); RS_DEBUG->print("main: init fontlist: OK"); RS_DEBUG->print("main: init patternlist.."); RS_PATTERNLIST->init(); RS_DEBUG->print("main: init patternlist: OK"); RS_DEBUG->print("main: loading translation.."); settings.beginGroup("Appearance"); QString lang = settings.value("Language", "en").toString(); QString langCmd = settings.value("LanguageCmd", "en").toString(); settings.endGroup(); RS_SYSTEM->loadTranslation(lang, langCmd); RS_DEBUG->print("main: loading translation: OK"); RS_DEBUG->print("main: creating main window.."); QC_ApplicationWindow appWin; RS_DEBUG->print("main: setting caption"); appWin.setWindowTitle(app.applicationName()); RS_DEBUG->print("main: show main window"); settings.beginGroup("Geometry"); int windowWidth = settings.value("WindowWidth", 1024).toInt(); int windowHeight = settings.value("WindowHeight", 1024).toInt(); int windowX = settings.value("WindowX", 32).toInt(); int windowY = settings.value("WindowY", 32).toInt(); settings.endGroup(); if (!first_load) appWin.resize(windowWidth, windowHeight); appWin.move(windowX, windowY); bool maximize = settings.value("Startup/Maximize", 0).toBool(); if (maximize || first_load) appWin.showMaximized(); else appWin.show(); RS_DEBUG->print("main: set focus"); appWin.setFocus(); RS_DEBUG->print("main: creating main window: OK"); if (show_splash) { RS_DEBUG->print("main: updating splash"); splash->raise(); splash->showMessage(QObject::tr("Loading..."), Qt::AlignRight|Qt::AlignBottom, Qt::black); RS_DEBUG->print("main: processing events"); qApp->processEvents(); RS_DEBUG->print("main: updating splash: OK"); } // Set LC_NUMERIC so that entering numeric values uses . as the decimal seperator setlocale(LC_NUMERIC, "C"); RS_DEBUG->print("main: loading files.."); bool files_loaded = false; for (QStringList::Iterator it = fileList.begin(); it != fileList.end(); ++it ) { if (show_splash) { splash->showMessage(QObject::tr("Loading File %1..") .arg(QDir::toNativeSeparators(*it)), Qt::AlignRight|Qt::AlignBottom, Qt::black); qApp->processEvents(); } appWin.slotFileOpen(*it, RS2::FormatUnknown); files_loaded = true; } RS_DEBUG->print("main: loading files: OK"); if (!files_loaded) { appWin.slotFileNewNew(); } if (show_splash) splash->finish(&appWin); else delete splash; if (first_load) settings.setValue("Startup/FirstLoad", 0); RS_DEBUG->print("main: entering Qt event loop"); int return_code = app.exec(); RS_DEBUG->print("main: exited Qt event loop"); return return_code; }
/** Constructor */ PeersDialog::PeersDialog(QWidget *parent) : RsAutoUpdatePage(1000,parent), historyKeeper(Rshare::dataDirectory() + "/his1.xml") { /* Invoke the Qt Designer generated object setup routine */ ui.setupUi(this); connect( ui.peertreeWidget, SIGNAL( customContextMenuRequested( QPoint ) ), this, SLOT( peertreeWidgetCostumPopupMenu( QPoint ) ) ); connect( ui.peertreeWidget, SIGNAL( itemDoubleClicked ( QTreeWidgetItem *, int)), this, SLOT(chatfriend())); /* hide the Tree +/- */ ui.peertreeWidget -> setRootIsDecorated( false ); /* Set header resize modes and initial section sizes */ QHeaderView * _header = ui.peertreeWidget->header () ; _header->setResizeMode (0, QHeaderView::Custom); _header->setResizeMode (1, QHeaderView::Interactive); _header->setResizeMode (2, QHeaderView::Interactive); /*_header->setResizeMode (3, QHeaderView::Interactive); _header->setResizeMode (4, QHeaderView::Interactive); _header->setResizeMode (5, QHeaderView::Interactive); _header->setResizeMode (6, QHeaderView::Interactive); _header->setResizeMode (7, QHeaderView::Interactive);*/ _header->resizeSection ( 0, 25 ); _header->resizeSection ( 1, 100 ); _header->resizeSection ( 2, 100 ); /*_header->resizeSection ( 3, 120 ); _header->resizeSection ( 4, 100 ); _header->resizeSection ( 5, 230 ); _header->resizeSection ( 6, 120 ); _header->resizeSection ( 7, 220 );*/ // set header text aligment QTreeWidgetItem * headerItem = ui.peertreeWidget->headerItem(); headerItem->setTextAlignment(0, Qt::AlignHCenter | Qt::AlignVCenter); headerItem->setTextAlignment(1, Qt::AlignHCenter | Qt::AlignVCenter); headerItem->setTextAlignment(2, Qt::AlignHCenter | Qt::AlignVCenter); loadEmoticonsgroupchat(); //setWindowIcon(QIcon(QString(":/images/rstray3.png"))); connect(ui.lineEdit, SIGNAL(textChanged ( ) ), this, SLOT(checkChat( ) )); connect(ui.Sendbtn, SIGNAL(clicked()), this, SLOT(sendMsg())); connect(ui.emoticonBtn, SIGNAL(clicked()), this, SLOT(smileyWidgetgroupchat())); //connect( ui.msgSendList, SIGNAL( customContextMenuRequested( QPoint ) ), this, SLOT( msgSendListCostumPopupMenu( QPoint ) ) ); connect( ui.msgText, SIGNAL(customContextMenuRequested(const QPoint&)), this, SLOT(displayInfoChatMenu(const QPoint&))); connect(ui.textboldChatButton, SIGNAL(clicked()), this, SLOT(setFont())); connect(ui.textunderlineChatButton, SIGNAL(clicked()), this, SLOT(setFont())); connect(ui.textitalicChatButton, SIGNAL(clicked()), this, SLOT(setFont())); connect(ui.fontsButton, SIGNAL(clicked()), this, SLOT(getFont())); connect(ui.colorChatButton, SIGNAL(clicked()), this, SLOT(setColor())); ui.fontsButton->setIcon(QIcon(QString(":/images/fonts.png"))); _currentColor = Qt::black; QPixmap pxm(16,16); pxm.fill(_currentColor); ui.colorChatButton->setIcon(pxm); mCurrentFont = QFont("Comic Sans MS", 12); ui.lineEdit->setFont(mCurrentFont); setChatInfo(tr("Welcome to RetroShare's group chat."), QString::fromUtf8("blue")); QStringList him; historyKeeper.getMessages(him, "", "THIS", 8); foreach(QString mess, him) ui.msgText->append(mess); //setChatInfo(mess, "green"); QMenu * grpchatmenu = new QMenu(); grpchatmenu->addAction(ui.actionClearChat); ui.menuButton->setMenu(grpchatmenu); _underline = false; QTimer *timer = new QTimer(this); timer->connect(timer, SIGNAL(timeout()), this, SLOT(insertChat())); timer->start(500); /* half a second */ ui.peertreeWidget->sortItems( 1, Qt::AscendingOrder ); /* Hide platform specific features */ #ifdef Q_WS_WIN #endif }
/** * Main. Creates Application window. * * Cleaning up #defines. */ int main(int argc, char** argv) { RS_DEBUG->setLevel(RS_Debug::D_WARNING); QCoreApplication::setApplicationName(XSTR(QC_APPNAME)); #if QT_VERSION < 0x040400 /* No such property in Qt 4.3 */ #else QCoreApplication::setApplicationVersion(XSTR(QC_VERSION)); #endif QApplication app(argc, argv); #if defined(Q_OS_MAC) && QT_VERSION > 0x050000 //need stylesheet for Qt5 on mac app.setStyleSheet( "QToolButton:checked" "{" " background-color: rgb(160,160,160);" " border-style: inset;" "}" "" "QToolButton" "{" " background-color: transparent;" "}" "" "QToolButton:hover" "{" " background-color: rgb(255,255,255);" " border-style: outset;" "}" ); #endif // for image mime resources from png files // TODO: kinda dirty to call that explicitly // QINITIMAGES_LIBRECAD(); #ifdef RS_SCRIPTING // qInitImages_librecad(); #endif const QString lpDebugSwitch0("-d"),lpDebugSwitch1("--debug") ; const QString help0("-h"), help1("--help"); bool allowOptions=true; QList<int> argClean; for (int i=0; i<argc; i++) { QString argstr(argv[i]); if(allowOptions&&QString::compare("--", argstr)==0){ allowOptions=false; continue; } if (allowOptions&&( help0.compare(argstr, Qt::CaseInsensitive)==0 || help1.compare(argstr, Qt::CaseInsensitive)==0 ) ){//hep information qDebug()<<"librecad::usage: <options> <dxf file>"; qDebug()<<"-h, --help\tdisplay this message"; qDebug()<<""; qDebug()<<" --help\tdisplay this message"; qDebug()<<"-d, --debug <level>"; RS_DEBUG->print( RS_Debug::D_NOTHING, "possible debug levels:"); RS_DEBUG->print( RS_Debug::D_NOTHING, " %d Nothing", RS_Debug::D_NOTHING); RS_DEBUG->print( RS_Debug::D_NOTHING, " %d Critical", RS_Debug::D_CRITICAL); RS_DEBUG->print( RS_Debug::D_NOTHING, " %d Error", RS_Debug::D_ERROR); RS_DEBUG->print( RS_Debug::D_NOTHING, " %d Warning", RS_Debug::D_WARNING); RS_DEBUG->print( RS_Debug::D_NOTHING, " %d Notice", RS_Debug::D_NOTICE); RS_DEBUG->print( RS_Debug::D_NOTHING, " %d Informational", RS_Debug::D_INFORMATIONAL); RS_DEBUG->print( RS_Debug::D_NOTHING, " %d Debugging", RS_Debug::D_DEBUGGING); exit(0); } if ( allowOptions&& ( argstr.startsWith(lpDebugSwitch0, Qt::CaseInsensitive)|| argstr.startsWith(lpDebugSwitch1, Qt::CaseInsensitive) ) ){ argClean<<i; // to control the level of debugging output use --debug with level 0-6, e.g. --debug3 // for a list of debug levels use --debug? // if no level follows, the debugging level is set argstr.remove(QRegExp("^"+lpDebugSwitch0)); argstr.remove(QRegExp("^"+lpDebugSwitch1)); char level; if(argstr.size()==0){ if(i+1<argc) { if(QRegExp("\\d*").exactMatch(argv[i+1])){ ++i; qDebug()<<"reading "<<argv[i]<<" as debugging level"; level=argv[i][0]; argClean<<i; }else level='3'; }else level='3'; //default to D_WARNING }else level=argstr.toStdString()[0]; // if( strlen( argv[i]) > iDebugSwitchLen) { switch(level) { case '?' : RS_DEBUG->print( RS_Debug::D_NOTHING, "possible debug levels:"); RS_DEBUG->print( RS_Debug::D_NOTHING, " %d Nothing", RS_Debug::D_NOTHING); RS_DEBUG->print( RS_Debug::D_NOTHING, " %d Critical", RS_Debug::D_CRITICAL); RS_DEBUG->print( RS_Debug::D_NOTHING, " %d Error", RS_Debug::D_ERROR); RS_DEBUG->print( RS_Debug::D_NOTHING, " %d Warning", RS_Debug::D_WARNING); RS_DEBUG->print( RS_Debug::D_NOTHING, " %d Notice", RS_Debug::D_NOTICE); RS_DEBUG->print( RS_Debug::D_NOTHING, " %d Informational", RS_Debug::D_INFORMATIONAL); RS_DEBUG->print( RS_Debug::D_NOTHING, " %d Debugging", RS_Debug::D_DEBUGGING); return 0; case '0' + RS_Debug::D_NOTHING : RS_DEBUG->setLevel( RS_Debug::D_NOTHING); ++i; break; case '0' + RS_Debug::D_CRITICAL : RS_DEBUG->setLevel( RS_Debug::D_CRITICAL); ++i; break; case '0' + RS_Debug::D_ERROR : RS_DEBUG->setLevel( RS_Debug::D_ERROR); ++i; break; case '0' + RS_Debug::D_WARNING : RS_DEBUG->setLevel( RS_Debug::D_WARNING); ++i; break; case '0' + RS_Debug::D_NOTICE : RS_DEBUG->setLevel( RS_Debug::D_NOTICE); ++i; break; case '0' + RS_Debug::D_INFORMATIONAL : RS_DEBUG->setLevel( RS_Debug::D_INFORMATIONAL); ++i; break; case '0' + RS_Debug::D_DEBUGGING : RS_DEBUG->setLevel( RS_Debug::D_DEBUGGING); ++i; break; default : RS_DEBUG->setLevel(RS_Debug::D_DEBUGGING); break; } // } // else { // RS_DEBUG->setLevel(RS_Debug::D_DEBUGGING); // } } } RS_DEBUG->print("param 0: %s", argv[0]); QFileInfo prgInfo( QFile::decodeName(argv[0]) ); QString prgDir(prgInfo.absolutePath()); RS_SETTINGS->init(XSTR(QC_COMPANYKEY), XSTR(QC_APPKEY)); RS_SYSTEM->init(XSTR(QC_APPNAME), XSTR(QC_VERSION), XSTR(QC_APPDIR), prgDir); // parse command line arguments that might not need a launched program: QStringList fileList = handleArgs(argc, argv, argClean); QString lang; QString langCmd; QString unit; RS_SETTINGS->beginGroup("/Defaults"); #ifndef QC_PREDEFINED_UNIT unit = RS_SETTINGS->readEntry("/Unit", "Invalid"); #else unit = RS_SETTINGS->readEntry("/Unit", QC_PREDEFINED_UNIT); #endif RS_SETTINGS->endGroup(); // show initial config dialog: if (unit=="Invalid") { RS_DEBUG->print("main: show initial config dialog.."); QG_DlgInitial di(NULL); di.setText("<font size=\"+1\"><b>Welcome to " XSTR(QC_APPNAME) "</b></font>" "<br>" "Please choose the unit you want to use for new drawings and your " "preferred language.<br>" "You can changes these settings later in the " "Options Dialog of " XSTR(QC_APPNAME) "."); QPixmap pxm(":/main/intro_librecad.png"); di.setPixmap(pxm); if (di.exec()) { RS_SETTINGS->beginGroup("/Defaults"); unit = RS_SETTINGS->readEntry("/Unit", "None"); RS_SETTINGS->endGroup(); } RS_DEBUG->print("main: show initial config dialog: OK"); } #ifdef QSPLASHSCREEN_H // RS_DEBUG->print("main: splashscreen.."); QPixmap* pixmap = new QPixmap(":/main/splash_librecad.png"); #endif RS_DEBUG->print("main: init fontlist.."); RS_FONTLIST->init(); RS_DEBUG->print("main: init fontlist: OK"); RS_DEBUG->print("main: init patternlist.."); RS_PATTERNLIST->init(); RS_DEBUG->print("main: init patternlist: OK"); RS_DEBUG->print("main: init scriptlist.."); RS_SCRIPTLIST->init(); RS_DEBUG->print("main: init scriptlist: OK"); RS_DEBUG->print("main: loading translation.."); RS_SETTINGS->beginGroup("/Appearance"); #ifdef QC_PREDEFINED_LOCALE lang = RS_SETTINGS->readEntry("/Language", ""); if (lang.isEmpty()) { lang=QC_PREDEFINED_LOCALE; RS_SETTINGS->writeEntry("/Language", lang); } langCmd = RS_SETTINGS->readEntry("/LanguageCmd", ""); if (langCmd.isEmpty()) { langCmd=QC_PREDEFINED_LOCALE; RS_SETTINGS->writeEntry("/LanguageCmd", langCmd); } #else lang = RS_SETTINGS->readEntry("/Language", "en"); langCmd = RS_SETTINGS->readEntry("/LanguageCmd", "en"); #endif RS_SETTINGS->endGroup(); RS_SYSTEM->loadTranslation(lang, langCmd); RS_DEBUG->print("main: loading translation: OK"); #ifdef QSPLASHSCREEN_H RS_SETTINGS->beginGroup("Appearance"); { bool showSplash=RS_SETTINGS->readNumEntry("/ShowSplash",1)==1; if(showSplash){ splash = new QSplashScreen(*pixmap); splash->show(); splash->showMessage(QObject::tr("Loading.."), Qt::AlignRight|Qt::AlignBottom, QC_SPLASH_TXTCOL); RS_DEBUG->print("main: splashscreen: OK"); } } RS_SETTINGS->endGroup(); #endif //QApplication::setStyle(new QWindowsStyle()); //QApplication::setStyle(new QPlatinumStyle()); #ifdef QC_BUILTIN_STYLE //js: RS_DEBUG->print("main: applying built in style.."); applyBuiltinStyle(); #endif RS_DEBUG->print("main: creating main window.."); QC_ApplicationWindow * appWin = new QC_ApplicationWindow(); RS_DEBUG->print("main: setting caption"); appWin->setWindowTitle(XSTR(QC_APPNAME)); RS_DEBUG->print("main: show main window"); appWin->show(); RS_DEBUG->print("main: set focus"); appWin->setFocus(); RS_DEBUG->print("main: creating main window: OK"); #ifdef QSPLASHSCREEN_H if (splash) { RS_DEBUG->print("main: updating splash.."); splash->showMessage(QObject::tr("Loading..."), Qt::AlignRight|Qt::AlignBottom, QC_SPLASH_TXTCOL); RS_DEBUG->print("main: processing events"); qApp->processEvents(); RS_DEBUG->print("main: updating splash: OK"); } #endif // Set LC_NUMERIC so that enetring numeric values uses . as teh decimal seperator setlocale(LC_NUMERIC, "C"); RS_DEBUG->print("main: loading files.."); bool files_loaded = false; for (QStringList::Iterator it = fileList.begin(); it != fileList.end(); ++it ) { #ifdef QSPLASHSCREEN_H if (splash) { splash->showMessage(QObject::tr("Loading File %1..") .arg(QDir::toNativeSeparators(*it)), Qt::AlignRight|Qt::AlignBottom, QC_SPLASH_TXTCOL); qApp->processEvents(); } #endif appWin->slotFileOpen(*it, RS2::FormatUnknown); files_loaded = true; } RS_DEBUG->print("main: loading files: OK"); #ifdef QSPLASHSCREEN_H # ifndef QC_DELAYED_SPLASH_SCREEN if (splash) { splash->finish(appWin); delete splash; splash = nullptr; } # endif delete pixmap; #endif //app.connect(&app, SIGNAL(lastWindowClosed()), &app, SLOT(quit())); RS_DEBUG->print("main: app.exec()"); if (!files_loaded) { appWin->slotFileNewNew(); } appWin->slotRunStartScript(); int r = app.exec(); RS_DEBUG->print("main: Temporary disabled delete appWin"); // delete appWin; RS_DEBUG->print("main: finished"); return r; }
void NewTag::showColor(QRgb color) { QPixmap pxm(16,16); pxm.fill(QColor(color)); ui.colorButton->setIcon(pxm); }
void FriendsDialog::colorChanged() { QPixmap pxm(16,16); pxm.fill(mCurrentColor); ui.colorChatButton->setIcon(pxm); }