コード例 #1
0
ファイル: qgscomposermanager.cpp プロジェクト: Aladar64/QGIS
void QgsComposerManager::duplicate_clicked()
{
  QListWidgetItem* item = mComposerListWidget->currentItem();
  if ( !item )
  {
    return;
  }

  QgsComposer* currentComposer = 0;
  QString currentTitle;
  QMap<QListWidgetItem*, QgsComposer*>::iterator it = mItemComposerMap.find( item );
  if ( it != mItemComposerMap.end() )
  {
    currentComposer = it.value();
    currentTitle = it.value()->title();
  }
  else
  {
    return;
  }

  QString newTitle = QgisApp::instance()->uniqueComposerTitle( this, false, currentTitle + tr( " copy" ) );
  if ( newTitle.isNull() )
  {
    return;
  }

  // provide feedback, since loading of template into duplicate composer will be hidden
  QDialog* dlg = new QgsBusyIndicatorDialog( tr( "Duplicating composer..." ) );
  dlg->setStyleSheet( QgisApp::instance()->styleSheet() );
  dlg->show();

  QgsComposer* newComposer = QgisApp::instance()->duplicateComposer( currentComposer, newTitle );

  dlg->close();
  delete dlg;
  dlg = 0;

  if ( newComposer )
  {
    // extra activation steps for Windows
    newComposer->activate();
  }
  else
  {
    QMessageBox::warning( this, tr( "Duplicate Composer" ),
                          tr( "Composer duplication failed." ) );
  }
}
コード例 #2
0
ファイル: mainwindow.cpp プロジェクト: AzanovAA/MediaRenamer
void MainWindow::filesRenamed(int count, int successCount)
{
//    QMessageBox *messageBox = new QMessageBox(this);
//    messageBox->setWindowTitle("Visual Renamer");
//    messageBox->setIconPixmap(QPixmap(":/resources/logo.png"));
//    messageBox->addButton(QMessageBox::Ok);

    if(count == successCount)
    {
        QDialog succesDialog;

        QLabel *logoLabel = new QLabel(&succesDialog);
        QLabel *messageLabel = new QLabel("All files have been\nrenamed successfully!", &succesDialog);
        QLabel *succesLabel = new QLabel(&succesDialog);
        QPushButton *okButton = new QPushButton("Ok");

        succesDialog.setStyleSheet("QFrame#add_files_frame {"
                             "border: 3px dashed rgb(220, 220, 220);"
                             "border-radius: 24px"
                             "}"
                             "QPushButton {"
                             "background: qlineargradient(x1:0.5, y1:0, x2:0.5, y2:1, stop:0 rgb(245, 245, 245), stop:1 rgb(214, 214, 214));"
                             "border: 1px solid rgb(171, 171, 171);"
                             "border-radius: 5px"
                             "}"
                             "QPushButton:pressed {"
                             "background: qlineargradient(x1:0.5, y1:0, x2:0.5, y2:1, stop:0 rgb(214, 214, 214), stop:1 rgb(230, 230, 230));"
                             "}"
                             "QWidget {"
                             "font: bold 13px \"Arial\";"
                             "color: rgb(58, 58, 58);"
                             "}");

        logoLabel->setPixmap(QPixmap(":/resources/logo.png"));
        succesLabel->setPixmap(QPixmap(":/resources/done.png"));
        messageLabel->setMargin(10);
        succesLabel->setMargin(10);

        okButton->setFixedSize(150, 30);

        QHBoxLayout *upperLayout = new QHBoxLayout;
        QVBoxLayout *mainLayout = new QVBoxLayout(&succesDialog);

        upperLayout->addWidget(logoLabel);
        upperLayout->addWidget(messageLabel);
        upperLayout->addWidget(succesLabel);

        mainLayout->addLayout(upperLayout);
        mainLayout->addWidget(okButton, 0, Qt::AlignHCenter);
        mainLayout->setSizeConstraint(QLayout::SetFixedSize);

        connect(okButton, SIGNAL(clicked()), &succesDialog, SLOT(accept()));

        succesDialog.exec();
    }
    else
    {
        QDialog failDialog;

        QLabel *logoLabel = new QLabel(&failDialog);
        QLabel *successMessageLabel = new QLabel(QString("%1 of %2 files have been\nrenamed successfully!").arg(successCount).arg(count), &failDialog);
        QLabel *failMessageLabel = new QLabel(QString("ERROR: %1 of %2 files\nhave not been renamed.").arg(count-successCount).arg(count), &failDialog);
        QLabel *succesLabel = new QLabel(&failDialog);
        QLabel *failLabel = new QLabel(&failDialog);

        QPushButton *okButton = new QPushButton("Ok");

        failDialog.setStyleSheet("QFrame#add_files_frame {"
                             "border: 3px dashed rgb(220, 220, 220);"
                             "border-radius: 24px"
                             "}"
                             "QPushButton {"
                             "background: qlineargradient(x1:0.5, y1:0, x2:0.5, y2:1, stop:0 rgb(245, 245, 245), stop:1 rgb(214, 214, 214));"
                             "border: 1px solid rgb(171, 171, 171);"
                             "border-radius: 5px"
                             "}"
                             "QPushButton:pressed {"
                             "background: qlineargradient(x1:0.5, y1:0, x2:0.5, y2:1, stop:0 rgb(214, 214, 214), stop:1 rgb(230, 230, 230));"
                             "}"
                             "QWidget {"
                             "font: bold 13px \"Arial\";"
                             "color: rgb(58, 58, 58);"
                             "}");

        logoLabel->setPixmap(QPixmap(":/resources/logo.png"));
        succesLabel->setPixmap(QPixmap(":/resources/done.png"));
        failLabel->setPixmap(QPixmap(":/resources/fail.png"));

        okButton->setFixedSize(150, 30);

        QVBoxLayout *messagesLayout = new QVBoxLayout;
        messagesLayout->addWidget(successMessageLabel);
        messagesLayout->addWidget(failMessageLabel);
        messagesLayout->setMargin(0);
        messagesLayout->setSpacing(0);

        QVBoxLayout *imagesLayout = new QVBoxLayout;
        imagesLayout->addWidget(succesLabel);
        imagesLayout->addWidget(failLabel);
        imagesLayout->setMargin(0);
        imagesLayout->setSpacing(0);

        QHBoxLayout *statusLayout = new QHBoxLayout;
        statusLayout->addLayout(messagesLayout);
        statusLayout->addLayout(imagesLayout);

        QHBoxLayout *upperLayout = new QHBoxLayout;
        upperLayout->addWidget(logoLabel);
        upperLayout->addLayout(statusLayout);

        QVBoxLayout *mainLayout = new QVBoxLayout(&failDialog);
        mainLayout->addLayout(upperLayout);
        mainLayout->addWidget(okButton, 0, Qt::AlignHCenter);
        mainLayout->setSizeConstraint(QLayout::SetFixedSize);

        connect(okButton, SIGNAL(clicked()), &failDialog, SLOT(accept()));

        failDialog.exec();
    }
}
コード例 #3
0
MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::MainWindow),
    m_Configurator(this),
    update_Timer(this)
{
    QObject::connect(&update_Timer, SIGNAL(timeout()), this, SLOT(UpdateTimer()));
    ui->setupUi(this);
    //ui->toolBar->setContextMenuPolicy(Qt::PreventContextMenu);
    this->setWindowFlags(Qt::WindowStaysOnTopHint | Qt::FramelessWindowHint);
    this->setAttribute(Qt::WA_TranslucentBackground);
    //Resize Option
    // QGridLayout is already in *.ui file
    // Using gridLayout_3 here which is the outer layout
    QSizeGrip * sizeGrip = new QSizeGrip(this);
    ui->gridLayout_3->addWidget(sizeGrip, 0,0,10,10,Qt::AlignBottom | Qt::AlignRight);
    sizeGrip->setStyleSheet("background: url(''); width: 16px; height: 16px;");

    QObject::connect(ui->btnTransparency, SIGNAL(clicked(bool)), this, SLOT(EnableTransparency(bool)));
    QObject::connect(ui->btnHelp, SIGNAL(clicked()), this, SLOT(LinkToWebsite()));
    QObject::connect(ui->btnConfig, SIGNAL(clicked()), &m_Configurator, SLOT(exec()));

    ScreenRecorder* screenRecorder = new ScreenRecorder;
    DmgMeter* dmgMeter = &screenRecorder->GetDmgMeter();
    screenRecorder->moveToThread(&m_ScreenRecorderThread);

    Ui::Configurator* uiConfig = m_Configurator.ui;
    dmgMeter->moveToThread(&m_ScreenRecorderThread);

    QObject::connect(&m_ScreenRecorderThread, SIGNAL(finished()), screenRecorder, SLOT(deleteLater()));
    QObject::connect(&m_ScreenRecorderThread, SIGNAL(started()), screenRecorder, SLOT(StartRecording()));
    QObject::connect(screenRecorder, SIGNAL(RequestInfoUpdate(QString)), ui->labelInfo, SLOT(setText(QString)));
    QObject::connect(dmgMeter, SIGNAL(RequestTimeUpdate(int)), this, SLOT(UpdateTime(int)));
    //QObject::connect(dmgMeter, SIGNAL(RequestDmgUpdate(unsigned long long)), this, SLOT(UpdateDmg(unsigned long long)));
    //QObject::connect(dmgMeter, SIGNAL(RequestDpsUpdate(int)), this, SLOT(UpdatePersonal()));
    //QObject::connect(dmgMeter, SIGNAL(RequestMaxDmgUpdate(int)), this, SLOT(UpdateMaxDmg(int)));
    QObject::connect(ui->btnReset, SIGNAL(clicked()), dmgMeter, SLOT(Reset()));
    QObject::connect(ui->btnAutoReset, SIGNAL(triggered(bool)), dmgMeter, SLOT(SetIsAutoResetting(bool)));
    QObject::connect(uiConfig->comboBoxScreenshots, SIGNAL(currentIndexChanged(QString)), screenRecorder, SLOT(SetScreenshotsPerSecond(QString)));
    QObject::connect(uiConfig->comboBoxUpdates, SIGNAL(currentIndexChanged(QString)), dmgMeter, SLOT(SetUpdatesPerSecond(QString)));
    QObject::connect(uiConfig->comboBoxSecondsInCombat, SIGNAL(currentIndexChanged(QString)), dmgMeter, SLOT(SetSecondsInCombat(QString)));
    QObject::connect(uiConfig->comboBoxConsideredLines, SIGNAL(currentIndexChanged(QString)), dmgMeter, SLOT(SetConsideredLineCount(QString)));
    QObject::connect(uiConfig->pushButtonReset, SIGNAL(clicked(bool)), &m_Configurator, SLOT(RestoreDefaults()));

    dmgMeter->SetUpdatesPerSecond(uiConfig->comboBoxUpdates->currentText());
    dmgMeter->SetSecondsInCombat(uiConfig->comboBoxSecondsInCombat->currentText());
    dmgMeter->SetConsideredLineCount(uiConfig->comboBoxConsideredLines->currentText());

    m_ScreenRecorderThread.start();

    Settings::ReadSettings<QMainWindow>(this);

    // Start screenshot timer from separate thread
    const int oldIndex = uiConfig->comboBoxScreenshots->currentIndex();
    uiConfig->comboBoxScreenshots->setCurrentIndex((uiConfig->comboBoxScreenshots->currentIndex() + 1) % uiConfig->comboBoxScreenshots->count());
    uiConfig->comboBoxScreenshots->setCurrentIndex(oldIndex);

    socket = new QTcpSocket(this);


    connect(socket, SIGNAL(connected()),this, SLOT(connected()));
    connect(socket, SIGNAL(disconnected()),this, SLOT(disconnected()));
    connect(socket, SIGNAL(readyRead()),this, SLOT(ready2Read()));

    qDebug() << "connecting to : " << HostIP << ":" << HostPort;

    // this is not blocking call

    // IP should be yours
    MyClientSlot=10; //no semi-handshake yet
    CurrentMeta=0;CurrentPos=0;
    int i;
    for (i=0;i<10;i++)
    {
        SlotDmg[i]=0;
        SlotDPS[i]=0;
        SlotAct[i]=0;
        SlotName[i][0]='\0';
    }
    AllDamageDone=0;
    hitCounter=0;
    m_critChance=0;
    critCounter=0;
    m_condiDmg=0;
    LastColor=0;

    socket->connectToHost(HostIP, HostPort);

    // we need to wait...
    if(!socket->waitForConnected(5000))
    {
        qDebug() << "Error: " << socket->errorString();
        QDialog *dialog = new QDialog();
        QHBoxLayout *layout = new QHBoxLayout(dialog);
        QLabel *label = new QLabel(this);
        label->setText("Connection to " + HostIP + " failed");
        layout->addWidget(label);
        layout->setMargin(50);
        dialog->setStyleSheet("background:red;");
        dialog->show();
    }
    m_Dps=0;m_Dmg=0;m_Activity=0;m_MaxDmg=0;
    update_Timer.start(1000);
}
コード例 #4
0
ファイル: qgscomposermanager.cpp プロジェクト: Aladar64/QGIS
void QgsComposerManager::on_mAddButton_clicked()
{
  QFile templateFile;
  bool loadingTemplate = ( mTemplate->currentIndex() > 0 );
  if ( loadingTemplate )
  {
    if ( mTemplate->currentIndex() == 1 )
    {
      templateFile.setFileName( mTemplatePathLineEdit->text() );
    }
    else
    {
      templateFile.setFileName( mTemplate->itemData( mTemplate->currentIndex() ).toString() );
    }

    if ( !templateFile.exists() )
    {
      QMessageBox::warning( this, tr( "Template error" ), tr( "Error, template file not found" ) );
      return;
    }
    if ( !templateFile.open( QIODevice::ReadOnly ) )
    {
      QMessageBox::warning( this, tr( "Template error" ), tr( "Error, could not read file" ) );
      return;
    }
  }

  QgsComposer* newComposer = 0;
  bool loadedOK = false;

  QString title = QgisApp::instance()->uniqueComposerTitle( this, true );
  if ( title.isNull() )
  {
    return;
  }

  newComposer = QgisApp::instance()->createNewComposer( title );
  if ( !newComposer )
  {
    QMessageBox::warning( this, tr( "Composer error" ), tr( "Error, could not create composer" ) );
    return;
  }
  else
  {
    loadedOK = true;
  }

  if ( loadingTemplate )
  {
    QDomDocument templateDoc;
    if ( templateDoc.setContent( &templateFile, false ) )
    {
      // provide feedback, since composer will be hidden when loading template (much faster)
      // (not needed for empty composer)
      QDialog* dlg = new QgsBusyIndicatorDialog( tr( "Loading template into composer..." ) );
      dlg->setStyleSheet( QgisApp::instance()->styleSheet() );
      dlg->show();

      newComposer->hide();
      loadedOK = newComposer->composition()->loadFromTemplate( templateDoc, 0, false );
      newComposer->activate();

      dlg->close();
      delete dlg;
      dlg = 0;
    }
  }

  if ( !loadedOK )
  {
    newComposer->close();
    QgisApp::instance()->deleteComposer( newComposer );
    newComposer = 0;
    QMessageBox::warning( this, tr( "Template error" ), tr( "Error, could not load template file" ) );
  }
}