~ubuntu-branches/ubuntu/hardy/avidemux/hardy

« back to all changes in this revision

Viewing changes to avidemux/ADM_userInterfaces/ADM_QT4/ADM_dialogFactory/T_dialogFactory.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Matvey Kozhev
  • Date: 2007-12-18 13:53:04 UTC
  • mfrom: (1.1.7 upstream)
  • Revision ID: james.westby@ubuntu.com-20071218135304-cdqec2lg2bglyz15
Tags: 1:2.4~preview3-0.0ubuntu1
* Upload to Ubuntu. (LP: #163287, LP: #126572)
* debian/changelog: re-added Ubuntu releases.
* debian/control:
  - Require debhelper >= 5.0.51 (for dh_icons) and imagemagick.
  - Build-depend on libsdl1.2-dev instead of libsdl-dev.
  - Build against newer libx264-dev. (LP: #138854)
  - Removed libamrnb-dev, not in Ubuntu yet.
* debian/rules:
  - Install all icon sizes, using convert (upstream installs none).
  - Added missing calls to dh_installmenu, dh_installman, dh_icons and
    dh_desktop.
* debian/menu, debian/avidemux-qt.menu:
  - Corrected package and executable names.
* debian/avidemux-common.install: Install icons.
* debian/avidemux.common.manpages: Install man/avidemux.1.
* debian/links, debian/avidemux-cli.links, debian/avidemux-gtk.links:
  - Link manpages to avidemux.1.gz.
* debian/install, debian/avidemux-qt.install, debian/avidemux-gtk.desktop,
  debian/avidemux-qt.desktop: Install desktop files.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/***************************************************************************
 
2
  DIA_dialogFactory.cpp
 
3
  (C) 2007 Mean Fixounet@free.fr 
 
4
***************************************************************************/
 
5
 
 
6
/***************************************************************************
 
7
 *                                                                         *
 
8
 *   This program is free software; you can redistribute it and/or modify  *
 
9
 *   it under the terms of the GNU General Public License as published by  *
 
10
 *   the Free Software Foundation; either version 2 of the License, or     *
 
11
 *   (at your option) any later version.                                   *
 
12
 *                                                                         *
 
13
 ***************************************************************************/
 
14
 
 
15
#include <config.h>
 
16
 
 
17
 
 
18
#include <string.h>
 
19
#include <stdio.h>
 
20
#include <stdlib.h>
 
21
#include <math.h>
 
22
 
 
23
#include <QDialog>
 
24
#include <QMessageBox>
 
25
#include <QGridLayout>
 
26
#include <QDialogButtonBox>
 
27
#include <QDialogButtonBox>
 
28
#include <QPushButton>
 
29
#include <QTabWidget>
 
30
 
 
31
#include "default.h"
 
32
#include "ADM_commonUI/DIA_factory.h"
 
33
#include "ADM_assert.h"
 
34
 
 
35
class factoryWindow : public QDialog
 
36
{
 
37
     Q_OBJECT
 
38
 
 
39
 public:
 
40
     factoryWindow();
 
41
 public slots:
 
42
 private slots:
 
43
 private:
 
44
};
 
45
 
 
46
static void insertTab(uint32_t index, diaElemTabs *tab, QTabWidget *wtab);
 
47
factoryWindow::factoryWindow()     : QDialog()
 
48
 {
 
49
//     ui.setupUi(this);
 
50
     //connect( (ui.pushButton),SIGNAL(pressed()),this,SLOT(buttonPressed()));
 
51
 }
 
52
 
 
53
 
 
54
/**
 
55
    \fn diaFactoryRun(const char *title,uint32_t nb,diaElem **elems)
 
56
    \brief  Run a dialog made of nb elems, each elem being described in the **elems
 
57
    @return 0 on failure, 1 on success
 
58
*/
 
59
 
 
60
uint8_t diaFactoryRun(const char *title,uint32_t nb,diaElem **elems)
 
61
{
 
62
  factoryWindow dialog;
 
63
  
 
64
  ADM_assert(title);
 
65
  ADM_assert(nb);
 
66
  ADM_assert(elems);
 
67
  
 
68
  dialog.setWindowTitle(QString::fromUtf8(title));
 
69
  
 
70
  QGridLayout layout(&dialog);
 
71
  
 
72
  /* First compute the size of our window */
 
73
  int vsize=0;
 
74
  for(int i=0;i<nb;i++)
 
75
  {
 
76
    ADM_assert(elems[i]);
 
77
     vsize+=elems[i]->getSize(); 
 
78
  }
 
79
 
 
80
 int  v=0;
 
81
  for(int i=0;i<nb;i++)
 
82
  {
 
83
    ADM_assert(elems[i]);
 
84
     elems[i]->setMe( (void *)&dialog,&layout,v); 
 
85
     v+=elems[i]->getSize();
 
86
    
 
87
  }
 
88
   for(int i=0;i<nb;i++)
 
89
  {
 
90
    ADM_assert(elems[i]);
 
91
     elems[i]->finalize(); 
 
92
  }
 
93
  // Add buttons
 
94
   QDialogButtonBox buttonBox((QWidget *)&dialog);
 
95
    buttonBox.setStandardButtons(QDialogButtonBox::Ok
 
96
                            | QDialogButtonBox::Cancel);
 
97
     QObject::connect(&buttonBox, SIGNAL(accepted()), &dialog, SLOT(accept()));
 
98
     QObject::connect(&buttonBox, SIGNAL(rejected()), &dialog, SLOT(reject()));
 
99
     layout.addWidget(&buttonBox,vsize,0);
 
100
  // run
 
101
  dialog.setLayout(&layout);
 
102
  if(dialog.exec()==QDialog::Accepted)
 
103
  {
 
104
     for(int i=0;i<nb;i++)
 
105
     {
 
106
        ADM_assert(elems[i]);
 
107
        elems[i]->getMe(); 
 
108
    
 
109
      }
 
110
    return 1;
 
111
  }
 
112
  return 0;
 
113
  
 
114
}
 
115
/**
 
116
    \fn shortkey(const char *in)
 
117
    \brief translate gtk like accelerator (_) to QT4 like accelerator (&)
 
118
*/
 
119
const char *shortkey(const char *in)
 
120
{
 
121
 char *t=ADM_strdup(in);
 
122
 for(int i=0;i<strlen(t);i++)
 
123
 {
 
124
    if(t[i]=='_') t[i]='&'; 
 
125
 }
 
126
  return t;
 
127
}
 
128
uint8_t diaFactoryRunTabs(const char *title,uint32_t nb,diaElemTabs **tabs)
 
129
{
 
130
    factoryWindow dialog;
 
131
  
 
132
  ADM_assert(title);
 
133
  ADM_assert(nb);
 
134
  ADM_assert(tabs);
 
135
  
 
136
  dialog.setWindowTitle(QString::fromUtf8(title));
 
137
  
 
138
  QGridLayout layout(&dialog);
 
139
 
 
140
  // Add tabs
 
141
  QTabWidget wtabs((QWidget *)&dialog);
 
142
  // Add buttons
 
143
   QDialogButtonBox buttonBox((QWidget *)&dialog);
 
144
    buttonBox.setStandardButtons(QDialogButtonBox::Ok
 
145
                            | QDialogButtonBox::Cancel);
 
146
     QObject::connect(&buttonBox, SIGNAL(accepted()), &dialog, SLOT(accept()));
 
147
     QObject::connect(&buttonBox, SIGNAL(rejected()), &dialog, SLOT(reject()));
 
148
     
 
149
     for(int i=0;i<nb;i++)
 
150
     {
 
151
        ADM_assert(tabs[i]);
 
152
        insertTab(i,tabs[i],&wtabs); 
 
153
    
 
154
      }
 
155
     
 
156
     layout.addWidget(&wtabs,0,0);
 
157
     layout.addWidget(&buttonBox,1,0);
 
158
  // run
 
159
  dialog.setLayout(&layout);
 
160
  if(dialog.exec()==QDialog::Accepted)
 
161
  {
 
162
      // Read tabs
 
163
       for(int tab=0;tab<nb;tab++)
 
164
     {
 
165
        ADM_assert(tabs[tab]);
 
166
        diaElemTabs *myTab=tabs[tab];
 
167
        for(int i=0;i<myTab->nbElems;i++)
 
168
        {
 
169
          myTab->dias[i]->getMe();
 
170
        }
 
171
    
 
172
      }
 
173
      return 1;
 
174
  }
 
175
  return 0;
 
176
  
 
177
}
 
178
 
 
179
void insertTab(uint32_t index, diaElemTabs *tab, QTabWidget *wtab)
 
180
{
 
181
 
 
182
  QWidget *wid=new QWidget;
 
183
  QGridLayout *layout=new QGridLayout(wid);
 
184
  
 
185
  /* First compute the size of our window */
 
186
  int vsize=0;
 
187
  for(int i=0;i<tab->nbElems;i++)
 
188
  {
 
189
    ADM_assert(tab->dias[i]);
 
190
     vsize+=tab->dias[i]->getSize(); 
 
191
  }
 
192
 
 
193
 int  v=0;
 
194
  for(int i=0;i<tab->nbElems;i++)
 
195
  {
 
196
     ADM_assert(tab->dias[i]);
 
197
     tab->dias[i]->setMe( wid,layout,v); 
 
198
     v+=tab->dias[i]->getSize();
 
199
    
 
200
  }
 
201
  
 
202
  wtab->addTab(wid,QString::fromUtf8(tab->title));
 
203
  for(int i=0;i<tab->nbElems;i++)
 
204
  {
 
205
    tab->dias[i]->finalize(); 
 
206
  }
 
207
}
 
208
//EOF