diff options
author | tpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da> | 2010-02-24 18:42:24 +0000 |
---|---|---|
committer | tpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da> | 2010-02-24 18:42:24 +0000 |
commit | f508189682b6fba62e08feeb1596f682bad5fff9 (patch) | |
tree | 28aeb0e6c19386c385c1ce5edf8a92c1bca15281 /src/libgui/new_dialogs.cpp | |
download | piklab-f508189682b6fba62e08feeb1596f682bad5fff9.tar.gz piklab-f508189682b6fba62e08feeb1596f682bad5fff9.zip |
Added KDE3 version of PikLab
git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/applications/piklab@1095639 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'src/libgui/new_dialogs.cpp')
-rw-r--r-- | src/libgui/new_dialogs.cpp | 83 |
1 files changed, 83 insertions, 0 deletions
diff --git a/src/libgui/new_dialogs.cpp b/src/libgui/new_dialogs.cpp new file mode 100644 index 0000000..d26c15c --- /dev/null +++ b/src/libgui/new_dialogs.cpp @@ -0,0 +1,83 @@ +/*************************************************************************** + * Copyright (C) 2005-2007 Nicolas Hadacek <hadacek@kde.org> * + * Copyright (C) 2003-2004 Alain Gibaud <alain.gibaud@free.fr> * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + ***************************************************************************/ +#include "new_dialogs.h" + +#include <klocale.h> +#include <kiconloader.h> +#include <kpushbutton.h> + +#include "common/gui/purl_gui.h" +#include "project.h" + +//---------------------------------------------------------------------------- +NewDialog::NewDialog(const QString &caption, QWidget *parent) + : Dialog(parent, "new_dialog", true, caption, Ok|Cancel, Ok, false) +{ + _top = new QGridLayout(mainWidget(), 0, 0, 10, 10); + _top->setColStretch(2, 1); + + _fLabel = new QLabel(mainWidget()); + _top->addWidget(_fLabel, 0, 0); + _filename = new QLineEdit(mainWidget()); + connect(_filename, SIGNAL(textChanged(const QString &)), SLOT(changed())); + _top->addMultiCellWidget(_filename, 0,0, 1,3); + + QLabel *label= new QLabel(i18n("Location:"), mainWidget()); + _top->addWidget(label, 1, 0); + _dir = new QLineEdit(mainWidget()); + connect(_dir, SIGNAL(textChanged(const QString &)), SLOT(changed())); + _top->addMultiCellWidget(_dir, 1,1, 1,2); + KIconLoader loader; + QIconSet iconset = loader.loadIcon("fileopen", KIcon::Toolbar); + KPushButton *button = new KPushButton(iconset, QString::null, mainWidget()); + connect(button, SIGNAL(clicked()), SLOT(browse())); + _top->addWidget(button, 1, 3); + + _filename->setFocus(); + enableButtonOK(false); +} + +void NewDialog::changed() +{ + enableButtonOK(!_filename->text().isEmpty() && !_dir->text().isEmpty()); +} + +void NewDialog::browse() +{ + PURL::Directory dir = PURL::getExistingDirectory(startDir(), this, QString::null); + if ( dir.isEmpty() ) return; + _dir->setText(dir.path()); +} + +//---------------------------------------------------------------------------- +NewFileDialog::NewFileDialog(Project *project, QWidget *parent) + : NewDialog(i18n("Create New File"), parent), _project(project) +{ + _fLabel->setText(i18n("File Name:")); + + if (project) { + _add = new QCheckBox(i18n("Add to project"), mainWidget()); + _add->setChecked(project); + _top->addMultiCellWidget(_add, 2,2, 1,2); + _top->setRowStretch(3, 1); + _dir->setText(project->directory().path()); + } +} + +QString NewFileDialog::startDir() const +{ + if (_project) return _project->directory().path(); + return ":new_file"; +} + +PURL::Url NewFileDialog::url() const +{ + return PURL::Url(PURL::Directory(_dir->text()), _filename->text()); +} |