Add AIDirPicker and use it. Remove indra/newview/ll{dir,file}picker.{h,cpp}.
Also removed some code from the Mac/windows code in indra/plugins/filepicker/llfilepicker.cpp that shouldn't be in there anymore (send_agent_pause/resume and updating the LLFrameTimer stuff).
This commit is contained in:
77
indra/newview/statemachine/aidirpicker.h
Normal file
77
indra/newview/statemachine/aidirpicker.h
Normal file
@@ -0,0 +1,77 @@
|
||||
/**
|
||||
* @file aidirpicker.h
|
||||
* @brief Directory picker State machine
|
||||
*
|
||||
* Copyright (c) 2011, Aleric Inglewood.
|
||||
*
|
||||
* 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/>.
|
||||
*
|
||||
* There are special exceptions to the terms and conditions of the GPL as
|
||||
* it is applied to this Source Code. View the full text of the exception
|
||||
* in the file doc/FLOSS-exception.txt in this software distribution.
|
||||
*
|
||||
* CHANGELOG
|
||||
* and additional copyright holders.
|
||||
*
|
||||
* 10/05/2011
|
||||
* Initial version, written by Aleric Inglewood @ SL
|
||||
*/
|
||||
|
||||
#ifndef AIDIRPICKER_H
|
||||
#define AIDIRPICKER_H
|
||||
|
||||
#include "aifilepicker.h"
|
||||
|
||||
// A directory picker state machine.
|
||||
//
|
||||
// Before calling run(), call open() to pass needed parameters.
|
||||
//
|
||||
// When the state machine finishes, call hasDirname to check
|
||||
// whether or not getDirname will be valid.
|
||||
//
|
||||
// Objects of this type can be reused multiple times, see
|
||||
// also the documentation of AIStateMachine.
|
||||
class AIDirPicker : protected AIFilePicker {
|
||||
public:
|
||||
// Allow to pass the arguments to open upon creation.
|
||||
//
|
||||
// The starting directory that the user will be in when the directory picker opens
|
||||
// will be the same as the directory used the last time the directory picker was
|
||||
// opened with the same context. If the directory picker was never opened before
|
||||
// with the given context, the starting directory will be set to default_path
|
||||
// unless that is the empty string, in which case it will be equal to the
|
||||
// directory used the last time the file- or dirpicker was opened with context
|
||||
// "openfile".
|
||||
AIDirPicker(std::string const& default_path = "", std::string const& context = "openfile") { open(default_path, context); }
|
||||
|
||||
// This should only be called if you want to re-use the AIDirPicker after it finished
|
||||
// (from the callback function, followed by a call to 'run'). Normally it is not used.
|
||||
void open(std::string const& default_path = "", std::string const& context = "openfile") { AIFilePicker::open(DF_DIRECTORY, default_path, context); }
|
||||
|
||||
bool hasDirname(void) const { return hasFilename(); }
|
||||
std::string const& getDirname(void) const { return getFilename(); }
|
||||
|
||||
public:
|
||||
// Basically all public members of AIStateMachine could made accessible here,
|
||||
// but I don't think others will ever be needed (not even these, actually).
|
||||
using AIStateMachine::state_type;
|
||||
using AIFilePicker::isCanceled;
|
||||
using AIStateMachine::run;
|
||||
|
||||
protected:
|
||||
// Call finish() (or abort()), not delete.
|
||||
/*virtual*/ ~AIDirPicker() { LL_DEBUGS("Plugin") << "Calling AIDirPicker::~AIDirPicker()" << LL_ENDL; }
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -107,6 +107,9 @@ void AIFilePicker::open(ELoadFilter filter, std::string const& default_path, std
|
||||
mOpenType = multiple ? load_multiple : load;
|
||||
switch(filter)
|
||||
{
|
||||
case DF_DIRECTORY:
|
||||
mFilter = "directory";
|
||||
break;
|
||||
case FFLOAD_ALL:
|
||||
mFilter = "all";
|
||||
break;
|
||||
@@ -314,7 +317,8 @@ void AIFilePicker::multiplex_impl(void)
|
||||
static char const* key_str[] = {
|
||||
"all_files", "sound_files", "animation_files", "image_files", "save_file_verb",
|
||||
"targa_image_files", "bitmap_image_files", "avi_movie_file", "xaf_animation_file",
|
||||
"xml_file", "raw_file", "compressed_image_files", "load_file_verb", "load_files"
|
||||
"xml_file", "raw_file", "compressed_image_files", "load_file_verb", "load_files",
|
||||
"choose_the_directory"
|
||||
};
|
||||
LLSD dictionary;
|
||||
for (int key = 0; key < sizeof(key_str) / sizeof(key_str[0]); ++key)
|
||||
|
||||
@@ -38,6 +38,7 @@
|
||||
|
||||
enum ELoadFilter
|
||||
{
|
||||
DF_DIRECTORY,
|
||||
FFLOAD_ALL,
|
||||
FFLOAD_WAV,
|
||||
FFLOAD_IMAGE,
|
||||
@@ -175,7 +176,7 @@ public:
|
||||
|
||||
private:
|
||||
LLPointer<LLViewerPluginManager> mPluginManager; //!< Pointer to the plugin manager.
|
||||
// FIXME: this should be a separate, thread-safe singleton.
|
||||
// AIFIXME: this should be a separate, thread-safe singleton.
|
||||
typedef std::map<std::string, std::string> context_map_type; //!< Type of mContextMap.
|
||||
context_map_type mContextMap; //!< Map context (ie, "snapshot" or "image") to last used folder.
|
||||
std::string mContext; //!< Some key to indicate the context (remembers the folder per key).
|
||||
|
||||
Reference in New Issue
Block a user