Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Shell|GUI: Added Preferences, FolderSelection widget, various tweaks
- Loading branch information
Showing
12 changed files
with
349 additions
and
58 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
/** @file folderselection.cpp Widget for selecting a folder. | ||
* | ||
* @authors Copyright © 2013 Jaakko Keränen <jaakko.keranen@iki.fi> | ||
* | ||
* @par License | ||
* GPL: http://www.gnu.org/licenses/gpl.html | ||
* | ||
* <small>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. This program is distributed in the hope that it | ||
* will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty | ||
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General | ||
* Public License for more details. You should have received a copy of the GNU | ||
* General Public License along with this program; if not, see: | ||
* http://www.gnu.org/licenses</small> | ||
*/ | ||
|
||
#include "folderselection.h" | ||
#include <QLineEdit> | ||
#include <QPushButton> | ||
#include <QHBoxLayout> | ||
#include <QFileDialog> | ||
|
||
DENG2_PIMPL(FolderSelection) | ||
{ | ||
QString prompt; | ||
QLineEdit *edit; | ||
QPushButton *button; | ||
|
||
Instance(Public &i) : Base(i), | ||
edit(0), | ||
button(0) | ||
{ | ||
/* | ||
// What's up with the extra spacing? | ||
QPalette pal = self.palette(); | ||
pal.setColor(self.backgroundRole(), Qt::red); | ||
self.setPalette(pal); | ||
self.setAutoFillBackground(true); | ||
*/ | ||
|
||
QHBoxLayout *layout = new QHBoxLayout; | ||
layout->setContentsMargins(0, 0, 0, 0); | ||
self.setLayout(layout); | ||
|
||
edit = new QLineEdit; | ||
edit->setMinimumWidth(280); | ||
button = new QPushButton(tr("...")); | ||
|
||
layout->addWidget(edit, 1); | ||
layout->addWidget(button, 0); | ||
} | ||
}; | ||
|
||
FolderSelection::FolderSelection(QString const &prompt, QWidget *parent) | ||
: QWidget(parent), d(new Instance(*this)) | ||
{ | ||
d->prompt = prompt; | ||
|
||
connect(d->button, SIGNAL(clicked()), this, SLOT(selectFolder())); | ||
} | ||
|
||
FolderSelection::~FolderSelection() | ||
{ | ||
delete d; | ||
} | ||
|
||
void FolderSelection::setPath(de::NativePath const &path) | ||
{ | ||
d->edit->setText(path.toString()); | ||
} | ||
|
||
de::NativePath FolderSelection::path() const | ||
{ | ||
return d->edit->text(); | ||
} | ||
|
||
void FolderSelection::selectFolder() | ||
{ | ||
QString dir = QFileDialog::getExistingDirectory(0, d->prompt, d->edit->text()); | ||
if(!dir.isEmpty()) | ||
{ | ||
d->edit->setText(dir); | ||
emit selected(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
/** @file folderselection.h Widget for selecting a folder. | ||
* | ||
* @authors Copyright © 2013 Jaakko Keränen <jaakko.keranen@iki.fi> | ||
* | ||
* @par License | ||
* GPL: http://www.gnu.org/licenses/gpl.html | ||
* | ||
* <small>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. This program is distributed in the hope that it | ||
* will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty | ||
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General | ||
* Public License for more details. You should have received a copy of the GNU | ||
* General Public License along with this program; if not, see: | ||
* http://www.gnu.org/licenses</small> | ||
*/ | ||
|
||
#ifndef FOLDERSELECTION_H | ||
#define FOLDERSELECTION_H | ||
|
||
#include <de/libdeng2.h> | ||
#include <de/NativePath> | ||
#include <QWidget> | ||
|
||
/** | ||
* Widget for selecting a folder. | ||
*/ | ||
class FolderSelection : public QWidget | ||
{ | ||
Q_OBJECT | ||
|
||
public: | ||
explicit FolderSelection(QString const &prompt, QWidget *parent = 0); | ||
virtual ~FolderSelection(); | ||
|
||
void setPath(de::NativePath const &path); | ||
|
||
de::NativePath path() const; | ||
|
||
signals: | ||
void selected(); | ||
|
||
public slots: | ||
void selectFolder(); | ||
|
||
private: | ||
struct Instance; | ||
Instance *d; | ||
}; | ||
|
||
#endif // FOLDERSELECTION_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.