22 #include <QtGui/QToolButton>
23 #include <QtGui/QPalette>
24 #include <QtGui/QMenu>
25 #include <QtCore/QTimer>
26 #include <QtCore/QUrl>
62 QString s = fi.absoluteFilePath()+
"/preview.tif";
63 if (!QFile::exists(s)) s = fi.absoluteFilePath()+
"/preview.png";
64 if (!QFile::exists(s))
_pm->setPixmap( QPixmap());
67 if ( !pix.isNull() )
_pm->setPixmap( pix );
68 else _pm->setPixmap( QPixmap() );
72 QImage img(fi.absoluteFilePath());
74 _pm->setPixmap(QPixmap::fromImage(img.scaled(128,128,Qt::KeepAspectRatio,Qt::SmoothTransformation)));
76 _pm->setPixmap( QPixmap() );
78 else _pm->setPixmap( QPixmap() );
79 _pm->setAlignment(Qt::AlignHCenter | Qt::AlignVCenter);
86 _pm =
new QLabel(
this );
87 _pm->setFrameStyle( QFrame::StyledPanel );
88 _pm->setBackgroundRole( QPalette::Base );
89 _pm->setAutoFillBackground(
true);
90 QVBoxLayout *layout =
new QVBoxLayout;
91 layout->setSpacing( 0 );
92 layout->setMargin( 0 );
93 layout->addWidget(
_pm);
106 QList<QLineEdit*> lineedits = findChildren<QLineEdit*>(QRegExp());
107 if (lineedits.size())
_nameEdit = (QLineEdit*)lineedits.at(0);
109 _nameEdit->disconnect(SIGNAL(returnPressed()));
114 QList<QPushButton*> myWidgets = findChildren<QPushButton*>(QRegExp());
115 for (
int w = 0; w < myWidgets.size(); w++)
117 QPushButton* item = (QPushButton*)myWidgets.at(w);
118 if (item->text().contains(
"Open"))
_okButton = item;
122 connect(
this, SIGNAL(currentChanged(
const QString&)),
134 setMinimumWidth(680);
140 if (fileMode() != QFileDialog::DirectoryOnly)
return;
142 if (entry ==
"")
return;
147 if (!d.exists(entry)) {
148 if (d.mkdir(entry)) {
155 QTimer::singleShot( 200,
this, SLOT(
resetDir()) );
166 if (str.contains(
'/'))
176 int slashcount = str.count(
'/');
178 QString foundDir =
"";
179 for (
int i=0; i<slashcount; i++)
181 QString section = str.section(
'/', 0, i);
182 if (d.cd(section)) foundDir = section;
184 if (foundDir.length())
186 setDirectory(foundDir);
187 QString remainder = str.right(str.length()-(foundDir.length()+1));
191 if (d.cd(str)) setDirectory(str);
195 else if (fileMode()==QFileDialog::DirectoryOnly)
handleOk();
202 QGridLayout *layout = findChild<QGridLayout *>(
"gridLayout");
207 std::string favlocation = getenv(
"HOME");
208 favlocation +=
"/paint3d/favorites/";
210 QString dirpath = QString::fromStdString(favlocation);
211 if (!d.cd(dirpath)) d.mkpath(dirpath);
213 if (!d.cd(dirpath)) d.mkpath(dirpath);
215 if (!(linkdir.isEmpty() || linkname.isEmpty()))
217 if (!QFile::exists(dirpath+linkname))
218 QFile::link(linkdir,dirpath+linkname);
224 QToolButton* fav =
new QToolButton(
this);
225 fav->setFixedSize(18,18);
226 fav->setIcon(folderFav);
227 fav->setToolTip(
"Favorites");
229 layout->addWidget(fav,0,3);
241 if ( paths.isEmpty ())
return;
243 QStringList h = history();
244 for (QStringList::Iterator
it=paths.begin();
it!=paths.end(); ++
it)
246 if (!h.contains(*
it)) h.push_back(*
it);
263 if ( filter.isEmpty() )
264 return QStringList();
266 int i = filter.indexOf(
";;", 0 );
269 if ( filter.indexOf(
"\n", 0 ) != -1 ) {
271 i = filter.indexOf( sep, 0 );
275 return filter.split( sep );
279 const QString& startWith,
const QString& filter )
281 if ( !filter.isEmpty() )
284 setNameFilters( filters );
287 if ( !startWith.isEmpty() ) setDirectory( startWith );
288 if ( !caption.isNull() ) setWindowTitle( caption );
289 setFileMode( QFileDialog::ExistingFile );
290 setAcceptMode( QFileDialog::AcceptOpen );
294 if ( exec()==QDialog::Accepted )
296 result = selectedFiles().first();
305 const QString& startWith,
const QString& filter )
307 if ( !filter.isEmpty() )
310 setNameFilters( filters );
313 if ( !startWith.isEmpty() ) setDirectory( startWith );
314 if ( !caption.isNull() ) setWindowTitle( caption );
315 setFileMode( QFileDialog::ExistingFiles );
316 setAcceptMode( QFileDialog::AcceptOpen );
321 if ( exec()==QDialog::Accepted )
323 lst = selectedFiles();
332 const QString& startWith,
const QString& filter )
334 if ( !filter.isEmpty() )
337 setNameFilters( filters );
340 if ( !startWith.isEmpty() ) setDirectory( startWith );
341 if ( !caption.isNull() ) setWindowTitle( caption );
342 setFileMode( QFileDialog::DirectoryOnly );
346 if ( exec()==QDialog::Accepted )
348 result = selectedFiles().first();
357 const QString& startWith,
const QString& filter )
367 const QString& startWith,
const QString& filter )
369 if ( !filter.isEmpty() )
372 setNameFilters( filters );
375 if ( !startWith.isEmpty() ) setDirectory( startWith );
376 if ( !caption.isNull() ) setWindowTitle( caption );
377 setFileMode( QFileDialog::AnyFile );
378 setAcceptMode( QFileDialog::AcceptSave );
382 if ( exec()==QDialog::Accepted )
384 result = selectedFiles().first();
395 QGridLayout *layout = findChild<QGridLayout *>(
"gridLayout");
399 _pw->setFixedWidth(160);
400 _pw->setMinimumHeight(160);
401 layout->addWidget(
_pw,1,3);
411 QGridLayout *layout = findChild<QGridLayout *>(
"gridLayout");
414 _cb =
new QCheckBox( s,
this );
415 _cb->setChecked(
false);
417 layout->addWidget(
_cb, 4,
_combo ? 2 : 0);
422 if (!
_cb)
return false;
423 return _cb->isChecked();
438 QGridLayout *layout = findChild<QGridLayout *>(
"gridLayout");
443 _combo =
new QComboBox(
this );
444 _combo->setEditable(
true);
445 _combo->setFixedWidth(160);
446 for ( QStringList::Iterator
it = sl.begin();
it != sl.end(); ++
it )
449 int rownum = layout->rowCount();
450 layout->addWidget(
_combo,rownum,1);
478 QList<QUrl> urls = sidebarUrls();
479 QUrl url = QUrl::fromLocalFile(s);
480 if (url.isValid() && QFile::exists(s))
483 setSidebarUrls(urls);
void selChanged(const QString &path)
void addFavoritesButton(QString dirname, QString linkname, QString linkdir)
void addCheckBox(QString s)
QString _workingDirectory
QString getExistingOrNewDirectory(const QString &caption=QString::null, const QString &startWith=QString::null, const QString &filter=QString::null)
static const char * folder_fav[]
static QStringList makeFiltersList(const QString &filter)
void addLookInEntries(QStringList paths)
QString getExistingDirectory(const QString &caption=QString::null, const QString &startWith=QString::null, const QString &filter=QString::null)
void addComboBox(QString s, QStringList sl)
double max(double x, double y)
void restoreLookInEntries()
QStringList getOpenFileNames(const QString &caption=QString::null, const QString &startWith=QString::null, const QString &filter=QString::null)
double min(double x, double y)
void addSidebarShortcut(const QString &s)
void setButtonName(const QString &str)
ExprFileDialog(QWidget *parent=0)
QString getSaveFileName(const QString &caption=QString::null, const QString &startWith=QString::null, const QString &filter=QString::null)
you may not use this file except in compliance with the License and the following modification to it
QString getOpenFileName(const QString &caption=QString::null, const QString &startWith=QString::null, const QString &filter=QString::null)