Exemplo n.º 1
0
void Widget::onIconClick(QSystemTrayIcon::ActivationReason reason)
{
    switch (reason)
    {
        case QSystemTrayIcon::Trigger:
        {
            if (isHidden())
            {
                show();
                activateWindow();
                if (wasMaximized)
                    showMaximized();
                else
                    showNormal();
            }
            else if (isMinimized())
            {
                forceShow();
                activateWindow();
                if (wasMaximized)
                    showMaximized();
                else
                    showNormal();
            }
            else
            {
                wasMaximized = isMaximized();
                if (Settings::getInstance().getMinimizeToTray())
                    hide();
                else
                    showMinimized();
            }

            break;
        }
        case QSystemTrayIcon::MiddleClick:
            wasMaximized = isMaximized();
            if (Settings::getInstance().getMinimizeToTray())
                hide();
            else
                showMinimized();
            break;
        case QSystemTrayIcon::Unknown:
            if (isHidden())
                forceShow();
            break;
        default:
            break;
    }
}
Exemplo n.º 2
0
void QProgressDialog::init( QWidget *creator,
			    const QString& lbl, const QString& canc,
			    int totstps)
{
    d = new QProgressDialogData(this, creator, lbl, totstps);
    d->autoClose = TRUE;
    d->autoReset = TRUE;
    d->forceHide = FALSE;
    setCancelButtonText( canc );
    connect( this, SIGNAL(canceled()), this, SIGNAL(cancelled()) );
    connect( this, SIGNAL(canceled()), this, SLOT(cancel()) );
    forceTimer = new QTimer( this );
    connect( forceTimer, SIGNAL(timeout()), this, SLOT(forceShow()) );
    layout();
}
Exemplo n.º 3
0
void Widget::onIconClick(QSystemTrayIcon::ActivationReason reason)
{
    switch (reason)
    {
        case QSystemTrayIcon::Trigger:
        {
            if (isHidden())
            {
                show();
                activateWindow();
            }
            else if (isMinimized())
            {
                forceShow();
            }
            else
            {
                hide();
            }

            break;
        }
        case QSystemTrayIcon::DoubleClick:
            forceShow();
            break;
        case QSystemTrayIcon::MiddleClick:
            hide();
            break;
        case QSystemTrayIcon::Unknown:
            if (isHidden())
                forceShow();
            break;
        default:
            break;
    }
}
bool QProgressDialog::qt_invoke( int _id, QUObject* _o )
{
    switch ( _id - staticMetaObject()->slotOffset() ) {
    case 0: cancel(); break;
    case 1: reset(); break;
    case 2: setTotalSteps((int)static_QUType_int.get(_o+1)); break;
    case 3: setProgress((int)static_QUType_int.get(_o+1)); break;
    case 4: setProgress((int)static_QUType_int.get(_o+1),(int)static_QUType_int.get(_o+2)); break;
    case 5: setLabelText((const QString&)static_QUType_QString.get(_o+1)); break;
    case 6: setCancelButtonText((const QString&)static_QUType_QString.get(_o+1)); break;
    case 7: setMinimumDuration((int)static_QUType_int.get(_o+1)); break;
    case 8: forceShow(); break;
    default:
	return QDialog::qt_invoke( _id, _o );
    }
    return TRUE;
}
Exemplo n.º 5
0
void QProgressDialogPrivate::init(const QString &labelText, const QString &cancelText,
                                  int min, int max)
{
    Q_Q(QProgressDialog);
    label = new QLabel(labelText, q);
    int align = q->style()->styleHint(QStyle::SH_ProgressDialog_TextLabelAlignment, 0, q);
    label->setAlignment(Qt::Alignment(align));
    bar = new QProgressBar(q);
    bar->setRange(min, max);
    autoClose = true;
    autoReset = true;
    forceHide = false;
    QObject::connect(q, SIGNAL(canceled()), q, SLOT(cancel()));
    forceTimer = new QTimer(q);
    QObject::connect(forceTimer, SIGNAL(timeout()), q, SLOT(forceShow()));
    if (useDefaultCancelText) {
        retranslateStrings();
    } else {
        q->setCancelButtonText(cancelText);
    }
}
Exemplo n.º 6
0
Kleo::ProgressDialog::ProgressDialog(Job *job, const QString &baseText,
                                     QWidget *creator, const char *name, WFlags f)
    : QProgressDialog(creator, name, false, f), mBaseText(baseText)
{
    assert(job);
    setBar(new ProgressBar(this, "replacement progressbar in Kleo::ProgressDialog"));

    setMinimumDuration(2000 /*ms*/);
    setAutoReset(false);
    setAutoClose(false);
    setLabelText(baseText);
    setProgress(0, 0);   // activate busy indicator

    connect(job, SIGNAL(progress(const QString &, int, int)),
            SLOT(slotProgress(const QString &, int, int)));
    connect(job, SIGNAL(done()), SLOT(slotDone()));
    connect(this, SIGNAL(canceled()),
            job, SLOT(slotCancel()));

    QTimer::singleShot(minimumDuration(), this, SLOT(forceShow()));
}
Exemplo n.º 7
0
void Kleo::ProgressDialog::setMinimumDuration(int ms)
{
    if(0 < ms && ms < minimumDuration())
        QTimer::singleShot(ms, this, SLOT(forceShow()));
    QProgressDialog::setMinimumDuration(ms);
}
Exemplo n.º 8
0
void toResultTableView::querySub(QSharedPointer<toConnectionSubLoan> &con, const QString &sql, toQueryParams const& param)
{
    setSqlAndParams(sql, param);

    TLOG(7, toDecorator, __HERE__) << "Query from toResultTableView::querySub :" << sql << std::endl;
    try
    {
        if (Model && running())
            Model->stop();
        freeModel();

        readAllAct->setEnabled(true);
        Ready = false;
        Finished = false;
        Working->setText(tr("Please wait..."));
        Working->hide();

        // sets visible true but won't show if parent is hidden
        QTimer t(this);
        t.singleShot(300, Working, SLOT(forceShow()));

        toEventQuery *query = new toEventQuery(this
                                               , con
                                               , sql
                                               , param
                                               , toEventQuery::READ_FIRST
                                               //, Statistics
                                              );

        toResultModel *model = allocModel(query);
        setModel(model);

        connect(Model, SIGNAL(done()), this, SLOT(slotHandleDone()));
        connect(Model, SIGNAL(modelReset()), this, SLOT(slotHandleReset()));
        connect(Model,
                SIGNAL(firstResult(const toConnection::exception &, bool)),
                this,
                SLOT(slotHandleFirst(const toConnection::exception &, bool)));
        setSortingEnabled(true);
        query->start();
    }
    catch (const toConnection::exception &str)
    {
        emit firstResult(toResult::sql(), str, true);
        emit done();
        slotHandleDone();
        Utils::toStatusMessage(str);
    }
    catch (const QString &str)
    {
        emit firstResult(toResult::sql(), str, true);
        emit done();
        slotHandleDone();
        Utils::toStatusMessage(str);
    }

    verticalHeader()->setVisible(false);
    verticalHeader()->setDefaultSectionSize(QFontMetrics(QFont()).height() + 4);

    horizontalHeader()->setHighlightSections(false);

    // when a new model is created the column sizes are lost
    ColumnsResized = false;
}
Exemplo n.º 9
0
ProgressDialog::ProgressDialog(const QString &labelText , /*
                               int totalSteps,
                               int showAfter,*/
                               QWidget *parent /*,
                               bool modal*/) :
    QProgressDialog(parent),
//    m_wasVisible(false),
//    m_frozen(false),
//    m_modal(modal),
//    m_minimumTimeHasExpired(false),
//    m_minimumDuration(1000),
//    m_sleepingBetweenOperations(false),
//    m_operationText(""),
//    m_totalSteps(totalSteps),
//    m_deferredClose(false),
    m_indeterminate(false)

{
    RG_DEBUG << "ProgressDialog::ProgressDialog - " << labelText << /* " - modal : " << modal << */ endl;

    setWindowTitle(tr("Rosegarden"));
    setBar(new ProgressBar(this));
    setLabelText(labelText);

    // Setting this to QString() causes the cancel button to be deleted.
    // The cancel buttons have never worked properly, and they are particularly
    // broken now, creating a very tricky plumbing problem.  Not being able to
    // cancel is not ideal, but at least not showing a cancel button is
    // truthful.
    setCancelButtonText(QString());

    setMinimumDuration(2000);
    setAttribute(Qt::WA_DeleteOnClose);
    hide();
//    setModal(modal);
/*    setWindowFlags(Qt::Dialog);

    QVBoxLayout *layout = new QVBoxLayout;
    setLayout(layout);
    layout->setAlignment(Qt::AlignCenter);

    QLabel *info = new QLabel(tr("<qt><h3>Processing...</h3></qt>"));
    layout->addWidget(info);

    QGroupBox *box = new QGroupBox;
    layout->addWidget(box);

    QVBoxLayout *boxLayout = new QVBoxLayout;
    box->setLayout(boxLayout);

    m_label = new QLabel(labelText);
    boxLayout->addWidget(m_label);

    m_progressBar = new ProgressBar(totalSteps);
    boxLayout->addWidget(m_progressBar);

    connect(m_progressBar, SIGNAL(valueChanged(int)),
            this, SLOT(slotCheckShow(int)));

    QDialogButtonBox *bb = new QDialogButtonBox(QDialogButtonBox::Cancel);
    layout->addWidget(bb);
    bb->setCenterButtons(true);

    connect(bb, SIGNAL(rejected()), this, SLOT(cancel()));
*/
    // don't show before this timer has elapsed
    m_showAfterTimer = new QTimer;
    m_showAfterTimer->setSingleShot(true);
    m_showAfterTimer->start(2000);
    connect(m_showAfterTimer, SIGNAL(timeout()), this, SLOT(forceShow()));

/*
    m_timer = new QTimer;
    m_timer->setSingleShot(true);
    QWidget::hide(); */
}
Exemplo n.º 10
0
int main(int argc,char* argv[]) {

    qRegisterMetaType<medDataIndex>("medDataIndex");

    // this needs to be done before creating the QApplication object, as per the
    // Qt doc, otherwise there are some edge cases where the style is not fully applied
    QApplication::setStyle("plastique");
    medApplication application(argc,argv);
    medSplashScreen splash(QPixmap(":/pixmaps/medInria-splash.png"));
    setlocale(LC_NUMERIC, "C");

    if (dtkApplicationArgumentsContain(&application, "-h") || dtkApplicationArgumentsContain(&application, "--help")) {
        qDebug() << "Usage: medInria [--fullscreen|--no-fullscreen] [--stereo] "
        #ifdef ACTIVATE_WALL_OPTION
        "[--wall] [--tracker=URL] "
        #endif
        "[--view] [files]]";
        return 1;
    }

    // Do not show the splash screen in debug builds because it hogs the
    // foreground, hiding all other windows. This makes debugging the startup
    // operations difficult.

    #if !defined(_DEBUG)
    bool show_splash = true;
    #else
    bool show_splash = false;
    #endif

    medSettingsManager* mnger = medSettingsManager::instance();

    QStringList posargs;
    for (int i=1;i<application.argc();++i) {
        const QString arg = application.argv()[i];
        if (arg.startsWith("--")) {
            bool valid_option = false;
            const QStringList options = (QStringList()
                    << "--fullscreen"
                    << "--no-fullscreen"
                    << "--wall" 
                    << "--tracker" 
                    << "--stereo"
                    << "--view");
            for (QStringList::const_iterator opt=options.constBegin();opt!=options.constEnd();++opt)
                if (arg.startsWith(*opt))
                    valid_option = true;
            if (!valid_option) { qDebug() << "Ignoring unknown option " << arg; }
            continue;
        }
        posargs.append(arg);
    }

    const bool DirectView = dtkApplicationArgumentsContain(&application,"--view") || posargs.size()!=0;
    int runningMedInria = 0;
    if (DirectView) {
        show_splash = false;
        for (QStringList::const_iterator i=posargs.constBegin();i!=posargs.constEnd();++i) {
            const QString& message = QString("/open ")+*i;
            runningMedInria = application.sendMessage(message);
        }
    } else {
        runningMedInria = application.sendMessage("");
    }

    if (runningMedInria)
        return 0;

    if (show_splash) {

        QObject::connect(medDatabaseController::instance().data(),
                         SIGNAL(copyMessage(QString,int,QColor)),
                         &splash,SLOT(showMessage(QString,int, QColor)));

        application.setMsgColor(Qt::white);
        application.setMsgAlignment(Qt::AlignLeft|Qt::AlignBottom);

        QObject::connect(medPluginManager::instance(),SIGNAL(loadError(const QString&)),
                         &application,SLOT(redirectMessageToSplash(const QString&)) );
        QObject::connect(medPluginManager::instance(),SIGNAL(loaded(QString)),
                         &application,SLOT(redirectMessageToSplash(QString)) );
        QObject::connect(&application,SIGNAL(showMessage(const QString&, int, const QColor&)),
                         &splash,SLOT(showMessage(const QString&, int, const QColor&)) );
        splash.show();
        splash.showMessage("Loading plugins...",Qt::AlignLeft|Qt::AlignBottom,Qt::white);
    }

    //  DATABASE INITIALISATION.
    //  First compare the current with the new data location

    QString currentLocation = medStorage::dataLocation();

    //  If the user configured a new location for the database in the settings editor, we'll need to move it

    QString newLocation = mnger->value("medDatabaseSettingsWidget", "new_database_location").toString();
    if (!newLocation.isEmpty()) {

        //  If the locations are different we need to move the db to the new location

        if (currentLocation.compare(newLocation)!=0) {
            if (!medDatabaseController::instance()->moveDatabase(newLocation)) {
                qDebug() << "Failed to move the database from " << currentLocation << " to " << newLocation;
                //  The new location is invalid so set it to zero
                newLocation = "";
            }
            mnger->setValue("medDatabaseSettingsWidget", "actual_database_location",newLocation);

            //  We need to reset the new Location to prevent doing it all the time

            mnger->setValue("medDatabaseSettingsWidget", "new_database_location","");
        }
    }
    // END OF DATABASE INITIALISATION

    medPluginManager::instance()->initialize();

    medMainWindow mainwindow;
    if (DirectView)
        mainwindow.setStartup(medMainWindow::WorkSpace,posargs);

    forceShow(mainwindow);

    bool fullScreen = medSettingsManager::instance()->value("startup", "fullscreen", false).toBool();

    const bool hasFullScreenArg   = application.arguments().contains("--fullscreen");
    const bool hasNoFullScreenArg = application.arguments().contains("--no-fullscreen");
    const bool hasWallArg         = application.arguments().contains("--wall");

    const int conflict = static_cast<int>(hasFullScreenArg)+static_cast<int>(hasNoFullScreenArg)+ static_cast<int>(hasWallArg);

    if (conflict>1)
        dtkWarn() << "Conflicting command line parameters between --fullscreen, --no-fullscreen and -wall. Ignoring.";
    else {
        if (hasWallArg) {
            mainwindow.setWallScreen(true);
            fullScreen = false;
        }

        if (hasFullScreenArg)
            fullScreen = true;

        if (hasNoFullScreenArg)
            fullScreen = false;
    }

    mainwindow.setFullScreen(fullScreen);


    if(application.arguments().contains("--stereo")) {
       QGLFormat format;
       format.setAlpha(true);
       format.setDoubleBuffer(true);
       format.setStereo(true);
       format.setDirectRendering(true);
       QGLFormat::setDefaultFormat(format);
    }

    if (show_splash)
        splash.finish(&mainwindow);

    if (medPluginManager::instance()->plugins().isEmpty()) {
        QMessageBox::warning(&mainwindow,
                             QObject::tr("No plugin loaded"),
                             QObject::tr("Warning : no plugin loaded successfully."));
    }

    //  Handle signals for multiple medInria instances.

    QObject::connect(&application,SIGNAL(messageReceived(const QString&)),
                     &mainwindow,SLOT(onNewInstance(const QString&)));

    application.setActivationWindow(&mainwindow);
    application.setMainWindow(&mainwindow);

    //  Start main loop.

    const int status = application.exec();

    medPluginManager::instance()->uninitialize();

    return status;
}