Ejemplo n.º 1
0
int main(int argc, char *argv[])
{
    bool hasTouchScreen = QFile::exists("/sys/devices/platform/rpi_ft5406");

    // Unless we have a touch screen, wait for keyboard to appear before displaying anything
    if (!hasTouchScreen)
        KeyDetection::waitForKeyboard();

    int rev = readBoardRevision();

    qDebug() << "Board revision is " << rev;

    int gpioChannel;

    if (rev == 2 || rev == 3)
        gpioChannel = 0;
    else
        gpioChannel = 2;

    QApplication a(argc, argv);
    RightButtonFilter rbf;
    LongPressHandler lph;
    GpioInput gpio(gpioChannel);

    bool runinstaller = false;
    bool gpio_trigger = false;
    bool keyboard_trigger = true;
    bool force_trigger = false;

    QString defaultLang = "en";
    QString defaultKeyboard = "gb";
    QString defaultDisplay = "0";
    QString defaultPartition = "800";

    // Process command-line arguments
    for (int i=1; i<argc; i++)
    {
        // Flag to indicate first boot
        if (strcmp(argv[i], "-runinstaller") == 0)
            runinstaller = true;
        // Enables use of GPIO 3 to force NOOBS to launch by pulling low
        else if (strcmp(argv[i], "-gpiotriggerenable") == 0)
            gpio_trigger = true;
        // Disables use of keyboard to trigger recovery GUI
        else if (strcmp(argv[i], "-keyboardtriggerdisable") == 0)
            keyboard_trigger = false;
        // Forces display of recovery GUI every time
        else if (strcmp(argv[i], "-forcetrigger") == 0)
            force_trigger = true;
        // Allow default language to be specified in commandline
        else if (strcmp(argv[i], "-lang") == 0)
        {
            if (argc > i+1)
                defaultLang = argv[i+1];
        }
        // Allow default keyboard layout to be specified in commandline
        else if (strcmp(argv[i], "-kbdlayout") == 0)
        {
            if (argc > i+1)
                defaultKeyboard = argv[i+1];
        }
        // Allow default display mode to be specified in commandline
        else if (strcmp(argv[i], "-dispmode") == 0)
        {
            if (argc > i+1)
                defaultDisplay = --argv[i+1];
        }
        // Allow default boot partition to be specified in commandline
        else if (strcmp(argv[i], "-partition") == 0)
        {
            if (argc > i+1)
                defaultPartition = argv[i+1];
        }
    }

    // Intercept right mouse clicks sent to the title bar
    a.installEventFilter(&rbf);

    // Treat long holds as double-clicks
    if (hasTouchScreen)
        a.installEventFilter(&lph);

#ifdef Q_WS_QWS
    QWSServer::setCursorVisible(false);
#endif

    QDir settingsdir;
    settingsdir.mkdir("/settings");

    // Set wallpaper and icon, if we have resource files for that
    if (QFile::exists(":/icons/raspberry_icon.png"))
        a.setWindowIcon(QIcon(":/icons/raspberry_icon.png"));

#ifdef Q_WS_QWS
    QWSServer::setBackground(BACKGROUND_COLOR);
#endif
    QSplashScreen *splash = new QSplashScreen(QPixmap(":/wallpaper.png"));
    splash->show();
    QApplication::processEvents();

    // Wait for drive device to show up
    QString drive;
    bool driveReady = false;
    QTime t;
    t.start();

    while (t.elapsed() < 10000)
    {
        if (drive.isEmpty())
        {
            /* We do not know the exact drive name to wait for */
            drive = findRecoveryDrive();
            if (!drive.isEmpty())
            {
                driveReady = true;
                break;
            }
        }
        else if (drive.startsWith("/dev"))
        {
            if (QFile::exists(drive))
            {
                driveReady = true;
                break;
            }
        }

        QApplication::processEvents(QEventLoop::WaitForMoreEvents, 100);
    }
    if (!driveReady)
    {
        QMessageBox::critical(NULL, "Files not found", QString("Cannot find the drive with NOOBS files %1").arg(drive), QMessageBox::Close);
        return 1;
    }
    qDebug() << "NOOBS drive:" << drive;

    // If -runinstaller is not specified, only continue if SHIFT is pressed, GPIO is triggered,
    // or no OS is installed (/settings/installed_os.json does not exist)
    bool bailout = !runinstaller
        && !force_trigger
        && !(gpio_trigger && (gpio.value() == 0 ))
        && hasInstalledOS(drive);

    if (bailout && keyboard_trigger)
    {
        t.start();

        while (t.elapsed() < 2000)
        {
            QApplication::processEvents(QEventLoop::WaitForMoreEvents, 10);
            if (QApplication::queryKeyboardModifiers().testFlag(Qt::ShiftModifier))
            {
                bailout = false;
                qDebug() << "Shift detected";
                break;
            }
            if (hasTouchScreen && QApplication::mouseButtons().testFlag(Qt::LeftButton))
            {
                bailout = false;
                qDebug() << "Tap detected";
                break;
            }
        }
    }

    if (bailout)
    {
        splash->hide();
        showBootMenu(drive, defaultPartition, true);
    }

#ifdef Q_WS_QWS
    QWSServer::setCursorVisible(true);
#endif

    // Main window in the middle of screen
    MainWindow mw(drive, defaultDisplay, splash);
    mw.setGeometry(QStyle::alignedRect(Qt::LeftToRight, Qt::AlignCenter, mw.size(), a.desktop()->availableGeometry()));
    mw.show();

#ifdef ENABLE_LANGUAGE_CHOOSER
     // Language chooser at the bottom center
    LanguageDialog* ld = new LanguageDialog(defaultLang, defaultKeyboard);
    ld->setGeometry(QStyle::alignedRect(Qt::LeftToRight, Qt::AlignHCenter | Qt::AlignBottom, ld->size(), a.desktop()->availableGeometry()));
    ld->show();
#endif

    a.exec();
    showBootMenu(drive, defaultPartition, false);

    return 0;
}
Ejemplo n.º 2
0
void SystemActions::generateActions(const std::vector<int> & actions)
{
    category()->setText(QCoreApplication::tr("System"));
    actions_.clear();

    std::vector<int> all = actions;
    if (all.size() <= 0)
    {
        all.push_back(ROTATE_SCREEN);
        all.push_back(SCREEN_UPDATE_TYPE);
        all.push_back(MUSIC);

#ifdef BUILD_WITH_TFT
        all.push_back(BACKLIGHT_BRIGHTNESS);
#endif
        if (sys::isIRTouch())
        {
            all.push_back(SYSTEM_VOLUME);
        }
        all.push_back(RETURN_TO_LIBRARY);
    }

    for(int i = 0; i < static_cast<int>(all.size()); ++i)
    {
        switch (all[i])
        {
        case ROTATE_SCREEN:
        {
            shared_ptr<QAction> rotate(new QAction(exclusiveGroup()));
            rotate->setCheckable(true);
            rotate->setText(QCoreApplication::tr("Rotate Screen"));
            rotate->setIcon(QIcon(QPixmap(":/images/screen_rotation.png")));
            rotate->setData(ROTATE_SCREEN);
            actions_.push_back(rotate);
            break;
        }
        case SCREEN_UPDATE_TYPE:
        {
            // Screen update type.
            shared_ptr<QAction> screen(new QAction(exclusiveGroup()));
            screen->setCheckable(true);
            if (onyx::screen::instance().defaultWaveform() == onyx::screen::ScreenProxy::GC)
            {
                screen->setText(QCoreApplication::tr("Full Refresh Off"));
                screen->setIcon(QIcon(QPixmap(":/images/fast_update.png")));
            }
            else
            {
                screen->setText(QCoreApplication::tr("Full Refresh On"));
                screen->setIcon(QIcon(QPixmap(":/images/full_update.png")));
            }
            screen->setData(SCREEN_UPDATE_TYPE);
            actions_.push_back(screen);
            break;
        }
        case FULL_SCREEN:
        {
            shared_ptr<QAction> fullScreen(new QAction(exclusiveGroup()));
            fullScreen->setCheckable(true);
            fullScreen->setText(QCoreApplication::tr("Full Screen"));
            fullScreen->setIcon(QIcon(QPixmap(":/images/full_screen.png")));
            fullScreen->setData(FULL_SCREEN);
            actions_.push_back(fullScreen);
            break;
        }
        case EXIT_FULL_SCREEN:
        {
            shared_ptr<QAction> exitFullScreen(new QAction(exclusiveGroup()));
            exitFullScreen->setCheckable(true);
            exitFullScreen->setText(QCoreApplication::tr("Exit Full Screen"));
            exitFullScreen->setIcon(QIcon(QPixmap(
                                              ":/images/exit_full_screen.png")));
            exitFullScreen->setData(EXIT_FULL_SCREEN);
            actions_.push_back(exitFullScreen);
            break;
        }
        case MUSIC:
        {
            if (sys::SystemConfig::isMusicPlayerAvailable())
            {
                // Music.
                shared_ptr<QAction> music(new QAction(exclusiveGroup()));
                music->setCheckable(true);
                music->setText(QCoreApplication::tr("Music"));
                music->setIcon(QIcon(QPixmap(":/images/music.png")));
                music->setData(MUSIC);
                actions_.push_back(music);
            }
            break;
        }
        case SYSTEM_VOLUME:
        {
            // when music and tts both are disabled, do not show volume configure
            bool music_available = sys::SystemConfig::isMusicPlayerAvailable();
            bool disable_tts = qgetenv("DISABLE_TTS").toInt();
            if (!music_available && disable_tts)
            {
                continue;
            }

            // system volume.
            shared_ptr<QAction> volume(new QAction(exclusiveGroup()));
            volume->setCheckable(true);
            volume->setText(QCoreApplication::tr("Volume"));
            volume->setIcon(QIcon(QPixmap(":/images/system_volume.png")));
            volume->setData(SYSTEM_VOLUME);
            actions_.push_back(volume);
            break;
        }
        case RETURN_TO_LIBRARY:
        {
            // Close document.
            shared_ptr<QAction> close(new QAction(exclusiveGroup()));
            close->setCheckable(true);
            close->setText(QCoreApplication::tr("Close"));
            close->setIcon(QIcon(QPixmap(":/images/return_to_library.png")));
            close->setData(RETURN_TO_LIBRARY);
            actions_.push_back(close);
            break;
        }
        case BACKLIGHT_BRIGHTNESS:
        {
            shared_ptr<QAction> br(new QAction(exclusiveGroup()));
            br->setCheckable(true);
            br->setText(QCoreApplication::tr("Brightness"));
            br->setIcon(QIcon(QPixmap(":/images/return_to_library.png")));
            br->setData(BACKLIGHT_BRIGHTNESS);
            actions_.push_back(br);
            break;
        }
        }
    }
}
Ejemplo n.º 3
0
int main(int argc, char *argv[])
{
    QApplication app(argc, argv);

    qInstallMessageHandler(CockatriceLogger);
    if (app.arguments().contains("--debug-output"))
        Logger::getInstance().logToFile(true);

#ifdef Q_OS_WIN
    app.addLibraryPath(app.applicationDirPath() + "/plugins");
#endif

    QCoreApplication::setOrganizationName("Cockatrice");
    QCoreApplication::setOrganizationDomain("cockatrice.de");
    QCoreApplication::setApplicationName("Cockatrice");

#ifdef Q_OS_MAC
    qApp->setAttribute(Qt::AA_DontShowIconsInMenus, true);
#endif

#ifdef Q_OS_MAC
    translationPath = qApp->applicationDirPath() + "/../Resources/translations";
#elif defined(Q_OS_WIN)
    translationPath = qApp->applicationDirPath() + "/translations";
#else // linux
    translationPath = qApp->applicationDirPath() + "/../share/cockatrice/translations";
#endif

    rng = new RNG_SFMT;
    settingsCache = new SettingsCache;
    themeManager = new ThemeManager;
    soundEngine = new SoundEngine;
    db = new CardDatabase;

    qtTranslator = new QTranslator;
    translator = new QTranslator;
    installNewTranslator();

    qsrand(QDateTime::currentDateTime().toTime_t());
    qDebug("main(): starting main program");

    MainWindow ui;
    qDebug("main(): MainWindow constructor finished");

    ui.setWindowIcon(QPixmap("theme:cockatrice"));
    
    settingsCache->setClientID(generateClientID());

    ui.show();
    qDebug("main(): ui.show() finished");

    app.setAttribute(Qt::AA_UseHighDpiPixmaps);
    app.exec();

    qDebug("Event loop finished, terminating...");
    delete db;
    delete settingsCache;
    delete rng;
    PingPixmapGenerator::clear();
    CountryPixmapGenerator::clear();
    UserLevelPixmapGenerator::clear();

    return 0;
}
Ejemplo n.º 4
0
SplashScreen::SplashScreen(const QPixmap &pixmap, Qt::WindowFlags f, bool isTestNet) :
    QSplashScreen(pixmap, f)
{
    setAutoFillBackground(true);

    // set reference point, paddings
    int paddingRight            = 50;
    int paddingTop              = 50;
    int titleVersionVSpace      = 17;
    int titleCopyrightVSpace    = 40;

    float fontFactor            = 1.0;

    // define text to place
    QString titleText       = tr("Mrcoin Core");
    QString versionText     = QString("Version %1").arg(QString::fromStdString(FormatFullVersion()));
    QString copyrightText   = QChar(0xA9)+QString(" 2009-%1 ").arg(COPYRIGHT_YEAR) + QString(tr("The Mrcoin Core developers"));
    QString testnetAddText  = QString(tr("[testnet]")); // define text to place as single text object

    QString font            = "Arial";

    // load the bitmap for writing some text over it
    QPixmap newPixmap;
    if(isTestNet) {
        newPixmap     = QPixmap(":/images/splash_testnet");
    }
    else {
        newPixmap     = QPixmap(":/images/splash");
    }

    QPainter pixPaint(&newPixmap);
    pixPaint.setPen(QColor(100,100,100));

    // check font size and drawing with
    pixPaint.setFont(QFont(font, 33*fontFactor));
    QFontMetrics fm = pixPaint.fontMetrics();
    int titleTextWidth  = fm.width(titleText);
    if(titleTextWidth > 160) {
        // strange font rendering, Arial probably not found
        fontFactor = 0.75;
    }

    pixPaint.setFont(QFont(font, 33*fontFactor));
    fm = pixPaint.fontMetrics();
    titleTextWidth  = fm.width(titleText);
    pixPaint.drawText(newPixmap.width()-titleTextWidth-paddingRight,paddingTop,titleText);

    pixPaint.setFont(QFont(font, 15*fontFactor));

    // if the version string is to long, reduce size
    fm = pixPaint.fontMetrics();
    int versionTextWidth  = fm.width(versionText);
    if(versionTextWidth > titleTextWidth+paddingRight-10) {
        pixPaint.setFont(QFont(font, 10*fontFactor));
        titleVersionVSpace -= 5;
    }
    pixPaint.drawText(newPixmap.width()-titleTextWidth-paddingRight+2,paddingTop+titleVersionVSpace,versionText);

    // draw copyright stuff
    pixPaint.setFont(QFont(font, 10*fontFactor));
    pixPaint.drawText(newPixmap.width()-titleTextWidth-paddingRight,paddingTop+titleCopyrightVSpace,copyrightText);

    // draw testnet string if testnet is on
    if(isTestNet) {
        QFont boldFont = QFont(font, 10*fontFactor);
        boldFont.setWeight(QFont::Bold);
        pixPaint.setFont(boldFont);
        fm = pixPaint.fontMetrics();
        int testnetAddTextWidth  = fm.width(testnetAddText);
        pixPaint.drawText(newPixmap.width()-testnetAddTextWidth-10,15,testnetAddText);
    }

    pixPaint.end();

    this->setPixmap(newPixmap);

    subscribeToCoreSignals();
}
Ejemplo n.º 5
0
MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow)
{
    isStart = false;
    isHexWorkspace = true;

    mAbout = new AboutUi(this);

    threadBuffer = (unsigned char*) malloc(BUFFER_SIZE);
    hexBuffer = (char*) malloc(4000);

    mSerialThread = new SerialThread(threadBuffer,BUFFER_SIZE);

    numberOfCharacter = 0;

    temp.reserve(1000);
    asciiOriginalBuffer.reserve(1000);

    QPixmap pix = QPixmap(":/MainUi/Start.png");
    iconStart = new QIcon(pix);
    pix = QPixmap(":/MainUi/Stop.png");
    iconStop = new QIcon(pix);
    pix = QPixmap(":/MainUi/Ascii.png");
    iconAscii = new QIcon(pix);
    pix = QPixmap(":/MainUi/Hex.png");
    iconHex = new QIcon(pix);
    pix = QPixmap(":/MainUi/DSR_R.png");
    iconDSR_R = new QIcon(pix);
    pix = QPixmap(":/MainUi/DTR_R.png");
    iconDTR_R = new QIcon(pix);
    pix = QPixmap(":/MainUi/RTS_R.png");
    iconRTS_R = new QIcon(pix);
    pix = QPixmap(":/MainUi/CTS_R.png");
    iconCTS_R = new QIcon(pix);
    pix = QPixmap(":/MainUi/DCD_R.png");
    iconDCD_R = new QIcon(pix);
    pix = QPixmap(":/MainUi/RNG_R.png");
    iconRNG_R = new QIcon(pix);
    pix = QPixmap(":/MainUi/DSR_V.png");
    iconDSR_V = new QIcon(pix);
    pix = QPixmap(":/MainUi/DTR_V.png");
    iconDTR_V = new QIcon(pix);
    pix = QPixmap(":/MainUi/RTS_V.png");
    iconRTS_V = new QIcon(pix);
    pix = QPixmap(":/MainUi/CTS_V.png");
    iconCTS_V = new QIcon(pix);
    pix = QPixmap(":/MainUi/DCD_V.png");
    iconDCD_V = new QIcon(pix);
    pix = QPixmap(":/MainUi/RNG_V.png");
    iconRNG_V = new QIcon(pix);

    mSerialPort = new QComboBox;
    Utils::setPortComList(mSerialPort);
    // Setup by setPortComList
    //mSerialPort->setCurrentIndex(0);

    mBaudrate = new QComboBox;
    QStringList baudrate;
    baudrate << tr("230400") << tr("115200") << tr("57600") << tr("56000") << tr("38400") << tr("28800") << tr("19200") << tr("14400") << tr("9600") << tr("4800") << tr("2400") << tr("1200") << tr("600") << tr("300") << tr("110");
    mBaudrate->addItems(baudrate);
    mBaudrate->setCurrentIndex(1);

    mStartStop = new QAction(tr("StartStop"), this);
    mStartStop->setShortcut(tr("Ctrl+Return"));
    mStartStop->setToolTip(tr("Start communication"));
    mStartStop->setStatusTip(tr("Start communication"));
    mStartStop->setWhatsThis(tr("Start communication"));
    mStartStop->setIcon(*iconStart);

    mHexAscii = new QAction(tr("HexAscii"), this);
    mHexAscii->setShortcut(tr("Ctrl+A"));
    mHexAscii->setToolTip(tr("Change to Ascii workspace"));
    mHexAscii->setStatusTip(tr("Change to Ascii workspace"));
    mHexAscii->setWhatsThis(tr("Change to Ascii workspace"));
    mHexAscii->setIcon(*iconAscii);

    mClearButton = new QAction(tr("Clear"), this);
    mClearButton->setShortcut(tr("Ctrl+E"));
    mClearButton->setToolTip(tr("Clean output ascii and hex"));
    mClearButton->setStatusTip(tr("Clean output ascii and hex"));
    mClearButton->setWhatsThis(tr("Clean output ascii and hex"));
    mClearButton->setIcon( QIcon(QPixmap(":/MainUi/Delete.png")));

    mConfigToolbar = addToolBar(tr("Pointer type"));
    mConfigToolbar->addWidget(mSerialPort);
    mConfigToolbar->addWidget(mBaudrate);
    mConfigToolbar->addAction(mStartStop);
    mConfigToolbar->addAction(mHexAscii);
    mConfigToolbar->addAction(mClearButton);

    ui->setupUi(this);

    connect( mStartStop, SIGNAL(triggered() ), this, SLOT(eventStartStop()) );
    connect( mHexAscii, SIGNAL(triggered() ), this, SLOT(eventHexAscii()) );
    connect( mClearButton, SIGNAL(triggered() ), this, SLOT(eventClearButton()) );
    connect( ui->actionQuit, SIGNAL(triggered() ), this, SLOT(eventQuit()) );
    connect( ui->actionAbout, SIGNAL(triggered() ), this, SLOT(eventAbout()) );
    connect( ui->actionSaveInputOutput, SIGNAL(triggered() ), this, SLOT(eventSaveInputOutput()) );
    connect( ui->actionSaveTerminalContent, SIGNAL(triggered() ), this, SLOT(eventSaveTerminalContent()) );
    connect( ui->actionSave_Input_Output, SIGNAL(triggered() ), this, SLOT(eventSaveInputOutput()) );
    connect( ui->actionSave_Terminal_Content, SIGNAL(triggered() ), this, SLOT(eventSaveTerminalContent()) );
    connect( mSerialPort, SIGNAL(currentIndexChanged(const QString &)),this, SLOT(eventSerialPort()));
    connect( mBaudrate, SIGNAL(currentIndexChanged(const QString &)),this, SLOT(eventBaudrate()));
    connect( ui->addOutputFrame, SIGNAL(clicked()), this, SLOT(eventAddOutputFrame()));
    connect( ui->deleteOutputFrame, SIGNAL(clicked()), this, SLOT(eventDeleteOutputFrame()));
    connect( ui->sendOutputFrame, SIGNAL(clicked()), this, SLOT(eventSendOutputFrame()));
    connect( ui->outputTable, SIGNAL(doubleClicked(QModelIndex)), this, SLOT(eventDoubleClickOutputTable(QModelIndex)));
    connect( ui->addOutputFrameHex, SIGNAL(clicked()), this, SLOT(eventAddOutputFrameHex()));
    connect( ui->deleteOutputFrameHex, SIGNAL(clicked()), this, SLOT(eventDeleteOutputFrameHex()));
    connect( ui->sendOutputFrameHex, SIGNAL(clicked()), this, SLOT(eventSendOutputFrameHex()));
    connect( ui->outputTableHex, SIGNAL(doubleClicked(QModelIndex)), this, SLOT(eventDoubleClickOutputTableHex(QModelIndex)));
    connect( ui->directAsciiText, SIGNAL(textChanged(QString)), this, SLOT(eventDirectAsciiChanged(QString)));
    connect( ui->directHexText, SIGNAL(textChanged(QString)), this, SLOT(eventDirectHexChanged(QString)));
    connect( ui->actionSetDTR, SIGNAL(triggered(bool)), this, SLOT(eventSetDTR(bool)));
    connect( ui->actionSetRTS, SIGNAL(triggered(bool)), this, SLOT(eventSetRTS(bool)));

    connect( ui->actionClear_log, SIGNAL(triggered()), this, SLOT(eventClearLog()));
    connect( ui->actionClear_Ascii_Hex_log, SIGNAL(triggered()), this, SLOT(eventClearAsciiHexLog()));
    connect( ui->actionClear_Ascii_log, SIGNAL(triggered()), this, SLOT(eventClearAsciiLog()));
    connect( ui->actionControl_Status, SIGNAL(triggered(bool)), this, SLOT(eventHideControlStatus(bool)));
    connect( ui->actionActivate_Control_Line, SIGNAL(triggered(bool)), this, SLOT(eventActivateControlLine(bool)) );

    connect( ui->actionOutput_Ascii, SIGNAL(triggered(bool)), this, SLOT(eventHideOutputAscii(bool)));
    connect( ui->actionOutput_Hex, SIGNAL(triggered(bool)), this, SLOT(eventHideOutputHex(bool)));
    connect( ui->actionLog, SIGNAL(triggered(bool)), this, SLOT(eventHideLog(bool)));
    connect( ui->actionOpenFrameProject, SIGNAL(triggered()), this, SLOT(eventOpenFrameProject()));

    ui->terminalOutputHex->setVerticalScrollBar(ui->verticalScrollBar);
    ui->terminalOutputAscii->setVerticalScrollBar(ui->verticalScrollBar);

    ui->dockOutputAscii->setFeatures(QDockWidget::DockWidgetMovable | QDockWidget::DockWidgetFloatable);
    ui->dockOutputHex->setFeatures(QDockWidget::DockWidgetMovable | QDockWidget::DockWidgetFloatable);
    ui->dockLog->setFeatures(QDockWidget::DockWidgetMovable | QDockWidget::DockWidgetFloatable);

    QFont font = ui->terminalOutputAscii->font();
#ifdef Q_OS_DARWIN
    font.setPointSize(14);
#else
    font.setPointSize(10);
#endif
    ui->terminalOutputAscii->setFont(font);
    ui->terminalOutputHex->setFont(font);
    ui->terminalOutputAsciiOnly->setFont(font);

    ui->terminalOutputAsciiOnly->setVisible(false);

    if (Settings::getFirstStart()==true)
    {
        ui->dockLog->setVisible(Settings::getLogStatus());
        ui->actionLog->setChecked(Settings::getLogStatus());
        ui->dockOutputAscii->setVisible(Settings::getOutputAsciiStatus());
        ui->actionOutput_Ascii->setChecked(Settings::getOutputAsciiStatus());
        ui->dockOutputHex->setVisible(Settings::getOutputHexStatus());
        ui->actionOutput_Hex->setChecked(Settings::getOutputHexStatus());
        ui->ControlToolBar->setVisible(Settings::getControlStatus());
        ui->actionControl_Status->setChecked(Settings::getControlStatus());
        if (Settings::getTerminalStatus()==true)
        {
            eventHexAscii();
        }
    }
    else
    {
        Settings::setFirstStart(true);
        Settings::setControlStatus(true);
        Settings::setLogStatus(true);
        Settings::setOutputAsciiStatus(true);
        Settings::setOutputHexStatus(true);
        Settings::setTerminalStatus(false);
    }
}
Ejemplo n.º 6
0
QLayout * PageEditTeam::bodyLayoutDefinition()
{
    QGridLayout * pageLayout = new QGridLayout();
    tbw = new QTabWidget();
    QWidget * page1 = new QWidget(this);
    binder = new KeyBinder(this, tr("Select an action to choose a custom key bind for this team"), tr("Use my default"), tr("Reset all binds"));
    connect(binder, SIGNAL(resetAllBinds()), this, SLOT(resetAllBinds()));
    tbw->addTab(page1, tr("General"));
    tbw->addTab(binder, tr("Custom Controls"));
    pageLayout->addWidget(tbw, 0, 0, 1, 3);

    QHBoxLayout * page1Layout = new QHBoxLayout(page1);
    page1Layout->setAlignment(Qt::AlignTop);

// ====== Page 1 ======
    QVBoxLayout * vbox1 = new QVBoxLayout();
    QVBoxLayout * vbox2 = new QVBoxLayout();
    page1Layout->addLayout(vbox1);
    page1Layout->addLayout(vbox2);

    GBoxHedgehogs = new QGroupBox(this);
    GBoxHedgehogs->setTitle(QGroupBox::tr("Team Members"));
    GBoxHedgehogs->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
    QGridLayout * GBHLayout = new QGridLayout(GBoxHedgehogs);


    GBHLayout->addWidget(new QLabel(tr("Hat")), 0, 0);
    GBHLayout->addWidget(new QLabel(tr("Name")), 0, 1);

    for(int i = 0; i < HEDGEHOGS_PER_TEAM; i++)
    {
        HHHats[i] = new HatButton(GBoxHedgehogs);
        GBHLayout->addWidget(HHHats[i], i + 1, 0);

        HHNameEdit[i] = new QLineEdit(GBoxHedgehogs);
        HHNameEdit[i]->setMaxLength(64);
        HHNameEdit[i]->setMinimumWidth(120);
        HHNameEdit[i]->setFixedHeight(36);
        HHNameEdit[i]->setWhatsThis(tr("This hedgehog's name"));
        HHNameEdit[i]->setStyleSheet("padding: 6px;");
        GBHLayout->addWidget(HHNameEdit[i], i + 1, 1);

        btnRandomHogName[i] = addButton(":/res/dice.png", GBHLayout, i + 1, 3, 1, 1, true);
        btnRandomHogName[i]->setFixedHeight(HHNameEdit[i]->height());
        btnRandomHogName[i]->setWhatsThis(tr("Randomize this hedgehog's name"));
    }

    btnRandomTeam = new QPushButton();
    btnRandomTeam->setText(tr("Random Team"));
    btnRandomTeam->setStyleSheet("padding: 6px 10px;");
    GBHLayout->addWidget(btnRandomTeam, 9, 0, 1, 4, Qt::AlignCenter);
    btnRandomTeam->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);

    vbox1->addWidget(GBoxHedgehogs);

    GBoxTeam = new QGroupBox(this);
    GBoxTeam->setTitle(QGroupBox::tr("Team Settings"));
    GBoxTeam->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
    QGridLayout * GBTLayout = new QGridLayout(GBoxTeam);
    QLabel * tmpLabel = new QLabel(GBoxTeam);
    tmpLabel->setText(QLabel::tr("Name"));
    GBTLayout->addWidget(tmpLabel, 0, 0);
    tmpLabel = new QLabel(GBoxTeam);
    tmpLabel->setText(QLabel::tr("Type"));
    GBTLayout->addWidget(tmpLabel, 1, 0);
    tmpLabel = new QLabel(GBoxTeam);
    tmpLabel->setText(QLabel::tr("Grave"));
    GBTLayout->addWidget(tmpLabel, 2, 0);
    tmpLabel = new QLabel(GBoxTeam);
    tmpLabel->setText(QLabel::tr("Flag"));
    GBTLayout->addWidget(tmpLabel, 3, 0);
    tmpLabel = new QLabel(GBoxTeam);
    tmpLabel->setText(QLabel::tr("Voice"));
    GBTLayout->addWidget(tmpLabel, 4, 0);

    TeamNameEdit = new QLineEdit(GBoxTeam);
    TeamNameEdit->setMaxLength(64);
    GBTLayout->addWidget(TeamNameEdit, 0, 1);
    vbox2->addWidget(GBoxTeam);

    CBTeamLvl = new QComboBox(GBoxTeam);
    CBTeamLvl->setIconSize(QSize(48, 48));
    CBTeamLvl->addItem(QIcon(":/res/botlevels/0.png"), QComboBox::tr("Human"));
    for(int i = 5; i > 0; i--)
        CBTeamLvl->addItem(
            QIcon(QString(":/res/botlevels/%1.png").arg(6 - i)),
            QString("%1 %2").arg(QComboBox::tr("Level")).arg(i)
        );
    GBTLayout->addWidget(CBTeamLvl, 1, 1);

    CBGrave = new QComboBox(GBoxTeam);
    CBGrave->setMaxCount(65535);
    CBGrave->setIconSize(QSize(32, 32));
    GBTLayout->addWidget(CBGrave, 2, 1);

    CBFlag = new QComboBox(GBoxTeam);
    CBFlag->setMaxCount(65535);
    CBFlag->setIconSize(QSize(22, 15));
    GBTLayout->addWidget(CBFlag, 3, 1);

    QHBoxLayout * hbox = new QHBoxLayout();
    CBVoicepack = new QComboBox(GBoxTeam);

    hbox->addWidget(CBVoicepack, 100);
    btnTestSound = addSoundlessButton(":/res/PlaySound.png", hbox, 1, true);
    hbox->setStretchFactor(btnTestSound, 1);

    GBTLayout->addLayout(hbox, 4, 1);

    GBoxFort = new QGroupBox(this);
    GBoxFort->setTitle(QGroupBox::tr("Fort"));
    QGridLayout * GBFLayout = new QGridLayout(GBoxFort);
    CBFort = new QComboBox(GBoxFort);
    CBFort->setMaxCount(65535);
    GBFLayout->addWidget(CBFort, 0, 0);
    FortPreview = new SquareLabel(GBoxFort);
    FortPreview->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
    FortPreview->setMinimumSize(128, 128);
    FortPreview->setPixmap(QPixmap());
    // perhaps due to handling its own paintevents, SquareLabel doesn't play nice with the stars
    //FortPreview->setAttribute(Qt::WA_PaintOnScreen, true);
    GBFLayout->addWidget(FortPreview, 1, 0);
    vbox2->addWidget(GBoxFort);

    vbox1->addStretch();
    vbox2->addStretch();

    return pageLayout;
}
Ejemplo n.º 7
0
DwarfClipboard::DwarfClipboard()
{

    setupUi(this);
    createActions();
    createTrayIcon();
    trayIcon->setIcon(QIcon(":/icons/images/DwarfClipboard.png"));
    trayIcon->show();
    setWindowTitle(tr("DwarfClipboard"));
    inputDelay = 100;
    thumbnailSize = 64;
    prevCursor.x = -30000;
    createShortcuts();
    heartbeatTimer = new QTimer(this);
    connectedLabel = new QLabel();
    createConnections();
    recentModel = new DwarfClipboardModel();
    tableViewRecent->setModel(recentModel);
    libraryModel = new DwarfClipboardModel();
    treeViewLibrary->setModel(libraryModel);

    DFMgr = NULL;
    DF = NULL;
    Pos = NULL;

    connected = connectToDF();
    loadConfig();
    thumbnailSizeLineEdit->setText(QString("%1").arg(thumbnailSize));
    inputDelayMsLineEdit->setText(QString("%1").arg(inputDelay));

    tilesetPathButton->setText(DwarfClipboardPng::getTileSetPath());
    colorPathButton->setText(DwarfClipboardPng::getColorPath());

    copyShortcutButton->setText(copyShortcut->shortcut());
    pasteDesignationShortcutButton->setText(pasteDesignationShortcut->shortcut());
    pasteBuildingShortcutButton->setText(pasteBuildingShortcut->shortcut());
    setCursorToPreviousPasteShortcutButton->setText(setCursorToPreviousPasteShortcut->shortcut());
    
    heartbeatTimer->start(1000);

    Ui_MainWindow::statusBar->addPermanentWidget(connectedLabel);
    
    connectedIcon = QPixmap(":/icons/images/connect.png");
    
    //This mess just converts the disconnected icon to look the same as a disabled one
    //It is the same code used in the icon object
    disconnectedIcon = QPixmap(":/icons/images/disconnect.png");
    QStyleOption opt(0);
    opt.palette = QApplication::palette();
    QPixmap generated = QApplication::style()->generatedIconPixmap(QIcon::Disabled, disconnectedIcon, &opt);
    disconnectedIcon = generated;
    loadDirectory();
    loadBuildCommands();
    if(connected){
        connected = false; //this is ugly, but just ensures everything will be set proprly
        setConnected();
    }
    else{
        connected = true;
        setDisconnected();
    }
    setupViews();   
}
void ThemeCreationWizard::onFinished(int status)
{
    if (status == 0)
        return;
    try
    {
        StfsPackage theme(ui->lblSavePath->text().toStdString(), StfsPackageCreate);

        // create a new file
        theme.metaData->magic = CON;
        theme.metaData->certificate.ownerConsoleType = consoleType;
        theme.metaData->certificate.consoleTypeFlags = (ConsoleTypeFlags)0;

        theme.metaData->contentType = Theme;
        theme.metaData->metaDataVersion = 2;
        theme.metaData->titleID = 0xFFFE07D1;

        theme.metaData->displayName = ui->txtName->text().toStdWString();
        theme.metaData->titleName = L"Xbox360 Dashboard";
        theme.metaData->transferFlags = 0x40;

        // set gamerpicture
        QByteArray ba1;
        QBuffer buffer1(&ba1);
        buffer1.open(QIODevice::WriteOnly);
        ui->imgThumbnail->pixmap()->save(&buffer1, "PNG");
        theme.metaData->thumbnailImage = (BYTE*)ba1.data();
        theme.metaData->thumbnailImageSize = ba1.length();

        // set title thumbnail image
        QByteArray ba2;
        QBuffer buffer2(&ba2);
        buffer2.open(QIODevice::WriteOnly);
        QPixmap(":/Images/defaultTitleImage.png").save(&buffer2, "PNG");
        theme.metaData->titleThumbnailImage = (BYTE*)ba2.data();
        theme.metaData->titleThumbnailImageSize = ba2.length();

        theme.metaData->WriteMetaData();
        theme.Rehash();

        // inject the wallpapers
        injectImage(&theme, &wallpaper1, "Wallpaper1");
        injectImage(&theme, &wallpaper2, "Wallpaper2");
        injectImage(&theme, &wallpaper3, "Wallpaper3");
        injectImage(&theme, &wallpaper4, "Wallpaper4");

        // create the parameters.ini file
        QString paramsFilePath = QDir::tempPath() + "/" + QUuid::createUuid().toString().replace("{", "").replace("}", "").replace("-", "");
        QFile params(paramsFilePath);
        params.open(QIODevice::Truncate | QIODevice::WriteOnly);

        // write the correct information to it
        QTextStream txtStream(&params);
        txtStream << "SphereColor=" << ui->cmbxSphereColor->currentIndex() << "\r\nAvatarLightingDirectional=0,0,0,0\r\nAvatarLightingAmbient=0\r\n";

        // close the file
        txtStream.flush();
        params.close();

        // inject the params file to the theme package
        theme.InjectFile(paramsFilePath.toStdString(), "parameters.ini");

        // create the dash style file
        QString dashStyleFilePath = QDir::tempPath() + "/" + QUuid::createUuid().toString().replace("{", "").replace("}", "").replace("-", "");
        FileIO ioD(dashStyleFilePath.toStdString(), true);
        ioD.write((DWORD)0);
        ioD.close();

        // inject the file
        theme.InjectFile(dashStyleFilePath.toStdString(), "DashStyle");

        // fix the package
        theme.Rehash();
        theme.Resign(QtHelpers::GetKVPath(theme.metaData->certificate.ownerConsoleType, this));

        // delete the temp files
        QFile::remove(paramsFilePath);
        QFile::remove(dashStyleFilePath);

        statusBar->showMessage("Theme created successfully", 3000);
    }
    catch (string error)
    {
        QMessageBox::critical(this, "Error", "An error occured while creating the theme.\n\n" + QString::fromStdString(error));
    }
}
Ejemplo n.º 9
0
SplashScreen::SplashScreen(Qt::WindowFlags f, const NetworkStyle *networkStyle) :
    QWidget(0, f), curAlignment(0)
{
    // set reference point, paddings
    int paddingRight            = 50;
    int paddingTop              = 50;
    int titleVersionVSpace      = 17;
    int titleCopyrightVSpace    = 40;

    float fontFactor            = 1.0;
    float devicePixelRatio      = 1.0;
#if QT_VERSION > 0x050100
    devicePixelRatio = ((QGuiApplication*)QCoreApplication::instance())->devicePixelRatio();
#endif

    // define text to place
    QString titleText       = tr("Bitcoin8m Core");
    QString versionText     = QString("Version %1").arg(QString::fromStdString(FormatFullVersion()));
    QString copyrightText   = QChar(0xA9)+QString(" 2009-%1 ").arg(COPYRIGHT_YEAR) + QString(tr("The Bitcoin8m Core developers"));
    QString titleAddText    = networkStyle->getTitleAddText();

    QString font            = QApplication::font().toString();

    // create a bitmap according to device pixelratio
    QSize splashSize(480*devicePixelRatio,320*devicePixelRatio);
    pixmap = QPixmap(splashSize);

#if QT_VERSION > 0x050100
    // change to HiDPI if it makes sense
    pixmap.setDevicePixelRatio(devicePixelRatio);
#endif

    QPainter pixPaint(&pixmap);
    pixPaint.setPen(QColor(100,100,100));

    // draw a slightly radial gradient
    QRadialGradient gradient(QPoint(0,0), splashSize.width()/devicePixelRatio);
    gradient.setColorAt(0, Qt::white);
    gradient.setColorAt(1, QColor(247,247,247));
    QRect rGradient(QPoint(0,0), splashSize);
    pixPaint.fillRect(rGradient, gradient);

    // draw the bitcoin8m icon, expected size of PNG: 1024x1024
    QRect rectIcon(QPoint(-150,-122), QSize(430,430));

    const QSize requiredSize(1024,1024);
    QPixmap icon(networkStyle->getAppIcon().pixmap(requiredSize));

    pixPaint.drawPixmap(rectIcon, icon);

    // check font size and drawing with
    pixPaint.setFont(QFont(font, 33*fontFactor));
    QFontMetrics fm = pixPaint.fontMetrics();
    int titleTextWidth  = fm.width(titleText);
    if(titleTextWidth > 160) {
        // strange font rendering, Arial probably not found
        fontFactor = 0.75;
    }

    pixPaint.setFont(QFont(font, 33*fontFactor));
    fm = pixPaint.fontMetrics();
    titleTextWidth  = fm.width(titleText);
    pixPaint.drawText(pixmap.width()/devicePixelRatio-titleTextWidth-paddingRight,paddingTop,titleText);

    pixPaint.setFont(QFont(font, 15*fontFactor));

    // if the version string is to long, reduce size
    fm = pixPaint.fontMetrics();
    int versionTextWidth  = fm.width(versionText);
    if(versionTextWidth > titleTextWidth+paddingRight-10) {
        pixPaint.setFont(QFont(font, 10*fontFactor));
        titleVersionVSpace -= 5;
    }
    pixPaint.drawText(pixmap.width()/devicePixelRatio-titleTextWidth-paddingRight+2,paddingTop+titleVersionVSpace,versionText);

    // draw copyright stuff
    pixPaint.setFont(QFont(font, 10*fontFactor));
    pixPaint.drawText(pixmap.width()/devicePixelRatio-titleTextWidth-paddingRight,paddingTop+titleCopyrightVSpace,copyrightText);

    // draw additional text if special network
    if(!titleAddText.isEmpty()) {
        QFont boldFont = QFont(font, 10*fontFactor);
        boldFont.setWeight(QFont::Bold);
        pixPaint.setFont(boldFont);
        fm = pixPaint.fontMetrics();
        int titleAddTextWidth  = fm.width(titleAddText);
        pixPaint.drawText(pixmap.width()/devicePixelRatio-titleAddTextWidth-10,15,titleAddText);
    }

    pixPaint.end();

    // Set window title
    setWindowTitle(titleText + " " + titleAddText);

    // Resize window and move to center of desktop, disallow resizing
    QRect r(QPoint(), QSize(pixmap.size().width()/devicePixelRatio,pixmap.size().height()/devicePixelRatio));
    resize(r.size());
    setFixedSize(r.size());
    move(QApplication::desktop()->screenGeometry().center() - r.center());

    subscribeToCoreSignals();
}
Ejemplo n.º 10
0
CaptureWgt::CaptureWgt( QWidget * parent )
: QMainWindow( parent )
{
    pd = new PD();
    pd->ui.setupUi( this );
    pd->crossFname = "./video.ini";
    pd->modifyLaserPos = false;
    pd->devMenu = 0;
    pd->resMenu = 0;
    pd->imgScale = 1.0;
    pd->drawArrow = false;
    pd->flipX = false;
    pd->flipY = false;
    pd->resolutionAcquired = false;
    pd->cap = new Capture( this );
    pd->ui.brightnessDw->setVisible( false );
    pd->brightness = new BrightnessWgt( this );
    pd->ui.brightnessDw->setWidget( pd->brightness );
    pd->cap->setBrightnessRange( pd->brightness->range() );
    connect( pd->brightness, SIGNAL(rangeChanged(const QPointF &)), 
             this,           SLOT(slotBrightnessChanged(const QPointF &)) );
    connect( pd->ui.brightnessRange, SIGNAL(triggered()), 
             this,                   SLOT(slotBrightness()) );

    Ui_CaptureWgt & ui = pd->ui;
    connect( ui.capture,  SIGNAL(triggered()), this, SLOT(slotCapture()) );
    connect( ui.settings, SIGNAL(triggered()), this, SLOT(slotSettings()) );
    connect( ui.cross,    SIGNAL(triggered()), this, SLOT(slotCrossEmphasis()) );

    pd->scene = new QGraphicsScene( pd->ui.view );
    pd->scene->setBackgroundBrush( QBrush( Qt::gray ) );
    pd->ui.view->setScene( pd->scene );

    pd->image = new QGraphicsPixmapItem( 0, pd->scene );
    pd->image->setPos( 0.0, 0.0 );
    pd->lineX1 = new QGraphicsLineItem( pd->image, pd->scene );
    pd->lineY1 = new QGraphicsLineItem( pd->image, pd->scene );
    pd->lineX2 = new QGraphicsLineItem( pd->image, pd->scene );
    pd->lineY2 = new QGraphicsLineItem( pd->image, pd->scene );
    pd->arrow = new QGraphicsPolygonItem( pd->image, pd->scene );
    // This is for laser spot position.
    pd->laserPosImage = new QGraphicsPixmapItem( 0, pd->scene );
    pd->laserPosImage->setPixmap( QPixmap( ":/images/laser.png" ) );
    pd->laserPosImage->setPos( -pd->laserPosImage->pixmap().width()/2, -pd->laserPosImage->pixmap().height()/2 );
    pd->laserPosImage->setVisible( false );

    connect( pd->ui.flipX, SIGNAL(triggered()), this, SLOT(slotFlipX()) );
    connect( pd->ui.flipY, SIGNAL(triggered()), this, SLOT(slotFlipY()) );

    pd->cap = new Capture( this );
    listDevices();
    connect( pd->cap, SIGNAL(frame(const QImage &)), this, SLOT(slotFrame(const QImage &)) );

    ui.view->installEventFilter( this );

    pd->inMenu = new QMenu( this );
    ui.input->setMenu( pd->inMenu );
    QAction * a = new QAction( "Default", this );
    a->setCheckable( true );
    a->setChecked( true );
    pd->inMenu->addAction( a );
    pd->inList << a;

    a = new QAction( "Usb", this );
    a->setCheckable( true );
    pd->inMenu->addAction( a );
    pd->inList << a;

    a = new QAction( "S-Video", this );
    a->setCheckable( true );
    pd->inMenu->addAction( a );
    pd->inList << a;

    a = new QAction( "Composite", this );
    a->setCheckable( true );
    pd->inMenu->addAction( a );
    pd->inList << a;

    for ( int i=0; i<pd->inList.size(); i++ )
    {
        QAction * a = pd->inList[i];
        connect( a, SIGNAL(triggered()), this, SLOT(slotInput()) );
    }

    // ƒействи¤ соответствующие фильтрам.
    pd->filterList << ui.equalizeHist;
    pd->filterList << ui.fullContrast;
    pd->filterList << ui.sobel;
    pd->filterList << ui.median;
    pd->filterList << ui.timeSmooth;
    pd->filterList << ui.highPass;
    pd->filterList << ui.surface;
    pd->filterList << ui.brightnessRange;
    for ( int i=0; i<pd->filterList.size(); i++ )
    {
        QAction * a = pd->filterList[i];
        connect( a, SIGNAL(triggered()), this, SLOT(slotFilter()) );
    }

    connect( ui.pixmap, SIGNAL(triggered()), this, SLOT(slotPixmap()) );


	QToolButton * btn = qobject_cast<QToolButton *>(ui.toolBar->widgetForAction(ui.input));
	if ( btn )
		btn->setPopupMode(QToolButton::InstantPopup);

	btn = qobject_cast<QToolButton *>(ui.toolBar->widgetForAction(ui.device));
	if ( btn )
		btn->setPopupMode(QToolButton::InstantPopup);
	
	btn = qobject_cast<QToolButton *>(ui.toolBar->widgetForAction(ui.resolution));
	if ( btn )
		btn->setPopupMode(QToolButton::InstantPopup);

    //pd->usbLight = new LightIcon( this );
    //ui.toolBar->addWidget( pd->usbLight );

    // Laser spot handling.
    QMenu * m = new QMenu( this );
    a = m->addAction( "Set laser spot position" );
    connect( a, SIGNAL(triggered()), this, SLOT(slotSetLaserSpot()) );
    btn = qobject_cast<QToolButton *>(ui.toolBar->widgetForAction(ui.laser));
    btn->setPopupMode( QToolButton::MenuButtonPopup );
    ui.laser->setMenu( m );

    updateCrossPos();
}
Ejemplo n.º 11
0
void RtKeyboard::LoadButtonImages(void)
{
//  Load background image
    m_ImageBackground = QPixmap(g_strKeyboardBK);

// Load Key1 image
    m_Key1[0] = QPixmap(g_strKey1Up);
    m_Key1[1] = QPixmap(g_strKey1Down);

// Load Key2 image
    m_Key2[0] = QPixmap(g_strKey2Up);
    m_Key2[1] = QPixmap(g_strKey2Down);

// Load Key3 image
    m_Key3[0] = QPixmap(g_strKey3Up);
    m_Key3[1] = QPixmap(g_strKey3Down);

// Load Key4 image
    m_Key4[0] = QPixmap(g_strKey4Up);
    m_Key4[1] = QPixmap(g_strKey4Down);

// Load Key5 image
    m_Key5[0] = QPixmap(g_strKey5Up);
    m_Key5[1] = QPixmap(g_strKey5Down);

// Load Key6 image
    m_Key6[0] = QPixmap(g_strKey6Up);
    m_Key6[1] = QPixmap(g_strKey6Down);

// Load Key7 image
    m_Key7[0] = QPixmap(g_strKey7Up);
    m_Key7[1] = QPixmap(g_strKey7Down);

// Load Key Del image
    m_Key_Del[0] = QPixmap(g_strKeyDelUp);
    m_Key_Del[1] = QPixmap(g_strKeyDelDown);

// Load Key Enter image
    m_Key_Enter[0] = QPixmap(g_strKeyEnterUp);
    m_Key_Enter[1] = QPixmap(g_strKeyEnterDown);

// Load Key Switch image
   m_Key_Switch[0] = QPixmap(g_strKeySwitchUp);
   m_Key_Switch[1] = QPixmap(g_strKeySwitchDown);
}
Ejemplo n.º 12
0
void ModelExportForm::handleExportFinished(void)
{
	finishExport(trUtf8("Exporting process sucessfuly ended!"));
	ico_lbl->setPixmap(QPixmap(QString(":/icones/icones/msgbox_info.png")));
}
Ejemplo n.º 13
0
void ModelExportForm::handleExportCanceled(void)
{
	finishExport(trUtf8("Exporting process canceled by user!"));
	ico_lbl->setPixmap(QPixmap(QString(":/icones/icones/msgbox_alerta.png")));
}
Ejemplo n.º 14
0
void ModelExportForm::captureThreadError(Exception e)
{
	finishExport(trUtf8("Exporting process aborted!"));
	ico_lbl->setPixmap(QPixmap(QString(":/icones/icones/msgbox_erro.png")));
	throw Exception(e.getErrorMessage(), e.getErrorType(),__PRETTY_FUNCTION__,__FILE__,__LINE__, &e);
}
Ejemplo n.º 15
0
QWizardPage *AddFeedWizard::createUrlFeedPage()
{
  QWizardPage *page = new QWizardPage;
  page->setTitle(tr("Create New Feed"));

  selectedPage = false;
  finishOn = false;

  urlFeedEdit_ = new LineEdit(this);
  urlFeedEdit_->setText("http://");

  titleFeedAsName_ = new QCheckBox(
        tr("Use title of the feed as displayed name"), this);
  titleFeedAsName_->setChecked(true);

  authentication_ = new QGroupBox(this);
  authentication_->setTitle(tr("Server requires authentication:"));
  authentication_->setCheckable(true);
  authentication_->setChecked(false);

  user_ = new LineEdit(this);
  pass_ = new LineEdit(this);
  pass_->setEchoMode(QLineEdit::Password);

  QGridLayout *authenticationLayout = new QGridLayout();
  authenticationLayout->addWidget(new QLabel(tr("Username:"******"Password:"******":/images/warning"));
  textWarning = new QLabel(this);
  QFont font = textWarning->font();
  font.setBold(true);
  textWarning->setFont(font);

  QHBoxLayout *warningLayout = new QHBoxLayout();
  warningLayout->setMargin(0);
  warningLayout->addWidget(iconWarning);
  warningLayout->addWidget(textWarning, 1);

  warningWidget_ = new QWidget(this);
  warningWidget_->setLayout(warningLayout);

  progressBar_ = new QProgressBar(this);
  progressBar_->setObjectName("progressBar_");
  progressBar_->setTextVisible(false);
  progressBar_->setFixedHeight(15);
  progressBar_->setMinimum(0);
  progressBar_->setMaximum(0);
  progressBar_->setVisible(false);

  QVBoxLayout *layout = new QVBoxLayout;
  layout->addWidget(new QLabel(tr("Feed URL or website address:")));
  layout->addWidget(urlFeedEdit_);
  layout->addWidget(titleFeedAsName_);
  layout->addSpacing(10);
  layout->addWidget(authentication_);
  layout->addStretch(1);
  layout->addWidget(warningWidget_);
  layout->addWidget(progressBar_);
  page->setLayout(layout);

  connect(urlFeedEdit_, SIGNAL(textChanged(const QString&)),
          this, SLOT(urlFeedEditChanged(const QString&)));
  connect(titleFeedAsName_, SIGNAL(stateChanged(int)),
          this, SLOT(titleFeedAsNameStateChanged(int)));

  return page;
}
Ejemplo n.º 16
0
void LightMaps::paintEvent(QPaintEvent *event)
{
    QPainter p;
    p.begin(this);
    m_normalMap->render(&p, event->rect());
    p.setPen(Qt::black);
    p.drawText(rect(),  Qt::AlignBottom | Qt::TextWordWrap,
               "Map data CCBYSA 2009 OpenStreetMap.org contributors");
    p.end();

    if (zoomed) {
        int dim = qMin(width(), height());
        int magnifierSize = qMin(MAX_MAGNIFIER, dim * 2 / 3);
        int radius = magnifierSize / 2;
        int ring = radius - 15;
        QSize box = QSize(magnifierSize, magnifierSize);

        // reupdate our mask
        if (maskPixmap.size() != box) {
            maskPixmap = QPixmap(box);
            maskPixmap.fill(Qt::transparent);

            QRadialGradient g;
            g.setCenter(radius, radius);
            g.setFocalPoint(radius, radius);
            g.setRadius(radius);
            g.setColorAt(1.0, QColor(255, 255, 255, 0));
            g.setColorAt(0.5, QColor(128, 128, 128, 255));

            QPainter mask(&maskPixmap);
            mask.setRenderHint(QPainter::Antialiasing);
            mask.setCompositionMode(QPainter::CompositionMode_Source);
            mask.setBrush(g);
            mask.setPen(Qt::NoPen);
            mask.drawRect(maskPixmap.rect());
            mask.setBrush(QColor(Qt::transparent));
            mask.drawEllipse(g.center(), ring, ring);
            mask.end();
        }

        QPoint center = dragPos - QPoint(0, radius);
        center = center + QPoint(0, radius / 2);
        QPoint corner = center - QPoint(radius, radius);

        QPoint xy = center * 2 - QPoint(radius, radius);

        // only set the dimension to the magnified portion
        if (zoomPixmap.size() != box) {
            zoomPixmap = QPixmap(box);
            zoomPixmap.fill(Qt::lightGray);
        }
        if (true) {
            QPainter p(&zoomPixmap);
            p.translate(-xy);
            m_largeMap->render(&p, QRect(xy, box));
            p.end();
        }

        QPainterPath clipPath;
        clipPath.addEllipse(center, ring, ring);

        QPainter p(this);
        p.setRenderHint(QPainter::Antialiasing);
        p.setClipPath(clipPath);
        p.drawPixmap(corner, zoomPixmap);
        p.setClipping(false);
        p.drawPixmap(corner, maskPixmap);
        p.setPen(Qt::gray);
        p.drawPath(clipPath);
    }
    if (invert) {
        QPainter p(this);
        p.setCompositionMode(QPainter::CompositionMode_Difference);
        p.fillRect(event->rect(), Qt::white);
        p.end();
    }
}
Ejemplo n.º 17
0
QVariant TemplateListModel::data( const QModelIndex & index, int role ) const
{
  if(!index.isValid())
  {
    return QVariant();
  }
  else if( role == Qt::DecorationRole )
  {
    switch( index.row() )
    {
      case NEWFROMTEMPLATE_EMPTY:
      {
        return QPixmap(":/images/osm-icon-open.png").scaled(85,85,Qt::KeepAspectRatio,Qt::SmoothTransformation);
      }
      case NEWFROMTEMPLATE_WIZARD:
      {
        return QPixmap(":/images/wizard.png").scaled(85,85,Qt::KeepAspectRatio,Qt::SmoothTransformation);
      }
      default:
      {
        return QVariant();
      }
    }
  }
  else if( role == Qt::SizeHintRole )
  {
    return QSize(100,100);
  }
  else if( role == Qt::ToolTipRole ) 
  {
    switch( index.row() )
    {
      case NEWFROMTEMPLATE_EMPTY:
      {
        return QString("Empty Building Model");
      }
      case NEWFROMTEMPLATE_WIZARD:
      {
        return QString("Building Model From Wizard");
      }
      default:
      {
        return QVariant();
      }
    }
  }
  else if( role == Qt::WhatsThisRole ) 
  {
    switch( index.row() )
    {
      case NEWFROMTEMPLATE_EMPTY:
      {
        return QString("Create a new empty building model.  Start here if you want to add your own Zones and HVAC Systems.");
      }
      case NEWFROMTEMPLATE_WIZARD:
      {
        return QString("Create a new building model using a wizard.  \
This option will create a complete building model through a series of basic inputs.");
      }
      default:
      {
        return QVariant();
      }
    }
  }
  else
  {
    return QVariant();
Ejemplo n.º 18
0
FooAbout::FooAbout(QWidget *parent)
		: QWidget(parent, Qt::Window)
{
	setWindowTitle(tr("About"));
	setAttribute(Qt::WA_DeleteOnClose);

	QWidget *top = new QWidget;

	QLabel *l_icon = new QLabel;
	l_icon->setPixmap(QPixmap(":images/icon64.png"));

	QWidget *blank = new QWidget;
	blank->setSizePolicy(QSizePolicy(QSizePolicy::Maximum, QSizePolicy::Expanding));

	QLabel *l_info = new QLabel;
	l_info->setText(QString("<span style=\"font-size: 16pt\"><center>fooaudio</span>"));
	l_info->setWordWrap(true);
	l_info->setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Minimum));

	QHBoxLayout *left_layout = new QHBoxLayout(top);
	left_layout->addWidget(l_icon);
	left_layout->addWidget(l_info);
	left_layout->addWidget(blank);

	// our TabWidget
	QTabWidget *tw_about = new QTabWidget(this);
	tw_about->setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Minimum));
	// end our TabWidget

	// create our info widgets
	// info
	QTextEdit *tb_info = new QTextEdit(tw_about);
	tb_info->setReadOnly(true);
	tb_info->setFrameStyle(QFrame::StyledPanel | QFrame::Plain);
	tb_info->setWordWrapMode(QTextOption::NoWrap);
	QString info_text;
	info_text += "This is foobar-like audio player";
	tb_info->setText(info_text);

	// authors
	QTextEdit *tb_authors = new QTextEdit(tw_about);
	tb_authors->setReadOnly(true);
	tb_authors->setFrameStyle(QFrame::StyledPanel | QFrame::Plain);
	tb_authors->setWordWrapMode(QTextOption::NoWrap);
	QString authors_text;
	authors_text += "Mateusz \'Matthew\' Marek\n";
	authors_text += "email: [email protected]\n\n";
	authors_text += "Bartłomiej \'uzi\' Zimoń\n";
	authors_text += "email: [email protected]\n";
	tb_authors->setText(authors_text);

	// people to thank
	QTextEdit *tb_thanks = new QTextEdit(tw_about);
	tb_thanks->setReadOnly(true);
	tb_thanks->setFrameStyle(QFrame::StyledPanel | QFrame::Plain);
	tb_thanks->setWordWrapMode(QTextOption::NoWrap);

	// license
	QTextEdit *tb_license = new QTextEdit(tw_about);
	tb_license->setReadOnly(true);
	tb_license->setFrameStyle(QFrame::StyledPanel | QFrame::Plain);
	tb_license->setWordWrapMode(QTextOption::WordWrap);
	tb_license->setText(QString("GPL v2"));

	// changelog
	//QTextEdit *tb_changelog = new QTextEdit(tw_about);
	//tb_changelog->setReadOnly(true);
	//tb_changelog->setFrameStyle(QFrame::StyledPanel | QFrame::Plain);
	//tb_changelog->setWordWrapMode(QTextOption::NoWrap);

	// add tabs
	tw_about->addTab(tb_info, tr("&Info"));
	tw_about->addTab(tb_authors, tr("A&uthors"));
	tw_about->addTab(tb_thanks, tr("&Thanks"));
	tw_about->addTab(tb_license, tr("&License"));
	//tw_about->addTab(tb_changelog, tr("&ChangeLog"));
	// end create our info widgets

	QWidget *bottom = new QWidget;

	QWidget *blank2 = new QWidget;
	blank2->setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Maximum));

	QPushButton *pb_close = new QPushButton(tr("Close"));
	connect(pb_close, SIGNAL(clicked()), this, SLOT(close()));

	QHBoxLayout *bottom_layout = new QHBoxLayout(bottom);
	bottom_layout->addWidget(blank2);
	bottom_layout->addWidget(pb_close);

	QVBoxLayout *layout = new QVBoxLayout(this);
	layout->addWidget(top);
	layout->addWidget(tw_about);
	layout->addWidget(bottom);

}
Ejemplo n.º 19
0
KisAboutApplication::KisAboutApplication(QWidget *parent)
    : QDialog(parent)
{
    setWindowTitle(i18n("About Krita"));

    QVBoxLayout *vlayout = new QVBoxLayout(this);
    vlayout->setMargin(0);
    QTabWidget *wdg = new QTabWidget;
    vlayout->addWidget(wdg);

    KisSplashScreen *splash = new KisSplashScreen(qApp->applicationVersion(), QPixmap(splash_screen_xpm), true);
    splash->setWindowFlags(Qt::Widget);
    splash->setFixedSize(splash->sizeHint());
    wdg->addTab(splash, i18n("About"));
    setMinimumSize(wdg->sizeHint());

    QTextEdit *lblAuthors = new QTextEdit();
    lblAuthors->setReadOnly(true);

    QString authors = i18n("<html>"
                          "<head/>"
                          "<body>"
                          "<h1 align=\"center\">Created By</h1></p>"
                          "<p>");

    QFile fileDevelopers(":/developers.txt");
    Q_ASSERT(fileDevelopers.exists());
    fileDevelopers.open(QIODevice::ReadOnly);

    foreach(const QByteArray &author, fileDevelopers.readAll().split('\n')) {
        authors.append(QString::fromUtf8(author));
        authors.append(", ");
    }
    authors.chop(2);
    authors.append(".</p></body></html>");
    lblAuthors->setText(authors);
    wdg->addTab(lblAuthors, i18n("Authors"));

    QTextEdit *lblKickstarter = new QTextEdit();
    lblKickstarter->setReadOnly(true);

    QString backers = i18n("<html>"
                          "<head/>"
                          "<body>"
                          "<h1 align=\"center\">Backed By</h1>"
                          "<p>");

    QFile fileBackers(":/backers.txt");
    Q_ASSERT(fileBackers.exists());
    fileBackers.open(QIODevice::ReadOnly);
    foreach(const QByteArray &backer, fileBackers.readAll().split('\n')) {
        backers.append(QString::fromUtf8(backer));
        backers.append(", ");
    }
    backers.chop(2);
    backers.append(i18n(".</p><p><i>Thanks! You were all <b>awesome</b>!</i></p></body></html>"));
    lblKickstarter->setText(backers);
    wdg->addTab(lblKickstarter, i18n("Backers"));



    QTextEdit *lblCredits = new QTextEdit();
    lblCredits->setReadOnly(true);
    QString credits = i18n("<html>"
                          "<head/>"
                          "<body>"
                          "<h1 align=\"center\">Thanks To</h1>"
                          "<p>");

    QFile fileCredits(":/credits.txt");
    Q_ASSERT(fileCredits.exists());
    fileCredits.open(QIODevice::ReadOnly);

    foreach(const QByteArray &credit, fileCredits.readAll().split('\n')) {
        if (!credit.isEmpty()) {
            QList<QByteArray> creditSplit = credit.split(':');
            Q_ASSERT(creditSplit.size() == 2);
            credits.append(QString::fromUtf8(creditSplit.at(0)));
            credits.append(" (<i>" + QString::fromUtf8(creditSplit.at(1)) + "</i>)");
            credits.append(", ");
        }
    }
    credits.chop(2);
    credits.append(i18n(".</p><p><i>For supporting Krita development with advice, icons, brush sets and more.</i></p></body></html>"));

    lblCredits->setText(credits);
    wdg->addTab(lblCredits, i18n("Also Thanks To"));

    QTextEdit *lblLicense = new QTextEdit();
    lblLicense->setReadOnly(true);
    QString license = i18n("<html>"
                           "<head/>"
                           "<body>"
                           "<h1 align=\"center\"><b>Your Rights</h1>"
                           "<p>Krita is released under the GNU General Public License (version 2 or any later version).</p>"
                           "<p>This license grants people a number of freedoms:</p>"
                           "<ul>"
                           "<li>You are free to use Krita, for any purpose</li>"
                           "<li>You are free to distribute Krita</li>"
                           "<li>You can study how Krita works and change it</li>"
                           "<li>You can distribute changed versions of Krita</li>"
                           "</ul>"
                           "<p>The Krita Foundation and its projects on krita.org are <b>committed</b> to preserving Krita as free software.</p>"
                           "<h1 align=\"center\">Your artwork</h1>"
                           "<p>What you create with Krita is your sole property. All your artwork is free for you to use as you like.</p>"
                           "<p>That means that Krita can be used commercially, for any purpose. There are no restrictions whatsoever.</p>"
                           "<p>Krita’s GNU GPL license guarantees you this freedom. Nobody is ever permitted to take it away, in contrast "
                           "to trial or educational versions of commercial software that will forbid your work in commercial situations.</p>"
                           "<br/><hr/><pre>");

    QFile licenseFile(":/LICENSE");
    Q_ASSERT(licenseFile.exists());
    licenseFile.open(QIODevice::ReadOnly);
    QByteArray ba = licenseFile.readAll();
    license.append(QString::fromUtf8(ba));
    license.append("</pre></body></html>");
    lblLicense->setText(license);

    wdg->addTab(lblLicense, i18n("License"));

    QPushButton *bnClose = new QPushButton(i18n("Close"));
    connect(bnClose, SIGNAL(clicked()), SLOT(close()));

    QHBoxLayout *hlayout = new QHBoxLayout;
    hlayout->setMargin(0);
    hlayout->addStretch(10);
    hlayout->addWidget(bnClose);

    vlayout->addLayout(hlayout);
}
void CDirectCamGraphicsView::clearView()
{
	m_imageItem->setPixmap(QPixmap());
}
Ejemplo n.º 21
0
void ATSkeletonWindow::connectTunnel( Tunnel_c &tunnel )
{
 	Tunnel_c *pt = &tunnel;
 
 	AddToLog( tunnel, "Connecting tunnel %s...", qPrintable( pt->strName ) );
 	AddToLog( tunnel, "Host: %s - Tunnel: %d:%s:%d", qPrintable( pt->strSSHHost ), pt->iLocalPort, qPrintable( pt->strRemoteHost ), pt->iRemotePort );
 
 	if ( pt->strSSHHost.isEmpty() )
 	{
 		AddToLog( tunnel, "Error: Tunnel %s has no host, please check the settings.", qPrintable( pt->strName ) );
 		return;
 	}
 
 #ifdef WIN32
 	QString strPlink = "plink.exe";
 
 	// Check that the executable is found
 	{
 		QDir dir( argv0 );
 		dir.cdUp();
 		if ( !dir.exists( strPlink ) )
 		{
 			const char *ptr = argv0, *ptr2 = argv0;
 			while ( *ptr2 ) { if ( *ptr2 == '\\' ) ptr = ptr2+1; ptr2++; }
 			AddToLog( tunnel, "Error: Could not find %s, please check that it is in the same directory as %s.", qPrintable( strPlink ), ptr );
 			return;
 		}
 	}
 #else
 	QString strPlink = "ssh";
 #endif
 
 	if ( pt->pProcess != NULL ) return; // already connected?

	if ( tunnel.twi ) tunnel.twi->setIcon( 0, QPixmap( ":connecting.png" ) );
  	//QTreeWidgetItem *twi = getTreeItemFromTunnelIndex( iTunnelIndex );
  	//if ( twi ) twi->setIcon( 0, QPixmap( ":connecting.png" ) );
 
 	ATASSERT( pt->pConnector == NULL );
 	pt->pConnector = new ATTunnelConnector_c( this, &tunnel );
 
 	pt->pProcess = new QProcess;
 	pt->pProcess->setProcessChannelMode( QProcess::MergedChannels );
 
 	QString strCommand;
 
 	strCommand += strPlink + " ";
 	strCommand += "-v ";
 
 #ifdef _WIN32
 	QStringList strListSSHHost = pt->strSSHHost.split( ':', QString::SkipEmptyParts );
 	if ( strListSSHHost.count() == 1 ) strListSSHHost << "22";
 
 	strCommand += strListSSHHost.at(0) + " -P " + strListSSHHost.at(1) + " ";
 #else
 	strCommand += pt->strSSHHost + " ";
 #endif
 
 	if ( !pt->strUsername.isEmpty() ) strCommand += QString( "-l %1 " ).arg( pt->strUsername );
 
 	if ( pt->bCompression ) strCommand += "-C ";
 
 	strCommand += ( pt->iSSH1or2 == 1 ) ? "-1 " : "-2 ";
 
 	if ( pt->iDirection == 0 ) // Local -> Remote
 	{
 		IF_NWIN32( strCommand += "-g " );
 		strCommand += QString( "-L %1:%2:%3 " ).arg( pt->iLocalPort ).arg( pt->strRemoteHost).arg( pt->iRemotePort );		
 	}
 	else // Remote -> Local
 	{
 		strCommand += QString( "-R %1:%2:%3 " ).arg( pt->iLocalPort ).arg( pt->strRemoteHost).arg( pt->iRemotePort );		
 	}
 
 	if ( !pt->strSSHKeyFile.isEmpty() ) strCommand += QString( "-i %1 " ).arg( pt->strSSHKeyFile );
 
 	strCommand += pt->strExtraArguments;
 
 	ATVERIFY( connect( pt->pProcess, SIGNAL( readyReadStandardOutput() ), pt->pConnector, SLOT( slotProcessReadStandardOutput() ) ) );
 	ATVERIFY( connect( pt->pProcess, SIGNAL( readyReadStandardError() ), pt->pConnector, SLOT( slotProcessReadStandardError() ) ) );
 	ATVERIFY( connect( pt->pProcess, SIGNAL( error(QProcess::ProcessError) ), pt->pConnector, SLOT( slotProcessError(QProcess::ProcessError) ) ) );
 	ATVERIFY( connect( pt->pProcess, SIGNAL( finished(int, QProcess::ExitStatus) ), pt->pConnector, SLOT( slotProcessFinished(int, QProcess::ExitStatus) ) ) );
 	ATVERIFY( connect( pt->pConnector, SIGNAL( finished(Tunnel_c*) ), this, SLOT( slotConnectorFinished(Tunnel_c*) ), Qt::QueuedConnection ) );
 
 	AddToLog( tunnel, "%s", qPrintable( strCommand ) );
 
 	pt->pProcess->start( strCommand );
}
Ejemplo n.º 22
0
MainDialog::MainDialog(QWidget *parent)
    : QDialog(parent)
    , mHostEdit(new QLineEdit)
    , mPortEdit(new QLineEdit)
    , mUserEdit(new QLineEdit)
    , mPswdEdit(new QLineEdit)
    , mLAddrEdit(new QLineEdit)
    , mLPortEdit(new QLineEdit)
    , mWaitEdit(new QLineEdit)
    , mCtrlBtn(new QPushButton(tr("Start")))
    , mQuitBtn(new QPushButton(tr("Quit")))
    , mLogList(new QListWidget)
    , mInfoIcon(QPixmap(":/icon-info.png"))
    , mWarnIcon(QPixmap(":/icon-warn.png"))
    , mErrorIcon(QPixmap(":/icon-error.png"))
    , mStoppedIcon(QPixmap(":/icon-stopped.png"))
    , mConnectingIcon(QPixmap(":/icon-connecting.png"))
    , mConnectedIcon(QPixmap(":/icon-connected.png"))
    , mSleepingIcon(QPixmap(":/icon-sleeping.png"))
    , mSettings(new QSettings(QSettings::IniFormat, QSettings::UserScope,
                              "glacjay", "sshproxy", this))
    , mIsKeepRunning(false)
    , mProcess(new QProcess(this))
    , mRestartTimer(new QTimer(this))
{
    setWindowTitle(tr("SSH Proxy"));
    setWindowIcon(mConnectedIcon);

    mHostEdit->setText(mSettings->value("ssh/host").toString());
    mPortEdit->setText(mSettings->value("ssh/port", "22").toString());
    mUserEdit->setText(mSettings->value("ssh/user").toString());
    mLAddrEdit->setText(mSettings->value("ssh/laddr", "127.0.0.1").toString());
    mLPortEdit->setText(mSettings->value("ssh/lport", "1077").toString());
    mWaitEdit->setText(mSettings->value("ssh/wait", "10").toString());

    mPortEdit->setValidator(new QIntValidator(1, 65535));
    mPswdEdit->setEchoMode(QLineEdit::Password);
    mLPortEdit->setValidator(new QIntValidator(1, 65535));
    mWaitEdit->setValidator(new QIntValidator);
    mLogList->setWordWrap(true);

    mProcess->setProcessChannelMode(QProcess::MergedChannels);

    QLabel *hostLabel = new QLabel(tr("SSH Host:"));
    hostLabel->setBuddy(mHostEdit);
    QLabel *portLabel = new QLabel(tr("SSH Port:"));
    portLabel->setBuddy(mPortEdit);
    QLabel *userLabel = new QLabel(tr("Username:"******"Password:"******"Listen Addr:"));
    lAddrLabel->setBuddy(mLAddrEdit);
    QLabel *lPortLabel = new QLabel(tr("Listen Port:"));
    lPortLabel->setBuddy(mLPortEdit);
    QLabel *waitLabel = new QLabel(tr("Seconds wait to reconnect:"));
    waitLabel->setBuddy(mWaitEdit);

    QVBoxLayout *inputLayout = new QVBoxLayout;
    inputLayout->addWidget(hostLabel);
    inputLayout->addWidget(mHostEdit);
    inputLayout->addWidget(portLabel);
    inputLayout->addWidget(mPortEdit);
    inputLayout->addWidget(userLabel);
    inputLayout->addWidget(mUserEdit);
    inputLayout->addWidget(pswdLabel);
    inputLayout->addWidget(mPswdEdit);
    inputLayout->addWidget(lAddrLabel);
    inputLayout->addWidget(mLAddrEdit);
    inputLayout->addWidget(lPortLabel);
    inputLayout->addWidget(mLPortEdit);
    inputLayout->addWidget(waitLabel);
    inputLayout->addWidget(mWaitEdit);
    inputLayout->insertStretch(-1);
    inputLayout->addWidget(mCtrlBtn);
    inputLayout->addWidget(mQuitBtn);

    QGroupBox *inputGroup = new QGroupBox(tr("Settings"));
    inputGroup->setLayout(inputLayout);

    QVBoxLayout *logLayout = new QVBoxLayout;
    logLayout->addWidget(mLogList);

    QGroupBox *logGroup = new QGroupBox(tr("Log"));
    logGroup->setLayout(logLayout);

    QSplitter *splitter = new QSplitter(Qt::Horizontal);
    splitter->addWidget(inputGroup);
    splitter->addWidget(logGroup);
    splitter->setStretchFactor(1, 5);

    QVBoxLayout *mainLayout = new QVBoxLayout;
    mainLayout->addWidget(splitter);

    setLayout(mainLayout);
    resize(1000, 600);

    connect(mCtrlBtn, SIGNAL(clicked(void)), this, SLOT(on_mCtrlBtn_clicked(void)));
    connect(mQuitBtn, SIGNAL(clicked(void)), this, SLOT(onQuit(void)));

    mTray = new QSystemTrayIcon(mStoppedIcon);
    mTray->show();

    setSshStatus(StatStopped);

    connect(mTray, SIGNAL(activated(QSystemTrayIcon::ActivationReason)),
            this, SLOT(on_mTray_activated(QSystemTrayIcon::ActivationReason)));

    QAction *toggleAction = new QAction(tr("Toggle Main Dialog"), this);
    connect(toggleAction, SIGNAL(triggered(void)),
            this, SLOT(on_toggleAction_triggered(void)));

    QAction *quitAction = new QAction(tr("Quit"), this);
    connect(quitAction, SIGNAL(triggered(void)),
            this, SLOT(onQuit(void)));

    QMenu *trayMenu = new QMenu;
    trayMenu->addAction(toggleAction);
    trayMenu->addSeparator();
    trayMenu->addAction(quitAction);

    mTray->setContextMenu(trayMenu);

    connect(qApp, SIGNAL(aboutToQuit(void)), this, SLOT(onQuit(void)));

    connect(mProcess, SIGNAL(started(void)), this, SLOT(on_mProcess_started(void)));
    connect(mProcess, SIGNAL(finished(int, QProcess::ExitStatus)),
            this, SLOT(on_mProcess_finished(int, QProcess::ExitStatus)));
    connect(mProcess, SIGNAL(error(QProcess::ProcessError)),
            this, SLOT(on_mProcess_error(QProcess::ProcessError)));
    connect(mProcess, SIGNAL(readyReadStandardOutput(void)),
            this, SLOT(on_mProcess_readyReadStandardOutput(void)));

    connect(mRestartTimer, SIGNAL(timeout(void)), this, SLOT(startRunning(void)));

    if (mHostEdit->text().isEmpty())
        mHostEdit->setFocus();
    else if (mPortEdit->text().isEmpty())
        mPortEdit->setFocus();
    else if (mUserEdit->text().isEmpty())
        mUserEdit->setFocus();
    else if (mPswdEdit->text().isEmpty())
        mPswdEdit->setFocus();
    else if (mLAddrEdit->text().isEmpty())
        mLAddrEdit->setFocus();
    else if (mLPortEdit->text().isEmpty())
        mLPortEdit->setFocus();
    else if (mWaitEdit->text().isEmpty())
        mWaitEdit->setFocus();
}
Ejemplo n.º 23
0
void PlayerSetupDialog::showAlphaMaskPreview(const QString& value)
{
    ui->alphaMaskPreview->setPixmap(QPixmap(value));
}
Ejemplo n.º 24
0
void OSDWidget::showOSD(const QString &str, OSDUserData *data)
{
    if (isScreenSaverActive()){
        hide();
        return;
    }
    setFont(FontEdit::str2font(data->Font.ptr, baseFont));
    QPainter p(this);
    p.setFont(font());
    unsigned nScreen = data->Screen.value;
    unsigned nScreens = screens();
    if (nScreen >= nScreens)
        nScreen = 0;
    int SHADOW_OFFS = SHADOW_DEF;
    QRect rcScreen = screenGeometry(nScreen);
    rcScreen = QRect(0, 0,
                     rcScreen.width()  - SHADOW_OFFS - XOSD_MARGIN * 2 - data->Offset.value,
                     rcScreen.height() - SHADOW_OFFS - XOSD_MARGIN * 2 - data->Offset.value);
    QRect rc = p.boundingRect(rcScreen, AlignLeft | AlignTop | WordBreak, str);
    if (rc.height() >= rcScreen.height() / 2){
        rcScreen = QRect(0, 0,
                         rcScreen.width() - SHADOW_OFFS - XOSD_MARGIN * 2 - data->Offset.value,
                         rcScreen.height() - SHADOW_OFFS - XOSD_MARGIN * 2 - data->Offset.value);
        rc = p.boundingRect(rcScreen, AlignLeft | AlignTop | WordBreak, str);
    }
    p.end();
    if (data->EnableMessageShowContent.bValue && data->ContentLines.value){
        QFontMetrics fm(font());
        int maxHeight = fm.height() * (data->ContentLines.value + 1);
        if (rc.height() > maxHeight)
            rc.setHeight(maxHeight);
    }
    int x = rcScreen.left();
    int y = rcScreen.top();
    int w = rc.width() + 1;
    int h = rc.height() + 1;
    int text_y = 0;
    if (data->Background.bValue){
        w += XOSD_MARGIN * 2;
        h += XOSD_MARGIN * 2;
        if (m_button == NULL){
            m_button = new QPushButton("", this);
            m_button->setPixmap(QPixmap((const char **)close_h_xpm));
            connect(m_button, SIGNAL(clicked()), this, SLOT(slotCloseClick()));
        }
        QSize s = m_button->sizeHint();
        m_button->resize(s.height() - 4, s.height() - 4);
        m_button->move(w - m_button->width() - 3, 2);
        text_y = m_button->height() + 4;
        h += text_y;
        m_button->show();
    }else{
        if (m_button){
            delete m_button;
            m_button = NULL;
        }
    }
    if (data->Shadow.bValue){
        w += SHADOW_OFFS;
        h += SHADOW_OFFS;
    }
    resize(QSize(w, h));
    switch (data->Position.value){
    case 1:
        move(x + data->Offset.value, y + data->Offset.value);
        break;
    case 2:
        move(x + rcScreen.width() - data->Offset.value - w, y + rcScreen.height() - data->Offset.value - h);
        break;
    case 3:
        move(x + rcScreen.width() - data->Offset.value - w, y + data->Offset.value);
        break;
    case 4:
        move(x + (rcScreen.width() - w) / 2, y + rcScreen.height() - data->Offset.value - h);
        break;
    case 5:
        move(x + (rcScreen.width() - w) / 2, y + data->Offset.value);
        break;
    case 6:
        move(x + (rcScreen.width() - w) / 2, y + (rcScreen.height() - h) /2);
        break;
    default:
        move(x + data->Offset.value, y + rcScreen.height() - data->Offset.value - h);
    }
    if (!data->Background.bValue || data->Shadow.bValue){
        QBitmap mask(w, h);
        p.begin(&mask);
#ifdef WIN32
        QColor bg(255, 255, 255);
        QColor fg(0, 0, 0);
#else
        QColor bg(0, 0, 0);
        QColor fg(255, 255, 255);
#endif
        p.fillRect(0, 0, w, h, bg);
        if (data->Background.bValue){
            p.fillRect(0, 0, w - SHADOW_OFFS, h - SHADOW_OFFS, fg);
            p.fillRect(SHADOW_OFFS, SHADOW_OFFS, w - SHADOW_OFFS, h - SHADOW_OFFS, fg);
        }else{
            p.setPen(fg);
            p.setFont(font());
            if (data->Shadow.bValue){
                rc = QRect(SHADOW_OFFS, SHADOW_OFFS, w - SHADOW_OFFS, h - SHADOW_OFFS);
                p.drawText(rc, AlignLeft | AlignTop | WordBreak, str);
                rc = QRect(0, 0, w - SHADOW_OFFS, h - SHADOW_OFFS);
                p.drawText(rc, AlignLeft | AlignTop | WordBreak, str);
            }else{
                rc = QRect(0, 0, w, h);
                p.drawText(rc, AlignLeft | AlignTop | WordBreak, str);
            }
        }
        p.end();
        setMask(mask);
    }
    qApp->syncX();
    QPixmap pict = QPixmap::grabWindow(QApplication::desktop()->winId(), this->x(), this->y(), width(), height());
    intensity(pict, -0.50f);
    p.begin(&pict);
    rc = QRect(0, 0, w, h);
    if (data->Background.bValue){
        if (data->Shadow.bValue){
            w -= SHADOW_OFFS;
            h -= SHADOW_OFFS;
            rc = QRect(0, 0, w, h);
        }
        QBrush bg(data->BgColor.value);
        p.fillRect(rc, bg);
#if COMPAT_QT_VERSION < 0x030000
        style().drawPopupPanel(&p, 0, 0, w, h, colorGroup(), 2, &bg);
#else
        style().drawPrimitive(QStyle::PE_PanelPopup, &p, rc, colorGroup());
#endif
        rc = QRect(XOSD_MARGIN, XOSD_MARGIN, w - XOSD_MARGIN * 2, h - XOSD_MARGIN * 2);
    }
    p.setFont(font());
    p.setPen(QColor(data->Color.value));
    rc.setTop(text_y);
    p.drawText(rc, AlignLeft | AlignTop | WordBreak, str);
    p.end();
    bgPict = pict;
    QWidget::show();
    raise();
}
Ejemplo n.º 25
0
SystemActions::SystemActions(void)
    : BaseActions()
{
    category()->setIcon(QIcon(QPixmap(":/images/system.png")));
}
Ejemplo n.º 26
0
QPixmap NoteDrag::feedbackPixmap(NoteSelection *noteList)
{
	if (noteList == 0)
		return QPixmap();

	static const int MARGIN  = 2;
	static const int SPACING = 1;

	QColor textColor       = noteList->firstStacked()->note->basket()->textColor();
	QColor backgroundColor = noteList->firstStacked()->note->basket()->backgroundColor().dark(NoteContent::FEEDBACK_DARKING);

	Q3ValueList<QPixmap> pixmaps;
	Q3ValueList<QColor>  backgrounds;
	Q3ValueList<bool>    spaces;
	QPixmap pixmap;
	int height = 0;
	int width  = 0;
	int i      = 0;
	bool elipsisImage = false;
	QColor bgColor;
	bool needSpace;
	for (NoteSelection *node = noteList->firstStacked(); node; node = node->nextStacked(), ++i) {
		if (elipsisImage) {
			pixmap = QPixmap(7, 2);
			pixmap.fill(backgroundColor);
			QPainter painter(&pixmap);
			painter.setPen(textColor);
			painter.drawPoint(1, 1);
			painter.drawPoint(3, 1);
			painter.drawPoint(5, 1);
			painter.end();
			bgColor   = node->note->basket()->backgroundColor();
			needSpace = false;
		} else {
			pixmap    = node->note->content()->feedbackPixmap(/*maxWidth=*/kapp->desktop()->width() / 2, /*maxHeight=*/96);
			bgColor   = node->note->backgroundColor();
			needSpace = node->note->content()->needSpaceForFeedbackPixmap();
		}
		if (!pixmap.isNull()) {
			if (pixmap.width() > width)
				width = pixmap.width();
			pixmaps.append(pixmap);
			backgrounds.append(bgColor);
			spaces.append(needSpace);
			height += (i > 0 && needSpace ? 1 : 0) + pixmap.height() + SPACING + (needSpace ? 1 : 0);
			if (elipsisImage)
				break;
			if (height > kapp->desktop()->height() / 2)
				elipsisImage = true;
		}
	}
	if (!pixmaps.isEmpty()) {
		QPixmap result(MARGIN + width + MARGIN, MARGIN + height - SPACING + MARGIN - (spaces.last() ? 1 : 0));
		QPainter painter(&result);
		// Draw all the images:
		height = MARGIN;
		Q3ValueList<QPixmap>::iterator it;
		Q3ValueList<QColor>::iterator  it2;
		Q3ValueList<bool>::iterator    it3;
		int i = 0;
		for (it = pixmaps.begin(), it2 = backgrounds.begin(), it3 = spaces.begin(); it != pixmaps.end(); ++it, ++it2, ++it3, ++i) {
			if (i != 0 && (*it3)) {
				painter.fillRect(MARGIN, height, result.width() - 2 * MARGIN, SPACING, (*it2).dark(NoteContent::FEEDBACK_DARKING));
				++height;
			}
			painter.drawPixmap(MARGIN, height, *it);
			if ((*it).width() < width)
				painter.fillRect(MARGIN + (*it).width(), height, width - (*it).width(), (*it).height(), (*it2).dark(NoteContent::FEEDBACK_DARKING));
			if (*it3) {
				painter.fillRect(MARGIN, height + (*it).height(), result.width() - 2 * MARGIN, SPACING, (*it2).dark(NoteContent::FEEDBACK_DARKING));
				++height;
			}
			painter.fillRect(MARGIN, height + (*it).height(), result.width() - 2 * MARGIN, SPACING, Tools::mixColor(textColor, backgroundColor));
			height += (*it).height() + SPACING;
		}
		// Draw the border:
		painter.setPen(textColor);
		painter.drawLine(0,                  0,                   result.width() - 1, 0);
		painter.drawLine(0,                  0,                   0,                  result.height() - 1);
		painter.drawLine(0,                  result.height() - 1, result.width() - 1, result.height() - 1);
		painter.drawLine(result.width() - 1, 0,                   result.width() - 1, result.height() - 1);
		// Draw the "lightly rounded" border:
		painter.setPen(Tools::mixColor(textColor, backgroundColor));
		painter.drawPoint(0,                  0);
		painter.drawPoint(0,                  result.height() - 1);
		painter.drawPoint(result.width() - 1, result.height() - 1);
		painter.drawPoint(result.width() - 1, 0);
		// Draw the background in the margin (the inside will be painted above, anyway):
		painter.setPen(backgroundColor);
		painter.drawLine(1,                  1,                   result.width() - 2, 1);
		painter.drawLine(1,                  1,                   1,                  result.height() - 2);
		painter.drawLine(1,                  result.height() - 2, result.width() - 2, result.height() - 2);
		painter.drawLine(result.width() - 2, 1,                   result.width() - 2, result.height() - 2);
		// And assign the feedback pixmap to the drag object:
		//multipleDrag->setPixmap(result, QPoint(-8, -8));
		return result;
	}
	return QPixmap();
}
Ejemplo n.º 27
0
/**
 * Cette méthode va afficher la photo de l'interface sur la fenêtre F_ChoisirSonde
 */
void Photo::paint(QPainter *painter, const QStyleOptionGraphicsItem */*option*/, QWidget */*widget*/)
{
    painter->drawPixmap(0, 0, QPixmap(this->sChemin + "/photo.png"));
}
Ejemplo n.º 28
0
void Frame::create_borders()
{
    layout = new QGridLayout(this); // 3x3 grid for window borders
    layout->setMargin(0);
    layout->setSpacing(0);
    setLayout(layout);

    // center frame where client apps is shown
    c_bdr = new Border(this);
    layout->addWidget(c_bdr, 1, 1);
    // top left border (icon)
    tl_bdr = new Border(this);
    tl_bdr->setToolTip(tr("Minimize(L)/Maximize(R)"));
    tl_bdr->setFixedSize(top_bdr_height, top_bdr_height);
    tl_bdr->setPixmap(minmax_pix);
    tl_bdr->setScaledContents(true);
    tl_bdr->setAlignment(Qt::AlignCenter);
    layout->addWidget(tl_bdr, 0, 0);
    // top right border (icon)
    tr_bdr = new Border(this);
    tr_bdr->setToolTip(tr("Close"));
    tr_bdr->setFixedSize(top_bdr_height, top_bdr_height);
    tr_bdr->setPixmap(close_pix);
    tr_bdr->setScaledContents(true);
    tr_bdr->setAlignment(Qt::AlignCenter);
    layout->addWidget(tr_bdr, 0, 2);
    // top mid header border (header frame)
    tm_bdr = new Header(cl_icon(), cl_name(), this);
    tm_bdr->set_pixmap(QPixmap(header_active_pix), QPixmap(header_inactive_pix), title_color);
    tm_bdr->setFixedHeight(top_bdr_height);
    layout->addWidget(tm_bdr, 0, 1);
    // bottom mid border
    bm_bdr = new Border(this);
    bm_bdr->setFixedHeight(bottom_bdr_height);
    bm_bdr->setCursor(Qt::SizeVerCursor);
    layout->addWidget(bm_bdr, 2, 1);
    // bottom left border
    bl_bdr = new Border(this);
    bl_bdr->setFixedSize(top_bdr_height, bottom_bdr_height);
    bl_bdr->setCursor(Qt::SizeBDiagCursor);
    layout->addWidget(bl_bdr, 2, 0);
    // bottom right border
    br_bdr = new Border(this);
    br_bdr->setFixedSize(top_bdr_height, bottom_bdr_height);
    br_bdr->setCursor(Qt::SizeFDiagCursor);
    layout->addWidget(br_bdr, 2, 2);
    // left border
    l_bdr = new Border(this);
    l_bdr->setCursor(Qt::SizeHorCursor);
    layout->addWidget(l_bdr, 1, 0);
    // right border
    r_bdr = new Border(this);
    r_bdr->setCursor(Qt::SizeHorCursor);
    layout->addWidget(r_bdr, 1, 2);

    if (frame_type == "Dialog") // no Max/Min on Dialog frames
    {
        tl_bdr->setEnabled(false);
    }

    // top left (icon)
    connect(tl_bdr, SIGNAL(mouse_left_press()), this, SLOT(iconify_it()));
    connect(tl_bdr, SIGNAL(mouse_right_press()), this, SLOT(maximize_it()));
    // top right (icon)
    connect(tr_bdr, SIGNAL(mouse_left_press()), this, SLOT(destroy_it()));
    // top mid (title bar)
    connect(tm_bdr, SIGNAL(mouse_double_click()), this, SLOT(iconify_it()));
    connect(tm_bdr, SIGNAL(mouse_left_press(QMouseEvent *)), this, SLOT(press_top_mid(QMouseEvent *)));
    connect(tm_bdr, SIGNAL(mouse_right_press()), this, SLOT(maximize_it()));
    connect(tm_bdr, SIGNAL(mouse_move(QMouseEvent *)), this, SLOT(move_top_mid(QMouseEvent *)));
    // bottom left
    connect(bl_bdr, SIGNAL(mouse_left_press(QMouseEvent *)), this, SLOT(press_bottom_left(QMouseEvent *)));
    connect(bl_bdr, SIGNAL(mouse_move(QMouseEvent *)), this, SLOT(move_bottom_left(QMouseEvent *)));
    // bottom right
    connect(br_bdr, SIGNAL(mouse_left_press(QMouseEvent *)), this, SLOT(press_bottom_right(QMouseEvent *)));
    connect(br_bdr, SIGNAL(mouse_move(QMouseEvent *)), this, SLOT(move_bottom_right(QMouseEvent *)));
    // bottom mid
    connect(bm_bdr, SIGNAL(mouse_left_press(QMouseEvent *)), this, SLOT(press_bottom_mid(QMouseEvent *)));
    connect(bm_bdr, SIGNAL(mouse_move(QMouseEvent *)), this, SLOT(move_bottom_mid(QMouseEvent *)));
    // left
    connect(l_bdr, SIGNAL(mouse_left_press(QMouseEvent *)), this, SLOT(press_left(QMouseEvent *)));
    connect(l_bdr, SIGNAL(mouse_move(QMouseEvent *)), this, SLOT(move_left(QMouseEvent *)));
    // right
    connect(r_bdr, SIGNAL(mouse_left_press(QMouseEvent *)), this, SLOT(press_right(QMouseEvent *)));
    connect(r_bdr, SIGNAL(mouse_move(QMouseEvent *)), this, SLOT(move_right(QMouseEvent *)));
}
Ejemplo n.º 29
0
bool CrystalFactory::readConfig()
{
	KConfig config("kwincrystalrc");
	KConfigGroup cg(&config, "General");
	QColor c;

	int value = cg.readEntry("TitleAlignment", 1);
	if (value == 0) titlealign_ = Qt::AlignLeft;
	else if (value == 1) titlealign_ = Qt::AlignHCenter;
	else if (value == 2) titlealign_ = Qt::AlignRight;
	
	drawcaption=(bool)cg.readEntry("DrawCaption",true);
	textshadow=(bool)cg.readEntry("TextShadow",true);
	captiontooltip=(bool)cg.readEntry("CaptionTooltip",true);
	wheelTask=(bool)cg.readEntry("WheelTask",false);

	active.transparency=(int)cg.readEntry("ActiveTransparency", 80);
	inactive.transparency=(int)cg.readEntry("InactiveTransparency", 60);
	
	active.outlineMode=(int)cg.readEntry("ActiveFrame",1);
	inactive.outlineMode=(int)cg.readEntry("InactiveFrame",1);
	c=QColor(160,160,160);
	active.frameColor=cg.readEntry("FrameColor1",c);
	c=QColor(128,128,128);
	inactive.frameColor=cg.readEntry("FrameColor2",c);

	active.inlineMode=(int)cg.readEntry("ActiveInline",0);
	inactive.inlineMode=(int)cg.readEntry("InactiveInline",0);
	c=QColor(160,160,160);
	active.inlineColor=cg.readEntry("InlineColor1",c);
	c=QColor(160,160,160);
	inactive.inlineColor=cg.readEntry("InlineColor2",c);

	borderwidth=cg.readEntry("Borderwidth",6);
	titlesize=cg.readEntry("Titlebarheight",21);
 
	buttonColor_normal=QColor(255,255,255);
	buttonColor_normal=cg.readEntry("ButtonColor",buttonColor_normal);
	buttonColor_hovered=cg.readEntry("ButtonColor2",buttonColor_normal);
	buttonColor_pressed=cg.readEntry("ButtonColor3",buttonColor_normal);
	minColor_normal=QColor(255,255,255);
	minColor_normal=cg.readEntry("MinColor",buttonColor_normal);
	minColor_hovered=cg.readEntry("MinColor2",buttonColor_normal);
	minColor_pressed=cg.readEntry("MinColor3",buttonColor_normal);
	maxColor_normal=QColor(255,255,255);
	maxColor_normal=cg.readEntry("MaxColor",buttonColor_normal);
	maxColor_hovered=cg.readEntry("MaxColor2",buttonColor_normal);
	maxColor_pressed=cg.readEntry("MaxColor3",buttonColor_normal);
	closeColor_normal=QColor(255,255,255);
	closeColor_normal=cg.readEntry("CloseColor",closeColor_normal);
	closeColor_hovered=cg.readEntry("CloseColor2",closeColor_normal);
	closeColor_pressed=cg.readEntry("CloseColor3",closeColor_normal);

	roundCorners=cg.readEntry("RoundCorners", 0x0f);

	hovereffect=cg.readEntry("HoverEffect",true);
	animateHover=cg.readEntry("AnimateHover",true);
	tintButtons=cg.readEntry("TintButtons",false);
	menuImage=cg.readEntry("MenuImage",true);
	buttontheme=cg.readEntry("ButtonTheme",9);

	{
		QString afname = cg.readEntry("OverlayFileActive","");
		QString ifname = cg.readEntry("OverlayFileInactive","");

		int aovmode = cg.readEntry("OverlayModeActive",2);
		int iovmode = cg.readEntry("OverlayModeInactive",2);

		active.stretch_overlay = cg.readEntry("OverlayStretchActive",false);
		inactive.stretch_overlay = cg.readEntry("OverlayStretchInactive",false);

		bool fwidth_active = cg.readEntry("OverlayFWidthActive",true);
		bool fwidth_inactive = cg.readEntry("OverlayFWidthInactive",true);

		int fwvalue_active = cg.readEntry("OverlayFWValueActive",256);
		int fwvalue_inactive = cg.readEntry("OverlayFWValueInactive",256);
		
		if (fwidth_active == false) fwvalue_active = 0;
		if (fwidth_inactive == false) fwvalue_inactive = 0;

		setupOverlay(&active,aovmode,afname,fwvalue_active);
		setupOverlay(&inactive,iovmode,ifname,fwvalue_inactive);
	}


	logoEnabled=cg.readEntry("LogoAlignment",1);
	logoStretch=cg.readEntry("LogoStretch",0);
	logoActive=cg.readEntry("LogoActive",false);
	logoDistance=cg.readEntry("LogoDistance",0);
	
	int logoIndex=cg.readEntry("LogoIndex", 0);
	QString filename=cg.readEntry("LogoFile","");

	if (logoEnabled!=1)
	{
		if (logoIndex == 0)
		{
			if (!filename.isNull() && logo.load(filename))
			{
				
			}else logoEnabled=1;
		} else {
			QImage img;
			
			switch (logoIndex)
			{
				default:
				case 1:
					img=QImage((uchar*)kde_data,26,26,QImage::Format_ARGB32);
					break;
				case 2:
					img=QImage((uchar*)tux_data,36,26,QImage::Format_ARGB32);
					break;
				case 3:
					img=QImage((uchar*)gentoo_data,64,67,QImage::Format_ARGB32);
					break;
				case 4:
					img=QImage((uchar*)kubuntu_data,24,26,QImage::Format_ARGB32);
					break;
				case 5:
					img=QImage((uchar*)ubuntu_data,64,64,QImage::Format_ARGB32);
					break;
				case 6:
					img=QImage((uchar*)opensuse_data,32,26,QImage::Format_ARGB32);
					break;
				case 7:
					img=QImage((uchar*)pclinuxos_data,26,26,QImage::Format_ARGB32);
					break;
			}
			logo = QPixmap::fromImage(img);
		}
		
		if ((logoEnabled != 1) && (logoStretch==0))
		{
			logo=logo.scaled(((titlesize-2)*logo.width())/logo.height(),titlesize-2);
		}
	}
	else logo = QPixmap ();
	return true;
}
Ejemplo n.º 30
0
QT_USE_NAMESPACE

int main(int argc, char **argv)
{
    Q_INIT_RESOURCE(linguist);

    QApplication app(argc, argv);
    QApplication::setOverrideCursor(Qt::WaitCursor);

    QStringList files;
    QString resourceDir = QLibraryInfo::location(QLibraryInfo::TranslationsPath);
    QStringList args = app.arguments();

    for (int i = 1; i < args.count(); ++i) {
        QString argument = args.at(i);
        if (argument == QLatin1String("-resourcedir")) {
            if (i + 1 < args.count()) {
                resourceDir = QFile::decodeName(args.at(++i).toLocal8Bit());
            } else {
                // issue a warning
            }
        } else if (!files.contains(argument)) {
            files.append(argument);
        }
    }

    QTranslator translator;
    QTranslator qtTranslator;
    QString sysLocale = QLocale::system().name();
    if (translator.load(QLatin1String("linguist_") + sysLocale, resourceDir)) {
        app.installTranslator(&translator);
        if (qtTranslator.load(QLatin1String("qt_") + sysLocale, resourceDir))
            app.installTranslator(&qtTranslator);
        else
            app.removeTranslator(&translator);
    }

    app.setOrganizationName(QLatin1String("Trolltech"));
    app.setApplicationName(QLatin1String("Linguist"));

    QSettings config;

    QWidget tmp;
    tmp.restoreGeometry(config.value(settingPath("Geometry/WindowGeometry")).toByteArray());

    QSplashScreen *splash = 0;
    int screenId = QApplication::desktop()->screenNumber(tmp.geometry().center());
    splash = new QSplashScreen(QApplication::desktop()->screen(screenId),
        QPixmap(QLatin1String(":/images/splash.png")));
    if (QApplication::desktop()->isVirtualDesktop()) {
        QRect srect(0, 0, splash->width(), splash->height());
        splash->move(QApplication::desktop()->availableGeometry(screenId).center() - srect.center());
    }
    splash->setAttribute(Qt::WA_DeleteOnClose);
    splash->show();

    MainWindow mw;
    mw.show();
    splash->finish(&mw);
    QApplication::restoreOverrideCursor();

    mw.openFiles(files, true);

    return app.exec();
}