Exemplo n.º 1
0
void DCommandHistory::redo() {
    DCommand* command = m_commands[ d->m_current + 1 ];
    command->execute();
    emit commandExecuted( command );

    if ( m_undo ) {
        m_undo->setEnabled(true);
        m_undo->setText( tr("&Undo: %1").arg(command->name()) );
    }

    ++d->m_current;

    if ( d->m_current == d->m_savedAt )
        emit documentRestored();

    if ( isRedoAvailable() ) {
        if ( m_redo ) {
            command = m_commands[ d->m_current + 1 ];
            m_redo->setEnabled(true);
            m_redo->setText( tr("&Redo: %1").arg(command->name()) );
        }
    } else {
        if( m_redo ) {
            m_redo->setEnabled(false);
            m_redo->setText( tr("&Redo") );
        }
    }

    emit modified();
}
Exemplo n.º 2
0
EditViewBase::EditViewBase(RosegardenDocument *doc,
                           std::vector<Segment *> segments,
                           QWidget * /* parent */) :
    // QMainWindow(parent),   // See following comments
    QMainWindow(0),
    m_doc(doc),
    m_segments(segments),
    m_configDialogPageIndex(0),
    m_shortcuts(0)
{
    setAttribute(Qt::WA_DeleteOnClose);
    // Address #1508:  Show the edit windows without activating them, so either
    // they or the main window can continue to have focus in Qt5.
    //
    // On my system (yg) and with parent passed to QMainWindow:
    //   - With Qt5 Qt::WA_ShowWithoutActivating has no effect: the main
    //     windows may always have focus but is always under the editors.
    //   - With Qt4 and WA_ShowWithoutActivating the editors are always
    //     opened under the main window.
    //
    // It seems that a Qt5 window is always under its child.
    // So when passing 0 as parent to QMainWindow the editors are no more child
    // of the main window and the problem is fixed.
    //
    // setAttribute(Qt::WA_ShowWithoutActivating);

    m_doc->attachEditView(this);

    connect(CommandHistory::getInstance(), SIGNAL(commandExecuted()),
            this, SLOT(slotTestClipboard()));

    m_shortcuts = new QShortcut(this);
}
Exemplo n.º 3
0
void DCommandHistory::addCommand(DCommand *command, bool execute)
{
    if ( !command )
        return;

    ++d->m_current;
    m_commands.insert( d->m_current, command );
    // Truncate history
    int count = m_commands.count();
    for ( int i = d->m_current + 1; i < count; ++i )
        delete m_commands.takeLast();

    // Check whether we still can reach savedAt
    if ( d->m_current < d->m_savedAt )
        d->m_savedAt = -2;

    if ( m_undo ) {
        m_undo->setEnabled(true);
        m_undo->setText( tr("&Undo: %1").arg(command->name()) );
    }
    if ( m_redo && m_redo->isEnabled() ) {
        m_redo->setEnabled(false);
        m_redo->setText( tr("&Redo") );
    }
    clipCommands();

    if ( execute )
    {
        command->execute();
        emit commandExecuted(command);
    }
}
Exemplo n.º 4
0
QString Connector::executeCommand(QStringList lst, int waitAt, QString waitFor){

    QString s;
    //Alle Eingaben durchgehen
    for(int i = 0; i < lst.length();++i){

        //Befehl schreiben
        this->_socket->write(lst.at(i).toUtf8() + "\n");
        //Warten bis die Daten geschrieben wurden & Daten zurückgekommen sind
        this->_socket->waitForBytesWritten();
        this->_socket->waitForReadyRead();

        //Ausgabe (utf8) hinzufügen
        QString out = QString::fromUtf8(this->_socket->readAll());
        if(waitAt == i){
            int k = 0;
            while(!out.contains(waitFor) && k < 8192*2){
                this->_socket->waitForReadyRead();
                out += QString::fromUtf8(this->_socket->readAll());
                ++k;
            }
        }
        s += (!s.isEmpty()?"\n":"") + out;


        //Consolenausgabe hinzufügen
        emit newConsoleOutput(lst.at(i) + "\n" + out);
    }

    //Enthält der Text die Befehlseingabezeile?
    if(s.contains(this->_username + "@")){

        //Letzte Zeile entfernen
        QStringList sl = s.split("\n");
        sl.removeLast();
        //Wieder zsmfügen
        s = sl.join("\n");
    }

    //Nicht jedesmal die "Updates" anzeigen

    //Nutzerfreundlichen Text & Icon abfragen
    QString icon;
    QString displayString = displayStringFromCommand(lst, icon);


    //Wenn gruppierung deaktiviert ist...
    if(!this->_grouped && !icon.isEmpty()){
        //Wurde ausgeführt
        emit commandExecuted(lst.first(), displayString, icon);
    }else{
        //Nur anhängen
        this->_groupedCommands.append(lst);
    }

    this->_consoleOutput.clear();
    return s;
}
Exemplo n.º 5
0
status_t BnEffectClient::onTransact(
    uint32_t code, const Parcel& data, Parcel* reply, uint32_t flags)
{
    switch (code) {
        case CONTROL_STATUS_CHANGED: {
            ALOGV("CONTROL_STATUS_CHANGED");
            CHECK_INTERFACE(IEffectClient, data, reply);
            bool hasControl = (bool)data.readInt32();
            controlStatusChanged(hasControl);
            return NO_ERROR;
        } break;
        case ENABLE_STATUS_CHANGED: {
            ALOGV("ENABLE_STATUS_CHANGED");
            CHECK_INTERFACE(IEffectClient, data, reply);
            bool enabled = (bool)data.readInt32();
            enableStatusChanged(enabled);
            return NO_ERROR;
        } break;
        case COMMAND_EXECUTED: {
            ALOGV("COMMAND_EXECUTED");
            CHECK_INTERFACE(IEffectClient, data, reply);
            uint32_t cmdCode = data.readInt32();
            uint32_t cmdSize = data.readInt32();
            char *cmd = NULL;
            if (cmdSize) {
                cmd = (char *)malloc(cmdSize);
                data.read(cmd, cmdSize);
            }
            uint32_t replySize = data.readInt32();
            char *resp = NULL;
            if (replySize) {
                resp = (char *)malloc(replySize);
                data.read(resp, replySize);
            }
            commandExecuted(cmdCode, cmdSize, cmd, replySize, resp);
            if (cmd) {
                free(cmd);
            }
            if (resp) {
                free(resp);
            }
            return NO_ERROR;
        } break;
        default:
            return BBinder::onTransact(code, data, reply, flags);
    }
}
Exemplo n.º 6
0
void Connector::stopGroupedMode(bool silent){

    //Wurde befehle ausgeführt?
    if(!this->_groupedCommands.isEmpty() && !silent){
        //Ja => Anzeigeparameter ermitteln & Signal senden
        QString icon;
        QString disp = displayStringFromCommand(this->_groupedCommands, icon);

        //Nicht anzeigen, direkt zurückgeben
        if(icon != "reload.png"){
            emit commandExecuted(this->_groupedCommands.first(),
                                 disp,icon);
        }
    }

    //Gruppierten Modus beenden
    this->_grouped = false;
}
Exemplo n.º 7
0
EditViewBase::EditViewBase(RosegardenDocument *doc,
                           std::vector<Segment *> segments,
                           QWidget *parent) :
    QMainWindow(parent),
    m_doc(doc),
    m_segments(segments),
    m_configDialogPageIndex(0),
    m_shortcuts(0)
{
    setAttribute(Qt::WA_DeleteOnClose);

    m_doc->attachEditView(this);

    connect(CommandHistory::getInstance(), SIGNAL(commandExecuted()),
            this, SLOT(slotTestClipboard()));

    m_shortcuts = new QShortcut(this);
}
Exemplo n.º 8
0
void CVSService::slotJobExited(bool normalExit, int exitStatus)
{
    if (!normalExit)
    {
        KMessageBox::sorry(0, i18n("<qt>The CVS command <b>%1</b> has failed. The error code was <i>%2</i>.</qt>").arg(m_cvsCommand).arg(exitStatus), i18n("Command Failed"));
    }
    if (exitStatus == 0)
    {
        emit commandExecuted(m_cvsCommand, m_files);
    }
    disconnectDCOPSignal(m_job.app(), m_job.obj(), "jobExited(bool, int)", "slotJobExited(bool, int)");
    disconnectDCOPSignal(m_job.app(), m_job.obj(), "receivedStdout(QString)", "slotReceivedStdout(QString)");
    disconnectDCOPSignal(m_job.app(), m_job.obj(), "receivedStderr(QString)", "slotReceivedStderr(QString)");
    //delete m_cvsJob;
    //m_cvsJob = 0L;
    emit showMessage(i18n("CVS command finished."), false);
    emit showMessage(" ", false);
}
Exemplo n.º 9
0
QDesignerFormWindow::QDesignerFormWindow(QDesignerFormWindowInterface *editor, QDesignerWorkbench *workbench, QWidget *parent, Qt::WindowFlags flags)
    : QMainWindow(parent, flags),
      m_editor(editor),
      m_workbench(workbench)
{
    Q_ASSERT(workbench);

    if (m_editor) {
        m_editor->setParent(this);
    } else {
        m_editor = workbench->core()->formWindowManager()->createFormWindow(this);
    }

    setCentralWidget(m_editor);

    m_action = new QAction(this);
    m_action->setCheckable(true);

    connect((QObject*)m_editor->commandHistory(), SIGNAL(commandExecuted()), this, SLOT(updateChanged()));
    connect(m_editor, SIGNAL(fileNameChanged(QString)), this, SLOT(updateWindowTitle(QString)));
}
Exemplo n.º 10
0
void DCommandHistory::undo() {
    Q_ASSERT( d->m_current >= 0 );

    DCommand* command = m_commands[ d->m_current ];

    command->unexecute();
    emit commandExecuted( command );
    if ( m_redo )
    {
        m_redo->setEnabled(true);
        m_redo->setText( tr("&Redo: %1").arg(command->name()) );
    }

    --d->m_current;
    if ( d->m_current >= 0 ) {
        // undoing further is possible
        if (m_undo ) {
            DCommand* command = m_commands[ d->m_current ];
            m_undo->setEnabled(true);
            m_undo->setText( tr("&Undo: %1").arg(command->name()) );
        }
    } else {
        // undoing further is not possible
        if ( m_undo ) {
            m_undo->setEnabled(false);
            m_undo->setText( tr("&Undo") );
        }
    }

    if ( d->m_current == d->m_savedAt )
        emit documentRestored();

    clipCommands(); // only needed here and in addCommand, NOT in redo

    emit modified();
}
Exemplo n.º 11
0
StandardRuler::StandardRuler(RosegardenDocument *doc,
                             RulerScale *rulerScale,
                             double xorigin,
                             int barHeight,
                             bool invert,
                             bool isForMainWindow,
                             QWidget* parent) :
        QWidget(parent),
        m_invert(invert),
        m_isForMainWindow(isForMainWindow),
        m_loopRulerHeight(10),
        m_currentXOffset(0),
        m_doc(doc),
        m_rulerScale(rulerScale),
        m_markerRuler(0)
{
//    QString localStyle("QWidget { background-color: #EEEEEE; color: #000000; }");

    QVBoxLayout *layout = new QVBoxLayout(this);
    layout->setMargin(0);
    layout->setSpacing(0);
    setLayout(layout);
	
    if (!m_invert) {
        m_markerRuler = new MarkerRuler
                       (m_doc, m_rulerScale, barHeight - m_loopRulerHeight, xorigin, this);
        layout->addWidget(m_markerRuler);
    }

    m_loopRuler = new LoopRuler
                  (m_doc, m_rulerScale, m_loopRulerHeight, xorigin, m_invert, m_isForMainWindow, this);
    layout->addWidget(m_loopRuler);

    if (m_invert) {
        m_markerRuler = new MarkerRuler
                       (m_doc, m_rulerScale, barHeight - m_loopRulerHeight, xorigin, this);
        layout->addWidget(m_markerRuler);
    }

//    m_markerRuler->setStyleSheet(localStyle);
//    m_loopRuler->setStyleSheet(localStyle);
//    m_markerRuler->setToolTip(QString("I am m_markerRuler. My style is: %1").arg(localStyle));


    QObject::connect
        (CommandHistory::getInstance(), SIGNAL(commandExecuted()),
         this, SLOT(update()));

    if (RosegardenMainWindow::self()) {
        QObject::connect
                (m_markerRuler, SIGNAL(editMarkers()),
                 RosegardenMainWindow::self(), SLOT(slotEditMarkers()));

        QObject::connect
                (m_markerRuler, SIGNAL(addMarker(timeT)),
                 RosegardenMainWindow::self(), SLOT(slotAddMarker(timeT)));

        QObject::connect
                (m_markerRuler, SIGNAL(deleteMarker(int, timeT, QString, QString)),
                 RosegardenMainWindow::self(), SLOT(slotDeleteMarker(int, timeT, QString, QString)));

        QObject::connect
                (m_loopRuler, SIGNAL(setPlayPosition(timeT)),
                 RosegardenMainWindow::self(), SLOT(slotSetPlayPosition(timeT)));
    }
}
Exemplo n.º 12
0
ControlEditorDialog::ControlEditorDialog
        (
            QWidget *parent,
            RosegardenDocument *doc,
            DeviceId device
       ):
        QMainWindow(parent),
        m_studio(&doc->getStudio()),
        m_doc(doc),
        m_device(device),
        m_modified(false)
{
    RG_DEBUG << "ControlEditorDialog::ControlEditorDialog: device is " << m_device << endl;

    QWidget *mainFrame = new QWidget(this);
    QVBoxLayout *mainFrameLayout = new QVBoxLayout;
    setCentralWidget(mainFrame);
    setAttribute(Qt::WA_DeleteOnClose);

    // everything else failed, so screw it, let's just set the fscking minimum
    // width the brute force way
    setMinimumWidth(935);

    setWindowTitle(tr("Manage Controllers"));

    QString deviceName(tr("<no device>"));
    MidiDevice *md =
        dynamic_cast<MidiDevice *>(m_studio->getDevice(m_device));
    if (md)
        deviceName = strtoqstr(md->getName());

    // spacing hack!
    new QLabel("", mainFrame);
    new QLabel(tr("  Controllers for %1 (device %2)")
           .arg(deviceName)
           .arg(device), mainFrame);
    new QLabel("", mainFrame);
    
    QStringList sl;
    sl  << tr("Name  ")
        << tr("Type  ")
        << tr("Number  ")
        << tr("Description  ")
        << tr("Min. value  ")
        << tr("Max. value  ")
        << tr("Default value  ")
        << tr("Color  ")
        << tr("Position on instrument panel");
    
    m_treeWidget = new QTreeWidget(mainFrame);
    m_treeWidget->setHeaderLabels(sl);
    m_treeWidget->setSortingEnabled(true);
    
    mainFrameLayout->addWidget(m_treeWidget);
    
    QFrame *btnBox = new QFrame(mainFrame);
    mainFrameLayout->addWidget(btnBox);
    mainFrame->setLayout(mainFrameLayout);

    btnBox->setSizePolicy(
        QSizePolicy(QSizePolicy::Minimum, QSizePolicy::Fixed));

    // QT3: I don't think it's necessary to replace the following ",4, 10" with
    // anything to explicitly set the dimensions of the HBox, but there might be
    // some compatibility trickery I'm not remembering, etc.  Leaving as a
    // reminder in case the layout turns out broken:
    QHBoxLayout* layout = new QHBoxLayout(btnBox /*, 4, 10 */);

    m_addButton = new QPushButton(tr("Add"), btnBox);
    m_deleteButton = new QPushButton(tr("Delete"), btnBox);

    m_closeButton = new QPushButton(tr("Close"), btnBox);

    m_addButton->setToolTip(tr("Add a Control Parameter to the Studio"));

    m_deleteButton->setToolTip(tr("Delete a Control Parameter from the Studio"));

    m_closeButton->setToolTip(tr("Close the Control Parameter editor"));

    layout->addStretch(10);
    layout->addWidget(m_addButton);
    layout->addWidget(m_deleteButton);
    layout->addSpacing(30);

    layout->addWidget(m_closeButton);
    layout->addSpacing(5);

    connect(m_addButton, SIGNAL(released()),
            SLOT(slotAdd()));

    connect(m_deleteButton, SIGNAL(released()),
            SLOT(slotDelete()));

    setupActions();

    connect(CommandHistory::getInstance(), SIGNAL(commandExecuted()),
            this, SLOT(slotUpdate()));

    connect(m_treeWidget, SIGNAL(itemDoubleClicked(QTreeWidgetItem *, int)),
            SLOT(slotEdit(QTreeWidgetItem *, int)));

    // Highlight all columns - enable extended selection mode
    //
    m_treeWidget->setAllColumnsShowFocus(true);
    
    m_treeWidget->setSelectionMode(QAbstractItemView::ExtendedSelection);

    initDialog();
    
    // Set the top item in the list, if able.
    if (m_treeWidget->topLevelItemCount()) {
        m_treeWidget->setCurrentItem(m_treeWidget->topLevelItem(0));
    }
}