コード例 #1
0
ファイル: mainwindow.cpp プロジェクト: KDE/kaffeine
void MainWindow::configureKaffeine()
{
	QDialog *dialog = new ConfigurationDialog(this);
	dialog->setAttribute(Qt::WA_DeleteOnClose, true);
	dialog->setModal(true);
	dialog->show();
}
コード例 #2
0
ファイル: mainwindow.cpp プロジェクト: thddaniel/QT
void MainWindow::about()
{
    QLabel *label = new QLabel;
    QLabel *pix   = new QLabel;
    label->setText(tr("<p><b>关于</b></p> "
                      "<p>版本:    1.0</p>"
                      "<p>库:      Qt 4.8.1</p>"
                      "<p>数据库:  Sqlite</p>"
                      "<p>作者:    唐昊</p> "
                      "<p>Email:thddaniel92gmail.com</p>"));
    pix->setPixmap(QPixmap("images/money.png"));
    QToolButton *btn = new QToolButton;
    btn->setMinimumSize(60,40);
    btn->setText(tr("关闭"));
    QHBoxLayout *layout = new QHBoxLayout;
    layout->addWidget(pix);
    layout->addWidget(label);
    QHBoxLayout *layout2 = new QHBoxLayout;
    //layout2->addStretch(12);
    layout2->addWidget(btn,Qt::AlignHCenter);
    //layout2->addStretch(12);
    QVBoxLayout *layout3 = new QVBoxLayout;
    layout3->addLayout(layout);
    layout3->addLayout(layout2);
    QDialog *dlg = new QDialog;
    connect(btn,SIGNAL(clicked()),dlg,SLOT(close()));
    dlg->setWindowTitle(tr("关于"));
    dlg->setAttribute(Qt::WA_DeleteOnClose);
    dlg->setLayout(layout3);
    dlg->exec();


}
コード例 #3
0
void AssetUploadDialogFactory::handleUploadFinished(AssetUpload* upload, const QString& hash) {
    if (upload->getError() == AssetUpload::NoError) {
        // show message box for successful upload, with copiable text for ATP hash
        QDialog* hashCopyDialog = new QDialog(_dialogParent);
        
        // delete the dialog on close
        hashCopyDialog->setAttribute(Qt::WA_DeleteOnClose);
        
        // set the window title
        hashCopyDialog->setWindowTitle(tr("Successful Asset Upload"));
        
        // setup a layout for the contents of the dialog
        QVBoxLayout* boxLayout = new QVBoxLayout;
        
        // set the label text (this shows above the text box)
        QLabel* lineEditLabel = new QLabel;
        lineEditLabel->setText(QString("ATP URL for %1").arg(QFileInfo(upload->getFilename()).fileName()));
        
        // setup the line edit to hold the copiable text
        QLineEdit* lineEdit = new QLineEdit;
       
        QString atpURL = QString("%1:%2.%3").arg(URL_SCHEME_ATP).arg(hash).arg(upload->getExtension());
        
        // set the ATP URL as the text value so it's copiable
        lineEdit->insert(atpURL);
        
        // figure out what size this line edit should be using font metrics
        QFontMetrics textMetrics { lineEdit->font() };
        
        // set the fixed width on the line edit
        // pad it by 10 to cover the border and some extra space on the right side (for clicking)
        static const int LINE_EDIT_RIGHT_PADDING { 10 };
        
        lineEdit->setFixedWidth(textMetrics.width(atpURL) + LINE_EDIT_RIGHT_PADDING );
        
        // left align the ATP URL line edit
        lineEdit->home(true);
        
        // add the label and line edit to the dialog
        boxLayout->addWidget(lineEditLabel);
        boxLayout->addWidget(lineEdit);
        
        // setup an OK button to close the dialog
        QDialogButtonBox* buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok);
        connect(buttonBox, &QDialogButtonBox::accepted, hashCopyDialog, &QDialog::close);
        boxLayout->addWidget(buttonBox);
        
        // set the new layout on the dialog
        hashCopyDialog->setLayout(boxLayout);
        
        // show the new dialog
        hashCopyDialog->show();
    } else {
        // display a message box with the error
        showErrorDialog(upload, _dialogParent);
    }
    
    upload->deleteLater();
}
コード例 #4
0
ファイル: mainframe.cpp プロジェクト: hunanhd/cbm
void MainFrame::editOptions()
{
    QDialog *dialog = new QDialog(this);
    dialog->setAttribute(Qt::WA_DeleteOnClose);
    Ui::OptionsDialog ui;
    ui.setupUi(dialog);

    dialog->show();
}
コード例 #5
0
ファイル: main.cpp プロジェクト: bingo2011/codes_TheBookOfQT4
int main(int argc, char*argv[])
{
  QApplication app(argc, argv);
  QDialog dlg;
  Ui::ByteConverterDialog ui;
  ui.setupUi(&dlg);
  dlg.setAttribute(Qt::WA_QuitOnClose);
  dlg.show();
  return app.exec();
}
コード例 #6
0
void AboutDialog::largeLogo(){
	QDialog * d = new QDialog(0);
	d->setAttribute(Qt::WA_DeleteOnClose);
	d->setLayout(new QHBoxLayout(d));
	QLabel *l = new QLabel(d);
	l->setPixmap(QPixmap(":/images/splash_large.png"));
	d->layout()->addWidget(l);
	d->setWindowTitle("TeXstudio");
	d->exec();
}
コード例 #7
0
void IbisHardwareModule::OpenTrackerSettingsDialog()
{
    QDialog * dialog = new QDialog();
    dialog->setAttribute(Qt::WA_DeleteOnClose);
    dialog->setWindowTitle( "Tracker Settings" );
    QVBoxLayout * layout = new QVBoxLayout( dialog );
    QWidget * dlg = m_tracker->CreateSettingsDialog( dialog );
    layout->addWidget( dlg );
    dialog->show();
}
コード例 #8
0
ファイル: qtmfc.cpp プロジェクト: KnowNo/test-code-backup
void WindowsApp::OnAppOptions()
{
    QWinWidget *win = new QWinWidget(theApp.m_pMainWnd);
    win->showCentered();

    QDialog *dialog = new QDialog(win);
    Ui::OptionsDialog ui;
    ui.setupUi(dialog);
    dialog->setAttribute(Qt::WA_DeleteOnClose);
    dialog->show();
}
コード例 #9
0
ファイル: ocupdater.cpp プロジェクト: msphn/client
void NSISUpdater::showDialog(const UpdateInfo &info)
{
    // if the version tag is set, there is a newer version.
    QDialog *msgBox = new QDialog;
    msgBox->setAttribute(Qt::WA_DeleteOnClose);

    QIcon infoIcon = msgBox->style()->standardIcon(QStyle::SP_MessageBoxInformation, 0, 0);
    int iconSize = msgBox->style()->pixelMetric(QStyle::PM_MessageBoxIconSize, 0, 0);

    msgBox->setWindowIcon(infoIcon);

    QVBoxLayout *layout = new QVBoxLayout(msgBox);
    QHBoxLayout *hlayout = new QHBoxLayout;
    layout->addLayout(hlayout);

    msgBox->setWindowTitle(tr("New Version Available"));

    QLabel *ico = new QLabel;
    ico->setFixedSize(iconSize, iconSize);
    ico->setPixmap(infoIcon.pixmap(iconSize));
    QLabel *lbl = new QLabel;
    QString txt = tr("<p>A new version of the %1 Client is available.</p>"
                     "<p><b>%2</b> is available for download. The installed version is %3.</p>")
                      .arg(Utility::escape(Theme::instance()->appNameGUI()),
                          Utility::escape(info.versionString()), Utility::escape(clientVersion()));

    lbl->setText(txt);
    lbl->setTextFormat(Qt::RichText);
    lbl->setWordWrap(true);

    hlayout->addWidget(ico);
    hlayout->addWidget(lbl);

    QDialogButtonBox *bb = new QDialogButtonBox;
    bb->setWindowFlags(bb->windowFlags() & ~Qt::WindowContextHelpButtonHint);
    QPushButton *skip = bb->addButton(tr("Skip this version"), QDialogButtonBox::ResetRole);
    QPushButton *reject = bb->addButton(tr("Skip this time"), QDialogButtonBox::AcceptRole);
    QPushButton *getupdate = bb->addButton(tr("Get update"), QDialogButtonBox::AcceptRole);

    connect(skip, &QAbstractButton::clicked, msgBox, &QDialog::reject);
    connect(reject, &QAbstractButton::clicked, msgBox, &QDialog::reject);
    connect(getupdate, &QAbstractButton::clicked, msgBox, &QDialog::accept);

    connect(skip, &QAbstractButton::clicked, this, &NSISUpdater::slotSetSeenVersion);
    connect(getupdate, SIGNAL(clicked()), SLOT(slotOpenUpdateUrl()));

    layout->addWidget(bb);

    msgBox->open();
}
コード例 #10
0
void AlbumCoverChoiceController::ShowCover(const Song& song) {
  QDialog* dialog = new QDialog(this);
  dialog->setAttribute(Qt::WA_DeleteOnClose, true);

  // Use Artist - Album as the window title
  QString title_text(song.albumartist());
  if (title_text.isEmpty()) title_text = song.artist();

  if (!song.album().isEmpty()) title_text += " - " + song.album();

  dialog->setWindowTitle(title_text);

  QLabel* label = new QLabel(dialog);
  label->setPixmap(AlbumCoverLoader::TryLoadPixmap(
      song.art_automatic(), song.art_manual(), song.url().toLocalFile()));

  dialog->resize(label->pixmap()->size());
  dialog->show();
}
コード例 #11
0
void AlbumCoverChoiceController::ShowCover(const Song& song) {
  QDialog* dialog = new QDialog(this);
  dialog->setAttribute(Qt::WA_DeleteOnClose, true);

  // Use (Album)Artist - Album as the window title
  QString title_text(song.effective_albumartist());
  if (!song.effective_album().isEmpty())
    title_text += " - " + song.effective_album();

  QLabel* label = new QLabel(dialog);
  label->setPixmap(AlbumCoverLoader::TryLoadPixmap(
      song.art_automatic(), song.art_manual(), song.url().toLocalFile()));

  // add (WxHpx) to the title before possibly resizing
  title_text += " (" + QString::number(label->pixmap()->width()) + "x" +
                QString::number(label->pixmap()->height()) + "px)";

  // if the cover is larger than the screen, resize the window
  // 85% seems to be enough to account for title bar and taskbar etc.
  QDesktopWidget desktop;
  int current_screen = desktop.screenNumber(this);
  int desktop_height = desktop.screenGeometry(current_screen).height();
  int desktop_width = desktop.screenGeometry(current_screen).width();

  // resize differently if monitor is in portrait mode
  if (desktop_width < desktop_height) {
    const int new_width = (double)desktop_width * 0.95;
    if (new_width < label->pixmap()->width()) {
      label->setPixmap(
          label->pixmap()->scaledToWidth(new_width, Qt::SmoothTransformation));
    }
  } else {
    const int new_height = (double)desktop_height * 0.85;
    if (new_height < label->pixmap()->height()) {
      label->setPixmap(label->pixmap()->scaledToHeight(
          new_height, Qt::SmoothTransformation));
    }
  }

  dialog->setWindowTitle(title_text);
  dialog->setFixedSize(label->pixmap()->size());
  dialog->show();
}
コード例 #12
0
ファイル: mainwindow.cpp プロジェクト: Team-2502/CodeTools
void MainWindow::showPlot()
{
    if(!currentImageSteps->at(currentImageSteps->size()-2))
        return;
//    if(!fp)
//        delete fp;
    QDialog* dlg = new QDialog(this);
//    QHBoxLayout* mainLayout = new QHBoxLayout(dlg);

//    fp = new FitnessPlot(currentImageSteps->at(currentImageSteps->size()-2));
//    fp->activate(currentImageSteps->at(currentImageSteps->size()-2),ui->rBox->value());
//    fp->resize(800,600);

//    mainLayout->addWidget(fp);
//    dlg->setLayout(mainLayout);
    dlg->setAttribute(Qt::WA_DeleteOnClose);
    dlg->resize(800,600);
    dlg->show();
}
コード例 #13
0
ファイル: UtmpWebView.cpp プロジェクト: 2life/BrowserCore
void UtmpWebView::SetFrameWindow(int flag)
{
    switch(flag)
    {
        case 0:
            this->close();
            break;
        case 1:
            this->showMinimized();
            break;
        case 2:
        {
            //全局也就只能有一个
            QDialog* d = new QDialog(this,(Qt::WindowMinimizeButtonHint|Qt::WindowMaximizeButtonHint|Qt::WindowCloseButtonHint));
            d->setAttribute(Qt::WA_DeleteOnClose, true);
            QWebInspector* wi = new QWebInspector(d);
            wi->setPage(this->page());
            d->setLayout(new QVBoxLayout());
            d->layout()->setMargin(0);
            d->layout()->addWidget(wi);
            d->show();
            d->resize(600,350);
            break;
        }
        case 3:
        {
            QMessageBox::StandardButton rb = QMessageBox::information(NULL, "from QT", "这是网页让QT弹出的对话框", QMessageBox::Yes | QMessageBox::No, QMessageBox::Yes);
            if(rb == QMessageBox::Yes)
            {
                //这样直接调用,执行速度异常慢
                //this->page()->mainFrame()->evaluateJavaScript("Ext.Msg.alert('from ext','这是QT让网页弹出的对话框');");
                this->page()->mainFrame()->evaluateJavaScript("testFun();");
            }
            break;
        }
        case 4:
        {
            this->reload();
        }
    }
}
コード例 #14
0
void MainWindow::showAbout()
{
    QDialog *about = new QDialog(this);
    about->setAttribute(Qt::WA_DeleteOnClose);
    about->setWindowTitle("About");

    QVBoxLayout *aboutLayout = new QVBoxLayout;
    QLabel *appName = new QLabel("BootLogo Changer 1.0", about);
    QFont font = appName->font();
    font.setPointSize(32);
    font.setBold(true);
    appName->setFont(font);
    appName->setAlignment(Qt::AlignCenter);
    aboutLayout->addWidget(appName);

    QLabel *aboutText = new QLabel("(c) 2013 Sergey Savkin", about);
    aboutLayout->addWidget(aboutText);

    about->setLayout(aboutLayout);
    about->show();
}
コード例 #15
0
ファイル: mainwindow.cpp プロジェクト: whjbinghun/learning
void MainWindow::open() {
    if (QMessageBox::Yes == QMessageBox::question(this,tr("Question"),tr("Are you OK?"), \
                                         QMessageBox::Yes | QMessageBox::No, QMessageBox::Yes)) {
        QMessageBox::information(this, tr("Hmmm..."), tr("I'm glad to hear that!"));
    } else {
        QMessageBox::information(this, tr("Hmmm..."), tr("I'm sorry!"));
    }
    //dialog建立在栈上
    /*//QDialog dialog(this);
    //QDialog dialog;
    dialog.setWindowTitle(tr("Hello, dialog!"));
    dialog.exec();
    //QMessageBox::information(this, tr( "Information" ), tr("Open"));
    */
    //dialog建立在堆上
    QDialog *dialog = new QDialog;
    //dialog 使用 new 在堆上分配空间, 却一直没有 delete。可以调用可以调用 deleteLater() 函数,或者是设置 dialog 的 WindowAttribute来delete dialog。
    dialog->setAttribute(Qt::WA_DeleteOnClose); // 或者 dialog->deleteLater();
    dialog->setWindowTitle(tr("hello, dialog!"));
    //dialog->show();
    dialog->open();

}
コード例 #16
0
ファイル: testplugin.cpp プロジェクト: oberleg/QupZilla
void TestPlugin::showSettings(QWidget* parent)
{
    // This function will be called from Preferences after clicking on Settings button.
    // Settings button will be enabled if PluginSpec.hasSettings == true

    QDialog* dialog = new QDialog(parent);
    QPushButton* b = new QPushButton("Example Plugin v0.0.1");
    QPushButton* closeButton = new QPushButton(tr("Close"));
    QLabel* label = new QLabel();
    label->setPixmap(QPixmap(":icons/other/about.png"));

    QVBoxLayout* l = new QVBoxLayout(dialog);
    l->addWidget(label);
    l->addWidget(b);
    l->addWidget(closeButton);
    dialog->setLayout(l);

    dialog->setAttribute(Qt::WA_DeleteOnClose);
    dialog->setWindowTitle(tr("Example Plugin Settings"));
    dialog->setWindowIcon(QIcon(":qupzilla.png"));
    connect(closeButton, SIGNAL(clicked()), dialog, SLOT(close()));

    dialog->show();
}
コード例 #17
0
ファイル: progManage.cpp プロジェクト: ngocthanhtnt/ledshow
void CprogManage::newScreen()
{
    //QTreeWidgetItem *curItem;
    //QTreeWidgetItem *parentItem;
    QString QStr;
    int i,size;//,type,index;
    int max = 0,tmp;

    if(verifyPSW() EQ 0)
        return;

    /*
    CinputPSWDialog *pswInput = new CinputPSWDialog(this);
    //pswInput->setOkButtonText(tr("确定"));
    pswInput->exec();
*/
    QStr = "screen";//QStr + "/" + QString(tr("area"));

    settings.beginGroup(QStr);
    QStringList groups = settings.childGroups(); //area列表

    size = groups.size();

    for(i = 0; i < size; i ++)
    {
      tmp = groups.at(i).toInt();
      if(tmp > max)
          max=tmp;
    }
    max++;


    //初始化分区属性
    settings.beginGroup(fixWidthNumber(max));
    settings.setValue("screenIndex", 1);//value("screenIndex").toString()
    settings.setValue("checkState", true);
    settings.setValue("spaceWidth", 1);
    settings.setValue("dotWidth", 2);
    settings.endGroup();
    settings.endGroup();


    //
    QTreeWidgetItem* item = new QTreeWidgetItem(treeWidget,QStringList(QString::number(size + 1)+tr("屏幕")));
    item->setData(0, Qt::UserRole, QVariant(QStr + "/" + fixWidthNumber(max)));
    item->setCheckState(0, Qt::Checked);

    QIcon icon = getTypeIcon(SCREEN_PROPERTY);
    item->setIcon(0,icon);

    treeWidget->addTopLevelItem(item);

    /*CMdiSubWindow * subWin =*/
    _newScreen(QString::number(size + 1) + tr("屏幕"), 0, 0, DEF_SCN_WIDTH, DEF_SCN_HEIGHT,1, 2, DEF_SCN_COLOR);
    w->screenArea->screenItem = item;

    w->progManage->treeWidget->setCurrentItem(item);

    //---------------
    QString str = w->screenArea->getCurrentScreenStr(); //当前屏幕str
    QDialog *facParaWin = new QDialog(this);
    QHBoxLayout *hLayout = new QHBoxLayout(facParaWin);

    facParaWin->setWindowTitle(tr("新建屏幕"));

    CcomTest *comTest = new CcomTest(facParaWin);
    CfacScreenProperty *facScreenProperty = new CfacScreenProperty(NEW_SCN, comTest, facParaWin);
    //facScreenProperty->setSettingsToWidget(str);

    hLayout->addWidget(facScreenProperty);
    hLayout->addWidget(comTest);

    facParaWin->setLayout(hLayout);
    facParaWin->setAttribute(Qt::WA_DeleteOnClose);
    connect(facScreenProperty->endButton, SIGNAL(clicked()), facParaWin, SLOT(close()));
    facParaWin->exec();
    //--------------------

    //判断参数是否被加载,没有被加载则删除已经生成的窗口
    settings.beginGroup(str);
    settings.beginGroup("facPara");
    int setFlag = settings.value("setFlag").toInt(); //是否加载设置了屏幕参数?
    settings.endGroup();
    settings.endGroup();

    if(setFlag EQ 0) //没有加载参数则删除上面建的屏幕
    {
       w->progManage->_deleteItem(0); //删除上面创建的屏幕
    }

    //读取屏幕参数
    //getScreenParaFromSettings(QStr + "/" + QString::number(max), Screen_Para);
    /*
    else
    {
       //subWin->resize(width + 8, height + 34);//setGeometry(0,0, width +8, height + 34);
       subWin->setFixedSize(width + 8, height + 34);
    }*/

}
コード例 #18
0
void ServerSummaryPage::showSettingsDialog()
{
	Q_ASSERT(d->server->isLocal());

	// Show a dialog for changing the local server's settings.
	QDialog *dlg = new QDialog(parentWidget());
	Ui_SettingsDialog ui;
	ui.setupUi(dlg);

	ui.restartAlert->setVisible(static_cast<const LocalServer*>(d->server)->isRunning());

	connect(ui.pickCert, &QPushButton::clicked, std::bind(&pickFilePath, this, ui.certFile));
	connect(ui.pickKey, &QPushButton::clicked, std::bind(&pickFilePath, this, ui.keyFile));

	QSettings cfg;
	cfg.beginGroup("ui");

	ui.trayIcon->setChecked(cfg.value("trayicon", true).toBool());
	ui.trayIcon->setEnabled(QSystemTrayIcon::isSystemTrayAvailable());

	cfg.endGroup();

	cfg.beginGroup("guiserver");
	if(cfg.value("session-storage", "file").toString() == "file")
		ui.storageFile->setChecked(true);
	else
		ui.storageMemory->setChecked(true);

	ui.port->setValue(cfg.value("port", 27750).toInt());
	ui.localAddress->setText(cfg.value("local-address").toString());

	if(cfg.value("use-ssl", false).toBool()) {
		if(cfg.value("force-ssl", false).toBool())
			ui.tlsRequired->setChecked(true);
		else
			ui.tlsOn->setChecked(true);
	} else {
		ui.tlsOff->setChecked(true);
	}
	ui.certFile->setText(cfg.value("sslcert").toString());
	ui.keyFile->setText(cfg.value("sslkey").toString());

	connect(dlg, &QDialog::accepted, this, [ui]() {
		QSettings cfg;
		cfg.setValue("ui/trayicon", ui.trayIcon->isChecked());
		cfg.beginGroup("guiserver");
		cfg.setValue("session-storage", ui.storageFile->isChecked() ? "file" : "memory");
		cfg.setValue("port", ui.port->value());
		cfg.setValue("local-address", ui.localAddress->text());
		cfg.setValue("use-ssl", !ui.tlsOff->isChecked());
		cfg.setValue("force-ssl", ui.tlsRequired->isChecked());
		cfg.setValue("sslcert", ui.certFile->text());
		cfg.setValue("sslkey", ui.keyFile->text());

		if(ui.trayIcon->isChecked())
			TrayIcon::showTrayIcon();
		else
			TrayIcon::hideTrayIcon();
	});

	dlg->setAttribute(Qt::WA_DeleteOnClose);
	dlg->show();
}
コード例 #19
0
ファイル: dia_qtutils.cpp プロジェクト: LabShare/IMOD
/*! Makes a scrolled text window with the text taken from the array of 
  character strings in [msg] */
void dia_smsg(const char **msg)
{
  char *p;
  char *buf;
  char *lineStart;
  char *temp;
  int maxline, maxrow, linesize;
  long bufsize;
  int i, twidth, doline;
  int lastspace, curpos;
  int maxWidth = (int)(0.8 * QApplication::desktop()->width());
  int maxHeight = (int)(0.8 * QApplication::desktop()->height());
  int height, width = 0;
  QString test;

  QDialog *dlg = new QDialog();
  dlg->setAttribute(Qt::WA_DeleteOnClose);

  for (i = 0, bufsize = 0; msg[i]; i++){
    linesize = strlen(msg[i]);
    bufsize += linesize;
  }

  buf = (char *)malloc(bufsize + i + 1);
  p = buf;
  for (p = buf, i = 0; msg[i]; i++) {
    p += strlen (strcpy (p, msg[i]));
    /* DNM: this macro call caused program built on Irix 6.5 to not run
       on earlier Irix's.  Casting as (int) didn't help - just do 
       explicit tests */
    /*if (!isspace (p[-1]))  spaces, tabs and newlines are spaces.. */
    if (p[-1] != ' ' && p[-1] != '\t' && p[-1] != '\n')
      *p++ = ' '; /* lines are concatenated, insert a space */
  }
  *--p = 0; /* get rid of trailing space... */

  // DNM: count the actual lines and their lengths to get the right size window

  maxline = 0;
  maxrow = 1;
  curpos = 0;
  lastspace = 40;
  lineStart = buf;

  for (p = buf; *p; p++) {
    doline = 0;
    if (*p == '\t')
      curpos = 8 * (curpos/ 8 + 1);
    else if (*p == ' ') {
      lastspace = curpos;
      curpos++;
    } else if (*p == '\n') {
      if (curpos >= maxline)
        maxline = curpos + 1;
      curpos = 0;
      doline = p + 1 - lineStart;
    } else if (curpos > 78 ) {
      if (lastspace >= maxline)
        maxline = lastspace + 1;
      curpos -= lastspace;
      doline = lastspace;
    } else
      curpos++;
    
    if (doline) {
      temp = (char *)malloc(doline + 1);
      if (temp) {
	strncpy(temp, lineStart, doline);
	temp[doline] = 0x00;
	test = temp;
	twidth = dlg->fontMetrics().width(test);
	if (width < twidth)
	  width = twidth;
	free(temp);
      }
      lineStart = p + 1;
      lastspace = 40;
      maxrow++;
    }
  }

  if (!maxline & !width) {
    maxline = curpos + 1;
    test = "";
    for (i = 0; i < maxline + 2; i++)
      test += "8";
    width = dlg->fontMetrics().width(test);
  }

  if (maxrow > 50)
    maxrow = 40;

  QString qmsg = buf;

  // Make a vertical layout with the text edit and a close button
  QVBoxLayout *vbox = new QVBoxLayout(dlg);
  QTextEdit *edit = new QTextEdit(dlg);
  edit->setText(qmsg);
  edit->setReadOnly(true);
  vbox->addWidget(edit);
  QHBoxLayout *hbox = diaHBoxLayout(vbox);
  QPushButton *button = diaPushButton("Close", dlg, hbox);
  diaSetButtonWidth(button, true, 1.4, "Close");
  QObject::connect(button, SIGNAL(clicked()), dlg, SLOT(close()));

  // Figure out width and height of text and height of button, and set size
  if (width > maxWidth)
    width = maxWidth;
  height = (maxrow + 5) * edit->fontMetrics().height();
  if (height > maxHeight)
    height = maxHeight;
  QSize hint = hbox->sizeHint();

  // This was width + 20 when the width was based on character count alone
  dlg->resize(width + 60, height + hint.height());

  // Set title
  test = Dia_title;
  test += " Help";
  dlg->setWindowTitle(test);
  dlg->show();
}
コード例 #20
0
void AssetUploadDialogFactory::handleUploadFinished(AssetUpload* upload, const QString& hash) {
    if (upload->getError() == AssetUpload::NoError) {
        // show message box for successful upload, with copiable text for ATP hash
        QDialog* hashCopyDialog = new QDialog(_dialogParent);
        
        // delete the dialog on close
        hashCopyDialog->setAttribute(Qt::WA_DeleteOnClose);
        
        // set the window title
        hashCopyDialog->setWindowTitle(tr("Successful Asset Upload"));
        
        // setup a layout for the contents of the dialog
        QVBoxLayout* boxLayout = new QVBoxLayout;
        
        // set the label text (this shows above the text box)
        QLabel* lineEditLabel = new QLabel;
        lineEditLabel->setText(QString("ATP URL for %1").arg(QFileInfo(upload->getFilename()).fileName()));
        
        // setup the line edit to hold the copiable text
        QLineEdit* lineEdit = new QLineEdit;
       
        QString atpURL = QString("%1:%2.%3").arg(ATP_SCHEME).arg(hash).arg(upload->getExtension());
        
        // set the ATP URL as the text value so it's copiable
        lineEdit->insert(atpURL);
        
        // figure out what size this line edit should be using font metrics
        QFontMetrics textMetrics { lineEdit->font() };
        
        // set the fixed width on the line edit
        // pad it by 10 to cover the border and some extra space on the right side (for clicking)
        static const int LINE_EDIT_RIGHT_PADDING { 10 };
        
        lineEdit->setFixedWidth(textMetrics.width(atpURL) + LINE_EDIT_RIGHT_PADDING );
        
        // left align the ATP URL line edit
        lineEdit->home(true);
        
        // add the label and line edit to the dialog
        boxLayout->addWidget(lineEditLabel);
        boxLayout->addWidget(lineEdit);
        
        // setup an OK button to close the dialog
        QDialogButtonBox* buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok);
        connect(buttonBox, &QDialogButtonBox::accepted, hashCopyDialog, &QDialog::close);
        boxLayout->addWidget(buttonBox);
        
        // set the new layout on the dialog
        hashCopyDialog->setLayout(boxLayout);
        
        // show the new dialog
        hashCopyDialog->show();
    } else {
        // figure out the right error message for the message box
        QString additionalError;
        
        switch (upload->getError()) {
            case AssetUpload::PermissionDenied:
                additionalError = PERMISSION_DENIED_ERROR;
                break;
            case AssetUpload::TooLarge:
                additionalError = "The uploaded content was too large and could not be stored in the asset-server.";
                break;
            case AssetUpload::FileOpenError:
                additionalError = "The file could not be opened. Please check your permissions and try again.";
                break;
            case AssetUpload::NetworkError:
                additionalError = "The file could not be opened. Please check your network connectivity.";
                break;
            default:
                // not handled, do not show a message box
                return;
        }
        
        // display a message box with the error
        showErrorDialog(QFileInfo(upload->getFilename()).fileName(), additionalError);
    }
    
    upload->deleteLater();
}